B
B
Bojczuk2015-04-20 13:35:22
Django
Bojczuk, 2015-04-20 13:35:22

How to start web development with python/django?

As far as I understand, for each application (django / flask) you need to create a separate environment? Are there situations where you can create one environment for several, for example, with identical packages, applications?
When running a web application on an apache2+mod-wsgi server, how does it work and recognize virtual environments?

#apache2 virtualhost:
#...
WSGIScriptAlias / var/www/mydomain.com/index.wsgi

#index.wsgi:
#...
activate_env=os.path.expanduser("~/.virtualenvs/myprojectenv/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))

Are these lines in the corresponding files enough for everything to work correctly? What else is worth paying attention to?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2015-04-20
@Bojczuk

1. It is considered good practice to create a virtualenv for each project. There are no obvious disadvantages here, unlike a different approach, and the matter is simple. ;-) Applications, of course, can use identical packages, but you need to think in the future.
2. It is this line that tells the module which environment to use:
activate_env=os.path.expanduser("~/.virtualenvs/myprojectenv/bin/activate_this.py")

V
Vadim Shandrinov, 2015-04-20
@suguby

To the first question - anyway, then it will come out that the applications use different packages (the bug was fixed on one, they didn’t reach the second hand, for example) and you will have to make separate ones. So make it separate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question