You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my model I've created a field:
site = models.ForeignKey(Site, default=Site.objects.get_current)
This field is set to readonly so I want to create Model items only for the current site. It looks like models.py gets loaded before middleware gets invoked so I get incorrect field value.
Currently I've made a workaround with
site = models.ForeignKey(Site, default=lambda:Site.objects.get_current())
Maybe there is a nicer solution for this problem?
The text was updated successfully, but these errors were encountered:
In my model I've created a field:
site = models.ForeignKey(Site, default=Site.objects.get_current)
This field is set to readonly so I want to create Model items only for the current site. It looks like models.py gets loaded before middleware gets invoked so I get incorrect field value.
Currently I've made a workaround with
site = models.ForeignKey(Site, default=lambda:Site.objects.get_current())
Maybe there is a nicer solution for this problem?
The text was updated successfully, but these errors were encountered: