Hi, I'd like to know if it is possible to have different fieldsets for
the same fields, subdivided by some criterion.
For example, the screen for adding a recipe referring to the following
model results in 5 "generic" (not grouped by any particular criterion)
fields. I'd like that for each category a list of available ingredients
is presented, subdivided in different fieldsets.
I don't know if it can be done in this way, but probably using the
fields option for meta.Admin() might help to clarify what I need.
Something like like this:

admin = meta.Admin(
  fields = (
      ('category1', {
          'classes': 'collapse',
          'fields': ('name', 'short_desc', 'long_desc')
      }),
      ('category2', {
          'classes': 'collapse',
          'fields' : ('name', 'short_desc', 'long_desc')
      }),
      ('category_n', {
          'classes': 'collapse',
          'fields' : ('name', 'short_desc', 'long_desc')
      }),
  ),
)

This is the model:

# Stripped off the details
class Recipe(meta.Model):
    name = meta.CharField('Name', maxlength=128)
    class META:
        admin = meta.Admin()

class Ing_category(meta.Model):
    name = meta.CharField('Name', maxlength=128)
    class META:
        admin = meta.Admin()

class Ingredient(meta.Model):
    name = meta.CharField('Name', maxlength=128)
    short_desc = meta.TextField('Short desc')
    long_desc = meta.TextField('Long desc')
    category = meta.ForeignKey(Ing_category, core=True)
    class META:
        admin = meta.Admin()

class Intermediary(meta.Model):
    ing = meta.ForeignKey(Ingredient)
    quantity = meta.IntegerField("Quantity")
    recipe = meta.ForeignKey(Recipe, edit_inline=True, num_in_admin=5)
    class META:
        verbose_name = "Ingredient list"


Thanks for your patience...
paolo

Reply via email to