Open mehdi-essebbar opened 6 years ago
to make the above work, make sure to add this to user_profile/apps.py
from django.apps import AppConfig
class UserProfileConfig(AppConfig):
name = 'user_profile'
def ready(self):
from .signals import save_profile
and to user_profile/__init.py__
add this:
default_app_config = 'user_profile.apps.UserProfileConfig'
BACKEND in user_profile module
When a user account is created, a new user record is added to the database, but the extension table does not create a new record to track additional user information (website and bio). Which create an issue during the update of user information.
To fix this issue, I added a signal which create a new record for the extended class each time a user is created.
The signals.py file I added to the app to solve the issue: `from django.db.models.signals import post_save from django.dispatch import receiver
from .models import UserProfile from django.contrib.auth.models import User
@receiver(post_save, sender=User, dispatch_uid='save_new_user_profile') def save_profile(sender, instance, created, **kwargs): user = instance if created: profile = UserProfile(user=user) profile.save()`
you might need additional instructions about how to make this work by checking this tuto: https://simpleisbetterthancomplex.com/tutorial/2016/07/28/how-to-create-django-signals.html