Upon accessing the test server/weblog/ url on localhost, in an environment with "latest everything stable" (python 2.7, django 1.4.1, apache 2.2.22) I'm getting:
NoReverseMatch at /weblog/
Reverse for 'zinnia_entry_add' with arguments '()' and keyword arguments '{}' not found.
Request Method: GET
Request URL: http://127.0.0.1/weblog/
Django Version: 1.4.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'zinnia_entry_add' with arguments '()' and keyword arguments '{}' not found.
Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py in render, line 424
Python Executable: /usr/bin/python
Python Version: 2.7.3
Excerpt from settings.py:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.staticfiles',
'django.contrib.admindocs',
'django.contrib.messages',
'django.contrib.comments',
'image_labeler',
'tagging',
'mptt',
'zinnia',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.static',
'zinnia.context_processors.version',
)
and from urls.py:
urlpatterns = patterns('',
# Example:
# (r'^lastpixel/', include('lastpixel.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^weblog/', include('zinnia.urls')),
(r'^comments/', include('django.contrib.comments.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^$', views.Index),
(r'^login/?$', views.Login),
(r'^logout/?$', views.Logout),
(r'^register/?$', views.Register),
(r'^i$', include('image_labeler.urls')),
(r'^i/', include('image_labeler.urls')),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/lastpixel/web/media', 'show_indexes': True}),
(r'^.*$', views.Index),
)
The application works otherwise (withouth the zinnia blog). Any idea what I might be doing wrong? Much appreciated!
I had a similar problem after updating zinnia.
This helped me out, although I didn't expect a solution in mysql:
First, edit /etc/my.conf
[client]
default-character-set=utf8
[mysqld]
default-character-set = utf8
skip-character-set-client-handshake
character-set-server = utf8
collation-server = utf8_general_ci
init-connect = SET NAMES utf8
Second, restart mysql
Taken from:
zinnia on github
It is likely that it is a namespace problem. In your error page, do you see the inline error highlight something that looks like {% block 'zinnia:zinnia_entry_add' %}? This is part of the zinnia name space, indicated by the zinnia: part of that definition. If you see something like this, you likely just need to add the correct namespace to your URLs:
urlpatterns = patterns('',
#.....
(r'^weblog/', include('zinnia.urls', namespace="zinnia")),
#.....
)
Related
I am studing the djanto multi-tenant package (https://github.com/django-tenants/django-tenants).
When i try to access the main page (landing page) at http://127.0.0.1:8000/, I got the following message:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Raised by: core.views.home
No tenant for hostname "127.0.0.1"
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to
False, and Django will display a standard 404 page.
How do I get the landing page to show correctly?
URL FILE
from core.views import home
urlpatterns = [
path('admin/', admin.site.urls),
path('', home, name='home'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
THE VIEW OF LANDINGPAGE
from django.shortcuts import render
def home(request):
return render(request, 'core/index.html')
PARTIAL SETTINGS FILES
DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
SHARED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_tenants',
'customer',
'core', //landing page
]
TENANT_APPS = [
# The following Django contrib apps must be in TENANT_APPS
'django.contrib.contenttypes',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
# your tenant-specific apps
'myclientapp',
]
INSTALLED_APPS = list(set(SHARED_APPS + TENANT_APPS))
Thank you very much!
The issue there is with the Django Tenants middleware. By default, django_tenants will show a Page 404 error if you go to a tenant that does not exist. You can change this behavior by over-modifying the middleware and having your own local copy or (the easiest solution) you can just provide a default case by adding SHOW_PUBLIC_IF_NO_TENANT_FOUND = True in your project's settings.py file. This will route to the public schema hence other url routes will work as they should.
I'm using Django (1.7.3) with zinnia blog (0.15.1) and I'm having an issue for rendering the 'image for illustration' that you can add for a blog entry.
I have the following urls.py files:
My top-dir url conf
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^ecv/', include('extended_cv.urls',namespace="ecv")),
url(r'^weblog/', include('zinnia.urls', namespace='zinnia')),
url(r'^comments/', include('django_comments.urls')),
)
The settins.py file:
# -*- coding: utf-8 -*-
** Snip**
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
# For using django.contrib.sites
SITE_ID = 2
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'pro',
'extended_cv',
'zinnia', # Added for zinnia blog usage
'django.contrib.sites',# Added for zinnia blog usage
'django_comments',# Added for zinnia blog usage
'mptt',# Added for zinnia blog usage
'tagging',# Added for zinnia blog usage
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'zinnia.context_processors.version',
)
** Snip**
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
When I create an entry for zinnia using admin UI, and when I add an image, no error appear, and the new entry is saved to database with no warning. The image then appear in the server tree file at the adress TopDir/upload/zinnia/date/of/publication/index_IKd2N0d.jpeg
But, when I read the new entry from the weblog app, I correctly see the new entry, but not the image. Moreover, the server output the following error:
GET /weblog/2015/01/18/1st-entry/uploads/zinnia/2015/01/18/index_IKd2N0d.jpeg HTTP/1.1" 404 8922
I guess the issue is kind of complicated to debug, then if you need more information, I'll be happy to give you more.
Thank you.
As explain by Daniel Roseman in the comments, the answer consists into defining the variables MEDIA_URL and MEDIA_ROOT, and to rewrite the top urls.py file as explained in https://docs.djangoproject.com/en/1.7/howto/static-files/#serving-files-uploaded-by-a-user-during-development:
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^ecv/', include('extended_cv.urls',namespace="ecv")),
url(r'^weblog/', include('zinnia.urls', namespace='zinnia')),
url(r'^comments/', include('django_comments.urls')),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
And the work is done.
I am pretty new into django and fully noob into django-social-auth.
My settings.py code is this (From installed app to social_auth_config) :
DJANGO_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
)
THIED_PARTY_APPS = (
#'south',
'captcha',
'social_auth',
)
MY_APPS = (
'account',
'dashboard',
)
INSTALLED_APPS = DJANGO_APPS + THIED_PARTY_APPS + MY_APPS
#------------------------------------------------- Social auth -------------------
LOGIN_URL = 'account/login/'
LOGIN_REDIRECT_URL = 'dashboard/'
LOGIN_ERROR_URL = '/login/'
AUTHENTICATION_BACKENDS = (
'social_auth.backends.contrib.github.GithubBackend',
'django.contrib.auth.backends.ModelBackend',
)
TEMPLATE_CONTEXT_PROCESSORS = (
"social_auth.context_processors.social_auth_by_type_backends",
"django.contrib.auth.context_processors.auth",
)
SOCIAL_AUTH_DEFAULT_USERNAME = 'nal_auth_user'
SOCIAL_AUTH_UID_LENGTH = 16
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 16
SOCIAL_AUTH_NONCE_SERVER_URL_LENGTH = 16
SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH = 16
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 16
SOCIAL_AUTH_ENABLED_BACKENDS = ('github',)
GITHUB_API_KEY = '2f1129e79efd4263bf88'
GITHUB_API_SECRET = '6f4cea73e6100d0a994fa5bfff44f7220432c87d'
In urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'website.views.index', name='index'),
url(r'auth/',include('social_auth.urls')),
url(r'account/',include('account.urls',namespace="account")),
url(r'dashboard/',include('dashboard.urls',namespace="dashboard")),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
)
In account.models login page i have this to show login url..
Login with GitHub
But problem is when ever i click that link it gives me this error
WrongBackend at /auth/login/github/
Incorrect authentication service "github"
Request Method: GET
Request URL: http://127.0.0.1:8000/auth/login/github/
Django Version: 1.5.4
Exception Type: WrongBackend
Exception Value:
Incorrect authentication service "github"
I tried to use google and its gives me the same error except in github its google. I also tried similar questions in stackoverflow.
Please help me if you can :)
check the version of the library of django_sociao_auth, as "THIS LIBRARY IS DEPRECATED IN FAVOR OF python-social-auth. RIGHT NOW THIS LIBRARY DEPENDS DIRECTLY ON python-social-auth AND SHOULD BE CONSIDERED AS A MIGRATION STEP".
Also check if SETTINGS_KEY_NAME = 'GITHUB_APP_ID' SETTINGS_SECRET_NAME = 'GITHUB_API_SECRET' are in class GithubAuth
then try to add this
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.associate.associate_by_email',
'social_auth.backends.pipeline.misc.save_status_to_session',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
'social_auth.backends.pipeline.misc.save_status_to_session',
)
Could someone explain me please what I'm doing wrong? I'm trying to enable admin panel in Django 1.2. But the link http://mysite.com/admin raises 404 error, and the link http://mysite.com raises an error like this:
TypeError at /
list objects are unhashable
Request Method: GET
Request URL: http://mysite/index.wsgi/
Django Version: 1.2.4
Exception Type: TypeError
Exception Value:
list objects are unhashable
Exception Location: /usr/local/lib/python2.5/re.py in _compile, line 230
Python Executable: /usr/local/bin/python
Python Version: 2.5.5
Python Path: ['/usr/local.20100210/lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg', '/usr/local/lib/python2.5/site-packages/Genshi-0.6-py2.5.egg', '/usr/local/lib/python2.5/site-packages/Babel-0.9.5-py2.5.egg', '/usr/local/lib/python2.5/site-packages/Pygments-1.4-py2.5.egg', '/usr/local/lib/python2.5/site-packages/pytz-2010o-py2.5.egg', '/usr/local/lib/python2.5/site-packages/Trac-0.12.1-py2.5.egg', '/usr/local/lib/python2.5/site-packages/IniAdmin-0.2-py2.5.egg', '/usr/local/lib/python2.5/site-packages/TracAccountManager-0.2.1dev-py2.5.egg', '/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.3-py2.5-freebsd-8.2-RELEASE-amd64.egg', '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/python2.5/plat-freebsd8', '/usr/local/lib/python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/PIL', '/usr/local/lib/python2.5/site-packages', '/home/casf58/www/site2/cgi-bin/']
Server time: Tue, 11 Jun 2013 20:52:41 +0400
This is the empty test project which works fine on local machine. But it doesn't work at hosting. Of course, I uncommented all the necessary lines in urls.py and setiings.py and checked it several times. If I comment them back, the Django Welcome page is displayed.
Still can't find a solution in google...
Python v.2.5. Project uses wsgi_mod.
Changes in settings.py:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
My urls.py:
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
r'^admin/', include(admin.site.urls)
)
You need to enclose your url pattern in ()
(r'^admin/', include(admin.site.urls)),
Try this:
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
I can't figure out why Django is not loading the admin page. It seems like it isn't even reading the urls.py file that I am editing - because even if I comment out the 'urlpatterns' statement, it still loads the local hello page fine once I run the server.
This is the error message:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/admin
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^hello/$
^time/$
^time/plus/(\d{1,2})/$
The current URL, admin, didn't match any of these.
This is my urlpatterns code:
from django.conf.urls import patterns, include, url
from mysite.views import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
('^hello/$', hello, ),
('^time/$', current_datetime, ),
(r'^time/plus/(\d{1,2})/$', hours_ahead, ),
# 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))
)
And this is a snippet os my settings.py file:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
# 'django.contrib.messages.middleware.MessageMiddleware'
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'mysite.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'mysite.wsgi.application'
TEMPLATE_DIRS = (
'/Users/pavelfage/Desktop/Coding/mysite/Templates',
# 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.
)
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',
'mysite.books'
)
Any help much appreciated!
I faced same problem. Uncommenting from django.contrib import admin in urls.py solved the problem.
I had the same problem. You may try this:
In your urls.py replace the call include(admin.site.urls) by this: admin.site.urls
In your setting.py if don't have any TEMPLATE_CONTEXT_PROCESSORS property (that was my situation) add this:
TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.core.context_processors.tz", "django.contrib.messages.context_processors.messages")
It seams to be roughly the default property in a normal django 1.4 configuration. Here are the docs talking about it: djangoproject-doc1 djangoproject-doc2
You may also have to uncomment the strings:
# 'django.contrib.messages',
# 'django.contrib.staticfiles',
in your INSTALLED_APPS property of the settings.py but i'm not sure about it.
Sorry about not explaining much better the reasons of those changes but I'm a django-beginner to. I just found your question corresponding to my problem and then a possible awnser.
I hope it may help you.
EDIT: as seen in a comment you may try to remove the url(...) instruction on the line concerning the url of the admin site
ben