title: How I can create an object in Tastypie API?
body: <p>I am creating a Tastypie API for my Django project. I have a models in django models.py like this:</p>
  
  <pre><code>class User(models.Model):
      nick = models.CharField(max_length = 255)
      email = models.CharField(max_length = 511)
      password = models.CharField(max_length = 63)
      reg_date = models.DateTimeField('register date')
      od_user = models.CharField(max_length = 1024)
  
      def __unicode__(self):
          aux = self.nick + " " + self.email
          return aux
  </code></pre>
  
  <p>and I also have a ModelResource for my Tastypie API like this:</p>
  
  <pre><code>class UserResource(ModelResource):
     class Meta:
        queryset = User.objects.all()
        resource_name = 'user'
        excludes = ['password']
        allowed_methods = ['get', 'post', 'put', 'delete']
        authorization = Authorization()
        always_return_data=True
  
     def obj_create(self, bundle, request=None, **kwargs):
        username, password = bundle.data['nick'], bundle.data['password']
        try:
            bundle.obj = User(nick, "email@test", password,timezone.now(),"od_test")
            bundle.obj.save()
        except IntegrityError:
            raise BadRequest('That username already exists')
        return bundle
  </code></pre>
  
  <p>but this doesn't work. I've looked <a href="https://stackoverflow.com/questions/8889153/how-to-create-or-register-user-using-django-tastypie-api-programmatically">How to create or register User using django-tastypie API programmatically?</a> but I don't know how create a user in my database.</p>
  
  <p>I use:</p>
  
  <pre><code>   curl -v -H "Content-Type: application/json" -X POST --data '{"nick":"test2", "password":"alparch"}' http://127.0.0.1:8000/api/v1/user/?format=json
  </code></pre>
  
  <p>to do POST method.</p>
  
  <p>How can I create an object with a Tastypie API? </p>