Starting from a vanilla mezzanine application, I can't seem to add a 
caption to the blog post model.

Reference URL instructions: 
http://mezzanine.jupo.org/docs/model-customization.html

In settings.py:


    EXTRA_MODEL_FIELDS = (
      (
        "mezzanine.pages.models.BlogPost.caption",
        "CharField",
        ("Caption",),
        {"blank": True, 'max_length': 150},
      ),
    )

>From this point, running *python ./manage.py makemigrations* 

returns *No changes detected*

So, I decided to try and create an app called UpdateBlogPost in Django

    from django.db import models
    from mezzanine.blog.models import BlogPost
        
    class BlogPost(BlogPost):
        caption           = models.CharField("Caption", max_length=200)
        tags              = models.CharField("Tags", max_length=100)
        featured_position = models.IntegerField("Featured Position", 
default=0, null=True)

Running makemigrations on the above produces a migration, but perhaps 
experienced Django developers will already realize that it produces 
OneToOneField migration to relate UpdateBlogPost.BlogPost to the Mezzanine 
model.


A broader, more useful question to be answered would be: How do I 
modify/extend a model from a 3rd party library from within one of my own 
django apps? Also, where is the code below supposed to go, after the above 
succeeds? It is currently sitting in my UpdateBlogPost application's 
admin.py.


    from copy import deepcopy
    from django.contrib import admin
    from mezzanine.blog.admin import BlogPostAdmin
    from mezzanine.blog.models import BlogPost
    
    blog_fieldsets = deepcopy(BlogPostAdmin.fieldsets)
    blog_fieldsets[0][1]["fields"].insert(1, "caption")
    
    class MyBlogPostAdmin(BlogPostAdmin):
        fieldsets = blog_fieldsets
    
    admin.site.unregister(BlogPost)
    admin.site.register(BlogPost, MyBlogPostAdmin)


Help will be greatly appreciated!

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to