I have installed django 3.0 in python 3.7 and started a basic django project. I have created a superuser and run the development server using python manage.py runserver
. When I go to localhost:8000/admin
it shows me ui to login after I entered my credentials it redirects back to localhost:8000/admin
but at that time server stops running without any error on console.
The last message I see in log file is
(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."expire_date" > '2019-12-11T08:52:16.929697+00:00'::timestamptz AND "django_session"."session_key" = 'tqpcf2gv6iqatc42pdmz6zdjpy7iri37') LIMIT 21; args=(datetime.datetime(2019, 12, 11, 8, 52, 16, 929697, tzinfo=<UTC>), 'tqpcf2gv6iqatc42pdmz6zdjpy7iri37')
(0.002) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 21; args=(1,)
Has someone faced this issue? What could be the solution?
EDIT: I found someone faced same issue in reddit looks like this is a bug in django
Uninstalling django then installing django 2.2.8 with pip install "django>=2.2,<3"
helped.
Then navigate to the admin panel’s URL in a browser of your choice. Be sure to input your server’s IP address. You will receive a login screen similar to this. Getting to this screen lets us know that we have successfully enabled the admin app. Though we have enabled the app, we may not have set up a Django administration account yet.
When you are done with testing your app, you can press CTRL + C to stop running the Django server. This will return you to your programming environment. When you are ready to leave your Python environment, you can run the deactivate command: Deactivating your programming environment will put you back to the terminal command prompt.
Recognize that running it that way will only keep it up and running while you’re logged on. Hopefully this is just for a test and that you’re not really going to try to leave a Django runserver running, exposed to the internet… Wow thanks for your fast answer!
Open a new terminal to connect to the server, or disable the Django app by pressing CTRL and C so that we can work on our server terminal’s programming environment. Django allows you to generate a super-user account, which we can do by running the manage.py file to start the super-user creation process.
Check up your python version. It should be 3.8+ for Django 3.0. I had the same problem when I was using python 3.7.
Either try upgrading to python 3.8 or downgrade to Django 2.2. Upgrading to Python 3.8 worked for me. Also, don't forget to add Python 3.8's path and pip's Path to your System's Environment variable, otherwise, it'll keep using pip 3.7's path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With