Answer the question
In order to leave comments, you need to log in
Django get filename from mode with FileField?
Good afternoon !
There is a model that contains, in addition to text fields, a file.
class Inform_note(models.Model):
id = models.AutoField(primary_key=True)
in_note_on = models.FileField(upload_to='notes', blank=True)
...
class Inform_noteEditView(generic.UpdateView):
model = Inform_note
fields = '__all__'
def get_form(self, form_class=None):
form = super().get_form(form_class)
form.helper = FormHelper()
form.helper.add_input(Submit('submit', 'Create', css_class='btn-primary'))
form.fields['in_note_on'].label = "Приложенный файл"
Answer the question
In order to leave comments, you need to log in
Solution:
Added to view.py before function def get_form(self, form_class=None):
queryset = Inform_note.objects.all()
def get_object(self):
ob = super().get_object()
print(ob.in_note_on)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question