I have a class Media as follows
class helloAdmin(admin.ModelAdmin):
class Media:
js = ['choice.js']
admin.site.register(hello,helloAdmin)
The staticfiles app prepends STATIC_URL
to the media path. But I want MEDIA_URL
to be prepended instead of STATIC_URL
and STATIC_URL
isn't empty. How can this be done?
You can achieve that with the following settings:
urls.py
admin.py
Using
MEDIA_URL
is not advised for serving static files. According to django documentation,MEDIA_URL
will not be referred for media files, whenSTATIC_URL
is not empty. Refer to this part of documentation.So I recommend you to use the following settings:
admin.py