Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django development server stops after logging into admin

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.

like image 875
Dev Khadka Avatar asked Dec 11 '19 08:12

Dev Khadka


People also ask

How do I enable the Django admin app?

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.

How do I turn off Django in Python?

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.

Is it possible to run Django runserver while logged on?

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!

How do I create a super user account in Django?

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.


2 Answers

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.

like image 94
ArthurLodbrock Avatar answered Oct 09 '22 07:10

ArthurLodbrock


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.

like image 28
Kishan Mishra Avatar answered Oct 09 '22 08:10

Kishan Mishra