I'm looking for advice on the best way to approach a conceptually
simple custom search feature for a basic Admin site. I've spent days
reading about custom views, advanced search, dynamic tables, EAV,
etc., enough to realize that there a lot of possible solutions, some
probably much easier and maintainable than others.

Say I have an Admin site that maintains Items and their associated
Characteristics. Items and Characteristics are both user-defined so I
have an Admin interface for each. When a Characteristic is assigned to
an Item a value is supplied; for example the user defines a
Characteristic named "color" and assigns that characteristic to an
item with a value of "red." Each Item can have many Characteristics
and each Characteristic can be assigned to many Items. So the models
look like this:

class Characteristic(models.Model):
    name = models.CharField(unique=True, max_length=100)
    items =
models.ManyToManyField('Item',blank=True,through='ItemCharacteristic')
    def __unicode__(self):
        return self.name

class Item(models.Model):
    name = models.CharField(unique=True, max_length=100)
    characteristics =
models.ManyToManyField('Characteristic',blank=True,through='ItemCharacteristic')
    def __unicode__(self):
        return self.name

class ItemCharacteristic(models.Model):
    item = models.ForeignKey(Item)
    characteristic = models.ForeignKey(Characteristic)
    characteristic_value = models.CharField(max_length=4000)
    def __unicode__(self):
        return self.item.name + ":" + self.characteristic.name

With these models the default Admin interface allows the user to
filter the ItemCharacteristic joining table for single Item/
Characteristic combinations. What I would like is a basic Item Search
by Characteristic page, that displays a text box for each defined
Characteristic, labeled with the Characteristic name, and filters the
Items changelist to show only Items that are assigned the chosen
Characteristics, with the entered Characteristic values.

Thanks very much for any help or ideas.

Lee

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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=en.

Reply via email to