Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django server stops immediatly after login into admin page

Tags:

python

django

Trying to login to django admin page immediately after clicking login button django server stops

New to Django trying to create a project in a virtual environment using venv. These are the following steps i did.

1.created a folder named api

2.created a virtual environment using python -m venv vapi

3.installed django and ran initial migrations then created super user

pip install django
django-admin startproject library .
python manage.py migrate
python manage.py createsuperuser

now tried to login to django adminpage

I haven't changed anything in setting.py file

using default sqllite db

python 3.7 django-admin 3.0

like image 968
naveen kumar Avatar asked Dec 07 '19 22:12

naveen kumar


2 Answers

Here are the solutions on how to solve this problem.

Attentions. These solutions work if you have the Django v3. I didn't face the same problem in the case of Django v2 etc. So, please, check your Django version and if you don't have v3, this answer, probably, won't help you. Sorry.

1) you can downgrade your Django version to v2+

but I don't like this way because I prefer to use the latest versions of everything

2) upgrade your python version to 3.8.0 and it should help . (I solved this problem in this way)

I suggest you use something like pyenv package if you have other projects that depend on your previous python version. Thanks to this package you can simply switch your python versions when you need to work on projects that require different python versions. Also, I'd like to suggest you use venv for your projects to keep your dependencies isolated. Using a different environment is a nice practice in the case of python development.

Hope it helps. Kind regards.

like image 79
Velidan Avatar answered Oct 30 '22 13:10

Velidan


I faced the same issue with Python version 3.7.0. It looks that there is already ticket for that. Updating Python to version 3.7.6 helped to resolve this issue for me:

# Updating version via pyenv
$ pyenv install 3.7.6

Creating new virtualenv using pipenv (remember to clear old venv if neccessary):

$ pipenv --rm
$ pipenv install --dev
Creating a virtualenv for this project…
Pipfile: /home/homeuser/projects/django_rest/Pipfile
Using /home/homeuser/.pyenv/versions/3.7.6/bin/python3 (3.7.6) to create virtualenv…
...

like image 31
devaerial Avatar answered Oct 30 '22 14:10

devaerial