Hi,

I have a Category model that extends Page. It has a field category_type 
which can be one of two values. 
When a new child category is created I want to propagate the parent's 
category_type to the child. 
I know I have to write a custom form for the Category but I am lost. One 
way is to set the value of category_type to the parent's category_type and 
make the category_type field non-editable. How do I access the parent page 
in the Form? 
Any help is greatly appreciated.


class Category(Page):
    """
    A category for grouping activities
    """
    category_type = models.CharField(max_length=15, 
choices=settings.CATEGORY_TYPES, default='M')

    class Meta:
        verbose_name = _("Category")
        verbose_name_plural = _("Categories")
        
        
class CategoryAdmin(PageAdmin):
    fieldsets = (
        (None, {
            "fields": ["title", "category_type"],
        }),
        (None, {
            "fields": ["status", ("publish_date", "expiry_date")],
        }),
        (_("Meta data"), {
            "fields": ["_meta_title", "slug", "in_sitemap"],
            "classes": ("collapse-closed",)
        }),
    )
    
Thanks in advance,
Preethi

-- 
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