Setup a new project

Install django-prospect

Create a project folder and enter it. Now you must install django-intranet dependencies and create a new project:

$ virtualenv apps
$ source apps/bin/activate
(apps)$ pip install Django PIL MySQL-python South
(apps)$ pip install django-prospect

(apps)$ startproject myintranet
(apps)$ cd myintranet

Now it’s time to setup your database and to configure the settings module accordingly.

Configuration of the settings module

Here is a possible configuration of the file Note that the variables ABSOLUTE_PATH, AUTHENTICATION_BACKENDS, ANONYMOUS_USER_ID, LOGIN_URL, LOGOUT_URL, LOGIN_REDIRECT_URL, PASSWORD_CHANGE_REDIRECT_URL, INTRANET_TITLE, AUTH_PROFILE_MODULE, PASSWORD_CHANGE_REDIRECT_URL are specific to django-intranet and must be specified. (Don’t forget the module imports at the beginning of the file.) Also check in the INSTALLED_APPS variable that you have not only django.contrib apps but also all the other apps like in the following example:

# -*- coding: utf-8 -*-
# Django settings for django-prospect project.
import os
from django.core.urlresolvers import reverse_lazy

ABSOLUTE_PATH = os.path.dirname(__file__)

DEBUG = True

    ('admin', ''),



    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'django_prospect_bdd',                      # Or path to database file if using sqlite3.
        'USER': 'admin',                      # Not used with sqlite3.
        'PASSWORD': 'the_password',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Paris'

# Language code for this installation. All choices can be found here:

SITE_NAME = "Django Prospect"

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/"
MEDIA_ROOT = os.path.join(ABSOLUTE_PATH, 'medias')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "", ""
MEDIA_URL = '/_medias/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/"
STATIC_ROOT = os.path.join(ABSOLUTE_PATH, 'collected_static')

# URL prefix for static files.
# Example: ""
STATIC_URL = '/_static/'

# Additional locations of static files
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    # os.path.join(ABSOLUTE_PATH, 'static'),

# List of finder classes that know how to find static files in
# various locations.
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',

# Make this unique, and don't share it with anybody.
SECRET_KEY = '_$6a=hh50yz!o@(oks0+#6hx+8tmm3^ga#5_9%)xw0hrda%l^b'

# List of callables that know how to import templates from various sources.
#     'django.template.loaders.eggs.Loader',


    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',

ROOT_URLCONF = 'myintranet.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'myintranet.wsgi.application'

    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    os.path.join(ABSOLUTE_PATH, 'templates'),


# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See for
# more details on how to customize your logging configuration.
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,

# Configuration of Django Guardian

LOGIN_URL = reverse_lazy('login')
LOGOUT_URL = reverse_lazy('logout')
LOGIN_REDIRECT_URL = reverse_lazy('dashboard')
PASSWORD_CHANGE_REDIRECT_URL = reverse_lazy('profile')

AUTH_PROFILE_MODULE = 'intranet.UserProfile'
PASSWORD_CHANGE_REDIRECT_URL = reverse_lazy('profile')

When the database and the settings are configured, type these commands:

(apps)$ python syncdb --noinput --migrate
(apps)$ python createsuperuser

Configure the urls

Open the file in the myintranet/myintranet folder and there you can setup the URLs of your project. For example:

# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
from django.core.urlresolvers import reverse_lazy
from django.conf import settings
from django.views.generic import RedirectView
from django.contrib import admin

from intranet.urls import urlpatterns as intranet_urlpatterns


# Default URLs patterns from intranet
urlpatterns = intranet_urlpatterns

# Add specific patterns
urlpatterns += patterns('',

                        url(r'^$', RedirectView.as_view(url=reverse_lazy('dashboard'))),

                        # Apps
                        url(r'^prospect/', include('prospect.urls')),

                        # Admin URLs
                        url(r'^_admin/', include(,
                        url(r'^_admin_tools/', include('admin_tools.urls')),


if settings.DEBUG:
    from django.conf.urls.static import static
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    urlpatterns += staticfiles_urlpatterns()

Configure the navbar

In the myintranet/myintranet folder, create a folder named templates. In that folder create a folder named intranet. In that last folder create a text file named navbar.html where you will define your navigation bar, like this:

{% load intranet_extra i18n %}
{% load url from future %}

<div class="navbar navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container-fluid">
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      <a class="brand" href="{% url 'dashboard' %}">{% intranet_title %}</a>
      <div class="nav-collapse">
        <ul class="nav">
          <li class="divider-vertical"></li>
          <li><a href="{% url 'dashboard' %}">
            <i class="icon-user icon-white"></i>&nbsp;{% trans "Dashboard" %}
          <li class="divider-vertical"></li>
          <li><a href="{% url 'prospect-list' %}">
            <i class="icon-briefcase icon-white"></i>&nbsp;{% trans "Prospects" %}
          <li class="divider-vertical"></li>
          <li><a href="{% url 'field-list' %}">
            <i class="icon-th-large icon-white"></i>&nbsp;{% trans "Fields" %}
          <li class="divider-vertical"></li>
          <li><a href="{% url 'activity-list' %}">
            <i class="icon-th-list icon-white"></i>&nbsp;{% trans "Activities" %}
          <li class="divider-vertical"></li>
        {% if request.user.is_authenticated %}
          <p class="navbar-text pull-right"><a href="{% url 'logout' %}">{% trans "Logout" %}</a></p>
          <ul class="nav pull-right"><li class="divider-vertical"></li></ul>
          <p class="navbar-text pull-right">{% trans "Logged in as" %}&nbsp;<a href="#">{{ request.user.username }}</a></p>
        {% endif %}
      </div><!--/.nav-collapse -->

Temporary file folder

Just one more thing, for the feature of file import to work correctly, you need to use a temporary file folder. If it doesn’t work with the default value, please define FILE_UPLOAD_TEMP_DIR in your settings.

That’s it. You are now ready to run the server and use the application.