Move Url FK cleaning away from model.clean() so ModelForm don't call it before the fk's have been set, causing unheard mayhem. Fixes #589 and thanks for the report!

This commit is contained in:
Thomas Steen Rasmussen 2020-07-17 22:36:50 +02:00
parent 7bb79506eb
commit 5c9b71b976

View file

@ -118,7 +118,7 @@ class Url(CampRelatedModel):
def __str__(self): def __str__(self):
return self.url return self.url
def clean(self): def clean_fk(self):
""" Make sure we have exactly one FK """ """ Make sure we have exactly one FK """
fks = 0 fks = 0
if self.speaker_proposal: if self.speaker_proposal:
@ -134,6 +134,11 @@ class Url(CampRelatedModel):
f"Url objects must have exactly one FK, this has {fks}" f"Url objects must have exactly one FK, this has {fks}"
) )
def save(self, *args, **kwargs):
"""Just clean_fk() and super save()."""
self.clean_fk()
super().save(*args, **kwargs)
@property @property
def owner(self): def owner(self):
""" """