Reputation: 13
When im using slug in my url, the .html files wont load the static files. I've already declared the static folder as "assets" and the rest of the 'templates'(the .html file) are good. but when it comes to example : "127.0.0.1:8000/edit_audio/2/" the edit_audio.html wont load my static files but when i access "127.0.0.1:8000/edit_audio" the html files works fine with the static css files
this is my static configuration on settings.py
STATIC_URL = '/assets/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR,'assets'),
]
This is on urls.py
urlpatters = [
url(r'^edit_audio_upload/(?P<pk>\d+)/$',views.edit_audio_upload, name='edit_audio_upload'),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
This is the href link from other html
{% for audio in data3 %}
<a href="{{ audio.get_absolute_url }}">
<button type="button" class="btn btn-success waves-effect waves-light" data-toggle="" data-target=""><span class="mdi mdi-pencil"></span></button>
</a>
{% endfor %}
This is the models.py
class Audio(models.Model):
#some atributes declaration
def get_absolute_url(self):
return "/edit_audio_upload/%s/"%(self.id)
EDIT : The Get request is wrong
[26/Sep/2019 19:43:49] "GET /edit_audio_upload/35/assets/js/pages/form-quilljs.init.js HTTP/1.1" 404 4417
Not Found: /edit_audio_upload/35/assets/js/app.min.js
the success path is
[26/Sep/2019 19:50:25] "GET /assets/js/pages/dashboard-1.init.js HTTP/1.1" 304 0
how to keep the get request on right path even im accessing the /edit_audio_upload ??
Upvotes: 1
Views: 542
Reputation: 1000
Just read the docs here Managing static files, you simply forgot to add {% load static %} on top of your template.
https://stackoverflow.com/a/15943634/11049364
Upvotes: 1