Найти - Пользователи
Полная версия: Расширение класса User и UserCreationForm
Начало » Django » Расширение класса User и UserCreationForm
1 2
romankrv
lov3catch
I got the error

Exception at /registration

Could you please share this full list of the Exception if you got on it, UI of course. It has a more detail what happened was.

Luck you man.
barabansheg
Попробуй так:
class MyRegisterForm(UserCreationForm):
    print "OK!"
    nick_name = forms.CharField(max_length=30, required=True, widget=forms.TextInput)
    print "Ook"
    class Meta:
        model = UserProfile
        exclude = (user, )
    def save(self, commit=True):
        if not commit:
            raise NotImplementedError("Can't create User and UserProfile without database save")
        print "Saving..."
        user = super(MyRegisterForm, self).save(commit=False)
        user.nick_name = self.cleaned_data["nick_name"]
        user_profile = UserProfile(user=user, nick_name=self.cleaned_data['nick_name'])
        user_profile.save()
        print "Saving complete"
        return user, user_profile
lov3catch
Like this?

Exception at /registration
<ul class=“errorlist”><li>nick_name<ul class=“errorlist”><li>This field is required.</li></ul></li><li>user<ul class=“errorlist”><li>This field is required.</li></ul></li></ul>
Request Method: POST
Request URL: http://127.0.0.1:8000/registration
Django Version: 1.4.1
Exception Type: Exception
Exception Value:
<ul class=“errorlist”><li>nick_name<ul class=“errorlist”><li>This field is required.</li></ul></li><li>user<ul class=“errorlist”><li>This field is required.</li></ul></li></ul>
Exception Location: E:\kavyarnya\registration\views.py in reg, line 67
Python Executable: c:\python27\python.exe
Python Version: 2.7.3
Python Path:
['E:\\kavyarnya',
‘c:\\python27\\lib\\site-packages\\grab-0.4.8-py2.7.egg’,
‘c:\\python27\\lib\\site-packages\\ply-3.4-py2.7.egg’,
‘c:\\python27\\lib\\site-packages\\flask-0.9-py2.7.egg’,
‘C:\\WINDOWS\\system32\\python27.zip’,
‘c:\\python27\\DLLs’,
‘c:\\python27\\lib’,
‘c:\\python27\\lib\\plat-win’,
‘c:\\python27\\lib\\lib-tk’,
‘c:\\python27’,
‘c:\\python27\\lib\\site-packages’,
‘c:\\python27\\lib\\site-packages\\PIL’,
‘c:\\python27\\lib\\site-packages\\win32’,
‘c:\\python27\\lib\\site-packages\\win32\\lib’,
‘c:\\python27\\lib\\site-packages\\Pythonwin’]
Server time: Mon, 20 May 2013 14:53:30 +0400

And I don`t see form for input nick-name in my template. Preview in screenshot
(Также не отображается форма для ввода ника в шаблоне. Пример на скриншоте.)
lov3catch
barabansheg
Попробуй так:
Спасибо, но не получилось.
romankrv
lov3catch
Exception Location: E:\kavyarnya\registration\views.py in reg, line 67
Please, display us one.
Did you analyzed the E:\kavyarnya\registration\views.py in string sixty seven and around here?
Exemption tells you about it.
Let's look here.

Likely the problem grows from here.

Please share this.

Have a nice time.
lov3catch
In sixty seven line just:
raise Exception(form.errors)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB