List Info

Thread: ManyToMany/ filter_interface / prepopluation problem




ManyToMany/ filter_interface / prepopluation problem
user name
2006-06-30 03:20:35
I just know this is a stupid question, but I'm only
beginning to figure
this out, so I hope you all will have mercy on me.

I'm trying to establish a many to many relationship and use
the
filter_interface to select which items from A are applicable
to B. My
problem is that the first of the two boxes has nothing in
it. The
heading's there, but no items. Shortened model below:

_______________________________

from django.db import models

STATUS_CHOICES = (
    ('vintage', 'Vintage'),
    ('postfender', 'Post-Fender'),
)

YEAR_CHOICES = (
    ('1950', '1950'),
    ('2006', '2006'),
 )

WIDTH_CHOICES = (
	('15 1/2', '15½'),
)
DEPTH_CHOICES = (
	('2 2/3', '2'),
)
STYLE_CHOICES = (
	('Single_Hollow', 'Single Cutaway Hollowbody'),
	('Double_Hollow', 'Double Cutaway Hollowbody'),
)

class Feature(models.Model):
	width = models.CharField(maxlength=200,
choices=WIDTH_CHOICES,
radio_admin=False, default='2')
	depth =  models.CharField(maxlength=200,
choices=DEPTH_CHOICES,
radio_admin=False, default='2')
	style =  models.CharField(maxlength=200,
choices=STYLE_CHOICES,
radio_admin=False, default='2')

class Color(models.Model):
	color = models.CharField(maxlength=200,
choices=COLOR_CHOICES,
radio_admin=False, default='2')

class Guitar(models.Model):
    status = models.CharField(maxlength=200,
choices=STATUS_CHOICES,
radio_admin=True, default='2')
    year = models.CharField(maxlength=200,
choices=YEAR_CHOICES,
radio_admin=False, default='2')
    model_number = models.CharField(maxlength=200)
    name = models.CharField(maxlength=200)
    model_variant = models.CharField(maxlength=200)
    colors = models.ManyToManyField(Color,
filter_interface=models.HORIZONTAL,
related_name="Guitar Color")

    class Admin:
         ordering = ['name']

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return "/guitars/%s/" % (self.slug)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )