#how do i change the default text displayed on the signup page
1 messages · Page 1 of 1 (latest)
i cannot post a picture here to show you waht im talking about
You can also change the model of your default User. That help_text stuff comes from that model.
Check your settings.py for AUTH_USER_MODEL
What is that set to?
there is no auth user model in settings
Cool. Add a model to your project for User. You probably want it to inherit from AbstractUser
from django.contrib.auth.models import AbstractUser
, then set AUTH_USER_MODEL= "[your app name].[your User Model name]"
How much exeprience do you have in django?
No, you'd import the AbstractUser in models.py
yes but i dont have anything written in there
Perfect. Add that import there first and then:
Something like:
class User(AbstractUser):
username = models.CharField(
_('username'),
max_length=150,
unique=True,
help_text=_('Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.'),
validators=[username_validator],
error_messages={
'unique': _("A user with that username already exists."),
},
)
Except change that help_text or anything else that you don't like. I just copied that from AbstractUser which is what django uses by default. By inheriting from that class, it will have all of the same fields as that class does, but you can override the ones you don't like.
To find the app name, look in your settings.py for the list of INSTALLED_APPS. You should find one that has the same name as the directory to your models.py file. If you do, perfect, what is it and I'll give you the exact string to put in your settings.py
Whatever that directory is, is probably the APP_NAME that you want to use for the next step, so I'll just tell you it.
- in your settings.py, add this line somewhere:
AUTH_USER_MODEL= "[your app name with your new models.py that you edited].User"
-
Run ./manage.py makemigrations
-
Run ./manage.py migrate
If your app is set up properly and you followed those steps, the changes that you made to your User model will now show up on your signup page. You can change the help_text to say anything that you want. You can disable the validators or change them by adding the username_validator to your User Model the same way that it's in AbstractUser.
Any time that you change a field of one of your models though, always run makemigrations and migrate to see them applied
this is what i have in my installed apps
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base',
]
AUTH_USER_MODEL= "base.User"
i did that
and when i do makemigrations
i get an error saying
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency base.0001_initial on database 'default'.
What is the name of the folder that your models.py is in?
It's saying that you have 2 migration folders. One that is called admin and one that is called base.
admin/migrations/0001_initial is listing base/migrations/0001_initial as a dependency but has already been applied somehow.
I'm gonna go to bed now, but in your terminal you can run something like
./manage.py migrate admin 0000;
./manage.py migrate base 0000;
./manage.py migrate;
And that should do something
Oh wait, sorry, i'm tired. Don't run line 3 of that...
It should be:
./manage.py migrate admin 0000;
./manage.py migrate base 0000;
./manage.py makemigrations;
./manage.py migrate;
and if that doesn't work, then do:
./manage.py migrate admin 0000;
./manage.py migrate base 0000;
Then delete your migration scripts found in admin/migrations and base/migrations
Then run
./manage.py makemigrations;
./manage.py migrate;
Sorry, without knowing the answers to questions I've been asking and what your folder/file structure looks like, that's the best that I can do for now. Hope that helps! Goodnight!
sorry for late reply