New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/ingredient images #1001
Feature/ingredient images #1001
Conversation
Note: setting up the database schema on this branch using a clean database gave me a migration conflict error. I worked around it by making a new migration using |
You are right, there is a migration missing, feel free to commit it |
Done |
@@ -167,11 +169,22 @@ def search(request): | |||
) | |||
|
|||
for ingredient in ingredients: | |||
if hasattr(ingredient, 'image'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we just do if ingredient.image:
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this but in that case RelatedObjectDoesNotExist is raised when the image is not there. The recommended way by Django to work around this is by using hasattr (according to https://docs.djangoproject.com/en/4.0/topics/db/examples/one_to_one/).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right
Thanks for the PR! still need to do some things before merging to master, but I think the backend is done |
Based on #653
Proposed Changes
Please check that the PR fulfills these requirements
Other questions
(e.g. database migration)?
No