Cookiecutter-django: ProgrammingError: relation "auth_user" does not exist

Created on 25 Oct 2014  路  6Comments  路  Source: pydanny/cookiecutter-django

When i try to add user using admin this give error

ProgrammingError: relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...

Most helpful comment

@raushanraj did you run python manage.py migrate (for Django 1.7) or python manage.py syncdb and then python manage.py migrate (for Django 1.6)?

All 6 comments

@raushanraj did you run python manage.py migrate (for Django 1.7) or python manage.py syncdb and then python manage.py migrate (for Django 1.6)?

@benregn yes,I run python manage.py migrate.nothing to migrate now.

I follow step by step from documentation.Every thing is working fine.User Login,User Regestration.But When Admin add user it throws error mentioned aboved.I tried two times the documentation but is not working

https://code.djangoproject.com/ticket/19353 please see this issue.some problem in users admin.py .

I ran into the same trouble. With the help of this blog post, I managed to fix it. My admin.py looks now like this:

# -*- coding: utf-8 -*-
from django.contrib import admin
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from .models import User


class MyUserCreationForm(UserCreationForm):
    def clean_username(self):
        username = self.cleaned_data["username"]
        try:
            User._default_manager.get(username=username)
        except User.DoesNotExist:
            return username
        raise forms.ValidationError(self.error_messages['duplicate_username'])

    class Meta(UserCreationForm.Meta):
        model = User


class UserAdmin(AuthUserAdmin):
    add_form = MyUserCreationForm
    update_form_class = UserChangeForm


admin.site.register(User, UserAdmin)

thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jayfk picture jayfk  路  4Comments

huydbui picture huydbui  路  3Comments

webyneter picture webyneter  路  3Comments

vladimirmyshkovski picture vladimirmyshkovski  路  4Comments

webyneter picture webyneter  路  3Comments