Well the __str__ function doesn't help here.  What I am talking about
is I have is  like this.  Notice the __str__ def in BuyerAlcoholUse
model.  I would do OneToOne, because that is what it is, but I wanted
it all on one page.  These are all stored in seperate tables each
model.  I don't know if this is a case for a view.  I'm pretty new to
Django.  The default admin for this lists a phrase "Buyer alcohol use
#1".  It does this I"m sure because of the ForeignKey, so it thinks
it's has multiple key potential.  The second issue is that the if there
was another model like BuyerAlcoholUse called BuyerCrime I want the
ability to list the BuyerCrime sub-section before the BuyerAlcoholUse
on the default edit view of this model.


class Buyer(models.Model):
    lastname = models.CharField(maxlength=100)
    firstname = models.CharField(maxlength=50)
    birthdate = models.DateField('Birthday')
    email = models.EmailField()
    phone = models.PhoneNumberField()
    address = models.CharField(maxlength=255)
    city = models.CharField(maxlength=50)
    state = models.USStateField()
    zip = models.IntegerField()
    gender = models.CharField(choices=GENDER_CHOICES, maxlength=6)
    buyer_num = models.CharField(maxlength=10)
    application_date = models.DateField('Application Date', null=True,
blank=Tru
e)
    def __str__(self):
        return self.buyer_num
    class Meta:
        db_table = 'buyers'
    class Admin:
        list_display = ('lastname', 'firstname', 'buyer_num',)
        search_fields = ['lastname','firstname','buyer_num',]
        list_filter = ('gender','application_date',)

class BuyerAlcoholUse(models.Model):
    #buyer = models.ForeignKey(Buyer, edit_inline=models.STACKED,
num_in_admin=1
, max_num_in_admin=1)
    buyer = models.ForeignKey(Buyer, edit_inline=models.STACKED,
num_in_admin=1,
 max_num_in_admin=1)
    have_used = models.CharField(choices=ANSWER_CHOICES, maxlength=3,
core=True)
    have_participated = models.CharField(choices=ANSWER_CHOICES,
maxlength=3, co
re=True)
    def __str__(self):
        return 'Alcohol Use'
    class Meta:
        db_table = 'buyer_alcohol_uses'


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to