Hello there,

Recently i've been tasked with using the 'limit_choices_to' attribute of a 
ForeignKey field, in order to limit choices.

My models are like this (params -> max_length, choices, etc):

class DeviceFeatures(models.Model):

# declare choices here: feature_choices #

features = models.CharField(params)
namespace = models.CharField(params)

class Device(models.Model):

jid = models.CharField(params)
name = models.CharField(params)
features = models.ManyToManyField(DeviceFeatures)

class DeviceMember(models.Model):

device = models.ForeignKey(Device)
features = models.ForeignKey(DeviceFeatures, 
limit_choices_to={"feature__in": [str(feature) for feature in 
device.features.all()]}) (theory)

What i would like to know, is how i can access the features of a device, 
inside of the DeviceMember model. More exactly, i want only the features of 
the device that DeviceMember - ForeignKey attribute points out to.

I've been studying for some hours how limit_choices_to works...and i know 
this is how i'm supposed to use it, i just can't figure out how to access 
the features of the foreign key device.

thank you all.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/996cc793-576b-4742-8be4-c101dbc92fc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to