Hi Xavier,
You are an angel! Thank you very much, the link to the API helped so much!!!!
Best Regards,
Mike
Gesendet: Sonntag, 08. November 2015 um 08:43 Uhr
Von: "Xavier Ordoquy" <xordo...@linovia.com>
An: django-users@googlegroups.com
Betreff: Re: Django-Restframework adding and accessing a user to a model / adding an owner?
Von: "Xavier Ordoquy" <xordo...@linovia.com>
An: django-users@googlegroups.com
Betreff: Re: Django-Restframework adding and accessing a user to a model / adding an owner?
Hi
Le 7 nov. 2015 à 22:00, lnzy3...@gmx.de a écrit :
It runs into an error. To me it seems like I cannot combine two models. My goal is to access all the tasks attached to that user, or to add a task to the user accessing the API at the momentSo it would be very helpful, when someone could explains me the two issues:1) How can I access the User information in a model?
Depending on what you want to achieve, you can:
- use authentication, set the UserTask model to Task and override the view’s get_queryset to filter against the authenticated user (explained in the documentation at http://www.django-rest-framework.org/api-guide/filtering/#filtering-against-the-current-user)
- set the UserTask model to Task and filter the task list against a user (http://www.django-rest-framework.org/api-guide/filtering/#filtering-against-query-parameters)
2) How can I add data and attach that to a model.
You code snippet is correct except for the model attached to the view.
Regards,
Xavier,
Linovia.
--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6C0670E8-4F53-4A40-9020-66D7B291F1B1%40linovia.com.
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/trinity-6e000e85-9c2c-481b-94bf-785d93a6dcd1-1447080651299%403capp-gmx-bs22.
For more options, visit https://groups.google.com/d/optout.