3

I'm using django-threadedcomments from ericflo on github. This app simply extends the native django comments framework. I am running into the same issue with both frameworks. I continue to get an error relating to mysql that site_id cannot be null. I have no use for the Site field in my comments. I tried to extend the Comment model with my own making site both blank and null but I am still getting the same error. What is the proper way to override that requirement? Thanks

I tried:

class Comment(Comment):
    site=models.ForeignKey(Site,null=True,blank=True)
dave
  • 827
  • 1
  • 7
  • 18

2 Answers2

2

I found it easier to just define one Site object. django-threadedcomments is not the only extension which requires that.

liori
  • 36,848
  • 11
  • 71
  • 101
  • I like this approach, it seems more efficient than always calling Site.objects.get_current() everytime a new comment is added. Where does this one site reside? Should it be in settings.py, or can you use a dummy site_id integer in settings.py? Or perhaps extending the save method with a subclassed Comment model that assigns an integer to site_id is the cleanest? Thanks again. – dave Mar 09 '11 at 19:36
1

You will not be able to change this without monkey-patching the current model, but it shouldn't be a big deal setting the site field to Site.objects.get_current() in the view/form when saving a comment!

Bernhard Vallant
  • 43,536
  • 16
  • 109
  • 135
  • 1
    That makes sense, although it seems like more work than the other solution provided you do this everytime? Thanks. – dave Mar 09 '11 at 19:37