On Oct 28, 10:29 am, Steve Holden <[EMAIL PROTECTED]> wrote: > Robert Dailey wrote: > > Hi, > > > I currently have the following model: > > > class Note( models.Model ): > > content = models.TextField() > > > I've setup the admin page to allow users to add "notes", which > > basically lets them fill in the content variable. However, on the > > admin page I want to add a column to show the user that added that > > note. This would be the username in the admin page that they logged in > > with. I hope that I can do this without adding any information to my > > Note class, but if I must then I don't mind. > > > So column 1 should be the user that added that note, and Column 2 > > should be the note itself. > > The usual way to do this is to establish a relationship between User and > Note. Since each note will only be created by a single user, and each > user can (presumably) issue many notes the sensible thing to do would be > to add a foreign key to Note to express which user created it. > > OK, assuming you can import your User model into the module that defines > your Note model, you would just need to add > > user = models.ForeignKey(User) > > to the Note model.
Thanks for your help. I tried the following: from django.db import models from django.contrib.auth.models import User # Create your models here. class Note( models.Model ): content = models.TextField() user = models.ForeignKey( User ) However, now when I visit the page that lists my notes, I get the following error: OperationalError at /admin/core/note/ (1054, "Unknown column 'core_note.user_id' in 'field list'") Any idea what is going on? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---