https://github.com/akmamun/django-static-file-handle
Django Static and Media File Handle
https://github.com/akmamun/django-static-file-handle
django django-framework django-media-file django-static-import python static-files
Last synced: 6 months ago
JSON representation
Django Static and Media File Handle
- Host: GitHub
- URL: https://github.com/akmamun/django-static-file-handle
- Owner: akmamun
- Created: 2017-11-23T06:50:26.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-09T19:52:42.000Z (over 7 years ago)
- Last Synced: 2025-02-01T18:43:32.126Z (8 months ago)
- Topics: django, django-framework, django-media-file, django-static-import, python, static-files
- Language: Python
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Django Static File Handle
* Used Django 1.11
* In Django, For Static File handling add those line of code in settings.py and urls.py# settings.py
At the end of setting.py add those lines
```python
STATIC_URL = '/static/'STATICFILES_DIRS = [
os.path.join(BASE_DIR,"static_folder_name"), #CSS/JS Static Files Handle
]STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "project_folder_name/static_cdn", "static_root") #Project Folder/ Media File Saving Folder
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "project_folder_name/static_cdn", "media_root") #Media File Saving Folder
```
# urls.py
At the beginning of urls.py add those lines
```python
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin #For Urlpatterns Not For Media Urlurlpatterns = [
url(r'^admin/', admin.site.urls),]
```
At the end of urls.py add those lines
```pythonif settings.DEBUG:
urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)