Start user profiles
This commit is contained in:
parent
98a6d92c3f
commit
26e5773271
0
accounts/__init__.py
Normal file
0
accounts/__init__.py
Normal file
18
accounts/models.py
Normal file
18
accounts/models.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models.signals import post_save, pre_save
|
||||
|
||||
|
||||
class Profile(models.Model):
|
||||
user = models.ForeignKey(User, unique = True)
|
||||
|
||||
def create_profile_callback(sender, **kwargs):
|
||||
'''
|
||||
Automatically create profile when creating new user.
|
||||
'''
|
||||
if kwargs['created']:
|
||||
profile, newprofile = Profile.objects.get_or_create(user = kwargs['instance'])
|
||||
if newprofile:
|
||||
profile.save
|
||||
|
||||
post_save.connect(create_profile_callback, sender = User)
|
16
accounts/tests.py
Normal file
16
accounts/tests.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
1
accounts/views.py
Normal file
1
accounts/views.py
Normal file
|
@ -0,0 +1 @@
|
|||
# Create your views here.
|
Loading…
Reference in New Issue
Block a user