Let's refine the form for inspirational quotes so that it can support Ajax uploads, using the following steps:
- First of all, add the following to your settings:
# settings.py or config/base.py# ...UPLOAD_URL = f'{MEDIA_URL}upload/'UPLOAD_ROOT = os.path.join(MEDIA_ROOT, 'upload')
- Then, in the quotes app, we will define a custom file storage system for uploads using the new setting:
# quotes/storages.pyfrom django.conf import settingsfrom django.core.files.storage import FileSystemStorageupload_storage = FileSystemStorage(location=settings.UPLOAD_ROOT)
- Getting ...