Monday, May 17, 2010

Setting User as foreign key

Hello,

So basically i want to link users to comments they write and ratings
they give on a video rating site.

this is my models.py:

from django.db import models
from django.contrib.auth.models import User

class Video(models.Model):
title = models.CharField(help_text="Title of the
video.",max_length=100)
url = models.URLField(help_text="URL of the video.")

def __str__(self):
return self.title

class Rating(models.Model):
user = models.ForeignKey(User, unique=True)
vid = models.ForeignKey(Video, unique=True)
rating = models.PositiveIntegerField(help_text="User rating of the
video.")

class Comment(models.Model):
#user = models.ForeignKey(User, unique=True)
vid = models.ForeignKey(Video, unique=True)
timeposted = models.DateTimeField(help_text="Time comment was
posted")
comment = models.CharField(help_text="Video comment",max_length=150)


what happens is i keep getting a TemplateSyntaxError when i try to
edit comments/ratings in the admin area.

Exception Type: TemplateSyntaxError
Exception Value: Caught an exception while rendering: no such column:
video_rating.user_id

if anyone could point my in the right direction it would be much
appreciated

thanks in advance,
pete

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate