I'm a beginner in using django and tryin to make my first app, but I keep on getting "Not found" every time I add a javascript file on my view
This is my setting.py
STATIC_URL = '/home/me/PycharmProjects/GLife/static/' MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media') MEDIA_URL = '/media/' STATIC_ROOT = 'static/' STATICFILES_DIRS = ( os.path.join(PROJECT_DIR, 'static'), ) urls.py
urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^register', include('register.urls')), url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), ]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += staticfiles_urlpatterns() html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!--<script src="/static/djangular/js/django-angular.min.js" type="text/javascript"></script>--> <script src="{% static '/js/_register/register.js' %}" type="text/javascript"></script> <title></title> </head> <body> I've already search about it but the suggestions failed, hope anyone could help
here's my project structure
myproject
--main
--register ---migrations ---templates --static ---js ----_register I'm just trying to make an alert display as a testing using js
register.js(and any other files that are giving you problems) located relative tomanage.py?STATIC_ROOTstart with a slash:'/static/'? Also: are you running this in development mode (with the development server), or in another way? In the later case, you may need to runmanage.py collectstatic.