django admin page not open on live website

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.

1 Like

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?

1 Like

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.

1 Like

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.

1 Like

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.


fig
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?