Giter VIP home page Giter VIP logo

django-html5-boilerplate's Introduction

{% comment %}

Django HTML5 Boilerplate

Introduction

This is a starting template for Django website projects with HTML5 Boilerplate integrated.

How to use the template

Using pip and virtualenv makes it a lot easier to set up a new project using this boilerplate. If you're unfamiliar with virtualenv, I've found a few good reads explaining the concept.

Start by creating your virtual environment (I'm using Doug Hellman's virtualenvwrapper):

mkvirtualenv projectname

Replace 'projectname' with your desired environment name.

Install Django:

pip install Django

When you're finished installing Django, create a new project using the startproject command with the --template argument (replace project_name with your project's name):

django-admin.py startproject --extension=html,py,ex,md --template=https://github.com/mike360/django-html5-boilerplate/zipball/master project_name

After creating the project you can boot up the development server right away:

python manage.py runserver

Then open up your browser and go to http://127.0.0.1:8000 -- if all went well you should see the "Hello world!" page.

Now you'll need to configure your database. Open up settings/dev.py and configure your local settings (database, etc.) I go into more detail about the way settings are handled in the Settings Module

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}

Now you're ready to run syncdb. This will set up your database, and since the Django Admin is included by default in this template, you'll go through the initial super user setup.

python manage.py syncdb

Once that's completed you can boot up the dev server again:

python manage.py runserver

The Django Admin is automatically included with this project, so now you can head to http://127.0.0.1:8000/admin/ and log in using the credentials you created in the syncdb step.

The Settings Module

After some reading and tinkering, I've abandoned the old settings_local.py file that was ignored in the repo in past versions of django-html5-boilerplate. Too many things can go wrong when your settings aren't version controlled. This new way of handling settings is much more manageable in my opinion, and in the opinion of a few others. I've based the settings module after the opinions found in those links, with some tweaks of my own.

In this new settings module, all settings are stored and versioned under the settings/ folder in the root of the project folder. All of the global and common settings are stored in settings/base.py and anything environment specific should be in a separate file that imports from base. There is a settings/dev.py file included, and it is the default DJANGO_SETTINGS_MODULE as specified in the wsgi.py file.

A template for subsequent environments (e.g. staging, production) is included in settings/environment.py.ex. In order to make use of those files you'll need to override the DJANGO_SETTINGS_MODULE environment variable set in wsgi.py and manage.py in your specific server environment. This is handled in various ways depending on your environment. It is a good practice to keep the other environments' settings files versioned as well.

This method of handling settings is great for the solo developer who needs to manage multiple deployment environments. It's ready out of the box to run well this way. When a project has multiple developers, each developer should maintain their own local settings file and exclude it from source control. This template can handle that with a couple of tweaks.

#}

django-html5-boilerplate's People

Contributors

mrob11 avatar jamestwebber avatar rorycawley avatar

Watchers

James Cloos avatar Duncan Brian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.