Wiadomość napisana w dniu 2009-07-15, o godz. 12:24, przez R C: > I would like to track the viewing history for users to my site to see > which blog entries are being viewed by whom. And I would like to > track the user who is viewing it *IF* they are logged in, otherwise I > would like to ignore the user field (see models below) > > [models.py] > class Entry(models.Model): > title = models.CharField(maxlength=250) > slug = models.SlugField( > maxlength=250, > prepopulate_from=('title'), > unique_for_date='pub_date' > ) > body = models.TextField() > pub_date = models.DateTimeField(default=datetime.now()) > > class ViewHistory(models.Model): > entry = models.ForeignKey(Entry) > user = models.ForeignKey(User, blank=True)
Should be: user = models.ForeignKey(User, blank=True, null=True) (blank is only for admin validation). > timestamp = models.DateTimeField(auto_now=True,editable=False) -- Artificial intelligence stands no chance against natural stupidity Jarek Zgoda, R&D, Redefine jarek.zg...@redefine.pl --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---