1

I am using Django Rest Framework to upload images. The upload is working fine and is getting uploaded under media folder.

But I am unable to make the media links browsable. It says Error 404.

To make them browsable these are the changes that I made.

  1. In settings.py I added the following lines.

    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

    STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/'

    MEDIA_ROOT = os.path.join(BASE_DIR, 'media') STATIC_URL = '/media/'

  2. In url.py I added the following lines

    if settings.DEBUG is True: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

DEBUG is True in settings.py as it's not in production. It is on my local machine under development.

But when I am starting the server it is showing me the following error:-

ImproperlyConfigured :- Empty static prefix not permitted

1 Answer 1

1

Sorry guys! I found my own mistake. Instead of MEDIA_URL I was using STATIC_URL

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.