On Sep 4, 12:36 pm, [EMAIL PROTECTED] wrote: > Guys, > > I have the following model : > > from pypo.contracts.models import job_id > from pypo.suppliers.models import Company > > ##Create your models here > > class ponum(models.Model): > contract = models.ForeignKey(job_id) > supplier = models.ForeignKey(Company) > Description = models.XMLField(max_length=200) > price = models.DecimalField(decimal_places=2, max_digits=7) > pub_date = models.DateTimeField(auto_now_add=True, editable=False) > pid = models.CharField(max_length=25) > > It pulls the job_id from one app, and the Company from another. > > The job_id class contains the following: > > class job_id(models.Model): > contract = models.CharField(max_length=5) > customer = models.CharField(max_length=30) > pub_date = models.DateTimeField(auto_now_add=True, editable=False) > > It's nice and simple. However, for class ponum, I want the user to be > able to submit job_id.contract into the ponum.contract field (what I've > got now)... but for the selection box on ponum.contract to show a str of > job_id.contract + " : " + job_id.customer. > > Is this possible using the admin interface, or am I going to have to > write a custom form to do it? > > Regards, > > Andy
If you define the __unicode__ method on job_id, Django will use that to populate the select box. class job_id(models.Model): .... def __unicode__(self): return u'%s: %s' % (self.contract, self.customer) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---