title: Tastypie foreignkey set to null
body: <p>I am creating UserResource and UserProfileResource. When I create a new user I see that my userprofile database table is also being updated. Which is good. But when I GET the user I get an error saying:</p>
  
  <pre><code>The model '' has an empty attribute 'profile' and doesn't allow a null value.
  </code></pre>
  
  <p>My code:</p>
  
  <p>resources.py</p>
  
  <pre><code>class UserProfileResource(ModelResource):
      home_address = fields.CharField(attribute='home_address')
      user = fields.ToManyField('resources.UserResource', attribute='user', related_name='profile')
      class Meta:
          queryset = UserProfile.objects.all()
          resource_name = 'profile'
          allowed_methods = ['get', 'post', 'delete', 'put']
          fields = ['home_address']
          authorization = Authorization()
          include_resource_uri = False
          include_absolute_url = False
  
  class UserResource(ModelResource):
      profile = fields.ToOneField('resources.UserProfileResource', attribute = 'profile', related_name='user', full=True)
      class Meta:
          queryset = User.objects.all()
          resource_name = 'user'
          allowed_methods = ['get', 'post', 'delete', 'put']
          fields = ['username']
          filtering = {
                  'username': ALL,
                  }
          authorization = Authorization()
  
      def obj_create(self, bundle, request=None, **kwargs):
          try:
              bundle = super(UserResource, self).obj_create(bundle, request, **kwargs)
              bundle.obj.set_password(bundle.data.get('password'))
              bundle.obj.save()
          except IntegrityError:
              raise BadRequest('IntegrityError')
          return bundle
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>class UserProfile(models.Model):
      user = models.ForeignKey(User, unique=True)
      home_address = models.TextField()
  </code></pre>
  
  <p>Anyone any ideas? 
  johnoc</p>