I'm trying to to add a new field to blog category called "catType".  The 
purpose of this new 1 character field is to use it in templates (eg. if 
catType = '-' don't display the category or '+' to highlight the 
category).  I need to be able to update it from the category admin page.

I've looked for help from a bunch of various guides/instructions eg:
http://mezzanine.jupo.org/docs/model-customization.html
https://stackoverflow.com/questions/15345067/add-a-field-to-mezzanine-blogpost 

https://stackoverflow.com/questions/19935812/mezzanine-field-missing-from-the-form

So far I've only got this working:

in settings.py:
EXTRA_MODEL_FIELDS = (
    (   "mezzanine.blog.models.BlogCategory.catType",
        "django.db.models.CharField",
        ("Category Type",),
        {"max_length":1, "blank": False, "null": True, "default": True},
    ),
)


sudo python manage.py makemigrations
python manage.py syncdb

the new field  "catType" is there...

sqlite> .schema blog_blogcategory
CREATE TABLE "blog_blogcategory" ("id" integer NOT NULL PRIMARY KEY 
AUTOINCREMENT, "title" varchar(500) NOT NULL, "slug" varchar(2000) NULL, 
"site_id" integer NOT NULL REFERENCES "django_site" ("id"), "catType" 
varchar(1) NULL);
CREATE INDEX "blog_blogcategory_9365d6e7" ON "blog_blogcategory" ("site_id"
);


=======================================
this part isn't working...
=======================================

I've created this "admin.py" and put it in my project's directory...

from copy import deepcopy
from django.contrib import admin
from mezzanine.blog.admin import BlogCategoryAdmin
from mezzanine.blog.models import BlogCategory

blog_fieldsets = deepcopy(BlogCategoryAdmin.fieldsets)
blog_fieldsets[0][1]["fields"].extend(["catType"])

class MyBlogCategoryAdmin(BlogCategoryAdmin):
    fieldsets = blog_fieldsets

admin.site.unregister(BlogCategory)
admin.site.register(BlogCategory, MyBlogCategoryAdmin)


I've created this "models.py" and put it in my project's directory...

from django.db import models
from mezzanine.pages.models import Page
print "in models"
print "in models"
print "in models"
class MyPage(Page):
  catType = models.TextField(max_length=1, blank=True, null=True)


My problem is that I don't really know what the correct steps are.

If I add "admin" to apps I get "models aren't loaded yet".  

Any assistance would be much 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