#16156 closed Bug (invalid)
Django overrides user-defined "User" model with its own
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.auth | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm getting some very weird results when I name my model "User".
Here's the definition.
from django.db import models class User(models.Model): email = models.EmailField() password = models.CharField(max_length=51) birthday = models.DateField() gender = models.BooleanField() # True => Male
Here's the ModelForm:
from django import forms class RegistrationForm(forms.ModelForm): class Meta(): model = User fields = ['email', 'password'] widgets = { 'email': forms.TextInput(attrs={'autocomplete': 'off'}), 'password': forms.PasswordInput(attrs={'autocomplete': 'off'}) }
When I render this form in my template with "{{ form.as_p }}" I see the following help text for the password input: "Use '[algo]$[salt]$[hexdigest]' or use the change password form.".
Seems as though there is some weird override of the Django-defined User model and mine.
Change History (2)
comment:1 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
I actually just figured it out (I think). Without thinking, I put this all in an app called auth
. I think that threw off the namespacing with the built-in Django auth, which I have in INSTALLED_APPS
and I am using for the admin.
I'd guess you are importing Django's User somewhere before you specify the model
User
in the meta class for your RegistrationForm. I do not see what you are describing, using your model, and avoiding any import of User fromdjango.contrib.auth.models
: