Adam Smith
Adam Smith

Reputation: 45

ProgrammingError at / relation does not exist

I can not find answer in other places. (Sorry for asking again but)

what is wrong? Did anyone have such an error?

ProgrammingError at /register/ relation "user_user" does not exist LINE 1: SELECT (1) AS "a" FROM "user_user" WHERE "user_user"."userna...

I extended user abstract model and error saying no relation When i extend user in sqlite3 no errors such this but postgre is full databse error

 class User(AbstractUser):
    social_username = models.CharField(max_length=100, null=True, blank=True)

views.py

def registration(request):
    if request.method == 'POST':
        form = RegisterUserForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            messages.success(request,'You were successfully registered  %s' % user.first_name)
            return HttpResponseRedirect('/')
        messages.error(request, 'Something went wrong while authenticating')
        return render(request, 'project/register.html', {'form': form})

    else:
        form = RegisterUserForm()
        return render(request, 'project/register.html', {'form': form})

settings.py

AUTH_USER_MODEL = 'user.User'

Upvotes: 3

Views: 2947

Answers (3)

Green Man
Green Man

Reputation: 1

i delete migrations from user app reconnect to local db in pgAdmin4 makemigrations migrate and all works i tryed to migrate separete my site app and user so error was when i try migrate user app helped to me :) gl.

Upvotes: 0

Shubham Dodeja
Shubham Dodeja

Reputation: 21

Not sure why this error occurs but you could just run this command and you are good to go without losing your data.

python manage.py migrate --run-syncdb

Upvotes: 2

Jerry
Jerry

Reputation: 1

Delete existing migrations, drop the database and create it again(WITH THE SAME NAME), make new migrations and you're good to go

Upvotes: -1

Related Questions