• Stars
    star
    286
  • Rank 144,690 (Top 3 %)
  • Language
    Python
  • Created over 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Django project template layout

{% comment %}

Django Layout

django-layout provides sane defaults for new Django projects based on established best practices and some configuration setups frequently used in Lincoln Loop's projects, like using pip-tools for dependency locking, using setup.py and making manage.py a console script.

To use django-layout:

  1. follow the steps for Python installation from the Pre-Requisites section;

  2. create and activate a virtualenv:

    python3.9 -m venv .venv
    . .venv/bin/activate
    
  3. install Django with pip install django or pip install Django==3.2b1 if you want the latest version;

  4. run the following command:

    django-admin.py startproject --template=https://github.com/lincolnloop/django-layout/zipball/master --extension=py,rst,gitignore,cfg,in,yml,json,dockerignore --name=Makefile,Dockerfile {{ project_name }}
    

Postgres

If you want to use Postgres database, you can

  • go to the generated project folder,
  • uncomment the lines preceded by # Postgres in
    • requirements/requirements.in
    • docker-compose.yml
    • {{ project_name }}/config.py
  • replace {{ project_name }} with the project name you chose.

Another alternative is to

  • download this repository to your local machine,

  • uncomment the lines preceded by # Postgres in
    • requirements/requirements.in
    • docker-compose.yml
    • {{ project_name }}/config.py
  • run the command with the appropriate path to the django-layout folder:

    django-admin.py startproject --template=<PATH_TO>/django-layout --extension=py,rst,gitignore,cfg,in,yml,json,dockerignore --name=Makefile,Dockerfile {{ project_name }}
    

Note

The text following this comment block will become the README.rst of the new project.


{% endcomment %}

{{ project_name }}

Docker Installation

Build and run the project:

docker-compose build
docker-compose up

To run Django commands like migrations and shell or to enter the container bash do:

docker-compose run --rm app bash
docker-compose run --rm app manage.py createsuperuser
docker-compose run --rm app manage.py migrate
docker-compose run --rm app manage.py shell

To stop containers run:

docker-compose down

To update a container after adding a new requirement for example:

docker-compose build app
docker-compose build client

Local Installation

Pre-Requisites

Python3.9

To install all of the system dependencies on a Debian-based system, run:

sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9 python3.9-venv python3.9-dev

Creating the Virtual Environment

First, create a clean base environment using virtualenv:

make .venv/bin/activate
. .venv/bin/activate

Installing the Project

Compile requirements to make sure you have all the latest dependencies:

make upgrade-pip
make requirements.txt
make requirements/dev.txt

Install the requirements and the project source:

make install
make install-dev

Configuring a Local Environment

If you're just checking the project out locally, you can generate the configuration file with already filled default values:

make {{ project_name }}.yml

This will create the {{ project_name }}.yml file where you can customize the variables used in project settings.

Optional: Configuring Postgres

If you want to use Postgres for the database, install it according to your OS requirements.

To configure the database enter PSQL shell and create the database and user:

$ sudo -u postgres psql
postgres=# create database {{ project_name }};
postgres=# create user {{ project_name }};
postgres=# alter role dataplatform SUPERUSER;
postgres=# alter role dataplatform with password '{{ project_name }}';

Replace {{ project_name }} with whatever values you want for database, user and password.

Change the value of DATABASE_URL in {{ project_name }}.yml:

DATABASE_URL: postgres://{{ project_name }}:{{ project_name }}@localhost:5432/{{ project_name }}

Replace the appropriate credentials if necessary.

Running the project

Docker

Run migrations:

docker-compose run --rm app manage.py migrate

Create super user:

docker-compose run --rm app manage.py createsuperuser

Make sure you have the containers running:

docker-compose up

Access localhost:8000/admin.

Local

Run migrations:

manage.py migrate

Create super user:

manage.py createsuperuser

Run the server:

manage.py runserver

Access localhost:8000/admin.

More Repositories

1

python-qrcode

Python QR Code image generator
Python
4,287
star
2

salmon

A simple monitoring system.
Python
478
star
3

amygdala

RESTful HTTP client for JavaScript powered web applications
JavaScript
392
star
4

django-startproject

Boilerplate code for new Django projects.
Python
238
star
5

django-dynamic-raw-id

(formerly known as django-salmonella) A raw_id_fields widget replacement that handles display of an object's string value on change and can be overridden via a template.
Python
161
star
6

goodconf

Transparently load variables from environment or JSON/YAML/TOML file.
Python
128
star
7

django-debug-logging

A plugin for the Django-Debug-Toolbar to provide statistic logging and a UI for reviewing the logs.
Python
103
star
8

django-webserver

Production webservers as a Django management command
Python
86
star
9

django-production

production settings for Django
Python
77
star
10

generator-frigate

Yeoman generator for webapp development with React, webpack hot reloading, es6 (babel), sass, karma and BrowserSync as a development server/proxy.
JavaScript
44
star
11

django-geotagging

Generic geotagging app built on GeoDjango
Python
43
star
12

lincoln-loop-deploy

An easy-to-use Fabric script for deploying Python projects
Python
41
star
13

python-package-manager-shootout

Benchmarking various Python package managers
HTML
41
star
14

django-cpserver

Management commands for serving Django via CherryPy's built-in WSGI server
Python
41
star
15

salt-stats

A collection of modules for collecting stats
Python
37
star
16

django-jsonit

Helpers for working with JSON responses in your Django project.
Python
35
star
17

django-alive

Healthchecks for Django
Python
32
star
18

django-protected-files

A Django application that lets you serve protected static files via your frontend server after authorizing the user against django.contrib.auth.
Python
32
star
19

round-up

Links and notes from the Django Round-Up podcast
30
star
20

emailed-me

A mini-site for checking Google's Gmail feed with Oauth.
Python
29
star
21

django-beancounter

Django-beancounter is a simple app I built to track my income and expenses.
JavaScript
26
star
22

django-ft-cache

A fault-tolerant pylibmc cache backend for Django
Python
24
star
23

django-render

Render unknown Django model instances based on their content type.
Python
21
star
24

saltdash

A read-only dashboard for Salt jobs
Python
21
star
25

django-kwalitee

A suite of scripts to measure the "kwalitee" of a Django project.
Python
21
star
26

django-selenium-intro

Introduction to Django Selenium blog post example
Python
20
star
27

crossing

JavaScript URL utility library
JavaScript
17
star
28

jquery.shuffleLetters

A fork of martinaglv's shuffleLetters discussed here: http://tutorialzine.com/2011/09/shuffle-letters-effect-jquery/
JavaScript
16
star
29

django-mailfriend

Generic "mail this to a friend" app for Django
Python
13
star
30

django-mineral

A collection of templates/widgets for rapid prototyping
JavaScript
12
star
31

django-launchpad

A simple application to track mailing list signups and unsubscribes. Useful for pre-launch signup pages.
Python
11
star
32

pyuwsgi-wheels

Wheel builder for pyuwsgi
Python
10
star
33

fab-pave

A Fabric script for paving a single web/database server
Python
8
star
34

django-redmine

A Django application to connect to an existing Redmine database
Python
8
star
35

django-locations

International location app following ISO 3166 standards
Python
7
star
36

django-pyuwsgi

Use django-webserver instead
Python
7
star
37

learn-backbone-integration

Syncing Backbone.js with Django
JavaScript
7
star
38

memcache-top

Automatically exported from code.google.com/p/memcache-top
Perl
5
star
39

python-realtimemagic

WorkInProgress. A set of tools to make writting a realtime sockjs server easy(er)
Java
5
star
40

django-paginav

A Django template pagination navigation tag
Python
4
star
41

paaws

CLI for Paaws
Python
4
star
42

pkg-uwsgi-python

uWSGI for Python Debian/Ubuntu package builder
4
star
43

django-libsql

libsql database backend for Django
Python
3
star
44

django-safe-admin-emails

Provides support for making sure sensitive information does not appear in admin emails.
3
star
45

Colloquy-MenuBar-Notifier-Plugin

An unobtrusive notifier for Colloquy.
Python
3
star
46

django-smatic

Python
3
star
47

jquery-slidify

A graphical range selector for jQuery
JavaScript
3
star
48

external-api-integration

Post subversion commits as Basecamp comments
Python
3
star
49

ecs-task

Helper for registering new task definitions on AWS ECS and updating associated services.
Python
3
star
50

flexmap

A HTML/CSS based sitemap
CSS
2
star
51

threads

Threads, the front-end
JavaScript
2
star
52

docker-graphite-api-grafana

JavaScript
2
star
53

element-queries-example

A news website layout with an article component that uses element queries.
HTML
2
star
54

django-linkback

An admin widget to show a link back to the original objects in foreign keys.
Python
2
star
55

docker-sentry

Python
1
star
56

terraform-aws-ecs-service-update

Terraform module to update Services and run Tasks on Amazon ECS
HCL
1
star
57

docker-google-auth-proxy

1
star
58

vectorprime

Lincoln Loop's hubot
CoffeeScript
1
star
59

django-static-installer

A static file dependency downloader/manager
Python
1
star
60

flexbox-fridays

The website for Lincoln Loop's Flexbox Fridays research project.
CSS
1
star
61

docker-nginx-push-stream

Build Nginx push stream module packages for Ubuntu 14.04
1
star
62

django-geotagging-new

An application for transparently geotagging your models.
Python
1
star
63

itinerary

Lightweight routing forked from Backbone, decoupled, and (soon to be) enhanced.
JavaScript
1
star
64

web-design-regularly

Landing page for LL's web design weekly
CSS
1
star
65

windmills

Stop Tilting at Windmills - Spotting Bottlenecks
Python
1
star
66

blinken-bloop

For Django Dash 2013.
CSS
1
star
67

crossing-react-router-demo

A demo showing using Crossing to manage URLs in a react-router based application
JavaScript
1
star