I am using Django 1.4.5 and accidentally deleted the superuser. How can I recreate the superuser account for an existing project? I found tutorials that show to do it when initially setting up a project but can't figure out how to create a superuser for an existing project.
I did try django-admin.py createsuperuser in the terminal without any luck
I apprecite the time and feedback.
You can invoke this command through manage.py
./manage.py createsuperuser
Related
I'm trying to deploy a simple django application (SQLite3) to render but I can't log in to the admin page even with valid superuser credentials. I could authenticate locally, but not while on the render deployed version.
Your help is much appreciated!
Try running python manage.py createsuperuser in the Render Shell.
Documentation on creating a Django admin account on Render deployments.
As a substitute to running python manage.py createsuperuser on Render Shell, you can do a quick deployment with python manage.py createsuperuser --no-input on your build script and have environment variables such as DJANGO_SUPERUSER_USERNAME set. You then have to remove this hack for later builds.
See https://stackoverflow.com/a/59467533/4932353 for more information.
I deleted that table (whoops), and now I'd like to regenerate it. Is there a command that allows me to do that? Looking online, everyone is saying to use the command ./manage.py syncdb, but that command is no longer available in the most recent version of Django. So I tried ./manage.py migrate, but that didn't generate the table. I also tried ./manage.py --run-syncdb, but that didn't do it either.
I'm pretty sure I can do it by hand, but I'm hoping there's a way to do this with a built-in command.
Since the admin app only has one table, django_admin_log, you can revert all migrations for the admin app by running
python manage.py migrate admin zero
then re-apply the the admin app migrations by running
python manage.py migrate
You might want to create a backup before doing this (or any migration, really) :)
I'm coding a web app with django and now I'm starting to handle users.
I'm trying to do the easy part, just create a new user throught admin interface, but when I try to do it I get a error and I don't find any info about it.
I enter django admin, log in with superuser, go to users, add user.
It only asks for: username and password.
When I submit changes then I get a NOT NULL constraint failed, this:
NOT NULL constraint failed: auth_user.last_login
I revised django documentation, and there it says to create a user like this:
from django.contrib.auth.models import User
user = User.objects.create_user('john', 'lennon#thebeatles.com', 'johnpassword')
So, I open a terminal, and do "./manage.py shell" "import django" "import User" and then I try this code, but fails too, it says:
NameError: name 'User' is not defined
Maybe I've changed something in the first part of the project? I've created models, templates, urls and used /static/ for references to files.
Thanks for your help!
last_login field changed in django 1.8. Just run the migrations
python manage.py migrate
Same issue, Had to run python manage.py migrate --fake and then python manage.py migrate and it worked perfectly.
In the app folder there is migration folder.. remove all files from it just keep pycache folder and init.py
then execute python manage.py migrate and then python manage.py makemigrations ..
simply we are removing the older migrations and migrating them again
I am trying to implement django registration-redux 1.2. I installed the application and added to it settings.py of my project. I ran manage.py syncdb as well as makemigrations/migrate. Typing these commands again and I get no changes detected. However it seems like the tables are not getting created. When I try to register I get the following error:
ProgrammingError at /main/register/ (1146, "Table 'la_test_serve.registration_registrationprofile' doesn't exist")
Is there a way to reset the project/app so that these tables get created?
Thanks,
Robert
Try to run schemamigration for your registration apps
python manage.py schemamigration registration --initial
after that run migrate
python manage.py migrate registration
Remove the app from your "INSTALLED APPS" setting. Then run manage.py makemigrations and manage.py migrate. Reinstall the app.
Note: If you didn't add 'registration' (yes, simply 'registration') to your "INSTALLED APPS", it won't work.
I found this error occurred when I was reinstalling django-registration-redux.
Either way, check that you have deleted not only the table for registration in the database but also ensure that in the migrations table delete the corresponding row, in this case 'registration'.
Is it possible to create more than one superusers in Django? When I create a new django app it automatically asks for creating a superuser. But I don't know how I can create more than one superuser to give admin access to other people ?
Use this command:
python manage.py createsuperuser
More: https://docs.djangoproject.com/en/dev/ref/django-admin/#createsuperuser