S
S
sazhyk2017-02-03 13:02:16
Django
sazhyk, 2017-02-03 13:02:16

How to edit such a form in Django?

The situation is
models.py

class Album(models.Model):
    title = models.CharField()
    cover = models.ImageField()
    
class Screenshots(models.Model):
    is_author = models.ForeignKey(Album, on_delete=models.CASCADE,)
    image = models.ImageField()

forms.py
class AlbumForm(forms.ModelForm):
    class Meta:
        model = Author
        fields = ('cover',  'title', )

class ScreenshotsForm(forms.ModelForm):
    class Meta:
        model = Screenshot
        fields = ('image', )

Then all this is displayed in one form. ScreenshotsForminline with AlbumForm. Everything is fine, everything is added / saved. Only one thing is not clear to me: how to display this matter in the edit form?
Let the template be passed form - this is the form of the album, and formset - this is a set of screenshot forms ( inlineformset_factory). How can I get the url's of the images saved when creating a post in the template?
Py.Sy: I googled, and so I realized that the problem is not trivial.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JRazor, 2017-02-03
@sazhyk

Certainly not trivial?
stackoverflow.com/questions/8850535/how-to-get-an-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question