Closed timobrembeck closed 3 years ago
Hi Timo, thanks for the report and the patch! Do you think you would be able to add a fixture to the tests, containing a model like yours that fails in get_absolute_url?
@claudep I now added a test case which fails for the current master branch and is fixed with my patch applied.
This was much simpler than I thought because there is another problem with fixtures independent from my special get_absolute_url()
: The function instance_pre_save()
tries to query the previous object from the database, but in the case of fixtures, this object does not yet exists, even though it has an id:
https://github.com/DjangoAdminHackers/django-linkcheck/blob/d086a1ef2d8db56c6fe3f4e49f80238b9bcce782/linkcheck/listeners.py#L119
Both problems are fixed if the pre-save method ignores raw
signals.
Thanks a lot!
This adds support for the
raw
flag to linkcheck'spre_save
signal.If the model is saved exactly as presented (i.e. when loading a fixture), one should not query/modify other records in the database as the database might not be in a consistent state yet (see documentation).
This is my first contribution to this repository, so I'm not sure how you would want this change to be represented in the tests. But if you give me a hint, I'm willing to add test cases for this patch. Thanks in advance for your feedback and help!
Fixes #106