python - custom views within Djangocms? -


i haven't found satisfactory way of doing this: have djangocms setup working fine. need add content table outside cms homepage , render content on template. can this, editing urls.py within cms use views so...

url(r'^', 'myapp.views.slideshow_info'), 

... excludes content cms. understand custom views accommodate cms' views doing, how achieve this?

at moment app's views says:

from myapp.models import model1, model2  def slideshow_info(request):     return render_to_response('index.html', {'slideshow_list' : model1.objects.all()}) 

many thanks

you can hook custom app instance django-cms page. here's documentation on how so: http://docs.django-cms.org/en/2.1.3/extending_cms/app_integration.html#app-hooks shouldn't need alter base url patterns re-route / view.

before custom app-hooks available, accomplish you're trying template tags.

hope helps out.

followup

ok, in completed site, had hook app titled "portfolio" display images on home page of django-cms site.

here relevant portions of code:

#portfolio/cms_app.py django.utils.translation import ugettext_lazy _  cms.app_base import cmsapp cms.apphook_pool import apphook_pool  class portfolioapphook(cmsapp):     name = _('portfolio')     urls = ['portfolio.urls']  apphook_pool.register(portfolioapphook)   #portfolio/urls.py django.conf.urls.defaults import *  urlpatterns = patterns('portfolio.views',     url(r'^(?p<slug>[-\w]+)/$', 'project_detail', name='project_detail'),     url(r'^$', 'portfolio_index', name='portfolio_index'), )  #portfolio/views.py django.http import httpresponseredirect django.contrib.auth.decorators import login_required django.shortcuts import get_object_or_404, render  portfolio.models import project   def portfolio_index(request):     project_objects = project.for_public if request.user.is_anonymous() \         else project.objects     projects = project_objects.all().select_related(depth=1)     return render('portfolio/index.html',         {'projects' : projects}, request)   def project_detail(request, slug):     project = get_object_or_404(project, slug=slug)     if not project.public , request.user.is_anonymous():         return httpresponseredirect('/?login=true')     return render('portfolio/project_detail.html',         {'project' : project}, request)  #urls.py (base urls) django.conf import settings django.conf.urls.defaults import * django.contrib import admin  views import login_user, logout_user  admin.autodiscover()  urlpatterns = patterns('',     (r'^admin/filebrowser/', include('filebrowser.urls')),     (r'^admin/doc/', include('django.contrib.admindocs.urls')),     (r'^admin/', include(admin.site.urls)),     (r'^tinymce/', include('tinymce.urls')),     url(r'^login/$', login_user, name='login_user'),     url(r'^logout/$', logout_user, name='logout_user'),     (r'^', include('sorl.thumbnail.urls')),     (r'^', include('cms.urls')), )  if settings.serve_static_media:     urlpatterns += patterns('',         (r'^' + settings.media_url.lstrip('/'), include('appmedia.urls')),     ) + urlpatterns 

as can see working example, haven't altered base urls accommodate home page view, rather i've provided urls portfolio app django-cms through cms_app.py

hope gets going.


Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

c# - how to write client side events functions for the combobox items -

ssh client with paramiko (python) -