Hello,
I would like to present only a subset of a given models. But so far,
in the admin, I have no value whereas there should be some.
I tried several syntax but did not find the right one.
Here are my implicated (and simplified) models :
class Dns(models.Model):
"""
DNS description
"""
TYPEDNS_CHOICES = (
('1', 'Reference'),
('2', 'Normal'),
)
name = models.CharField(blank=True, max_length=100)
dnstype = models.CharField(max_length=100,
choices=TYPEDNS_CHOICES)
class Url(models.Model):
"""
Url description
"""
name = models.CharField(blank=True, max_length=100)
[...]
cnamevalue = models.ForeignKey(Dns, limit_choices_to = {'dns':
'get_sql(Dns.dnstype="2")'}, blank=True)
Could someone explain me what is the right syntax ?
I could use formfield_for_foreignkey for admin contrib but I would
prefer using limit_choices_to that I see as a native solution.
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
Thanks,
Nicolas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---