Guest User

Untitled

a guest
Jan 17th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. class CustomClearableFileInput(ClearableFileInput):
  2.  
  3. def get_context(self, name, value, attrs):
  4. logging.debug("%s",name)
  5. logging.debug("%s",value)
  6. value.name = path.basename(value.name)
  7. context = super().get_context(name, value, attrs)
  8. return context
  9.  
  10. class CompanySettingEdit(forms.ModelForm):
  11. company_logo = forms.ImageField(widget=CustomClearableFileInput)
  12.  
  13. https://imgur.com/a/M42Mz <-- display correct
  14. https://bucketname.s3.amazonaws.com/media/certiport_logo.png <-- invalid url
  15.  
  16. class CustomClearableFileInput(ClearableFileInput):
  17.  
  18. def get_context(self, name, value, attrs):
  19. logging.debug("%s",name)
  20. logging.debug("%s",value)
  21. # value.name = path.basename(value.name) <-- remove this
  22. context = super().get_context(name, value, attrs)
  23. return context
  24.  
  25. class CompanySettingEdit(forms.ModelForm):
  26. company_logo = forms.ImageField(widget=CustomClearableFileInput)
  27.  
  28. https://imgur.com/a/rGi8f <-- display incorrect
  29. https://bucketname.s3.amazonaws.com/media/company_logo/15/certiport_logo.png <--valid url
  30.  
  31. display: certiport_logo.png
  32. url: https://bucketname.s3.amazonaws.com/media/company_logo/15/certiport_logo.png
Add Comment
Please, Sign In to add comment