I've created a new website using Django 1.8, created a superuser account and logged into the admin interface to initialize some database fields. I can log continue to log into both the admin site and the actual website, as can a couple hundred users.
I've created a second Django website under a separate project (separate database, settings file, etc.) that contains identical code. I ran syncdb and created a different superuser account but when I attempt to log into the admin site with my superuser account, it tells me my username or password is incorrect. I've compared everything with the original website and I can't find anything that's not consistent.
I've confirmed:
I can log directly into the MySQL database using the database name, database user and password that are contained in the settings file
I'm referencing the correct settings file from manage.py
My user record in auth_user has is_staff, is_superuser and is_active all set to 1
I've tried to compare all the configuration files between the two projects and everything matches up as expected. Does anyone have any suggestions about what could affect the authentication or how I might debug this?
Thanks.
After running out of places to look, I deleted and recreated the site database and then reran manage.py syncdb. After that, I was able to log into the admin site. My working theory is that when I entered the superuser password the first time, I pasted into a PUTTY terminal and what it stored for the password was not what I thought it was.
Which kind of doesn't make sense because I did try to add a second superuser using manage.py createsuperuser with a really simple password and I still couldn't log in.
Anyway, thanks for the help.
Related
I'm trying to restore the database with the maintenance script provided. But there is a check in the script which doesn't allow me to restore if the user is postgres.
Any reason for that ?
It is a custom to not use the postgres user in this case. Similar to the custom that when operating a linux server, you use a user account instead of the root account.
You can remove the passage from the script if you want to proceed anyway. However, cookiecutter-django should have generated a .env/.production/.postgres file with a different username than postgres.
So I am currently building a project with Django and will need to change the admin email to someone higher up in my division. However I am not sure who's email that will be as they are not sure yet either. If I put my email in now (as I will need to be using it when building the app), can I change it once it is ready to be delivered?
There is no limit to the number of admin accounts you can make. When the time comes to transfer ownership, simply create a new super user and use it to delete the old one.
python manage.py createsuperuser
I have inherited a django project which uses Wagtail for CMS. When I go to (project_url)/cms/ I am asked for a username and password, which I do not have.
Is there any way to create a default user account in the settings.py file, or reset the existing account so that I can gain access to the CMS section?
You can run the changepassword command (django-admin changepassword your_username, for example) to change a password for the existing your_username user.
Alternatively you can create a new superuser using the createsuperuser command by running django-admin createsuperuser.
I'm working on a multi tenant app using django-tenant-schema(and postgresql). Now as soon as the new schema is getting created, I'm using the call_command to create a superuser. I also thought of the option of using signal post_migrate.
My doubt is how can I auto create a superuser without typing the password in shell.
The use case is as soon as the user registers for his/her schema, a superuser is generated and the user logs in with the superuser username and password and can change the password thereafter.
I'm using the following to call the createsuperuser command:
call_command('createsuperuser', schema_name=self.schema_name, username='admin', email='admin#admin.com')
One way to solve the issue is to change Django's createsuperuser.py file and provide a password over there automatically, buts thats not an acceptable route, ie cahnging the source code for some use case. Could I please request for some better methods
you can "prepare" password for new superuser and pass md5 value to bash:
a=# select md5('some password'||'test');;
md5
----------------------------------
d5b3eb515b64edf295b2ee9062946d24
(1 row)
a=# create user test superuser password 'md5d5b3eb515b64edf295b2ee9062946d24';
CREATE ROLE
so you can use d5b3eb515b64edf295b2ee9062946d24 in bash, saving password somewhere else?..
My admin site has started refusing to let any superusers log in. I've tried making a whole new set of superusers using manage.py, but the admin site doesn't see any of them, even while manage.py is happy to change passwords for existing superusers.
Haven't made any changes to the admin packages, what I did do however was delete the SQLlite database to clear all the test stuff I've put in. I ran syncdb immediately after, but admin isn't having a bar of it, even after making multiple superusers as per above. So, pretty new to django and at a bit of a loss as to the next step.
Cheers
Worked out what the problem was, it's pretty well spelled out in this, but basically I had added the django-facebook auth backend, which then apparently meant that the normal auth backend was not included and this is what admin uses. To steal the answer from the above link, django.contrib.auth.backends.ModelBackend needs to be added to AUTHENTICATION_BACKENDS.
Thanks to Yuji.
Fairly basic, but do the users have is_staff and is_active set to True?
If that's not the problem then we'll probably need more information. You could post the output of manage.py dumpdata auth.User --indent 4 to let us see what your User data looks like, which might help.