Open jothamgoh opened 4 years ago
STATICFILES_DIRS are used to populate STATIC_ROOT, you should configure you server to serve STATIC_ROOT on STATIC_URL in production or use whitenoise.
Also, why prefix your static files paths with assets/ ?
If confused, try this article which un-confused a bunch of users on stackoverflow:
I have a similar problem, for some reason the templates try to render something based on static files in {{STATIC_ROOT}}/admin/js/vendor/select2, but this folder does not exist (similar things appear to happen for css and img instead of js). If the files are present in these folders everything works perfectly fine, but collectstatic does not put them here. Findstatic shows the files specified don't exist. Some folder searching revealed that there are in fact static folders in the packages, and these probably are collected, but none of them contain the word admin so this is probably where it breaks.
I'm on 3.8.1 btw, but looking at changelogs that should have no major differences from most recent version (3.8.2).
Same here.
the templates try to render something based on static files in {{STATIC_ROOT}}/admin/js/vendor/select2, but this folder does not exist
Do you have django.contrib.admin in INSTALLED_APPS? Because the files are there: https://github.com/django/django/tree/main/django/contrib/admin/static/admin/js/vendor/select2
Thanks for the fast reply. It is, but for some reason collectstatic didn't add them, so I had to put a copy of django-autocomplete-light in my static folder.
Do you have django.contrib.admin in INSTALLED_APPS? Because collectstatic will copy them from django.contrib.admin if you have that in INSTALLED_APPS
Hi All,
I've been trying to get DAL to work for a week or more, and I've read almost all the questions but can't seem to solve my problem.
I followed the tutorial, and after registering the autocomplete view, I'm able to open the view in a url (I can reverse the URL and see data).
However, I'm encountering the problem of not able to find the relevant JS files. They are not found in my static folder when I install DAL. This causes an empty dropdown as the pic below.
When I run python manage.py collectstatic, the auto-complete folder with some JS files appear in my static root but not my staticfile dir.
FYI my static file settings:
I tried copying the autocomplete JS files from statfiles dir to static folder, and reference them in my template. However that did not work.
Am I missing something from the static folders? And which of the JS files should I add to my template? FYI im using a basic autocomplete.Select2QuerySetView outside the admin, and I ensured that {{ form.media }} tag is after the JS.
settings.py
INSTALLED_APPS = [ 'dal', 'dal_select2', 'twotionapp.apps.TwotionappConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'phonenumber_field', 'formtools', 'crispy_forms', ]
base_form.py
views.py
forms.py