13👍
Django, while being nice, all-encompassing and well-supported, is sometimes too much for a small web application. Django wants you to play by its rules from the beginning, you’ll have to avoid things like the database and admin panels if you don’t need them. It’s also easier, with Django, to follow its project layout, even when it’s too complex for a simple app.
The so-called micro frameworks might suit you better for your small app. They are built upon the opposite principle: use the bare minimum of features now, add more as you need them.
-
Flask is based on Werkzeug WSGI library and Jinja2 templating (the latter is switchable), is extensively documented (with notes concerning virtualenv and stuff) and well-suited for small and larger apps alike. It comes bundled with an auto-reloading dev server (no need for Apache on your dev machine) and Werkzeug-powered interactive debugger. There are extensions for things like HTML forms and database ORM.
-
Bottle is as small as a microframework can get, consisting of 1 (one) file, dev server included. Drop it into your project folder and start hacking. The built-in SimpleTemplate templating engine is switchable, but the dev server is flakier in comparison to Flask’s. The documentation is less complete, and, in my opinion, the whole thing is less polished and convenient as Flask.
In both cases, you use dev server locally, and then deploy using WSGI, the server interface for Python web apps which both frameworks support. There are many ways to deploy a WSGI app, Apache mod_wsgi
being one of the popular ones.
I’d totally go with Flask unless one dependency (Bottle) is better than three (Flask, Jinja2 and Werkzeug).
(There are many other frameworks as well, so wait for their users to come and tell about them. I’d suggest to avoid web.py: it works, but is full of magic, and is inelegant compared to Flask or Bottle.)
5👍
One way of getting to working webapp quickly is by first understanding, and then modifying, something like the App Engine “guestbook” example. This has the benefit that much of the otherwise necessary tedium of running a web server and setting up a database server (assuming you need persistence) is done for you. App Engine also provides a fairly flexible development environment. It’s certainly not the only way to go, and I’ll admit to bias in recommending it, but it’s fairly low friction.
GCI scripting is hardly a thing of the past, though it’s not what the cool kids are doing. CGI has the benefit, and the curse, of exposing more of the raw plumbing. It forces you to understand a lot about primitive (in the low-level sense) web architecture, but it’s also a bit of a large bite to chew on if you have an immediate problem to solve that can solved by simpler means.
- Can you find out if a Django Model instance is "dirty"?
- Dynamic Django Mail Configuration
- Django TypeError 'method' object is not subscriptable
- Django – missing 1 required positional argument: 'request'
4👍
It appears most python web development seems to be done by frameworks these days. There are a couple reasons for this:
-
a plethora of mature tools. Django has built in user auth, built in database management, built in sessions, built in just about everything ORM which lets you seamlessly supports a couple databases.
-
Built in webservers. The larger python frameworks like django and pylons have built in webservers. Django has a very simple webserver
python manage.py startserver
(that simple) That makes it extremely easy to create and debug applications. It is single threaded so dropping a debugger into it is painless -
Huge communities. If you have a django question it will be answered very quickly the so community is huge.
The django tutorial will introduce you to all the major aspects of development. It is only 4 pages and you will be able to get your app going a lot simpler than having to read, learn and fiddle with an apache setup.
https://docs.djangoproject.com/en/dev/intro/tutorial01/
Although django for right now might be overkill if your app is just going to be 1 form and a script to process it. Because of its seamless testing framework it is quite easy to grow any project. I have never used flask or bottle or the other microframeworks, but I would keep in mind where your project will be in the future.
As for where django fits into this, it is a full stack framework encompassing presentation (templates), data management (server orm), authentication, middleware, forms … everything necessary to create a completely inclusive web application. Django and almost all other python frameworks implement the wsgi standard. It is an interface that allows for interoperation between webservers. http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface it is pretty dry and you will never have to interface it directly. That is what these frameworks do under the hood.
- Passing a variable in redirect in Django
- Running django in virtualenv – ImportError: No module named django.core.management?
2👍
Why setup and maintain your own webserver if you can use app engine. It has an excellent SDK for testing your code. Here is an example https://developers.google.com/appengine/docs/python/gettingstarted/handlingforms
And Django you will find here : https://developers.google.com/appengine/docs/python/gettingstarted/templates
I prefer to use Jinja for templating.
-1👍
Django comes with its own server, but in your case i would recommend apache and mod_python since it seems to be a rather simple site you’re building.
Setting up Apache is a breeze and a simple search on the web should give you all you need.
You can find more information on mod_python here read up a little bit on it and then google after a tutorial that fits your needs.
- Compacting/minifying dynamic html
- Passing an argument to a custom save() method
- Readonly fields in django formset