gfernandes
gfernandes

Reputation: 57

Dynamically deploy django admin app

I've recently started my python/django walkthrough and there's still a question that bothers me: I dont find a really easy, unobtrusive, painless way to deploy a Django app =(. I only see tutorials of mod_python, fastCGI, wsgi stuff - all of them are necessary for each webapp I create..

I'm used to Java web-apps (JSF+Tomcat) and I'm used to just drop the *war package in the webapps folder. Or uploading the *war through tomcat-manager. Or, even better, make a maven-hot-remote-deploy. And as far as I'm concerned, simple PHP apps also need minimum config (after setting up the apache2 conf, just cp the php-webapp-folder to /var/www/ would do..). I cant believe that Python lacks this kind of feature =((

My point is: after a clean OS install (let's take a JEE-VPS for example), I only need do setup my web server once. If I develop the webapp01, I choose one of the options above to deploy it. When I develop my webapp02, the same thing - no need to change tomcat-some-conf.xml to deploy it after webapp01. Obviously I consider only small webapps, like Django admin ones. =]

My target is to setup a Python/Django webserver and dynamically create Django admin webapp's, automatically hot deploying them to the webserver. So, I'd initially setup the web server stuff once and have a ready http://myserver.com. When user A generated a webappA01, it would be transparently available in http://myserver.com/userA/webappA01.

Is it possible?

Upvotes: 0

Views: 397

Answers (2)

nickzam
nickzam

Reputation: 813

Modern approach is to use uwsgi with Apache or NGINX (I recommend this one). I don't know a tool which will auto-deploy your Django app. There are many web services like Heroku which deploy your app automatically (you supply just your VCS repository).

You can deploy your Django app semi-automatically by writing some scripts that will sync your code base, apply migrations for the db and reload web server. Check fabric or Buildbot.

Upvotes: 1

Gonzalo
Gonzalo

Reputation: 4269

First, Python/Django does not provide a "drop-in" deploy function by themselves, nor I know any way of doing something similar to war packages.

There are services that provide easy deploy methods like Heroku, but I recommend reading Django's official documentation about deploying for starters.

My target is to setup a Python/Django webserver and dynamically create Django admin webapp's, automatically hot deploying them to the webserver. So, I'd initially setup the web server stuff once and have a ready http://myserver.com. When user A generated a webappA01, it would be transparently available in http://myserver.com/userA/webappA01.

Sounds like what you want to do can be accomplished with custom AdminSite instances. Basically, you can write a view that instantiates an AdminSite instance named "webapp" (you can pull those parameters from the url of course, and check if the webapp data exists on the database). You'll need to connect any models you want to that AdminSite instance either from that view or by overriding its init method. The autodiscover function of the Django admin may not work for custom admin sites.

Upvotes: 0

Related Questions