Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- myapp/models.py:
- ----------------
- class Testimonial(models.Model):
- title = models.CharField(max_length=255)
- slug = models.SlugField(unique=True)
- teaser = models.CharField(max_length=255)
- body = PlaceholderField(blank=True, help_text="This is the testimonial text itself.")
- author = models.CharField(max_length=50)
- publish = models.BooleanField(default=True)
- def __unicode__(self):
- return self.title
- @models.permalink
- def get_absolute_url(self):
- return ('story', ['story', self.slug])
- myapp/cms_app.py
- ----------------
- class StoryApphook(CMSApp):
- name = "Testimonials"
- urls = ["myapp.urls"]
- apphook_pool.register(StoryApphook)
- myapp/urls.py
- -------------
- urlpatterns = patterns('myapp.views',
- url(r'^(story/(?P<story_slug>[\d\w\-\. ]+)/$', 'story_view', name='story'),
- ...
- )
- myapp/views.py
- --------------
- the usual.
- myapp/admin.py
- --------------
- class TestimonialAdmin(PlaceholderAdmin):
- prepopulated_fields = {"slug": ("title",)}
- admin.site.register(Testimonial, TestimonialAdmin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement