How to configure Django / Apache for a developer environment

I have been developing in my own django environment for a while using manage.py runserver without any problems, but now that we have a designer and interface developer who needs to work on the project, I find myself at a loss as to what is the best practice for them Wednesday.

I could ask them to set up their own python environment, but it is very difficult to ask, since they are not Python people and they are running Windows (my developer and production environment is Linux).

Therefore, instead, I installed them on a remote server, on the disk of which they can be mounted locally. However, in this setup, I actually use different instances of manage.py runserver ip:port running on the screen instance. It doesnโ€™t handle things like constant reboot (common for our designer) and it freezes from time to time due to the single-threaded nature of the dev server. I would like to know how to configure this using Apache.

The problem with this, of course, is staticfiles . Each time one of the above parties wants to add or modify a static file, they will have to run manage.py collectstatic , which is just not practical. I just don't know how to do this. All the documentation I found to use Apache is for the production environment, so ... why am I here.

+6
source share
2 answers

The answer to this question was much simpler than I thought, and I apologize for embarrassing those who answered. Basically, all I wanted was a way to put our design environment in something more stable than ./manage.py runserver ip:port in a screen session. I decided that there should be a way to install something similar for Apache, but had no idea what it was.

Here is what I got:

In your settings.py set the variables STATIC_URL and MEDIA_URL to relative URLs. In my case, I used /static/ and /media/ .

 MEDIA_ROOT = PROJECT_ROOT + "/htdocs/media/" MEDIA_URL = "/media/" SERVE_STATIC = True STATIC_ROOT = PROJECT_ROOT + "/htdocs/public/" STATIC_URL = "/static/" 

Configure Apache as if you had no static files. In other words, ignore the document recommendations for using SetHandler None in the <Locaiton> block.

 <VirtualHost *:80> WSGIScriptReloading On WSGIDaemonProcess someprocessname WSGIProcessGroup somegroupname WSGIApplicationGroup somegroupname WSGIPassAuthorization On WSGIScriptAlias / /path/to/config.wsgi ServerName somewhere.awesome.ca <Location "/"> Order Allow,Deny Allow from all </Location> ErrorLog /var/log/apache2/somewhere.awesome.ca.err CustomLog /var/log/apache2/somewhere.awesome.ca.log combined </VirtualHost> 

Hope this helps point someone in the right direction in the future.

0
source

Source control? Ask them to check for changes, and then configure a message commit hook to collect and reboot the server. With beautiful Windows GUIs, I never had a designer who could not understand the basic concepts. If you use dcvs, you can always have them in your own plug, so you will have to combine into basic agreements so that they are not mistaken.

0
source

Source: https://habr.com/ru/post/905311/


All Articles