Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin DoesNotExist at /admin/

Tags:

django

I have some problems with Django admin.

after syncdb, the result is:

  Creating tables ...   Installing custom SQL ...   Installing indexes ...   No fixtures found. 

What does this mean?

Anyway, when I visit the website admin panel http://www.example.com/admin/, I receive this message:

DoesNotExist at /admin/ Site matching query does not exist. 

setting.py contains:

INSTALLED_APPS = (     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',     'django.contrib.sites',     'django.contrib.messages',     'django.contrib.staticfiles',     # Uncomment the next line to enable the admin:     'django.contrib.admin', ) 

ur.py contains:

from django.conf.urls.defaults import patterns, include, url  # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover()  urlpatterns = patterns('',     # Examples:     # url(r'^$', 'rshd.views.home', name='home'),     # url(r'^rshd/', include('rshd.foo.urls')),      # Uncomment the admin/doc line below to enable admin documentation:      url(r'^admin/doc/', include('django.contrib.admindocs.urls')),      # Uncomment the next line to enable the admin:      url(r'^admin/', include(admin.site.urls)), ) 
like image 811
creative creative Avatar asked Mar 16 '12 12:03

creative creative


People also ask

How do I make administrative superuser in Django?

Django's “Hello World” application Start the terminal by clicking on the “Run” button. Type python3 manage.py createsuperuser in the given terminal and press “Enter”. The system will ask for credentials, after which a superuser will be created. To run the server, we type the command python3 manage.py runserver 0.0.

How do I give permission to admin in Django?

Test the 'view' permission is added to all modelsUsing #3 for Django 1.7 only creates the permission objects if the model doesn't already exist. Is there a way to create a migration (or something else) to create the permission objects for existing models?

How do I get to the admin page in Django?

To login to the site, open the /admin URL (e.g. http://127.0.0.1:8000/admin ) and enter your new superuser userid and password credentials (you'll be redirected to the login page, and then back to the /admin URL after you've entered your details).

What is default Django admin password?

Run 'python manage.py migrate' to apply them. Username (leave blank to use 'chatru'): admin Email address: [email protected] Password: Password (again): The password is too similar to the username.


1 Answers

You don't really need the sites framework if you only run one site from the project, so the easiest fix would be to remove the following item from your INSTALLED_APPS and the error should go away:

'django.contrib.sites' 

You can also re-create the missing Site object from shell. Run python manage.py shell and then:

from django.contrib.sites.models import Site Site.objects.create(pk=1, domain='www.example.com', name='example.com') 
like image 67
Ramandeep Singh Avatar answered Sep 27 '22 19:09

Ramandeep Singh