Code:
company = Company.objects.get(pk=pk)
if request.POST:
company_name = request.POST['company_name']
company_logo = request.FILES['company_logo']
fs = FileSystemStorage(location='/home/ubuntu/mywebsite/media/company/' + str(company.pk) + '/')
filename = fs.save(company_logo.name, company_logo)
uploaded_file_url = fs.url(filename)
fs.url
returns: /media/thefilename.png
which is wrong ... apparently the .url
method doesn't take in to account what you've set your location
attribute to?
How do I ensure that the correct path is being returned?