Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. myapp/models.py:
  2. ----------------
  3.  
  4. class Testimonial(models.Model):
  5.     title = models.CharField(max_length=255)
  6.     slug = models.SlugField(unique=True)
  7.     teaser = models.CharField(max_length=255)
  8.     body = PlaceholderField(blank=True, help_text="This is the testimonial text itself.")
  9.     author = models.CharField(max_length=50)
  10.     publish = models.BooleanField(default=True)
  11.  
  12.     def __unicode__(self):
  13.         return self.title
  14.  
  15.     @models.permalink
  16.     def get_absolute_url(self):
  17.         return ('story', ['story', self.slug])
  18.  
  19.  
  20. myapp/cms_app.py
  21. ----------------
  22.  
  23. class StoryApphook(CMSApp):
  24.     name = "Testimonials"
  25.     urls = ["myapp.urls"]
  26.  
  27. apphook_pool.register(StoryApphook)
  28.  
  29.  
  30. myapp/urls.py
  31. -------------
  32.  
  33. urlpatterns = patterns('myapp.views',
  34.     url(r'^(story/(?P<story_slug>[\d\w\-\. ]+)/$', 'story_view', name='story'),
  35.     ...
  36. )
  37.  
  38.  
  39. myapp/views.py
  40. --------------
  41. the usual.
  42.  
  43.  
  44. myapp/admin.py
  45. --------------
  46.  
  47. class TestimonialAdmin(PlaceholderAdmin):
  48.     prepopulated_fields = {"slug": ("title",)}
  49. admin.site.register(Testimonial, TestimonialAdmin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement