Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tutorial for Django CMS App Hook

I have a Django CMS Project, which needs to create a Non CMS App "Achievemnets". The Customer wants full control over the page design, that means the page should be a CMS Page. However I have created specific views to show all the achievemtns in a page and clicking on the more link, it will show in detail. I need to port it to Django CMS I have tried as per the CMS App Hook method in the Django CMS Documentation. But none of them works.

Please tell me a tutorial which is good for learning CMS App Hooking

like image 656
Jubin Thomas Avatar asked Feb 13 '12 10:02

Jubin Thomas


1 Answers

When you "hook" an application's URLs to a Django-CMS page, your app's URLs and view functions take over from there.

Let's say your Django-CMS page URL is: /achievements/

On this page, you want to display a list of achievements, which is going to come from your application.

#your_app.urls
from django.conf.urls.defaults import url, patterns

urlpatterns = patterns('your_app.views',
    (r'^$', 'index'),
)

#your_app.views
from django.shortcuts import render

from your_app.models import Achievement

def index(request):
    achievements = Achievement.objects.all()
    return render(request, 'achievements/index.html',
        {'achievements' : achievements})

The Django-CMS app hook you write tells Django-CMS which URLs to follow after in addition to the page you hook your app to. So, not only is Django-CMS going to pull content for the page by the slug, it's also going to hand off the matching URL pattern to your app.

I hope that makes sense.

like image 192
Brandon Avatar answered Oct 16 '22 17:10

Brandon