Django Haystack SearchQuerySet returns none using solr - django

I'm making use of Django haystack for my blog with solr as my search engine. I have also setup my solr(version 6.6.6) properly and all query are showing on the solr website. But when I make use of the SearchQuerySet
it returnss none upon query. I have included code below.
views.py
from django.shortcuts import render, redirect
from django.urls import reverse_lazy
from django.views import generic
from blog.views import Post
from django.views.generic.base import TemplateView
from haystack.query import SearchQuerySet
import logging
logger = logging.getLogger(__name__)
class Search(TemplateView):
template_name = 'blog/post_search.html'
def get(self, request, **kwargs):
query = request.GET.get('query', '')
results = SearchQuerySet().models(Post).filter(content='query').load_all()
total = results.count()
return render(request, self.template_name, {'results':results, 'total':total})
search_indexes.py
from haystack import indexes
from blog.models import Post
class PostIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
publish = indexes.DateTimeField(model_attr='publish_date')
def get_model(self):
return Post
def index_queryset(self, using=None):
return self.get_model().objects.published()
settings.py
"""
Django settings for radd project.
Generated by 'django-admin startproject' using Django 3.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
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__)))
TEMPLATE_DIR = os.path.join(BASE_DIR,'templates')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
SITE_ID = 1
ALLOWED_HOSTS = ['www.rad.com', '127.0.0.1', 'rad.com', 'localhost', '192.168.43.195']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django_comments',
'django_comments_xtd',
'rest_framework',
'blog',
'mptt',
'haystack',
# third party apps
'crispy_forms',
]
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr/blog',
'ADMIN_URL': 'http://127.0.0.1:8983/solr/admin/cores',
},
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

Related

It is required that you pass in a value for the "algorithms" argument when calling decode()

The following pages are the code of projects:
If i am using token = jwt.encode(payload,'secret', algorithm='HS256').decode('utf-8') statement
then
'str' object has no attribute 'decode'
error is occuring. Also, when I am removing and using it without .decode('utf-8') and proceeding with the further code. it is working fine. But when I am applying payload = jwt.decode(token, 'secret', algorithm=['HS256'])
then
It is required that you pass in a value for the "algorithms" argument when calling decode()"
This above-mentioned error is occurring. Please Help me to rectify this error. This is the mentioned error that saying algorithms argument when calling decode() error should be rectified.
View Page:
from django.http import request, response
from django.shortcuts import render
from rest_framework import serializers
from rest_framework.views import APIView
from myusers.serializers import UserSerializer
from rest_framework.exceptions import AuthenticationFailed
from rest_framework.response import Response
from .models import User
import jwt, datetime
# Create your views here.
class RegisterView(APIView):
def post(self,request):
serializer = UserSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data)
class LoginView(APIView):
def post(self,request):
email=request.data['email']
password = request.data['password']
user = User.objects.filter(email=email).first()
if user is None:
raise AuthenticationFailed('User Not Found!!!')
if not user.check_password(password):
raise AuthenticationFailed('Incorrect Password!!!')
payload={
'id':user.id,
'exp':datetime.datetime.utcnow() + datetime.timedelta(minutes=60),
'iat':datetime.datetime.utcnow()
}
token = jwt.encode(payload,'secret', algorithm='HS256').decode('utf-8')
response = Response()
response.data={
"jwt":token
}
response.set_cookie(key='jwt', value=token, httponly=True)
return response
class Userview(APIView):
def get(self,request):
token = request.COOKIES.get('jwt')
if not token:
raise AuthenticationFailed('User Authentication Failed!!!')
try:
payload = jwt.decode(token, 'secret', algorithm=['HS256'])
except jwt.ExpiredSignatureError:
raise AuthenticationFailed('Unauthenticated!')
user = User.objects.filter(id = payload['id']).first()
serializer = UserSerializer(user)
return Response(serializer.data)
class LogoutView(APIView):
def post(self, request):
response = Response()
response.delete_cookie('jwt')
response.data = {
'message': 'success'
}
return response
Serializer Page:
from django.db.models import fields
from rest_framework import serializers
from .models import User
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ['id', 'name','email','password']
extra_kwargs={
'password' : {'write_only':True}
}
def create(self, validated_data):
password = validated_data.pop('password',None)
instance = self.Meta.model(**validated_data)
if password is not None:
instance.set_password(password)
instance.save()
return instance
Model Page:
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
name = models.CharField(max_length=255)
email = models.CharField(max_length=250, unique=True)
password = models.CharField(max_length=255)
username = None
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
Urls page:
from django.urls import path
from .views import RegisterView, LoginView, Userview
urlpatterns = [
path('register',RegisterView.as_view()),
path('login',LoginView.as_view()),
path('user',Userview.as_view()),
path('logout',Userview.as_view()),
]
Setting Page:
"""
Django settings for login project.
Generated by 'django-admin startproject' using Django 4.0.1.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-k02ug7k7bm-q0cgy4uini(mol=__ye-cm)$c1q+utmhg86ds$7'
# 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',
'django.contrib.staticfiles',
'myusers',
'rest_framework',
'corsheaders'
]
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 = 'login.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',
],
},
},
]
WSGI_APPLICATION = 'login.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/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/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
AUTH_USER_MODEL = 'myusers.User'
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
You're missing an 's', the parameter is called "algorithms" in the decode function:
payload = jwt.decode(token, 'secret', algorithms=['HS256'])
and you're also passing an array of possible values.
When you call encode, the parameter is "algorithm" and only takes a single value.
The reason is that during encoding (i.e signing), you have to use explicitly one algorithm, because a token can only be signed using one algorithm. But during decoding (verifying), you tell the function which algorithms you accept.
Another solution is to downgrade the PyJWT version to 1.7.1, so you wouldn't need to pass the "algorithms" argument.
Like this:
jwt.decode(encoded, verify=False)
I had to pass
verify=False, options={'verify_signature': False} in order to get it working.

how to use django markdown in my blog

at first I successfully install django markdown
pip install django-markdown
than I add django-markdown in my setting.py file
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
'django-markdown',
]
then, I change my urls.py like as:
from django.conf.urls import include, url
from django.contrib import admin
from resume import views
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^home/$', views.home, name='home'),
url(r'^blog/', include('blog.urls',namespace='blog',app_name='blog')),
url('^markdown/', include('django_markdown.urls')),
]
I also change my admin.py file like as:
from django.contrib import admin
from .models import Post
from django_markdown.admin import MarkdownModelAdmin
class PostAdmin(admin.ModelAdmin):
list_display = ('title','slug','author','publish','status')
list_filter = ('status','created','publish','author')
search_fields = ('title','body')
prepopulated_fields = {'slug':('title',)}
raw_id_fields = ('author',)
date_hierarchy = 'publish'
ordering = ['status','publish']
# Register your models here.
admin.site.register(Post,MarkdownModelAdmin, PostAdmin)
but, when I start my runserver, django gives me an error like this:
ModuleNotFoundError: No module named 'django-markdown'
how can i solve my problem?
In installed apps you should add django_markdown instead of django-markdown

Django- Files are not being uploaded in /media/<user> file

I am trying to upload file in /media/ folder in my django project name codewar.Here I am creating a independent folder for each user and placing the uploaded files in it. However my files are not being uploaded and I am getting error after submitting the query as
TypeError at /index/
an integer is required
Request Method: POST
Request URL: http://127.0.0.1:8000/index/
Django Version: 1.7
Exception Type: TypeError
Exception Value:
an integer is required
Exception Location: C:\Python27\codewar\codewar\views.py in cust_proc, line 38
Python Executable: C:\Python27\python.exe
Python Version: 2.7.5
Python Path:
['C:\\Python27\\codewar',
'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages']
Server time: Mon, 16 Feb 2015 17:29:28 +0530
my urls.py is
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf.urls.static import static
from codewar.views import *
from django.conf import settings
urlpatterns = patterns('',(r'^index/$',mainsite),url(r'^admin/', include(admin.site.urls))) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += patterns('',) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
my views.py is
from django.shortcuts import *
from django.http import *
from django.template.loader import *
from django.template import *
from os import *
from os.path import *
from django.template import RequestContext
from django.conf import settings
def mainsite(request):
if request.method=='POST':
return render_to_response('index.html',context_instance=RequestContext(request,processors=[cust_proc]))
else:
return render_to_response('index.html',context_instance=RequestContext(request))
def cust_proc(request):
data={}
if request.method == 'POST':
newpath="C:\\Python27\\codewar\\media\\"+request.POST.get('name')
if not exists(newpath):
mkdir(newpath)
#t=save_file(request.POST.get('name'),request.FILES.get('browse'))
if 'file' in request.FILES:
file = request.FILES['file']
print file
# Other data on the request.FILES dictionary:
# filesize = len(file['content'])
# filetype = file['content-type']
dirname=request.POST.get('name')
filename = request.POST.get('filename')#file['filename']
s= settings.MEDIA_ROOT+"\\"+dirname+"\\"+filename
print s
#fd = open('%s' % (s), 'wb')
fd=request.FILES['file'].read()
fdd=open(s,"w")
ffd.write(fd)
fdd.close()
#fd.write(file['content'])
data={
'name':request.POST.get('name'),
'filename':request.POST.get('filename'),
'code':request.FILES['file'].read()
}
return {'data':data}
my settings.py is:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
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',
)
ROOT_URLCONF = 'codewar.urls'
WSGI_APPLICATION = 'codewar.wsgi.application'
STATIC_URL = '/static/'
STATIC_ROOT = "C:\Python27\codewar\static"
TEMPLATE_DIRS=(
'C:\Python27\codewar',
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
STATICFILES_DIRS = (
'C:\Python27\codewar\staticfiles',
)
MEDIA_ROOT = 'C:\Python27\codewar\media'
MEDIA_URL = '/media/'
I think line 38 is this line:
fdd=open(s,"w")
Note that you are importing os.open using this statement in the beginning of your views.py:
from os import *
In line 38 you are actually trying to call os.open. Now, os.open (docs) is different than built-in open (docs). It expects an integer mode argument.
You should modify your import line to import only necessary functions from os library.
As a side note, wildcard imports are not advised because of namespace pollution causing errors of this kind.

django cmsplugin-blog not working

I've installed Django 1.3 with django-cms. All is working correctly.
After that I installed cmsplugin-blog (from the extensions page of the djanog-cms website), version 1.1.1
I can't seem to get my urls working correctly. It looks like the correct urls are being produced by the blog app, but when opening the posts, I get 404 error. I think it might be a mistake in the urls.py of the blog application:
from django.conf import settings
from django.conf.urls.defaults import *
from django.core.urlresolvers import reverse
from django.views.generic.date_based import archive_year, archive_month, archive_day, object_detail
from django.views.generic.list_detail import object_list
from tagging.views import tagged_object_list
from menus.utils import set_language_changer
from cms.models import Title
from cms.utils.urlutils import urljoin
from cmsplugin_blog.feeds import EntriesFeed, TaggedEntriesFeed, AuthorEntriesFeed
from cmsplugin_blog.models import Entry
from cmsplugin_blog.views import EntryDateDetailView, EntryArchiveIndexView
blog_info_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
'allow_empty': True,
'paginate_by': 15,
}
blog_info_tagged_dict = {
'queryset_or_model': Entry.objects.all(),
'allow_empty': True,
}
blog_info_author_dict = {
'queryset': Entry.objects.all(),
'allow_empty': True,
'template_name': 'cmsplugin_blog/entry_author_list.html',
}
blog_info_month_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
'month_format': '%m',
'allow_empty': True,
}
blog_info_year_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
'make_object_list': True,
'allow_empty': True,
}
blog_info_detail_dict = dict(blog_info_month_dict, slug_field='entrytitle__slug')
def language_changer(lang):
request = language_changer.request
return request.get_full_path()
blog_archive_index = EntryArchiveIndexView.as_view()
def blog_archive_year(request, **kwargs):
kwargs['queryset'] = kwargs['queryset'].published()
set_language_changer(request, language_changer)
return archive_year(request, **kwargs)
def blog_archive_month(request, **kwargs):
kwargs['queryset'] = kwargs['queryset'].published()
set_language_changer(request, language_changer)
return archive_month(request, **kwargs)
def blog_archive_day(request, **kwargs):
kwargs['queryset'] = kwargs['queryset'].published()
set_language_changer(request, language_changer)
return archive_day(request, **kwargs)
blog_detail = EntryDateDetailView.as_view()
def blog_archive_tagged(request, **kwargs):
kwargs['queryset_or_model'] = kwargs['queryset_or_model'].published()
set_language_changer(request, language_changer)
return tagged_object_list(request, **kwargs)
def blog_archive_author(request, **kwargs):
author = kwargs.pop('author')
kwargs['queryset'] = kwargs['queryset'].published().filter(entrytitle__author__username=author)
kwargs['extra_context'] = {
'author': author,
}
set_language_changer(request, language_changer)
return object_list(request, **kwargs)
urlpatterns = patterns('',
(r'^$', blog_archive_index, blog_info_dict, 'blog_archive_index'),
(r'^(?P<year>\d{4})/$',
blog_archive_year, blog_info_year_dict, 'blog_archive_year'),
(r'^(?P<year>\d{4})/(?P<month>\d{2})/$',
blog_archive_month, blog_info_month_dict, 'blog_archive_month'),
(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$',
blog_archive_day, blog_info_month_dict, 'blog_archive_day'),
(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
blog_detail, blog_info_detail_dict, 'blog_detail'),
(r'^tagged/(?P<tag>[^/]*)/$', blog_archive_tagged, blog_info_tagged_dict, 'blog_archive_tagged'),
(r'^author/(?P<author>[^/]*)/$', blog_archive_author, blog_info_author_dict, 'blog_archive_author'),
(r'^rss/any/tagged/(?P<tag>[^/]*)/$', TaggedEntriesFeed(), {'any_language': True}, 'blog_rss_any_tagged'),
(r'^rss/tagged/(?P<tag>[^/]*)/$', TaggedEntriesFeed(), {}, 'blog_rss_tagged'),
(r'^rss/any/author/(?P<author>[^/]*)/$', AuthorEntriesFeed(), {'any_language': True}, 'blog_rss_any_author'),
(r'^rss/author/(?P<author>[^/]*)/$', AuthorEntriesFeed(), {}, 'blog_rss_author'),
(r'^rss/any/$', EntriesFeed(), {'any_language': True}, 'blog_rss_any'),
(r'^rss/$', EntriesFeed(), {}, 'blog_rss')
)
Any help is appreciated!
If you need more configurations, I can post them.
Thanks
settings.py
# -*- coding: utf-8 -*-
import os
gettext = lambda s: s
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
DEBUG = True
TEMPLATE_DEBUG = DEBUG
MANAGERS = ADMINS
DEFAULT_LANGUAGE = 0
DATABASES = {
'default': {
'ENGINE': '*******',
'NAME': '*******',
'USER': '*******',
'PASSWORD': '*********',
'HOST': '*******',
'PORT': '*******',
}
}
TIME_ZONE = 'Europe/Amsterdam'
LANGUAGE_CODE = 'nl'
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
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
# Make this unique, and don't share it with anybody.
SECRET_KEY = '**************************'
# 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',
)
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',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
'cmsplugin_blog.middleware.MultilingualBlogEntriesMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.static',
'cms.context_processors.media',
'sekizai.context_processors.sekizai',
)
CMS_TEMPLATES = (
('base.html', 'Main Template'),
)
ROOT_URLCONF = 'urls'
TEMPLATE_DIRS = (
os.path.join(PROJECT_DIR, 'templates'),
)
#for cms-blog
JQUERY_JS = 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'
JQUERY_UI_JS = 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js'
JQUERY_UI_CSS = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/themes/smoothness/jquery-ui.css'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.staticfiles',
'debug_toolbar',
'cms',
'menus',
'mptt',
'south',
'cms.plugins.text',
'cms.plugins.picture',
'cms.plugins.link',
'cms.plugins.file',
'cms.plugins.snippet',
'cms.plugins.googlemap',
'sekizai',
'cmsplugin_contact',
'cmsplugin_blog',
'djangocms_utils',
'simple_translation',
'tagging',
'staticfiles',
)
cms_app.py:
from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
from django.utils.translation import ugettext_lazy as _
class BlogApphook(CMSApp):
name = _("Blog Apphook")
urls = ["cmsplugin_blog.urls"]
apphook_pool.register(BlogApphook)
You need to mount the Apphook of the blog app to a page (see http://readthedocs.org/docs/django-cms/en/latest/extending_cms/extending_examples.html#my-first-app-apphook).
You need to do this for every language.
After you do that, you unfortunately have to restart the server.
Never mind. I've found the solution(s)....
After many hours of debugging I found out it was my mistake after all. I am using wsgi and the settings in the apache.wsgi file were incorrect.
In my sys.path I also appended a path from another django project. Since this append was the first one, it was never possible for any of my apps to read the correct settings files and url.py files.
After that it took me some time searching why the zinnia app (I moved from cmsplugin-blog to zinnia, which has much more options) wasn't working. This post helped in the right direction:
http://groups.google.com/group/django-blog-zinnia/browse_thread/thread/4de2827343fb79e0
After I put my url patterns in the correct order, everything worked fine!

GAE: django-nonrel: No module named myapp.views

I'm using django-nonrel on google app engine.
I've got this problem when visiting http://localhost:8080/album
Could not import myapp.views. Error was: No module named myapp.views
my urls:
urlpatterns = patterns('',
('^_ah/warmup$', 'djangoappengine.views.warmup'),
('^$', 'django.views.generic.simple.direct_to_template', {'template': 'home.html'}),
(r'^album/$', 'myapp.views.view_albums'),
(r'^admin/', include(admin.site.urls)),
)
my views:
def view_albums(request):
return direct_to_template(request, 'album.html', locals())
Part of Settings:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
# 'django.contrib.sites',
'djangotoolbox',
# djangoappengine should come last, so it can override a few manage.py commands
'djangoappengine',
)
PROJECT_DIR = os.path.dirname(__file__)
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
ADMIN_MEDIA_PREFIX = '/media/admin/'
TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
ROOT_URLCONF = 'urls'
I'm not using django's site framework, the app structure is
myapp
-\dbindexer
-\django
-\djangoappengine
-\djangotoolbox
-\media
-\templates
-__init__.py
-app.yaml
-views.py
-urls.py
-settings.py
-models.py
-manage.py
-cron.yaml
-dbindexes.py
...
I think you are using
from myapp.views import * in urlconf
please try
-- in urlconf
from views import *