Answer the question
In order to leave comments, you need to log in
How to get data id from forms.py?
from django import forms
from lev.Libary.Upload import Upload
from .models import Product
from multiupload.fields import MultiFileField
class ProductForm(forms.ModelForm):
image = MultiFileField(max_num=5)
class Meta:
model = Product
fields = ('title', 'short_text', 'text', 'alias', 'category', 'status', 'image')
def clean_image(self):
Upload.UploadFiles(self.cleaned_data.get('image'))
{'category': <Category: ASAS>, 'image': [<InMemoryUploadedFile: 4to.jpg (image/jpeg)>], 'title': '123123', 'short_text': 'asdsad', 'alias': 'adasd', 'status': True, 'text': 'dasd'}
Answer the question
In order to leave comments, you need to log in
Intercept directly from the instance:
def clean_image(self):
my_id = self.instance.id
Upload.UploadFiles(self.cleaned_data.get('image'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question