Pregunta

I have my development environment setup on Win 7 like this:

Django development structure

Apache      -server-        C:\Program Files (x86)\Apache Software Foundation\Apache2.4
PostgreSQL  -database-      C:\Program Files\PostgreSQL\9.2
Django      -framework-     C:\Python27\Lib\site-packages\django
Python      -code-          C:\Python27
Project     -root-          C:\mysite
    |----------apps
    |----------HTML
    |----------CSS
    |----------JavaScript
    |----------assets

I am attempting to keep this extremely simple to start out. There are 5 main directories each with a distinct purpose. All the code resides in the project folder.

compared to WAMP structure:

C:\WAMP
    |----------C:\Apache
    |----------C:\MySQL
    |----------C:\PHP
    |----------C:\www

I like how Apache, MySQL, and PHP all reside in a neat directory. I know to keep the root project OUTSIDE in another directory in Django for security reasons.

  • Is it fine that Apache, PostgreSQL, and Python are installed all over the place in the Django environment?
  • Did I miss a core Django component and/or directory?
  • Will deploying and scaling be a problem?

I want this to be a guideline for beginning Django web programmers.

¿Fue útil?

Solución

I can answer the question one by one:

  • Is if fine that Apache, PostgreSQL, and Python are installed all over the place in the Django environment?

    All over the place sounds weird but yes it is totally fine.

  • Did I miss a core Django component and/or directory?

    No you don't miss anything, Django core is in site-packages folder already and your site code is mysite, which can be located anywhere you want.

  • Will deploying and scaling be a problem?

    No it won't be a problem with current structure. You will deploy your mysite only, the other will be installed separately.

Something you should get familiar with when starting with Django development:

  • Most likely when you deploy your project, it will be on a Linux server, so install and learn Linux maybe?

  • virtualenv: Soon you will have to install Django, then a bunch of external packages to support your project. virtualenv helps you isolate your working environment. Well it's "unofficial" a must when you start with python development.

  • virtualenvwrapper to make your life easier when working with virtualenv

  • git and github or bitbucket: if you don't know git yet, you should now.

Otros consejos

Apache is just web server, it is used to serve files, but to make a website you do not necessary need it. Django comes with its own development server. See :

python manage.py runserver

Apache is required when you are developing PHP websites because your computer do not know how to compile and interpret it. But for Django, you use the Python language, and you have already install it if you are using Django.

Read https://docs.djangoproject.com/en/1.5/intro/tutorial01/

And where it will be the time to set up your own server using Apache look at : https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/.

Scaling will be a problem on windows. Python in Apache on windows gets 64 threads in one process. Couple this with the GIL and you will have scaling issues.

Python and Apache on Linux don't have this same problem. Under Linux wsgi can create multiple processes that have multiple threads each, minimizing GIL issues.

WSGI in Apache on windows is not a scalable solution in my opinion.

However you can develop there and move to linux for deployment, I do it all the time.

You will want to take advantage of the Apache Alias directive to serve all your static content like css, js, favicon.ico. This frees up python to only handle requests that require logic.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top