Friday, August 30, 2013

Admin: Add new dataset with a pre-selected foreign key?

Hi,

I have a data model like this:
class Samples(models.Model): 
  sample_id = models.CharField(max_length=128, help_text='Id of the sample')
  entry_created = models.DateTimeField(auto_now_add=True)
  sample_status = models.CharField(choices=SAMPLE_STATUS_CHOICES, max_length=128)
  comments = models.TextField(null=True, blank=True)
  def __unicode__(self):
    return ("%s" % (self.sample_id))

class StatusLog(models.Model):
  sample_id = models.ForeignKey(Samples)
  lsu_proc_id = models.IntegerField()
  orig_lab = models.ForeignKey(OriginatingLab)
  cruise_id = models.ForeignKey(Cruises)
  tier = models.ForeignKey(Tiers)
  orig_tier_tote_nr = models.IntegerField()
  gear_type = models.ForeignKey(GearType)
  orig_number_jars = models.IntegerField()
  all_consumed = models.CharField(max_length=3, choices=YES_NO_CHOICE)
  def __unicode__(self):
    return ("%s %s" %(self.sample_id, self.lsu_proc_id))

....

So first I add a Sample, and later I want to add a status log entry - using the admin interface.
Problem: My list of samples will be LONG (right now roughly 1000 entries, more are coming).

Is there any way that I can call the "add" page (http://MYSERVER/admin/statuslog/statuslog/add/) with the sample already preselected, so I don't have to go through the whole list?

Any ideas?

Thanks!
Katja

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment