Gertjan Klein wrote:
> Hi,
> 
> I am writing a timekeeping app with Django, and have some design
> questions. Stripped down, I have a model somewhat like this:
> 
> class Customer(models.Model):
>     Name = models.CharField(max_length=200)
> 
> class ProjectCode(models.Model):
>     Customer = models.ForeignKey('Customer')
>     Code = models.CharField(max_length=30)
> 
> class Hours(models.Model):
>     Customer = models.ForeignKey('Customer')
>     ProjectCode = models.ForeignKey('ProjectCode', blank=True)
>     Date = models.DateField()
>     Hours = models.FloatField()
> 
> That is, the time registration class (Hours) has both a customer, and
> (optionally) a project code.
> 
> I am currently using the standard admin interface to enter/edit objects,
> and it works to my expectations. However, there is one obvious problem
> here: when editing an Hours instance, the ProjectCode dropdown lists
> *all* project codes, not just those related to the selected customer.
> 
> Obviously, I am going to need either a wizard-like interface or an Ajax
> solution to fix this. My preference here would be Ajax (to populate the
> ProjectCode dropdown based on the selected Customer).
> 
> My question is twofold:
> 
> - Does the standard admin application have provisions for something like
> this?
> 
> - Alternatively, is there a change in my design I can make so the admin
> interface *can* cope with this?
> 
> I'd really prefer to keep using the standard admin for now, focussing on
> adding functionality rather than getting the user interface the way I
> want it.
> 
Gertjan:

As long as you only want this in th admin, check out the
"ForeignKey.limit_choices_to" attribute. However, I don't know whether
this would give you the correct results where no project code was
specified, and I'm not sure how to do this in general applications yet.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/

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

Reply via email to