Re: How to use an optional ForeignKey to sites.Site and admin's "View on site"?

2012-05-30 Thread Dirk van Oosterbosch, IR labs
Indeed, I'm using optional (and nullable) ForeignKeys in other places as well. The problem with an optional ForeignKey to Django's contrib sites.Site model, is that it breaks the "View on site" button in the admin section. near line 60 in /django/contrib/contenttypes/views.py: object_domain

Re: How to use an optional ForeignKey to sites.Site and admin's "View on site"?

2012-05-30 Thread Derek
Actually, you can have a nullable ForeignKey (and there can be good reasons for this). This is mentioned in the docs themselves; see: https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete I am not sure about the error that the OP is encountering. On May

Re: How to use an optional ForeignKey to sites.Site and admin's "View on site"?

2012-05-29 Thread Thomas Lockhart
... Hi, I have a model which has a ForeignKey to the Django contrib sites.Site model. This field should be optional. If it is optional it is not a foreign key. You can put a constraint on the field to have a non-null value be present in the other table, and perhaps there is a way to do this

How to use an optional ForeignKey to sites.Site and admin's "View on site"?

2012-05-29 Thread Dirk van Oosterbosch, IR labs
Hi, I have a model which has a ForeignKey to the Django contrib sites.Site model. This field should be optional. class MyModel(models.Model): optional_domain = models.ForeignKey('sites.Site', related_name='optional_site', null=True, blank=True) ... However, I'm running into