I am starting out with django and have gone through only beginners' documentation. I was trying out the following.

models.py

```
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from org.models import Organization

# Create your models here.

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    organization = models.ForeignKey(Organization, null=True)

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        Profile.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
    instance.profile.save()

```

When I create a user, the code works fine. Row gets added to auth\_user table and to 'profile' table. At the time of user creation I do not associate Organization to user. organization\_id in the 'profile' table remains NULL. 

```
mysql> select * from user_profile;
+----+---------------+---------+
| id | organization_id | user_id |
+----+---------------+---------+
|  2 |          NULL |       3 |
+----+---------------+---------+

```

Later I associate user to organization. I have the following code.

views.py

```
...
def user_association_done(request):
    organization_id = request.POST['organization_id']
    user_id = request.POST['user_id']
    organization = Organization(id=organization_id)
    user = User(id=user_id)
    user.profile.organization = organization
    user.save()
    return HttpResponse('Done')
...

```

The code above associates the organization to user (entry in the profile table gets updated to populate the organization\_id.), 

```
mysql> select * from user_profile;
+----+---------------+---------+
| id | organization_id | user_id |
+----+---------------+---------+
|  2 |             1 |       3 |
+----+---------------+---------+

```

but the data from the row in auth\_user table gets blanked out

```
mysql> select id, password, username from auth_user where id=3;
+----+----------+----------+
| id | password | username |
+----+----------+----------+
|  3 |          |          |
+----+----------+----------+
1 row in set (0.00 sec)

```

The row itself remains though. Obviously, I am not doing this right and perhaps the call to save() is not the right one.

1. What is the right way?
2. I am curious as to why/how the data gets blanked out from the parent table(auth\_user in this case)