Did you add "cw_auth" to your "INSTALED_APPS"?
On Thu, Jun 25, 2015 at 11:32 PM, James Schneider <jrschneider83@gmail.com> wrote:
Have you tried cw_auth.models.AppUser as the value for AUTH_USER_MODEL?
-James
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciV%3DpNU4zMpQLJdcQ%2BAKfuWPyA-BSNAP5vqr3%3DSSBiaxag%40mail.gmail.com.On Jun 25, 2015 12:45 PM, "MamEshe5minPlz" <dmitriy.zhura@gmail.com> wrote:--I'm trying to use custom User model. Created app named "cw_auth", created "AppUser" model in it, added module to INSTALLED_APPS and added--to settings.py file. But when I'm trying to perform
AUTH_USER_MODEL = 'cw_auth.AppUser'I'm getting errors
./manage.py makemigrations cw_auth
Traceback (most recent call last):File "manage.py", line 10, in <module>execute_from_command_line(sys.argv)File "c:\Python34\lib\site-packages\django\core\management\__init__.py", line338, in execute_from_command_lineutility.execute()File "c:\Python34\lib\site-packages\django\core\management\__init__.py", line330, in executeself.fetch_command(subcommand).run_from_argv(self.argv)File "c:\Python34\lib\site-packages\django\core\management\base.py", line 390,in run_from_argvself.execute(*args, **cmd_options)File "c:\Python34\lib\site-packages\django\core\management\base.py", line 441,in executeoutput = self.handle(*args, **options)File "c:\Python34\lib\site-packages\django\core\management\commands\makemigrations.py", line 63, in handleloader = MigrationLoader(None, ignore_no_migrations=True)File "c:\Python34\lib\site-packages\django\db\migrations\loader.py", line 47,in __init__self.build_graph()File "c:\Python34\lib\site-packages\django\db\migrations\loader.py", line 287,in build_graphparent = self.check_key(parent, key[0])File "c:\Python34\lib\site-packages\django\db\migrations\loader.py", line 165,in check_keyraise ValueError("Dependency on unknown app: %s" % key[0])ValueError: Dependency on unknown app: cw_authcw_auth/models.py code bellow:
from django.db import models
from django.contrib.auth.models import (
BaseUserManager, AbstractBaseUser
)
class AppUserManager(BaseUserManager):
def create_user(self, email, first_name, last_name, role=3, password=None):
"""
Creates and saves a User
"""
if not email:
raise ValueError('Users must have an email address')
user = self.model(
email=self.normalize_email(email),
first_name=first_name,
last_name=last_name,
role=role,
)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, email, first_name, last_name, password):
"""
Creates and saves a superuser
"""
user = self.create_user(email,
first_name=first_name,
last_name=last_name,
role=1,
password=password
)
return user
class AppUser(AbstractBaseUser):
ROLES = ((1, 'Administrator'),
(2, 'Manager'),
(3, 'Customer'),
(4, 'Provider'))
role = models.IntegerField(choices=ROLES, db_index=True)
bonus_coins = models.DecimalField(max_digits=9, decimal_places=3)
balance = models.DecimalField(max_digits=12,decimal_places=2)
consumables = models.IntegerField() # amount of available bids for providers
avatar = models.ImageField(max_length=250)
rating = models.DecimalField(max_digits=4,decimal_places=2)
company_name = models.TextField(max_length=100, blank=True)
birth_date = models.DateField()
email = models.EmailField(verbose_name='email address', max_length=255, unique=True)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
is_active = models.BooleanField(default=False)
date_joined = models.DateTimeField(auto_now_add=True)
objects = AppUserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['first_name', 'last_name']
def get_full_name(self):
return ' '.join([self.first_name, self.last_name])
def get_short_name(self):
return self.first_name
def __str__(self):
return self.get_full_name()
def has_perm(self, perm, obj=None):
"""Does the user have a specific permission?"""
# Simplest possible answer: Yes, always
return True
def has_module_perms(self, app_label):
"""Does the user have permissions to view the app `app_label`?"""
# Simplest possible answer: Yes, always
return True
@property
def is_staff(self):
"""Is the user a member of staff?"""
# If role is admin or manager
return self.role == 1 or self.role == 2
Without AUTH_USER_MODEL migrations going well. Please help.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6bc750f3-2774-407a-9827-978e739fe0f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
| Filipe Ximenes +55 (81) 8245-9204 Vinta Software Studio http://www.vinta.com.br |
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA-QWB3BezGjtpstZ7CQi0XOe21SVkd9rrRCymxciTX457CbZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment