Hi,

I'm trying to build a small app to create size charts like:
http://www.steepplanet.com/prodimages/Giordana/size_chart.jpg

So each size chart need to have it's own number of necessary columns
and rows. And each size chart can be assigned to any amount of
brands.

So my models.py looks like

from django.db import models
import django_tables as tables
from sizechart.translation import TranslationModel

class Brand(models.Model):
        name = models.CharField(max_length=255)
        slug = models.SlugField(help_text='Automatically built from name.')

        class Meta:
                ordering = ["name"]
                verbose_name_plural = "Brands"

        def __unicode__(self):
                return self.name

class SizeChart(TranslationModel):
        brands = models.ManyToManyField("sizechart.Brand", blank=True, )
        name = models.CharField(max_length=255)

        class Meta:
                ordering = ["name"]
                verbose_name_plural = "Size charts"

        class Translation:
                fields = ['name', ]

        def __unicode__(self):
                return self.name

class Row(models.Model):
        sizechart = models.ForeignKey("sizechart.SizeChart")

        def __unicode__(self):
                return u"Row"

class Column(TranslationModel):
        """(Column description)"""
        row = models.ForeignKey("sizechart.Row")
        value = models.CharField(blank=True, max_length=100)

        class Translation:
                field = ['value', ]

        def __unicode__(self):
                return u"Column"


and admin.py

from django.contrib import admin
from sizechart.models import Brand, SizeChart, Row, Column

class SizeChartInline(admin.TabularInline):
        model = SizeChart.brands.through
        extra = 1
        max_num = 10

class ColumnInline(admin.StackedInline):
        model = Column
        extra = 1
        max_num = 10
        classes = ('collapse-open',)
        allow_add = True

class RowInline(admin.StackedInline):
        model = Row
        extra = 1
        max_num = 10
        classes = ('collapse-open',)
        allow_add = True
        inlines = (ColumnInline)

class BrandAdmin(admin.ModelAdmin):
        list_display = ('name', 'slug', )
        search_fields = ('name', 'slug', )
        prepopulated_fields = {"slug" : ('name',)}
        inlines = (SizeChartInline, )

class SizeChartAdmin(admin.ModelAdmin):
        list_display = ('name', )
        search_fields = ('name', )
        inlines = (RowInline, )

admin.site.register(Brand, BrandAdmin)
admin.site.register(SizeChart, SizeChartAdmin)




////////////////////

But the ColumnInline doesn't seem to register.

Does anyone have a better idea of how to implement this?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.


Reply via email to