Unable to load admin interface - django

I have created a new Django project where in I am able to access http://127.0.0.1:8000 but I can't access the admin dashboard http://127.0.0.1:8000/admin/.
INSTALLED APPS
INSTALLED_APPS = (
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
#'django.contrib.sites',
'django.contrib.messages',
'health',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
)
URLS
from django.conf.urls import patterns, include, url
from django.contrib import admin
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# 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)),
url(r'^$','authentication.views.login_authenticate'),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin_tools/', include('admin_tools.urls')),
)
Response
DoesNotExist at /admin/
Site matching query does not exist.
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.4.2
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: /Library/Python/2.6/site-packages/django/db/models/query.py in get, line 366
Python Executable: /usr/bin/python
Python Version: 2.6.1
Python Path:
['/Users/iceman/Documents/onkar_workspace/MyProject',
'/Library/Python/2.6/site-packages/PyMySQL-0.5-py2.6.egg',
'/Library/Python/2.6/site-packages/elementtree-1.2.7_20070827_preview-py2.6.egg',
'/Library/Python/2.6/site-packages/Markdown-2.2.0-py2.6.egg',
'/Library/Python/2.6/site-packages/xhtml2pdf-0.0.4-py2.6.egg',
'/Library/Python/2.6/site-packages/pyPdf-1.13-py2.6.egg',
'/Library/Python/2.6/site-packages/pytz-2012c-py2.6.egg',
'/Library/Python/2.6/site-packages/django_bootstrap_toolkit-2.5.4-py2.6.egg',
'/Users/iceman/Documents/epicomm/PRHealth',
'/Users/iceman/Downloads/eclipse/plugins/org.python.pydev_2.7.0.2012110722/pysrc',
'/Library/Python/2.6/site-packages/ipython-0.13-py2.6.egg',
'/Library/Python/2.6/site-packages/icalendar-3.0.1b2-py2.6.egg',
'/Library/Python/2.6/site-packages/reportlab-2.5-py2.6-macosx-10.6-universal.egg',
'/Library/Python/2.6/site-packages/PIL-1.1.7-py2.6-macosx-10.6-universal.egg',
'/Library/Python/2.6/site-packages/html5lib-0.95-py2.6.egg',
'/Library/Python/2.6/site-packages/django_timepiece-0.5.2-py2.6.egg',
'/Library/Python/2.6/site-packages/django_compressor-1.1.2-py2.6.egg',
'/Library/Python/2.6/site-packages/django_selectable-0.4.1-py2.6.egg',
'/Library/Python/2.6/site-packages/django_pagination-1.0.7-py2.6.egg',
'/Library/Python/2.6/site-packages/python_dateutil-1.5-py2.6.egg',
'/Library/Python/2.6/site-packages/distribute-0.6.28-py2.6.egg',
'/Library/Python/2.6/site-packages/MySQL_python-1.2.4b4-py2.6-macosx-10.6-universal.egg',
'/Users/iceman/Downloads/eclipse/plugins/org.python.pydev_2.7.0.2012110722/pysrc/pydev_sitecustomize',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
'/Library/Python/2.6/site-packages',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip']

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.xxx.com', name='xxx.com')
I guess this might help you.

Related

DoesNotExist at /admin/login/

DoesNotExist at /admin/login/
Site matching query does not exist.
Request Method: GET
Request URL: https://tehb123.pythonanywhere.com/admin/login/?next=/admin/
Django Version: 1.9.3
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: /usr/local/lib/python3.5/dist-packages/django/db/models/query.py in get, line 387
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.5.1
Python Path:
['/var/www',
'.',
'',
'/home/tehb123/.local/lib/python3.5/site-packages',
'/var/www',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/usr/local/lib/python3.5/dist-packages',
'/usr/lib/python3/dist-packages',
'/home/tehb123/mysite']
Server time: Thu, 13 Oct 2016 05:34:55 +0000
urls
from django.conf.urls import url, patterns, include
from django.contrib import admin
from django.contrib.flatpages import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('Mysitez.urls')),
# url(r'^pages/', include('django.contrib.flatpages.urls')),
]
urlpatterns += [
url(r'^(?P<url>.*/)$', views.flatpage),
]
settings
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.templatetags',
'django.apps',
'django.contrib.sites',
'django.contrib.flatpages',
'Mysitez',
]
SITE_ID=1 in setting and all work, but why? not have idae =(
I found the solution in this other post:
"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'
"
The admin site
once you create the project with django version > 1.6 , the admin site will enable django itself. but make sure you have following ["https://docs.djangoproject.com/en/1.10/ref/contrib/admin/"], once you create project , make python manage.py migrate then create the admin user using (python manage.py createsuperuser ). do the run command see the url like ("http://127.0.0.1:8000/admin/") you can see the login page

how to proceed after registering google are a service provider for allauth

I want to use the allauth django app.
I did everything described in this allauth tutorial: http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/. I continues until "Now we can login using Django or Facebook" subpart.
After that I can't go to the address that is indicated in the tutorial: http://127.0.0.1:8000/accounts/login/
I want you to see the database that I have. its exatly like the tutorial indicates:
This is my setting.py file:
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"/srv/http/proj04/proj/templates",
)
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend"
)
TEMPLATE_CONTEXT_PROCESSORS = (
# Required by allauth template tags
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
# allauth specific context processors
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
LOGIN_REDIRECT_URL = '/'
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': ['email', 'publish_stream'],
'METHOD': 'oauth2' # instead of 'oauth2'
}
}
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
'captcha',
'django.contrib.admin',
# Uncomment the next line to enable the admin:
# Uncomment the next line to enable admin documentation:
'allauth',
'allauth.account',
'allauth.socialaccount',
# ... include the providers you want to enable:
'allauth.socialaccount.providers.amazon',
'allauth.socialaccount.providers.dropbox',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.flickr',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.instagram',
'allauth.socialaccount.providers.linkedin',
'allauth.socialaccount.providers.linkedin_oauth2',
'allauth.socialaccount.providers.openid',
'allauth.socialaccount.providers.tumblr',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.vimeo',
'allauth.socialaccount.providers.vk',
# 'django.contrib.admindocs',
)
This is my url.py file:
....
admin.autodiscover()
urlpatterns = patterns('',
(r'^accounts/', include('allauth.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)),
)
urlpatterns += [
# ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
I don;t know what to do next.
I tried
http://127.0.0.1:8000/accounts/login/
Only to get this exception:
DoesNotExist at /accounts/login/
Site matching query does not exist.
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/
Django Version: 1.6.5
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: /srv/http/proj04/lib/python3.4/site-packages/django/db/models/query.py in get, line 310
Python Executable: /srv/http/proj04/bin/python
Python Version: 3.4.1
...
or sometimes i get this exception ( i dont know why but these exception alternate):
ImproperlyConfigured at /accounts/login/
No Facebook app configured: please add a SocialApp using the Django admin
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/
Django Version: 1.6.5
Exception Type: ImproperlyConfigured
Exception Value:
No Facebook app configured: please add a SocialApp using the Django admin
Exception Location: /srv/http/proj04/lib/python3.4/site-packages/allauth/socialaccount/providers/facebook/provider.py in media_js, line 106
Python Executable: /srv/http/proj04/bin/python
Python Version: 3.4.1
What am I missing?
Thanks in advance.
You need to modify your allauth google settings in your app settings. Take a look at the docs to see what settings are avaliable.
http://django-allauth.readthedocs.org/en/latest/#google
You'll also need to change your installed apps to only include these allauth apps
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google'
Add "SITE_ID" in settings.py
django_site table must contain a row with the same value of id (by default equals to 1), as SITE_ID.
And in your SocialApplication table 'localhost:8000/admin/socialaccount/socialapp/' for different providers give this site ID and try to run again, it will work.

dojango test install results in 404

I made a fresh install of django 1.6.2 in it's own virtualenv. No syncdb, no other configs. The only other apps installed are pip, setuptools and dojango. I followed the instructions in this wiki page https://github.com/klipstein/dojango/wiki/Gettingstarted
when I try 127.0.o.1:8000/dojango/test/ or localhost:8000/dojango/test I get
Page not found (404)
Request Method: GET
Request URL: http://127.0.o.1:8000/dojango/test/
Using the URLconf defined in dojango.urls, Django tried these URL patterns, in this order:
^dojango/ ^dojango/
The current URL, dojango/test/, didn't match any of these.
this is my INSTALLED_APPS
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dojo_tutor',
'dojango',)
and this is my urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^dojango/', include('dojango.urls')),
# url(r'^admin/', include(admin.site.urls)),
)
The wiki page says to use (r'^dojango/', include('dojango.urls')), but I tried both like that and url(r'^dojango/', include('dojango.urls')),. I still get 404
Ok, it was a silly mistake. Foolishly I had named my project dojango so naturally there was a naming conflict. Deleted the project and recreated it with another name. Now it works.

Django 1.5 and Heroku: My admin main has no links to anything

As I said above, I'm using Django 1.5 and Heroku. Everything works fine locally, but in the Heroku admin I just get the main page and that's it. There are no links to my app or anything in the "auth" category or ANYTHING. The image below is what comes up.
As you can see, no links, no buttons, nothing but text.
Has anyone experienced before or have any ideas? I would be happy to post my code, but I don't want to overload this with useless junk so ask and I'll be happy to add whatever info you might want to see.
Some basic things:
Settings.py snippets:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
#'gunicorn',
#'django_evolution',
#Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'CRM',
)
urls.py snippet:
urlpatterns = patterns('',
#Uncomment the next line to enable the admin:
url(r'^/', include('CRM.urls')),
url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT,
}),
)
admin.autodiscover()
Everything is registered in my admin.py
admin.site.register(Client, ClientAdmin)
admin.site.register(Project, ProjectAdmin)
Thanks!
I figured it out! Yay! For those of you in the near or distant future that suffer from this, you need admin.autodiscover() at the TOP of your urls.py file.

URL matching in tutorial fails (admin)

I've followed the Django tutorial part 1, and am now on part 2 where I'm supposed to get the admin interface up and running.
I've followed the step very carefully but when I try to load the site I get the following error:
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
1. ^admin/
The current URL, , didn't match any of these.
I first uncommented 'django.contrib.admin' in settings.py:
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',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'polls',
)
...after that I run python manage.py syncdb, which output:
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
...and then I uncommented the three lines that I was supposed to according to the tutorial, in urls.py:
from django.conf.urls 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'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.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)),
)
As mentioned above this generates an error message if run.
What can be wrong? I mean I've followed the tutorial exactly as supposed.
Notice the instruction in the tutorial:
Now, open a Web browser and go to “/admin/” on your local domain – e.g., http://127.0.0.1:8000/admin/.
Add the error shows, you are trying to go to the root URL, not /admin/ as directed.