1. Jesper Noehr
  2. django-piston
  3. Issues
Issue #25 resolved

BaseHandler.create passes dicitonary of attributes as a single parameter to model __init__.

Matthew Marshall
created an issue

No description provided.

Comments (4)

  1. Matthew Marshall reporter

    Here's the code as it currently stands in 23ebc37c78e8 :

        def create(self, request, *args, **kwargs):
            if not self.has_model():
                return rc.NOT_IMPLEMENTED
            
            attrs = self.flatten_dict(request.POST)
            
            try:
                inst = self.model.objects.get(**attrs)
                return rc.DUPLICATE_ENTRY
            except self.model.DoesNotExist:
                inst = self.model(attrs)
                inst.save()
                return inst
     
    

    On the "inst = self.model(attrs)" line I get an error about not being able to convert dict to int. (I assume that's because a single positional argument is used as the ID.) Expanding the contents of attrs as keyword arguments works.

  2. Log in to comment