ImportError at /admin/ No module named views - python

I can't understand the source of this problem, anyone can help me to understand?
I checkouted from development server and all works except the admin
ImportError at /admin/
No module named views
Request Method: GET
Request URL: http://192.168.43.121:8000/admin/
Django Version: 1.5.5
Exception Type: ImportError
Exception Value:
No module named views
Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/home/maurizio/workspace/bigfloproject',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
Server time: Sat, 26 Apr 2014 05:07:55 -0500
This is the traceback:
Environment:
Request Method: GET
Request URL: http://192.168.43.121:8000/admin/
Django Version: 1.5.5
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django_extensions',
'kompat',
'customers',
'dbeffect',
'dbpatent',
'spark',
'statistics',
'website')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in wrapper
219. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
202. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in index
361. model_dict['admin_url'] = reverse('admin:%s_%s_changelist' % info, current_app=self.name)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in reverse
467. app_list = resolver.app_dict[ns]
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in app_dict
311. self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _populate
274. for name in pattern.reverse_dict:
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in reverse_dict
297. self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _populate
286. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in callback
230. self._callback = get_callable(self._callback_str)
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in wrapper
31. result = func(*args)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in get_callable
97. mod = import_module(mod_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
35. __import__(name)
Exception Type: ImportError at /admin/
Exception Value: No module named views
This is my url.py
from django.conf.urls import patterns, include, url
from django.conf.urls import patterns, url, include
from django.views.generic import TemplateView
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'kompat.views.home', name='home'),
# url(r'^kompat/', include('kompat.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)),
#(r'^accounts/', include('registration.urls')),
#include url sito statico
(r'', include('website.urls')),
#include url dfeffectti
(r'^dbeffect/', include('dbeffect.urls')),
#include url kompat
(r'^kompat/', include('kompat.urls')),
#include url gestione utenti
(r'^user/', include('customers.urls')),
#include spark
(r'^spark/', include('spark.urls')),
#include dbpatent
(r'^dbpatent/', include('dbpatent.urls')),
)
############# SERVING STATIC FILES IN DEVELOPMENT MODE #########
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT,
}),
)
This is My settings.py
#from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
import os
PROJECT_DIR = os.path.dirname(__file__)
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '..\kompatdata', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
# 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.core.context_processors.request",
# "django.contrib.messages.context_processors.messages")
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static/media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/static/media/'
#directory dei file privati per sviluppo locale
PRIVATE_DIR =os.path.join(PROJECT_DIR, 'static')
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'static',
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = '5#z%#zix3()rd4#4#lb!5)r4*5xez^ees4zd5%n-_ja5qg-x3h'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
#SESSION_ENGINE = "django.contrib.sessions.backends.file"
#SESSION_ENGINE = "django.contrib.sessions.backends.cache"
#SESSION_FILE_PATH = "E:\\temp"
SESSION_SAVE_EVERY_REQUEST = True
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 = 'bigfloproject.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'bigfloproject.wsgi.application'
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.
os.path.join(PROJECT_DIR, 'customers/templates/'),
os.path.join(PROJECT_DIR, 'dbeffects/templates/'),
os.path.join(PROJECT_DIR, 'kompat/templates/'),
os.path.join(PROJECT_DIR, 'spark/templates/'),
os.path.join(PROJECT_DIR, 'statistics/templates/'),
os.path.join(PROJECT_DIR, 'website/templates/'),
os.path.join(PROJECT_DIR, 'dbpatent/templates/'),
# 'C:/Django-1.5/Django-1.5/bigfloproject/customers/templates/'
# 'C:/Django-1.5/Django-1.5/bigfloproject/dbeffects/templates/'
# 'C:/Django-1.5/Django-1.5/bigfloproject/kompat/templates/'
# 'C:/Django-1.5/Django-1.5/bigfloproject/spark/templates/'
# 'C:/Django-1.5/Django-1.5/bigfloproject/statistics/templates/'
# 'C:/Django-1.5/Django-1.5/bigfloproject/website/templates/'
# 'C:/Django-1.5/Django-1.5/bigfloproject/dbpatent/templates/'
)
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',
'django_extensions',
#'registration',
'kompat',
'customers',
'dbeffect',
'dbpatent',
'spark',
'statistics',
'website'
)
LOGIN_URL = '/user/login/'
LOGIN_REDIRECT_URL = '/user/welcome-user/'
AUTH_PROFILE_MODULE = "customers.User"
AUTH_USER_MODEL ="customers.User"
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
ACCOUNT_ACTIVATION_DAYS = 2
Thank's in advance

Related

server 500 error python (visualstudio)

I'm developing a python app using Djgango and I'm getting the server 500 error. I believe my paths are set correctly, the python manage.py runserver returns that the server is running. When I look at developer tools on the page it says "Failed to load resource: the server responded with a status of 404 (not found) http://localhost:64915/favicon.co" and "failed to load resource: the server responded with a status of 500 (internal server error) http://localhost:64915/."
I don't know what is going on? I'm new to Django coming from asp.net which runs without all the go around. can you help me? Here is my wsgi.py file code.
"""
WSGI config for SmartShopper project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "SmartShopper.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
here is my settings.py file code
"""
Django settings for SmartShopper project.
"""
from os import path
PROJECT_ROOT = path.dirname(path.abspath(path.dirname(__file__)))
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = (
'localhost',
)
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': path.join(PROJECT_ROOT, 'db.sqlite3'),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
LOGIN_URL = '/login'
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = path.join(PROJECT_ROOT, 'static').replace('\\', '/')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'n(bd1f1c%e8=_xad02x5qtfn%wgwpi492e$8_erx+d)!tpeoim'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
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 = 'SmartShopper.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'SmartShopper.wsgi.application'
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.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
# Specify the default test runner.
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
when running with debug = true it says I have an error in the view.py on line 19 - the render line. This is an autogenerated view by visual studio. I already had to change the url.py to reflect an upated django format. I wonder if you guys can help me spot the same here. here is my code for the views.py.
Definition of views.
"""
from django.shortcuts import render
from django.http import HttpRequest
from django.template import RequestContext
from datetime import datetime
def home(request):
"""Renders the home page."""
assert isinstance(request, HttpRequest)
return render(
request,
'app/index.html',
context_instance = RequestContext(request,
{
'title':'Home Page',
'year':datetime.now().year,
})
)
def contact(request):
"""Renders the contact page."""
assert isinstance(request, HttpRequest)
return render(
request,
'app/contact.html',
context_instance = RequestContext(request,
{
'title':'Contact',
'message':'Your contact page.',
'year':datetime.now().year,
})
)
def about(request):
"""Renders the about page."""
assert isinstance(request, HttpRequest)
return render(
request,
'app/about.html',
context_instance = RequestContext(request,
{
'title':'About',
'message':'Your application description page.',
'year':datetime.now().year,
})
)
here is the traceback.
Environment:
Request Method: GET
Request URL: http://localhost:64625/
Django Version: 1.10.2
Python Version: 3.5.2
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'app')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\handlers\exception.py" in inner
39. response = get_response(request)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response
249. response = self._get_response(request)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\USER\Documents\GitHub\Capstone\SmartShopper\SmartShopper\app\views.py" in home
19. 'year':datetime.now().year,
Exception Type: TypeError at /
Exception Value: render() got an unexpected keyword argument 'context_instance'
For render(), you can pass context as a plain dictionary. If you're going to use a keyword argument, use context not context_instance (docs). That's why you're getting render() got an unexpected keyword argument 'context_instance':
def home(request):
"""Renders the home page."""
assert isinstance(request, HttpRequest)
return render(request, 'app/index.html', context={'title':'Home Page', 'year':datetime.now().year})

Django CMS Aldryn Create Wizard database error

I'm using Aldryn Newsblog and FAQ plugins. Django version 1.8.8, Django CMS 3.2.0.
I'm trying to create a new blog article or FAQ question by pressing "Create" in the toolbar (image 1).
It pops up a nice wizard for filling in the content, but when I actually submit it I get the error in image 2:
"DatabaseError at /cms_wizard/create/
Save with update_fields did not affect any rows.".
Stack trace:
Environment:
Request Method: POST
Request URL: http://localhost:9000/cms_wizard/create/
Django Version: 1.8.8
Python Version: 2.7.10
Installed Applications:
('djangocms_admin_style',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'menus',
'sekizai',
'treebeard',
'djangocms_text_ckeditor',
'djangocms_ckeditor_filer',
'filer',
'easy_thumbnails',
'wwb',
'adminsortable2',
'aldryn_apphooks_config',
'aldryn_boilerplates',
'aldryn_categories',
'aldryn_common',
'aldryn_newsblog',
'aldryn_faq',
'aldryn_people',
'aldryn_reversion',
'aldryn_translation_tools',
'parler',
'reversion',
'sortedm2m',
'taggit',
'gunicorn')
Installed Middleware:
('cms.middleware.utils.ApphookReloadMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
'djangocms_ckeditor_filer.middleware.ThumbnailMiddleware')
Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in inner
145. return func(*args, **kwargs)
File "/Library/Python/2.7/site-packages/cms/wizards/views.py" in dispatch
38. request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/formtools/wizard/views.py" in dispatch
237. response = super(WizardView, self).dispatch(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in dispatch
89. return handler(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/formtools/wizard/views.py" in post
300. return self.render_done(form, **kwargs)
File "/Library/Python/2.7/site-packages/formtools/wizard/views.py" in render_done
357. **kwargs)
File "/Library/Python/2.7/site-packages/cms/wizards/views.py" in done
148. instance = form_two.save()
File "/Library/Python/2.7/site-packages/aldryn_newsblog/cms_wizards.py" in save
112. body=content,
File "/Library/Python/2.7/site-packages/cms/api.py" in add_plugin
347. plugin.save()
File "/Library/Python/2.7/site-packages/djangocms_text_ckeditor/models.py" in save
47. super(AbstractText, self).save(*args, **kwargs)
File "/Library/Python/2.7/site-packages/cms/models/pluginmodel.py" in save
248. super(CMSPlugin, self).save(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in save
734. force_update=force_update, update_fields=update_fields)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in save_base
762. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in _save_table
831. raise DatabaseError("Save with update_fields did not affect any rows.")
Exception Type: DatabaseError at /cms_wizard/create/
Exception Value: Save with update_fields did not affect any rows.
Settings.py file:
import os
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'g67=r(8b)#=!x1^ddido=qp&9_pq=5&acs%u=xr_xe7t3uq70n'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
ROOT_URLCONF = 'myapp.urls'
WSGI_APPLICATION = 'myapp.wsgi.application'
LANGUAGE_CODE = 'en'
TIME_ZONE = 'Europe/Dublin'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'media/')
STATIC_ROOT = os.path.join(DATA_DIR, 'static/')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'myapp', 'static'),
os.path.join(BASE_DIR, 'myapp', 'templates'),
)
SITE_ID = 1
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'wwb', 'templates'),
],
'OPTIONS': {
'debug': True,
'context_processors':
[
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.i18n',
'django.core.context_processors.debug',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.csrf',
'django.core.context_processors.tz',
'sekizai.context_processors.sekizai',
'django.core.context_processors.static',
'cms.context_processors.cms_settings',
'aldryn_boilerplates.context_processors.boilerplate',
],
'loaders':
[
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
]
}
},
]
MIDDLEWARE_CLASSES = (
'cms.middleware.utils.ApphookReloadMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
'djangocms_ckeditor_filer.middleware.ThumbnailMiddleware'
)
INSTALLED_APPS = (
'djangocms_admin_style',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'menus',
'sekizai',
'treebeard',
'djangocms_text_ckeditor',
#for uploading images to ckeditor
'djangocms_ckeditor_filer',
'filer',
'easy_thumbnails',
'wwb',
#for aldryn-blog and aldryn-faq
'adminsortable2',
'aldryn_apphooks_config',
'aldryn_boilerplates',
'aldryn_categories',
'aldryn_common',
'aldryn_newsblog',
'aldryn_faq',
'aldryn_people',
'aldryn_reversion',
'aldryn_translation_tools',
'parler',
'reversion',
'sortedm2m',
'taggit',
'gunicorn',
)
ALDRYN_BOILERPLATE_NAME = 'bootstrap3'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
THUMBNAIL_HIGH_RESOLUTION = True
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'easy_thumbnails.processors.scale_and_crop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters',
)
LANGUAGES = (
('en', gettext('en')),
)
CMS_TEMPLATES = (
('staticpage.html', 'Static page'),
)
CMS_PERMISSION = True
CMS_PLACEHOLDER_CONF = {
'carousel': {
'plugins': ['CMSCarouselPlugin']
},
'info section - image cycle': {
'plugins': ['ImageCyclePlugin']
}
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'HOST': 'localhost',
'NAME': 'project.db',
'PORT': '',
}
}
CKEDITOR_SETTINGS = {
'toolbar': 'Basic',
'extraPlugins': 'filerimage',
'removePlugins': 'image,flash',
}
However, it works fine through the main Admin area, and adding "New FAQ category" through the wizard also works fine.
Any thoughts?
Comparing the save() method for the CMSWizards of both Aldryn FAQ (which works for you) and Aldryn NewsBlog (which does not) there is a clue that perhaps you have set the settings WIZARD_CONTENT_PLUGIN and WIZARD_CONTENT_PLUGIN_BODY? FAQ uses these settings whereas NewsBlog does not, instead it requires the used of djangocms-text-ckeditor's TextPlugin.
I do see that you have djangocms-text-ckeditor installed though. I wonder if you haven't yet run migrations for it yet, perhaps?
Are you able to use a normal TextPlugin elsewhere in your project?
So the answer is I need to be using djangocms-text-ckeditor>=2.8.1 for my version of Django==3.2.0.
Thank you #mkoistinen!

404 Not Found in django admin page when using django-non-rel for google app engine

I am using python 2.7 and django 1.8 and django-non-rel to make my project run on google app engine for django non-rel.
When i open http://127.0.0.1:8000/ it works fine and takes me to the google app engine sdk page..
But when i go to http://127.0.0.1:8000/admin/ , I get error -
404 Not Found
The resource could not be found.
Please help me to set up the admin page.
My urls.py file is this -
from django.conf.urls import *
from django.contrib import admin
import dbindexer
handler500 = 'djangotoolbox.errorviews.server_error'
# django admin
admin.autodiscover()
# search for dbindexes.py in all INSTALLED_APPS and load them
dbindexer.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'bookncart.views.home', name='home'),
# url(r'^bookncart/', include('bookncart.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('^_ah/warmup$', 'djangoappengine.views.warmup'),
url(r'^admin/', include(admin.site.urls)),
)
The settings.py file is this -
# Django settings for bookncart project.
# Initialize App Engine and import the default settings (DB backend, etc.).
# If you want to use a different backend you have to remove all occurences
# of "djangoappengine" from this file.
from djangoappengine.settings_base import *
import os
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
# Activate django-dbindexer for the default database
DATABASES['native'] = DATABASES['default']
DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}
AUTOLOAD_SITECONF = 'indexes'
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = False
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'y*ik#rc7+ifd5&_^hc(yk-ca15ze^%ooltm_s)po^zyjzj$t9b'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
# This loads the index definitions, so it has to come first
'autoload.middleware.AutoloadMiddleware',
'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',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.request',
'django.core.context_processors.media',
)
ROOT_URLCONF = 'bookncart.urls'
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.
)
# This test runner captures stdout and associates tracebacks with their
# corresponding output. Helps a lot with print-debugging.
TEST_RUNNER = 'djangotoolbox.test.CapturingTestSuiteRunner'
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',
'djangotoolbox',
'autoload',
'dbindexer',
# djangoappengine should come last, so it can override a few manage.py commands
'djangoappengine',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
DEBUG = True
settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
)
urls.py
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
)

using Tinymce for django error.

I am trying to use TinyMCE Editor in django for textarea. I followed the instructions given on django-tinymce.readthedocs.org/en/latest/usage.html#python-code which give me a error
Environment:
Request Method: GET
Request URL: http://localhost:8000/home/
Django Version: 1.6.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tinymce')
Installed Middleware:
('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')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/hussain/django/ali/ali/views.py" in HomePage
6. print " form :: ",form
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/utils/encoding.py" in <lambda>
60. klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/forms/forms.py" in __str__
103. return self.as_table()
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/forms/forms.py" in as_table
223. errors_on_separate_row = False)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/forms/forms.py" in _html_output
186. 'field': six.text_type(bf),
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/forms/forms.py" in __str__
425. return self.as_widget()
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/forms/forms.py" in as_widget
475. return widget.render(name, self.value(), attrs=attrs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/forms/widgets.py" in render
572. options = self.render_options(choices, value)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/forms/widgets.py" in render_options
528. for option_value, option_label in chain(self.choices, choices):
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/forms/models.py" in __iter__
1044. for obj in self.queryset.all():
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/models/query.py" in __iter__
96. self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/models/query.py" in _fetch_all
854. self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/models/query.py" in iterator
220. for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/models/sql/compiler.py" in results_iter
710. for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/models/sql/compiler.py" in execute_sql
781. cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/backends/util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6.1-py2.7.egg/django/db/backends/sqlite3/base.py" in execute
450. return Database.Cursor.execute(self, query, params)
Exception Type: OperationalError at /home/
Exception Value: no such table: django_site
I feel to stupid to not get this. :'(.
these are my files.
settings.py
"""
Django settings for ali project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Django settings for corating project.
PROJECT_DIR = os.path.dirname(__file__)
print 'BASE_DIR ',BASE_DIR
print 'PROJECT_DIR ',PROJECT_DIR
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '-=153zwy^8$sz%gsw#kb377pp#r3wmcer(4tc$j-h4(^3s+zw+'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tinymce',
)
MIDDLEWARE_CLASSES = (
'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 = 'ali.urls'
WSGI_APPLICATION = 'ali.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static_root')
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(PROJECT_DIR, 'static'),
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
TINYMCE_JS_URL = os.path.join(STATIC_URL, "js/tiny_mce/tiny_mce.js")
TINYMCE_JS_ROOT = os.path.join(STATIC_URL, "js/tiny_mce")
print "TINYMCE_JS_ROOT ",TINYMCE_JS_ROOT
print "TINYMCE_JS_URL ",TINYMCE_JS_URL
TEMPLATE_DIRS = (
'/home/hussain/django/ali/ali/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.
)
forms.py
from django import forms
from django.contrib.flatpages.models import FlatPage
from tinymce.widgets import TinyMCE
class FlatPageForm(forms.ModelForm):
content = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
class Meta:
model = FlatPage
views.py
from django.shortcuts import render_to_response
from page.forms import FlatPageForm
def HomePage(request):
form = FlatPageForm()
print " form :: ",form
return render_to_response('HomePage.html',{'form':form})
urls.py
from django.conf.urls import patterns, include, url
from ali.views import HomePage
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'ali.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
#url(r'^admin/', include(admin.site.urls)),
url(r'^home/', 'ali.views.HomePage' ),
url(r'^tinymce/', include('tinymce.urls') ),
)
You don't seem to have installed flatpages app. Also flatpages app depends in sites framework Follow the steps in the documentation to get it right:
--- excerpts --
To install the flatpages app, follow these steps:
Install the sites framework by adding 'django.contrib.sites' to your INSTALLED_APPS setting, if it’s not already in there.
Also make sure you’ve correctly set SITE_ID to the ID of the site the settings file represents. This will usually be 1 (i.e. SITE_ID = 1, but if you’re using the sites framework to manage multiple sites, it could be the ID of a different site.

Admin pages on django 1.4 doesn't work

I'm trying to establish a simple thing I have done many times before, which is enabling the admin pages on Django, but this time is on 1.4 version.
I keep getting this message over and over (ImportError at /admin/ No module named django.contrib.auth).
This is my urls file:
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.conf import settings
from filebrowser.sites import site
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
import django
from django.contrib import auth
from django.contrib.admin import *
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/filebrowser/', include(site.urls)),
url(r'^polls/', include('volcano.urls')),
url(r'^contact/', include('form_handle_app.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
#url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
#url(r'^admin/', include('django.contrib.admin.urls')),
url(r'^login/', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
)
This is settings file:
# Django settings for sito project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
import os
#PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
PROJECT_ROOT = '/home/framoau/sito'
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'testo', # Or path to database file if using sqlite3.
'USER': '********', # Not used with sqlite3.
'PASSWORD': '********', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = '/home/framoau/sito/media/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = 'media'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = '$hebtpijge6%o*7uegb6!sny5vl0n4w9j2wao-(fxsdb1#kv7b'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
)
# URL of the login page.
LOGIN_URL = '/contact/login/'
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"
)
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 = 'sito.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'sito.wsgi.application'
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.
'/home/framoau/sito/templates',
)
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:
'grappelli',
'filebrowser',
'django.contrib.admindocs',
'volcano',
'form_handle_app',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
My admin page:
from volcano.models import Poll, Choice
from form_handle_app.models import Document
from django.contrib import admin
#admin.site.register(Poll)
#admin.site.register(Choice)
admin.site.register(Document)
Finally, Django's error dump:
> Environment:
Request Method: GET
Request URL: http://192.168.0.4/admin/
Django Version: 1.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'grappelli',
'filebrowser',
'django.contrib.admindocs',
'volcano',
'form_handle_app')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/contrib/admin/sites.py" in wrapper
213. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/views/decorators/cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/contrib/admin/sites.py" in inner
192. current_app=self.name):
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/urlresolvers.py" in reverse
447. app_list = resolver.app_dict[ns]
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/urlresolvers.py" in app_dict
290. self._populate()
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/urlresolvers.py" in _populate
253. for name in pattern.reverse_dict:
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/urlresolvers.py" in reverse_dict
276. self._populate()
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/urlresolvers.py" in _populate
265. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/urlresolvers.py" in callback
216. self._callback = get_callable(self._callback_str)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/utils/functional.py" in wrapper
27. result = func(*args)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/urlresolvers.py" in get_callable
105. not module_has_submodule(import_module(parentmod), submod)):
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/utils/importlib.py" in import_module
35. __import__(name)
Exception Type: ImportError at /admin/
Exception Value: No module named django.contrib.auth
I tried importing all the libraries inside manage.py shell console, applied all introspection techniques on all the objects, and everything worked very easily, things only stop when I run Django normally. What am I doing wrong?
I got it :))
The problem is in importing/including other urls in the main url.
Tried to comment this line url(r'^contact/', include('form_handle_app.urls')),
and things went well.
I found out that uform_handle_app.urls, has a bad line that doesn't refer to anything (url(r'^$', 'contact'),) , and at the same time, django doesn't complain unless it's being touched by the browser; when adding admin pages, all the urls that you have should be fine, even if you will not use them.
`

Categories

Resources