i have install django through cpanel but admin page is not open what should I do
Weâre going to need a lot more information to be able to try and help.
- What hosting provider are you using?
- What instructions are you following for doing the deployment?
- Have you verified at each step that things are progressing as they should?
- What error messages are you getting, or what information is available to you in any log files?
- When you say that the admin page isnât opening, what exactly is happening when you go to your site?
Thatâs probably enough to start - we may have more questions once we start diving into this.
iâm using linux hosting
i followed all instructions as per my knowledge
using following URLs code
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path(âadmin/â, admin.site.urls),
path(ââ, views.contact, name=âhomeâ),
]
migrations & superuser created successfully,
but when i try to open admin page following msg received
Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
We really need the complete details here. Which hosting provider and what instructions?
Hosting provider hetzner
installed python 3.7.8
Application startup file: passenger_wsgi.py
Application Entry point: application
installed django 2.1
following are settings
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))
DEBUG = True
ALLOWED_HOSTS = [correctly typed the host]
Application definition
INSTALLED_APPS = [
âdjango.contrib.adminâ,
âdjango.contrib.authâ,
âdjango.contrib.contenttypesâ,
âdjango.contrib.sessionsâ,
âdjango.contrib.messagesâ,
âdjango.contrib.staticfilesâ,
]
MIDDLEWARE = [
âdjango.middleware.security.SecurityMiddlewareâ,
âdjango.contrib.sessions.middleware.SessionMiddlewareâ,
âdjango.middleware.common.CommonMiddlewareâ,
âdjango.middleware.csrf.CsrfViewMiddlewareâ,
âdjango.contrib.auth.middleware.AuthenticationMiddlewareâ,
âdjango.contrib.messages.middleware.MessageMiddlewareâ,
âdjango.middleware.clickjacking.XFrameOptionsMiddlewareâ,
]
ROOT_URLCONF = âproject.urlsâ
TEMPLATES = [
{
âBACKENDâ: âdjango.template.backends.django.DjangoTemplatesâ,
âDIRSâ: [],
âAPP_DIRSâ: True,
âOPTIONSâ: {
âcontext_processorsâ: [
âdjango.template.context_processors.debugâ,
âdjango.template.context_processors.requestâ,
âdjango.contrib.auth.context_processors.authâ,
âdjango.contrib.messages.context_processors.messagesâ,
],
},
},
]
WSGI_APPLICATION = âproject.wsgi.applicationâ
DATABASES = {
âdefaultâ: {
âENGINEâ: âdjango.db.backends.sqlite3â,
âNAMEâ: os.path.join(BASE_DIR, âdb.sqlite3â),
}
}
STATIC_URL = â/static/â
STATIC_ROOT = os.path.join(BASE_DIR, âstaticâ)
urls.py
from django.contrib import admin
from django.urls import path, include
from . import views
urlpatterns = [
path(âadmin/â, admin.site.urls),
path(ââ, views.contact, name=âhomeâ),
path(âshop/â, include(âshop.urlsâ)),
]
passenger_wsgi.py
passenger_wsgi.py
above is the main setting of my project
when i install django, django static page becomes live but admin page not open
It looks like youâre missing your application in INSTALLED_APPS.
You run the command python manage.py runserver after making migration and superuser or not ? If not run this command after making migration and superuser.
in pycharm Id everything is ok but when in run this in cpanel then I face above said issue,
migration done suceessfully
I also had a same problem.
When deploy django-app on cPanel after few setup.
Projects page works fine.
But when directing/go the page to âdomain.name/adminâ I got error in console which said ârefused to apply styleâ because its MIME type
The only thing I realized is mostly my django project started inside virtual environment.
But cPanel created his own environment when you deployed Python App.
I donât know much about server side. But I think itâs from there.
local dir project make sense for me. But this cPanel setup screw me up also.
Imagine we have to replace/move static file to some directory.
The setup on cPanel quite make sense. But applying those thing from local to server/cPanel doesnât make sense for me.
I still figure it out for about a week. Iâll update latter if I found a solution.
- if anybody could figure this out, let us know.
Extra:
I also tried type inside cPanel python shell. BASE_DIR actually works fine.
If I have to create custom admin layout maybe it could be work. But such a waste.
Just figured it out
But I tested it on Django 3.1.2 and Python 3.7.8
All pages, include admin section works fine.
I tried to typed it here. But hard to read.
Good luck.
Hi @prsfx , We are facing the exact issue. Used passengar_wsgi in cpanel and the site loads up fine but domain/admin gives us 404 with ErrorDocument.
I tried accessing your github link but itâs giving 404. Could you help share your findings?