When I create a user via django admin panel, and mark it staff it can login django admin page as it should, but when I create user vie UserForm
and mark it as staff it can not login. It says invalid username password for staff and so on.
I suspect the error is because I am using,
TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth','django.core.context_processors.request')
Currently I have the following code:
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
As form:
class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta:
model = User
fields = ('username', 'email', 'password')
Now tell me, how can I by pass this problem?
phew, I had to add something like this: