Hi Neto,

As said in Documentation of 'limit_choices_to'
<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to>
value for this key should be:
`Either a dictionary, a Q object, or a callable returning a dictionary or Q
object can be used.`

For your case these mean that you should use at least callable as 'use__id'
should be defined every Request/Response cycle.

Regards,


On Wed, Aug 3, 2016 at 7:25 PM, Neto <paulosouzamac...@gmail.com> wrote:

> I have a field with *limit_choices_to*, and want it to be only filtered
> items related the account ('ID') user. How can I do this?
>
> Example (Does not work):
>
> class Car(models.Model):
>     user = models.ForeignKey(User)
>     color = models.CharField(max_length=200)
>     typeo = models.ForeignKey(Typeo, limit_choices_to={'user__id': 
> session['user_id']})
>
> --
> 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+unsubscr...@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/8d2b4b10-83b9-489c-b834-31ddebc0c9df%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8d2b4b10-83b9-489c-b834-31ddebc0c9df%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@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/CAK52boXQ3T1Hb-OodKYLR%3DT66JDW76H_sBuRY0A33etJS-JFnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to