refer to the user model through settings.AUTH_USER_MODEL
authorrougeronj
Thu, 28 May 2015 09:56:40 +0200
changeset 103 b707607e8a38
parent 102 622f5d1955b6
child 104 7f2f72449dd8
refer to the user model through settings.AUTH_USER_MODEL
server/README.md
server/ammico/models.py
server/authentication/migrations/0001_initial.py
server/authentication/migrations/__init__.py
server/authentication/models.py
--- a/server/README.md	Wed May 27 19:06:00 2015 +0200
+++ b/server/README.md	Thu May 28 09:56:40 2015 +0200
@@ -1,2 +1,5 @@
 Ammico server
 =============
+
+> python manage.py syncdb
+> python manage.py createcachetable
\ No newline at end of file
--- a/server/ammico/models.py	Wed May 27 19:06:00 2015 +0200
+++ b/server/ammico/models.py	Thu May 28 09:56:40 2015 +0200
@@ -3,11 +3,11 @@
 from django.db import models
 from taggit.managers import TaggableManager
 
-from authentication.models import AmmicoUser
+import settings
 
 
 class Book(models.Model):
-    user = models.ForeignKey(AmmicoUser, related_name = "books")
+    user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name = "books")
     idArticle = models.CharField(max_length=512, null=True)
     title = models.CharField(max_length=512, blank=True)
     description = models.CharField(max_length=512, blank=True, null=True)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/authentication/migrations/0001_initial.py	Thu May 28 09:56:40 2015 +0200
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import django.core.validators
+import django.utils.timezone
+from django.conf import settings
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('auth', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='AmmicoUser',
+            fields=[
+                ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
+                ('password', models.CharField(verbose_name='password', max_length=128)),
+                ('last_login', models.DateTimeField(verbose_name='last login', default=django.utils.timezone.now)),
+                ('is_superuser', models.BooleanField(verbose_name='superuser status', help_text='Designates that this user has all permissions without explicitly assigning them.', default=False)),
+                ('username', models.CharField(verbose_name='username', unique=True, help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=30, validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username.', 'invalid')])),
+                ('first_name', models.CharField(verbose_name='first name', blank=True, max_length=30)),
+                ('last_name', models.CharField(verbose_name='last name', blank=True, max_length=30)),
+                ('email', models.EmailField(verbose_name='email address', blank=True, max_length=75)),
+                ('is_staff', models.BooleanField(verbose_name='staff status', help_text='Designates whether the user can log into this admin site.', default=False)),
+                ('is_active', models.BooleanField(verbose_name='active', help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', default=True)),
+                ('date_joined', models.DateTimeField(verbose_name='date joined', default=django.utils.timezone.now)),
+                ('idUser', models.CharField(blank=True, max_length=50)),
+                ('groups', models.ManyToManyField(to='auth.Group', help_text='The groups this user belongs to. A user will get all permissions granted to each of his/her group.', verbose_name='groups', blank=True, related_name='user_set', related_query_name='user')),
+                ('user_permissions', models.ManyToManyField(to='auth.Permission', help_text='Specific permissions for this user.', verbose_name='user permissions', blank=True, related_name='user_set', related_query_name='user')),
+            ],
+            options={
+                'verbose_name': 'user',
+                'verbose_name_plural': 'users',
+                'abstract': False,
+            },
+            bases=(models.Model,),
+        ),
+        migrations.CreateModel(
+            name='Profile',
+            fields=[
+                ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
+                ('image', models.URLField(blank=True, max_length=2048)),
+                ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
+            ],
+            options={
+            },
+            bases=(models.Model,),
+        ),
+    ]
--- a/server/authentication/models.py	Wed May 27 19:06:00 2015 +0200
+++ b/server/authentication/models.py	Thu May 28 09:56:40 2015 +0200
@@ -2,10 +2,12 @@
 from django.contrib.auth.models import AbstractUser
 from django.db import models
 
+import settings
+
 
 class AmmicoUser(AbstractUser):
     idUser = models.CharField(max_length=50, blank=True)
     
 class Profile(models.Model):
-    user = models.OneToOneField(AmmicoUser)
+    user = models.OneToOneField(settings.AUTH_USER_MODEL)
     image = models.URLField(max_length=2048, blank=True)
\ No newline at end of file