title: How to create or register User using django-tastypie API programmatically?
body: <p>My code below kinda works, it creates the User object and saves but it doesn't save the password:</p>
  
  <pre><code>class CreateUserResource(ModelResource):
      class Meta:
          allowed_methods = ['post']
          object_class = User
          authentication = Authentication()
          authorization = Authorization()
          include_resource_uri = False
          fields = ['username']
  
      def obj_create(self, bundle, request=None, **kwargs):
          try:
              bundle = super(CreateUserResource, self).obj_create(bundle, request, **kwargs)
          except IntegrityError:
              raise BadRequest('That username already exists')
          return bundle
  </code></pre>
  
  <p>If I add 'password' to the Meta fields then it does save the raw password but not hashing it. What am I doing wrong?</p>
  
  <hr>
  
  <p>So this is what worked for me:</p>
  
  <pre><code>def obj_create(self, bundle, request=None, **kwargs):
      username, password = bundle.data['username'], bundle.data['password']
      try:
          bundle.obj = User.objects.create_user(username, '', password)
      except IntegrityError:
          raise BadRequest('That username already exists')
      return bundle
  </code></pre>