Django FastCGI and static files

66 views
Skip to first unread message

Martin Jaan Leesment

unread,
Sep 17, 2019, 12:16:31 PM9/17/19
to Django users
Hey

I'm new to serving Django website on a shared server as well as using fastcgi and .htaccess so this might be a basic question. Namely I'm having difficulties serving static content. I've tried playing with htaccess rules, but no luck yet. My project structure:

myproject/
├── myapp
│   ├── admin.py
│   ├── apps.py
│   ├── models.py
│   ├── static
│   │   └── myapp
│   │       ├── css
│   │       │   ├── bootstrap.min.css
│   │       │   ├── bootstrap.min.min_myproject.css
│   │       │   └── proj.css
│   │       ├── fonts
│   │       ├── images
│   │       │   ├── logo.png
│   │       └── scripts
│   │           ├── bootstrap.bundle.min.js
│   │           └── bootstrap.min.js
│   ├── templates
│   │   └── myapp
│   │       ├── base.html
│   │       ├── footer.html
│   │       ├── header.html
│   │       ├── index.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── manage.py
├── myproject
│   ├── __init__.py
│   ├── locale
│   ├── media
│   ├── settings
│   │   ├── base.py
│   │   ├── dev.py
│   │   ├── __init__.py
│   │   ├── prod.py
│   ├── static
│   ├── templates
│   │   └── base.html
│   ├── urls.py
│   └── wsgi.py
├── requirements
└── test.py

My htaccess

Options +ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteRule ^(/static.*)$ /static//$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ cgi-bin/mydjangapp.fcgi/$1 [QSA,L]


If anybody can help me figure out how to solve it, would really appreciate.

Thanks!

Best
MJ

Martin Jaan Leesment

unread,
Sep 17, 2019, 2:59:01 PM9/17/19
to Django users
It works by moving static directory but was wondering about a more intelligent solution, that is, if it exists with fastcgi.

Anike Sadia

unread,
Sep 28, 2019, 10:00:12 AM9/28/19
to django...@googlegroups.com
Hi pls how to leave this group 


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/80c1e98b-8a0a-482c-a20f-29b4c7afdcab%40googlegroups.com.

Sipum

unread,
Sep 28, 2019, 12:47:20 PM9/28/19
to django...@googlegroups.com
Block or mark as spam.
I think it will work. Give it a try

Deep Sukhwani

unread,
Sep 30, 2019, 9:38:45 AM9/30/19
to django...@googlegroups.com
At the end of every email, the instructions are clearly mentioned - Here it is:

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Hope this helps.

--
Regards
Deep L Sukhwani


Budi Hermansyah

unread,
Sep 30, 2019, 11:36:04 PM9/30/19
to django...@googlegroups.com
you can collect your static files into 1 folder after deployment into server, and you can set it in base.py. then on webserver settings you can set only one static path.
OR
you can split  static files into many folder, but in your base.py setting you put all static path using STATICFILES_DIRS  then you SET STATIC_URL and STATIC_ROOT to your physical path on webserver settings.
STATIC_ROOT = os.getenv(
    'STATIC_ROOT', os.path.join(BASE_DIR, 'collected_static'))
STATIC_URL = '/static/'

Hope you understand it.

Rgrds,
HRM 

anil polineni

unread,
Oct 1, 2019, 10:18:04 PM10/1/19
to Django users
hi  Django project structure is clearly understandable but I want CURD Operations mini-project  by using Django project
Reply all
Reply to author
Forward
0 new messages