Tuesday, February 2, 2016

Re: How to limit ForeignKey field to another model FK depending on value

Just for reference: 
i could get it to work by passing limit_choices_to to the "province" in Project model. 

class Project(models.Model):
    project_name 
= models.CharField(max_length=100)
    province 
= models.ForeignKey(Province, limit_choices_to={"country": 1})

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20a3f45d-e470-4b23-8e26-25b474465d5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment