i'm a newbie to Django and i just started this project....
After Creating Superuser using this command python manage.py createsuperuser I tried to access the admin route but on typing the /admin on the browser it's displays this error on the browser
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/login
Using the URLconf defined in myblog.urls, Django tried these URL patterns, in this order:
1. admin/
I tried adding: LOGIN_REDIRECT_URL = '/admin/' in the settings.py as someone suggested on stackoverflow but it shows the same thing.
Kindly direct me on what i'm not doing right
CodePudding user response:
You need to run:
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
Check if you have on settings:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles'
Your apps
]
And in your URLs from the app:
urlpatterns = [
#
path('admin/', admin.site.urls)
Your apps urls
]
CodePudding user response:
I finally got it right
I started the project from beginning but i made slight changes I did the following: Created a new folder for my project
- Cd into the folder
- Run python -m venv name-of-virtual-env
- Cd into name-of-virtual-env
- Cd into Scripts
- Run activate.bat
- Cd ../../
The name of the virtual environment will appear inside bracket near your directory name, indicating that you've activated your Virtualenv. Then you start your project.... using
django-admin startproject (name of the project)
