1234567891011121314151617181920212223 |
- from django.db import models
- from django.contrib.auth.models import User
- # Create your models here.
- from django.db.models.signals import post_save, post_delete
- from django.dispatch import receiver
- class UserProfile(models.Model):
- '''
- Extension for the default Django User model
- '''
- user = models.OneToOneField(User, on_delete=models.CASCADE)
- wallet = models.CharField(max_length = 128, blank=True, null=True)
-
- @receiver(post_save, sender=User)
- def create_user_profile(sender, instance, created, **kwargs):
- if created:
- UserProfile.objects.create(user=instance)
|