You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
590 B
21 lines
590 B
from django.db import models
|
|
from django.db.models.signals import post_save
|
|
from django.contrib.auth.models import User
|
|
from decimal import Decimal
|
|
|
|
class UserProfile(models.Model):
|
|
user = models.ForeignKey(User, unique=True)
|
|
balance = models.DecimalField(max_digits=9, decimal_places=2, default=Decimal(0))
|
|
|
|
def __unicode__(self):
|
|
return "%s (Kontostand: %s)" % (self.user ,self.balance)
|
|
|
|
def createUserProfile(sender, instance, created, **kwargs):
|
|
if created:
|
|
profile = UserProfile()
|
|
profile.user = instance
|
|
profile.save()
|
|
|
|
post_save.connect(createUserProfile, sender=User)
|
|
|