class Ticket(models.Model): """ An order placed by a customer. """ account = models.ForeignKey(Account) client = models.ForeignKey(Client, choices=Client.objects.filter(account=self.account))
Obviously this wouldn’t work because there is no instance available for ‘self’,but you can see what I’m trying to do here. I have a system where you can have an account
. Your account can have clients
, and clients can create tickets
. I obviously don’t want account holder A to be able to login to the system and create a ticket and assign it to account holder B’s client. How would I limit the choices like this, or am I going about this all wrong in the first place?
Do your account holders use django admin interface or your ordinary custom views to assign tickets? If it is the second case, you should use customize ModelForm.