Is your new 'Users' class defined in an 'auth' module/app inside your
project?

I guess the problem here is that you are supposed to refer to the module
containing the 'models.py' in which you have defined 'Users' class.

For example, if your module/app is 'mysite' and you have defined 'Users'
class in 'mysite/models.py', then your settings.AUTH_USER_MODEL should be
'mysite.Users'


On Tue, Apr 9, 2013 at 4:52 PM, Cody Scott <cody.j.b.sc...@gmail.com> wrote:

> I placed the code in those places, I put AUTH_USER_MODEL     =
> 'auth.Users' right after INSTALLED_APPS
>
> "CommandError: One or more models did not validate:
> auth.user: Model has been swapped out for 'auth.Users' which has not been
> installed or is abstract.
> admin.logentry: 'user' has a relation with model auth.Users, which has
> either not been installed or is abstract."
>
> On Monday, 8 April 2013 11:56:40 UTC-4, Anderson Borges wrote:
>
>> You can use BaseUserManager, AbstractBaseUser,**PermissionsMixin.
>> here is a exemple:
>>
>> from django.db import models
>> from django.contrib.auth.models import AbstractBaseUser,
>> PermissionsMixin, BaseUserManager
>> from django.conf    import settings
>>
>>
>> class MyUserManager(BaseUserManager)**:
>>     def create_user(self, email, password=None):
>>         if not email:
>>             raise ValueError('Users must have an email address')
>>
>>         user = self.model(
>>             email=MyUserManager.normalize_**email(email),
>>         )
>>         user.set_password(password)
>>         user.save(using=self._db)
>>         return user
>>
>>     def create_superuser(self, email, password):
>>         user = self.create_user(email,
>>             password=password
>>         )
>>         user.is_admin = True
>>         user.save(using=self._db)
>>         return user
>>
>> class Users(AbstractBaseUser,**PermissionsMixin):
>>     email             = models.EmailField(verbose_**name='email
>> address', max_length=255,unique=True,db_**index=True,)
>>     name              = models.CharField(verbose_name=**'Name',
>> max_length=50,blank=True)
>>     is_active         = models.BooleanField(default=**True)
>>     is_admin         = models.BooleanField(default=**False)
>>     is_customer     = models.BooleanField(default=**False)
>>     datecreated     = models.DateField(auto_now=**True)
>>
>>     objects         = MyUserManager()
>>     USERNAME_FIELD     = 'email'
>>     REQUIRED_FIELDS = ['name']
>>
>>     def get_full_name(self):
>>         return self.email
>>
>>     def get_short_name(self):
>>         return self.email
>>
>>     def __unicode__(self):
>>         return self.email
>>
>>     @property
>>     def is_staff(self):
>>         return self.is_admin
>>
>>
>>
>> Now in your settings you have to add : AUTH_USER_MODEL     = 'auth.Users'
>>
>>
>>
>>
>>
>>
>> If you want change in ADMIN here the code
>>
>>
>> from django.contrib import admin
>> from django import forms
>> from django.contrib.auth.admin import UserAdmin
>> from django.contrib.auth.forms import ReadOnlyPasswordHashField
>>
>> from models import Users
>>
>> class UserCreationForm(forms.**ModelForm):
>>     password1 = forms.CharField(label='**Password',
>> widget=forms.PasswordInput)
>>     password2 = forms.CharField(label='**Password confirmation',
>> widget=forms.PasswordInput)
>>
>>     class Meta:
>>         model = Users
>>
>>     def clean_password2(self):
>>         # Check that the two password entries match
>>         password1 = self.cleaned_data.get("**password1")
>>         password2 = self.cleaned_data.get("**password2")
>>         if password1 and password2 and password1 != password2:
>>             raise forms.ValidationError("**Passwords don't match")
>>         return password2
>>
>>     def save(self, commit=True):
>>         # Save the provided password in hashed format
>>         user = super(UserCreationForm, self).save(commit=False)
>>         user.set_password(self.**cleaned_data["password1"])
>>         if commit:
>>             user.save()
>>         return user
>>
>> class UserChangeForm(forms.**ModelForm):
>>     password = ReadOnlyPasswordHashField()
>>     class Meta:
>>         model = Users
>>
>>     def clean_password(self):
>>         return self.initial["password"]
>>
>> class MyUserAdmin(UserAdmin):
>>     form         = UserChangeForm
>>     add_form     = UserCreationForm
>>
>>     list_display = ('email', 'is_admin')
>>     list_filter = ('is_admin',)
>>     fieldsets = (
>>         (None, {'fields': ('email', 'password')}),
>>         ('Permissions', {'fields': ('is_admin','groups','user_**
>> permissions')}),
>>         ('Important dates', {'fields': ('last_login',)}),
>>     )
>>     add_fieldsets = (
>>         (None, {
>>             'classes': ('wide',),
>>             'fields': ('email', 'password1', 'password2')}
>>         ),
>>     )
>>     search_fields = ('email',)
>>     ordering = ('email',)
>>     filter_horizontal = ()
>>
>> admin.site.register(Users, MyUserAdmin)
>>
>>
>>
>>
>>
>> On Mon, Apr 8, 2013 at 9:49 AM, Cody Scott <cody.j....@gmail.com> wrote:
>>
>>> Yes I am using Django 1.5
>>>
>>>
>>> On Monday, 8 April 2013 11:11:57 UTC-4, Anderson Borges wrote:
>>>
>>>> Hey Cody are using django 1.5?
>>>>
>>>>
>>>> On Mon, Apr 8, 2013 at 9:09 AM, Cody Scott <cody.j....@gmail.com>wrote:
>>>>
>>>>> To create a User object you need to have a unique username.
>>>>>
>>>>> I would like to use an email and a password to identify users, since
>>>>> an email is already required for my site's functionality.
>>>>>
>>>>> It seems silly for a framework so restrict you.
>>>>>
>>>>>
>>>>>  --
>>>>> 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...@**googlegroups.**com.
>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>>
>>>>> Visit this group at http://groups.google.com/**group**
>>>>> /django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>>>> .
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Anderson Dias Borges
>>>> Senior Analyst Developer
>>>>
>>>> Tu cumprirás o desejo do meu coração se eu Te buscar...
>>>> I can't see but I'll take my chances
>>>> To hear You call my name
>>>>
>>>  --
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> Anderson Dias Borges
>> Senior Analyst Developer
>>
>> Tu cumprirás o desejo do meu coração se eu Te buscar...
>> I can't see but I'll take my chances
>> To hear You call my name
>>
>  --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to