Django CMS Aldryn Create Wizard database error - python

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!

Related

ValueError at /admin/login/ - dictionary update sequence element #0 has length 0; 2 is required

I have a django project that I haven't touched in about a month. I have comeback to see an error when trying to connect to any page for the app (including admin login page). The error is:
ValueError at /admin/login/
dictionary update sequence element #0 has length 0; 2 is required
Here is the full traceback:
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/login/?next=/admin/
Django Version: 1.11.4
Python Version: 3.6.2
Installed Applications:
['ad_app.apps.AdAppConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py" in inner
41. response = get_response(request)
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response
217. response = self.process_exception_by_middleware(e, request)
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response
215. response = response.render()
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\response.py" in render
107. self.content = self.rendered_content
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\response.py" in rendered_content
84. content = template.render(context, self._request)
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\backends\django.py" in render
66. return self.template.render(context)
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\base.py" in render
205. with context.bind_template(self):
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\contextlib.py" in __enter__
81. return next(self.gen)
File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\context.py" in bind_template
263. updates.update(processor(self.request))
Exception Type: ValueError at /admin/login/
Exception Value: dictionary update sequence element #0 has length 0; 2 is required
Here is my settings.py file:
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '***'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
LOGIN_URL = '/welcome'
AUTHENTICATION_BACKENDS = ['ad_app.authentication.EmailBackend']
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'ad_app.apps.AdAppConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'ad_project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'ad_app.views.wallet',
],
},
},
]
WSGI_APPLICATION = 'ad_project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = False
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
# TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
Any help would be much appreciated, I can provide more information if needed!
Removed line
'ad_app.views.wallet',
from context processors. Many thanks to Daniel Roseman!

Why I have AttributeError in django-realtime

I use this framework https://github.com/anishmenon/django-realtime
I read solution and write this:
def index(request):
post = Post.objects.get(id=1)
print(post.title)
ishout_client.emit(
Post.title,
'notifications',
data={ 'test' : 'test' }
)
return render(request, 'index.html', { })
But i got this:
AttributeError: 'NoneType' object has no attribute 'read'
I just want write webapclication where I click button and another browser get console log 'clicked' for example.
Environment:
Request Method: GET
Request URL: http://localhost:8000/tescik/
Django Version: 1.10.4
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'corsheaders',
'django.contrib.staticfiles',
'drealtime',
'tescik']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'drealtime.middleware.iShoutCookieMiddleware']
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
39. response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _legacy_get_response
249. response = self._get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/marek/tescior/mysite/tescik/views.py" in index
19. data={ 'test' : 'test' }
File "/usr/local/lib/python2.7/dist-packages/drealtime/__init__.py" in emit
87. response.read()
Exception Type: AttributeError at /tescik/
Exception Value: 'NoneType' object has no attribute 'read'
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'b78yjnhx_j0s#x%nc)8h-(znk%)l(i9ze--$4!0xrw^nmvxihv'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'corsheaders',
'django.contrib.staticfiles',
'drealtime',
'tescik',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'drealtime.middleware.iShoutCookieMiddleware',
]
ROOT_URLCONF = 'mysite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'mysite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/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.10/howto/static-files/
STATIC_URL = '/static/'
html
<head>
{% load drealtimetags %}
</head>
test
Are you sure an object Post with id=1 exists?
Try get_object_or_404() method instead of get() to avoid such errors.

TemplateDoesNotExist at / base.html

friends.
I try to repeat by doing the example of project in book: "Learning Django Web Development" by Jaiswal, Sanjeev.
Running the server i get such exception: TemplateDoesNotExist at /base.html
TemplateDoesNotExist at /
base.html
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8.3
Exception Type: TemplateDoesNotExist
Exception Value: base.html
Exception Location: C:\Python34\lib\site-packages\django\template\loader.py in get_template, line 46
Python Executable: C:\Python34\python.EXE
Python Version: 3.4.3
Python Path:
['C:\\dj\\mytweets',
'C:\\WINDOWS\\system32\\python34.zip',
'C:\\Python34\\DLLs',
'C:\\Python34\\lib',
'C:\\Python34',
'C:\\Python34\\lib\\site-packages']
Server time: Tue, 14 Jul 2015 14:01:27 +0300
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
C:\Python34\lib\site-packages\django\contrib\admin\templates\base.html (File does not exist)
C:\Python34\lib\site-packages\django\contrib\auth\templates\base.html (File does not exist)
My settings.py file:
import os
SETTINGS_PATH = os.path.dirname(__file__)
PROJECT_PATH = os.path.join(SETTINGS_PATH, os.pardir)
PROJECT_PATH = os.path.abspath(PROJECT_PATH)
TEMPLATE_PATH = os.path.join(PROJECT_PATH, "templates")
SECRET_KEY = 'khcr3h6u+ghi+rtb+g_(mvgq!mtn9u4&%=hu20vt2*u(p8-kde'
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tweets',
)
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',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'mytweets.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(PROJECT_PATH, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'mytweets.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_PATH, 'db.sqlite3'),
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(
os.path.dirname(__file__),
'static',
),
)
TEMPLATE_DIRS = (
TEMPLATE_PATH,
)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
I tried to change settings.py in such way too:
changed settings.py:
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_PATH = os.path.join(BASE_DIR, "templates")
SECRET_KEY = 'khcr3h6u+ghi+rtb+g_(mvgq!mtn9u4&%=hu20vt2*u(p8-kde'
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tweets',
)
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',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'mytweets.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'mytweets.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(
os.path.dirname(__file__),
'static',
),
)
My project structure:
views.py:
from django.views.generic import View
from django.shortcuts import render
class Index(View):
def get(self, request):
params = {}
params['name'] = 'Django'
return render(request, 'base.html', params)
urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from tweets.views import Index
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', Index.as_view()),
url(r'^admin/', include(admin.site.urls)),
)
Traceback:
Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
C:\Python34\lib\site-packages\django\contrib\admin\templates\base.html (File does not exist)
C:\Python34\lib\site-packages\django\contrib\auth\templates\base.html (File does not exist)
Traceback:
File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in get_response
132.response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python34\lib\site-packages\django\views\generic\base.py" in view
71.return self.dispatch(request, *args, **kwargs)
File "C:\Python34\lib\site-packages\django\views\generic\base.py" in dispatch
89.return handler(request, *args, **kwargs)
File "C:\dj\mytweets\tweets\views.py" in get
9.return render(request, 'base.html', params)
File "C:\Python34\lib\site-packages\django\shortcuts.py" in render
67.template_name, context, request=request, using=using)
File "C:\Python34\lib\site-packages\django\template\loader.py" in render_to_string
98.template = get_template(template_name, using=using)
File "C:\Python34\lib\site-packages\django\template\loader.py" in get_template
46.raise TemplateDoesNotExist(template_name)
Exception Type: TemplateDoesNotExist at /
Exception Value: base.html
Please, give an advice, what should i change to get rendered page?
I'm not familiar with the book you are using, so I can't give you any advice based on that. If the book is for Django 1.7, you will find it easier to use Django 1.7 instead of Django 1.8, at least when you are beginning with Django.
If you want to stick with Django 1.8, here's how to fix the error you are currently seeing:
Your settings.py file has a mixture of old templates settings, like TEMPLATE_DIRS and TEMPLATE_LOADERS (Django <= 1.7), and the new settings under TEMPLATES (Django 1.8+).
First, remove the old settings TEMPLATE_DIRS and TEMPLATE_LOADERS.
Secondly, it looks as if DIRS is incorrect in your TEMPLATES setting.
Define BASE_DIR, which should be included in settings.py by default when you run ./manage.py startproject
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Then change TEMPLATES to
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
...
I had same problem first I tried to solve it with adding path to shortcuts of HTML templates {% extends "base.html" %} to {% extends "foldername/template/base.html" %} it did not work.
After that I add to 'base.html' file in every projects templates folder. It worked for me.
In installed apps add mytweets instead of tweets .
I had exactly that problem, base.html not found in my_project/templates/base.html.
I fixed it moving the directory templates just after the app that calls it
(before buggy)
--my_project
--templates
--app_a
(after fixed)
--my_project
--app_a
--templates
Set your template path in DIR [] of settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [**'C:\\Python27\\Lib\\site-packages\\django\\contrib\\admin\\templates\\admin'**],
'APP_DIRS':True,
'OPTIONS': {

ImportError at /admin/ No module named views

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

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.

Categories

Resources