find alternative to assertion statements which is more graceful #7761
Unanswered
deanmcginndm
asked this question in
Ideas & Suggestions
Replies: 2 comments
-
Do you have any example of how this is implemented in Django or in another library ? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Absolutely! I will update the post shortly with a working example for you to test |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checklist
master
branch of Django REST framework.Steps to reproduce
write a simple model, serialiser, viewset and add it into the urls of the django app, using the default router
add a second model, serialiser, viewset which is related to the first, like Book -> Author (primary key relationship) and add it to the urls of the django app, using the default router
on your serialiser, we want to display this field as a url that the browsable API will render with another view so we will use the HyperlinkRelatedField serialiser and provide the view_name as "api:book-detail" and allow a moment for django to reload the application then the queryset as Book.objects.all()
this results in the assertion error freezing the reload, so for example a project in a docker environment doesn't auto-reload and the developer must restart or in some cases even rebuild the container entirely
Expected behavior
between adding the view_name and queryset kwargs, django should reload the application due to changes in a file within the project directory being made
Actual behavior
assertion error is raised and subsequent changes dont trigger auto reloading of the application, and the subsequent changes which will resolve the assertion error
A solution would be to raise an improperly configured error, which would allow the reload to be triggered.
Beta Was this translation helpful? Give feedback.
All reactions