Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CustomClearableFileInput(ClearableFileInput):
- def get_context(self, name, value, attrs):
- logging.debug("%s",name)
- logging.debug("%s",value)
- value.name = path.basename(value.name)
- context = super().get_context(name, value, attrs)
- return context
- class CompanySettingEdit(forms.ModelForm):
- company_logo = forms.ImageField(widget=CustomClearableFileInput)
- https://imgur.com/a/M42Mz <-- display correct
- https://bucketname.s3.amazonaws.com/media/certiport_logo.png <-- invalid url
- class CustomClearableFileInput(ClearableFileInput):
- def get_context(self, name, value, attrs):
- logging.debug("%s",name)
- logging.debug("%s",value)
- # value.name = path.basename(value.name) <-- remove this
- context = super().get_context(name, value, attrs)
- return context
- class CompanySettingEdit(forms.ModelForm):
- company_logo = forms.ImageField(widget=CustomClearableFileInput)
- https://imgur.com/a/rGi8f <-- display incorrect
- https://bucketname.s3.amazonaws.com/media/company_logo/15/certiport_logo.png <--valid url
- display: certiport_logo.png
- url: https://bucketname.s3.amazonaws.com/media/company_logo/15/certiport_logo.png
Add Comment
Please, Sign In to add comment