Hey Angela, great question!
So, I’m going to try to walk through this without using code:
- Set up the form as normal for uploading an image.
- In the view for the edit_photos page, you can check how many uploads have occurred, and if more than one has happened, then you can send a variable to the template to hide the new-upload form if there is already something in uploads for that user.
- And then you can use a modelform to update the currently uploaded image.
So you’ll restrict what’s in the database to just one image per user to start. :) And that way, when you query for all images, you’ll only receive one.
You can strengthen that by changing your query in the view you passed along — instead of
[:1], try using
I think both of those will get you closer to what you want! Let me know if that helps.
(BTW, this is just one potential solution, there are likely many other ways to do this, but this is what came into my head!)