django-nbskel

The purpose of this application is to contain a basic django project and help you out configure it to speed up the process of starting up a new development, be it a quick hack or a long project.

I often need to produce new django projects and I don't enjoy doing repetitive things. They start basically with the same structure so with this app I can wrap all the first steps into a couple of actions. It also makes me feel secure because I always tend to forget to initialize settings, include files, import modules, and so on, so with django-nbskel I am sure I am beginning to develop upon a tested and stable code.

Please be warned this is code that automates stuff for me, so you will be probably modifying it to fit your django configuration, tools, and deployment layout. A much recommended way to do this is forking the project and host it in social distributed code hosting sites like Bitbucket or Github.

Download

Please refer to the first and second steps in the How to use it section.

Source code

django-nbskel resides in Bitbucket here.

If you want to add new features, fix a bug or use your customized version of django-nbskel, you may want to fork it to your Bitbucket own space (I highly recommend it), or clone it to your machine using Mercurial:

hg clone http://bitbucket.org/nabucosound/django-nbskel/

Or you can migrate it to other control version tools like git or subversion.

Project layout

At this moment for most of my projects I am using apache2 web server with mod_wsgi and nginx as proxy. So once the project is going to be deployed for the first time, the conf folder includes the apache and nginx configuration files to be copied to their respective directories, and the wsgi contains the mod_wsgi config files. For this purpose, a first_deply is also created, containing commands to be executed.

I also make use of the ubiquitous Trac project management software. If you include Trac to be configured by django-nbskel (setting the TRAC parameter to True in the project_conf), additional files are produced to set another domain that will hold the Trac instance, as well as an htpasswd file in the root folder, in order to protect the Trac site from undesirable eyes.

I am not going to explain how to deploy django projects here, tyhe choices are vast and interent is plenty of docs, how-to's, etc. You surely are going to modify django-nbskel to your systems architecture needs (unless you are happy with my initial layout) so you will have to understand how things work in your machine (web server configuration stuff mainly) in order to modify the code.

The django project

Once the app is downloaded, you can notice there is a django-nbskel/nbskel folder, containing a django project. This is what I call a django skeleton project (hence the "skel" part of the app name, django-nbskel, the "nb" stands for my website, nomadblue). It contains the basic settings, as well as a minimal django app called website along with some templates and some other things I almost always include in my projects.

How to use it

Following this steps you'll be ready to start working within minutes.

  1. Download the latest version. Do not clone it! It would add repository files you don't want in your project, simply because you probably will add it to your preferred revision control system. You can use the download URL that points to the latest app changeset (tip):

    http://bitbucket.org/nabucosound/django-nbskel/get/tip.tar.gz
    
  2. Extract the tarball contents and rename the resulting django-nbskel folder to whatever your project is going to call (in the example below a name it myproject):

    $ tar xzvf tip.tar.gz && mv django-nbskel myproject
    
  3. Move to this folder and edit the conf/project_conf settings to your values. These are being used by the setup.py to search and replace inside the apache, nginx, wsgi and django configuration files, and to rename them afterwards. Don't go ahead until you have filled out these settings, follow the examples in the file for each setting.

  4. Run the setup.py script. If you have included Trac to be configured, you will be asked for an htpasswd password:

    $ python conf/setup.py
    
  5. At this point you can begin coding. As long as you have all the necessary included into your django project, you can forget about all those startup quirks and go straight to the point.

  6. Your development will take you or your team minutes, hours, days, years, but sooner or later the first deployment time comes. Again, django-nbskel made your life easier because all your files are ready. So, once you have been put your whole project in the path you specified in the PROJECT_PATH folder, move to the conf folder and execute all the commands listed in the first_deploy file. If everything went right, reload apache and nginx and go to the URL specified in the DOMAIN setting and your site will be up and running!

Comments


blog comments powered by Disqus