Hello,

did you run manage.py migrate?

When you add a ForeignKey or OneToOne to a model, what actually gets stored
in the DB is the ID of the referenced object (in this case, a
auth.models.User). So the user_id column should be created for you during
the next makemigrations+migrate combo.

On a side note, giving a plural name to your models is bad practise,
especially if you use the builtin admin site.

Best,
Gergely
On May 23, 2016 18:42, "McKinley" <[email protected]> wrote:

> I have a Users table inside of a postgresql database in which auth_user
> also lives. I want the Users objects to have a OneToOne to the auth_user
> model. I added a line to my models.py under my Users class:
>
> user = models.OneToOneField(User, unique=True)
>
> There are probably other things wrong, because at this point my basic
> template returns this traceback:
>
> Exception Type: ProgrammingError at /scripts/users/
> Exception Value: column users.user_id does not exist
> LINE 1: SELECT "users"."id", "users"."user_id", "users"."email", "us..
>
>  I know my Users table doesn't have the user_id column. I do not know how
> to add it. Do Django users prefer to write a migration for this? Migrations
> themselves are not detecting any changes per app at all so I am completely
> flummoxed on how to add this column properly. I was going to manually do it
> in postgres, but I didn't know how to make it conform to the corresponding
> field in auth_user. Thank you for your 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3e89ccba-dcb9-42ef-b084-c6cc4b7d6891%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3e89ccba-dcb9-42ef-b084-c6cc4b7d6891%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULk4THu13xFBfP2je0XDBPgMCe-aBXjNxna%3DYkaf0Q_ZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to