Want more features on Pastebin? Sign Up, it's FREE!
Guest

extend-mezzanine-blog

By: vojd on Jul 9th, 2012  |  syntax: Python  |  size: 0.92 KB  |  views: 112  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # extending mezzanines blog model
  2.  
  3. # -- settings.py --
  4.  
  5. EXTRA_MODEL_FIELDS = (
  6.     # Featured Image Thumbnail
  7.     (
  8.         "mezzanine.blog.models.BlogPost.featured_image_thumbnail",
  9.         "ImageField",
  10.         ("Featured image thumbnail", ),
  11.         {"upload_to" : "uploads/thumbnail", "blank": True, "null": True}
  12.     ),
  13. )
  14. # -- end of settings.py --
  15.  
  16. # -- admin.py --
  17. from copy import deepcopy
  18. from django.contrib import admin
  19. from mezzanine.blog.admin import BlogPostAdmin
  20. from mezzanine.blog.models import BlogPost
  21.  
  22. blog_fieldsets = deepcopy(BlogPostAdmin.fieldsets)
  23. blog_fieldsets[0][1]["fields"].insert(-2, "featured_image_thumbnail")
  24.  
  25. class MyBlogPostAdmin(BlogPostAdmin):
  26.     fieldsets = blog_fieldsets
  27.  
  28. admin.site.unregister(BlogPost)
  29. admin.site.register(BlogPost, MyBlogPostAdmin)
  30.  
  31. # -- end of admin.py --
  32.  
  33. # -- finally --
  34. # make a migration of the new structure to a directory of your choice.
  35. #
clone this paste RAW Paste Data