Re: Error when checking owner in REST API CreateAPIView

2015-07-09 Thread James Schneider
Also check out this thread where I answered a similar question: https://groups.google.com/d/msg/django-users/W5uCKzWOnuE/Ang4RFK0BCYJ -James On Thu, Jul 9, 2015 at 1:16 PM, Carlton Gibson wrote: > Hi Daniel, > > The call to get_object won't work, since Create views don't yet have an > object to

Re: Error when checking owner in REST API CreateAPIView

2015-07-09 Thread Carlton Gibson
Hi Daniel, The call to get_object won't work, since Create views don't yet have an object to fetch. The correct approach is override perform_create and pass the user to your serialiser's save method. There's a section in the tutorial that covers this exact use case: http://www.dja

Error when checking owner in REST API CreateAPIView

2015-07-09 Thread Daniel Grace
With CreateAPIView from the REST API I am trying to stop users from creating data in another users name. In models.py: class UserData(models.Model): user = models.OneToOneField(User, db_index=True, related_name='userdata', blank=False, null=False) textdata = models.TextField(blank=True,