I have two models, presented below:
class Winery(models.Model):
"""(Winery description)"""
name = models.CharField(blank=False, maxlength=100,
db_index=True)
winery_id = models.CharField(blank=True, maxlength=100)
corporate_name = models.CharField(blank=True, maxlength=100)
address = models.CharField(blank=True, maxlength=100)
city = models.CharField(blank=True, maxlength=100)
state = models.CharField(blank=True, maxlength=10)
zipcode = models.CharField(blank=True, maxlength=11)
class Admin:
list_display = ('name',)
search_fields = ('name',)
class Meta:
ordering = ('name',)
verbose_name_plural = "Wineries"
def __str__(self):
return self.name
def __unicode__(self):
return self.name
class Wine(models.Model):
"""The Wine table"""
class_number = models.CharField(blank=True, maxlength=100)
wine_name = models.CharField(blank=True, maxlength=100,
db_index=True)
appellation = models.CharField(blank=True, maxlength=100)
appellation_id = models.ForeignKey(Appellation,
verbose_name="Appellation")
vintage_date = models.CharField(blank=True, maxlength=10)
estate_bottled = models.NullBooleanField()
vineyard_designation = models.NullBooleanField(default=False)
vineyard_name = models.CharField(blank=True, maxlength=100)
varietal = models.CharField(blank=True, maxlength=100)
varietal_id = models.ForeignKey(Varietal, verbose_name="Varietal")
gallons_produced = models.PositiveIntegerField(blank=True,
null=True)
residual_sugar = models.DecimalField(max_digits=2,
decimal_places=2)
retail_price = models.DecimalField(max_digits=5, decimal_places=2)
bottle_size = models.CharField(blank=True, maxlength=100)
winery_id = models.ForeignKey(Winery, verbose_name="Winery")
class Meta:
ordering = ('winery_id','appellation_id','class_name')
class Admin:
ordering = ('winery_id','appellation_id','class_name')
list_display =
('winery_id','wine_name','class_name','vintage_date')
list_filter = ("award_medal",)
search_fields = ('^winery_id__name',)
def __unicode__(self):
return self.wine_name
In Admin, no data is shown when I list Wines. If I remove the
"winery_id" reference in Wine's list_display, I get a complaint about
the Meta classes' ordering line. ((1054, "Unknown column
'winecomp_winery.name' in 'order clause'"))
If I comment out the Meta class (and remove the winery_id field), I
get a list. But without the Winery field.
If I comment out the Meta class and leave in the winery_id field, I
get a list, but with no data.
Django version 0.97-pre-SVN-unknown, using settings
'winesite.settings'
I started playing around with this app as a learning tool last summer,
it's evolved and I picked it up again as I gave myself the Django book
as a Christmas present. It seems like this was working before. But it
was several months ago and I'm old and foggy.
The book says that the __str()__ of the related object is used if a
foreign key is used in a list_display. When I came back to the
project, it seemed like in some situations (that I can't recall right
now) __unicode()__ was preferred. That's why I have both.
Any guidance would be appreciated. I've googled the group and the
internet without much recent commentary on this, so I'm hoping there's
a typo someone will see.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---