Coder Social home page Coder Social logo

fengyuan's Introduction

Django 1.10+ project template

Dependency Status

This is a simple Django 1.10+ project template with my preferred setup. Most Django project templates make way too many assumptions or are just way too complicated. I try to make the least amount of assumptions possible while still trying provide a useful setup. Most of my projects are deployed to Heroku, so this is optimized for that but is not necessary.

Note: If you're looking for the previous Django 1.7+ project template layout check out the 1.7 branch.

Features

  • Django 1.10
  • Development, Staging and Production settings with django-configurations.
  • Get value insight and debug information while on Development with django-debug-toolbar.
  • Load environment variables from .env with django-dotenv.
  • Collection of custom extensions with django-extensions.
  • HTTPS and other security related settings on Staging and Production.
  • Procfile for running gunicorn with New Relic's Python agent.
  • PostgreSQL database support with psycopg2.

How to install

$ django-admin.py startproject \
  --template=https://github.com/jpadilla/django-project-template/archive/master.zip \
  --name=Procfile \
  --extension=py,md,env \
  project_name
$ mv example.env .env
$ pip install -r requirements.txt -r requirements/dev.txt

Environment variables

These are common between environments. The ENVIRONMENT variable loads the correct settings, possible values are: DEVELOPMENT, STAGING, PRODUCTION.

ENVIRONMENT='DEVELOPMENT'
DJANGO_SECRET_KEY='dont-tell-eve'
DJANGO_DEBUG='yes'

These settings(and their default values) are only used on staging and production environments.

DJANGO_SESSION_COOKIE_SECURE='yes'
DJANGO_SECURE_BROWSER_XSS_FILTER='yes'
DJANGO_SECURE_CONTENT_TYPE_NOSNIFF='yes'
DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS='yes'
DJANGO_SECURE_HSTS_SECONDS=31536000
DJANGO_SECURE_REDIRECT_EXEMPT=''
DJANGO_SECURE_SSL_HOST=''
DJANGO_SECURE_SSL_REDIRECT='yes'
DJANGO_SECURE_PROXY_SSL_HEADER='HTTP_X_FORWARDED_PROTO,https'

Deployment

It is possible to deploy to Heroku or to your own server.

Heroku

$ heroku create
$ heroku addons:add heroku-postgresql:dev
$ heroku addons:add newrelic
$ heroku pg:promote DATABASE_URL
$ heroku config:set ENVIRONMENT=PRODUCTION
$ heroku config:set DJANGO_SECRET_KEY=`./manage.py generate_secret_key`

License

The MIT License (MIT)

Copyright (c) 2012-2016 José Padilla

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

fengyuan's People

Contributors

pellaeon avatar

Stargazers

Ping-yu Chou avatar Tony Lin avatar hydai avatar

Watchers

James Cloos avatar Frank Zheng avatar Sun, Wen-Lin (XiaoLeS) avatar  avatar

Forkers

xiaoles

fengyuan's Issues

Survey: extensibility for VueJS

Problem

We'd like some parts of the frontend dynamic and overridable, such as the sidebar previewer in Files app, the Files app itself should support showing basic file information like ctime and mtime, but it should leave advanced previewing to pluggable (and possibly third-party) plugins (implemented as a Django app). For example, to preview a JPEG file, user can install a "Photos" plugin, the plugin will override the previewer component, and display information specific to that file type, such as EXIF information.

Technical difficulty

Components in Vue must be built together if using .vue source files format. And there's no way to inherit or override code externally.

Solution 1: iframe and dynamic table

Sidebar will be in 2 parts: an iframe and a table. The iframe's URL will be static, some file metadata are passed as GET params, apps can override the view function to show custom content, such as for pictures the iframe can be an <img> and for sounds it can be <audio>. The table is used for text-based metadata, such as EXIF, plugins can simply respond with a JSON and Files app renders that into table cells.

Solution 2: AJAX-loaded template string

Vue component initialization allows template from string, which we can obtain via an out-of-band AJAX call, and allow plugins to override that string.
This is dirty.

Solution 3: x/template loaded template

Improved from sol2, template can be loaded from Django-rendered x/template element. Slightly better, still dirty. Related

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.