mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-25 19:14:03 +03:00
Merge branch 'master' of https://github.com/pydanny/cookiecutter-django
This commit is contained in:
commit
1ceb309631
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -2,6 +2,17 @@
|
|||
All enhancements and patches to Cookiecutter Django will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
##[2016-06-03]
|
||||
### Added
|
||||
- Documentation for debugging with Docker (@mjsisley)
|
||||
- Apache 2 License option in `cookiecutter.json` (@dot2dotseurat)
|
||||
- Removed unnecessary version check from `pre_gen_project.py` (@suledev)
|
||||
- Add gulp alternative as a js task runner and fix navbar style issue (@viviangb and @xpostudio4)
|
||||
|
||||
### Deleted
|
||||
- AngularJS (@pydanny)
|
||||
- django-secure (@xpostudio4)
|
||||
|
||||
##[2016-06-02]
|
||||
### Added
|
||||
- Added better instructions for installing postgres on Mac OS X (@dot2dotseurat )
|
||||
|
|
|
@ -87,6 +87,7 @@ Listed in alphabetical order.
|
|||
Kevin Ndung'u `@kevgathuku`_
|
||||
Krzysztof Szumny `@noisy`_
|
||||
Krzysztof Żuraw `@krzysztofzuraw`_
|
||||
Leonardo Jimenez `@xpostudio4`_
|
||||
Lin Xianyi `@iynaix`_
|
||||
Luis Nell `@originell`_
|
||||
Lukas Klein
|
||||
|
@ -97,6 +98,7 @@ Listed in alphabetical order.
|
|||
Matt Menzenski `@menzenski`_
|
||||
Matt Warren `@mfwarren`_
|
||||
Meghan Heintz `@dot2dotseurat`_
|
||||
mjsisley `@mjsisley`_
|
||||
mozillazg `@mozillazg`_
|
||||
Pablo `@oubiga`_
|
||||
Raphael Pierzina `@hackebrot`_
|
||||
|
@ -107,12 +109,14 @@ Listed in alphabetical order.
|
|||
stepmr `@stepmr`_
|
||||
Sławek Ehlert `@slafs`_
|
||||
Srinivas Nyayapati `@shireenrao`_
|
||||
Sule Marshall `@suledev`_
|
||||
Taylor Baldwin
|
||||
Théo Segonds `@show0k`_
|
||||
Tom Atkins `@knitatoms`_
|
||||
Tom Offermann
|
||||
Travis McNeill `@Travistock`_ @tavistock_esq
|
||||
Travis McNeill `@Travistock`_ @tavistock_esq
|
||||
Vitaly Babiy
|
||||
Vivian Guillen `@viviangb`_
|
||||
Yaroslav Halchenko
|
||||
========================== ============================ ==============
|
||||
|
||||
|
@ -151,6 +155,7 @@ Listed in alphabetical order.
|
|||
.. _@ikkebr: https://github.com/ikkebr
|
||||
.. _@iynaix: https://github.com/iynaix
|
||||
.. _@jazztpt: https://github.com/jazztpt
|
||||
.. _@xpostudio4: https://github.com/xpostudio4
|
||||
.. _@juliocc: https://github.com/juliocc
|
||||
.. _@jvanbrug: https://github.com/jvanbrug
|
||||
.. _@ka7eh: https://github.com/ka7eh
|
||||
|
@ -160,6 +165,7 @@ Listed in alphabetical order.
|
|||
.. _@MathijsHoogland: https://github.com/MathijsHoogland
|
||||
.. _@menzenski: https://github.com/menzenski
|
||||
.. _@mfwarren: https://github.com/mfwarren
|
||||
.. _@mjsisley: https://github.com/mjsisley
|
||||
.. _@mozillazg: https://github.com/mozillazg
|
||||
.. _@originell: https://github.com/originell
|
||||
.. _@oubiga: https://github.com/oubiga
|
||||
|
@ -170,8 +176,10 @@ Listed in alphabetical order.
|
|||
.. _@shireenrao: https://github.com/shireenrao
|
||||
.. _@slafs: https://github.com/slafs
|
||||
.. _@stepmr: https://github.com/stepmr
|
||||
.. _@suledev: https://github.com/suledev
|
||||
.. _@Travistock: https://github.com/Tavistock
|
||||
.. _@trungdong: https://github.com/trungdong
|
||||
.. _@viviangb: httpsL//github.com/viviangb
|
||||
.. _@yunti: https://github.com/yunti
|
||||
.. _@zcho: https://github.com/zcho
|
||||
.. _@noisy: https://github.com/noisy
|
||||
|
|
|
@ -14,9 +14,11 @@ Cookiecutter Django
|
|||
|
||||
Powered by Cookiecutter_, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
|
||||
|
||||
See Troubleshooting_ for common errors and obstacles.
|
||||
|
||||
.. _cookiecutter: https://github.com/audreyr/cookiecutter
|
||||
|
||||
**Warning**: if you get the error "jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'." , please upgrade your cookiecutter version to >= 1.4 (see issue # 528_ )
|
||||
.. _Troubleshooting: https://cookiecutter-django.readthedocs.io/en/latest/troubleshooting.html
|
||||
|
||||
.. _528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373
|
||||
|
||||
|
@ -26,7 +28,6 @@ Features
|
|||
* For Django 1.9
|
||||
* Renders Django projects with 100% starting test coverage
|
||||
* Twitter Bootstrap_ v4.0.0 - alpha_
|
||||
* AngularJS_
|
||||
* 12-Factor_ based settings via django-environ_
|
||||
* Optimized development and production settings
|
||||
* Registration via django-allauth_
|
||||
|
@ -55,7 +56,6 @@ Optional Integrations
|
|||
|
||||
.. _alpha: http://blog.getbootstrap.com/2015/08/19/bootstrap-4-alpha/
|
||||
.. _Bootstrap: https://github.com/twbs/bootstrap
|
||||
.. _AngularJS: https://github.com/angular/angular.js
|
||||
.. _django-environ: https://github.com/joke2k/django-environ
|
||||
.. _12-Factor: http://12factor.net/
|
||||
.. _django-allauth: https://github.com/pennersr/django-allauth
|
||||
|
@ -99,8 +99,6 @@ You'll be prompted for some values. Provide them, then a Django project will be
|
|||
|
||||
**Warning**: After this point, change 'Daniel Greenfeld', 'pydanny', etc to your own information.
|
||||
|
||||
**Warning**: project_slug must be a valid Python module name or you will have issues on imports.
|
||||
|
||||
Answer the prompts with your own desired options_. For example::
|
||||
|
||||
Cloning into 'cookiecutter-django'...
|
||||
|
@ -131,7 +129,6 @@ Answer the prompts with your own desired options_. For example::
|
|||
use_docker [y]: y
|
||||
use_heroku [n]: n
|
||||
use_grunt [n]: y
|
||||
use_angular [n]: n
|
||||
Select open_source_license:
|
||||
1 - MIT
|
||||
2 - BSD
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
"use_python2": "n",
|
||||
"use_docker": "y",
|
||||
"use_heroku": "n",
|
||||
"use_grunt": "n",
|
||||
"use_angular": "n",
|
||||
"open_source_license": ["MIT", "BSD", "Not open source"]
|
||||
"js_task_runner": ["Gulp", "Grunt", "None"],
|
||||
"open_source_license": ["MIT", "BSD", "Apache Software License 2.0", "Not open source"]
|
||||
}
|
||||
|
|
|
@ -141,3 +141,45 @@ If you want to run the stack in detached mode (in the background), use the ``-d`
|
|||
::
|
||||
|
||||
$ docker-compose -f dev.yml up -d
|
||||
|
||||
Debugging
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
ipdb
|
||||
"""""
|
||||
|
||||
If you are using the following within your code to debug:
|
||||
|
||||
::
|
||||
|
||||
import ipdb; ipdb.set_trace()
|
||||
|
||||
Then you may need to run the following for it to work as desired:
|
||||
|
||||
::
|
||||
|
||||
$ docker-compose run -f dev.yml --service-ports django
|
||||
|
||||
django-debug-toolbar
|
||||
""""""""""""""""""""
|
||||
|
||||
In order for django-debug-toolbar to work with docker you need to add your docker-machine ip address (the output of `Get the IP ADDRESS`_) to INTERNAL_IPS in local.py
|
||||
|
||||
|
||||
.. May be a better place to put this, as it is not Docker specific.
|
||||
|
||||
You may need to add the following to your css in order for the django-debug-toolbar to be visible (this applies whether Docker is being used or not):
|
||||
|
||||
.. code-block:: css
|
||||
|
||||
/* Override Bootstrap 4 styling on Django Debug Toolbar */
|
||||
#djDebug[hidden], #djDebug [hidden] {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
#djDebug [hidden][style='display: none;'] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,20 +9,32 @@ The steps below will get you up and running with a local development environment
|
|||
* virtualenv
|
||||
* PostgreSQL
|
||||
|
||||
First make sure to create and activate a virtualenv_, then open a terminal at the project root and install the os dependencies::
|
||||
First make sure to create and activate a virtualenv_.
|
||||
|
||||
$ sudo ./install_os_dependencies.sh install
|
||||
.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
|
||||
|
||||
Then install the requirements for your local development::
|
||||
|
||||
$ pip install -r requirements/local.txt
|
||||
|
||||
.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
|
||||
|
||||
Then, create a PostgreSQL database with the following command, where `[project_slug]` is what value you entered for your project's `project_slug`::
|
||||
|
||||
$ createdb [project_slug]
|
||||
|
||||
You can now run the usual Django ``migrate`` and ``runserver`` commands::
|
||||
|
||||
$ python manage.py migrate
|
||||
$ python manage.py runserver
|
||||
|
||||
At this point you can take a break from setup and start getting to know the files in the project.
|
||||
|
||||
But if you want to go further with setup, read on.
|
||||
|
||||
(Note: the following sections still need to be revised)
|
||||
|
||||
Setting Up Env Vars for Production
|
||||
-----------------------------------
|
||||
|
||||
`Cookiecutter Django` uses the excellent `django-environ`_ package with its ``DATABASE_URL`` environment variable to simplify database configuration in your Django settings. Now all you have to do is rename env.example to .env and then compose a definition for ``DATABASE_URL`` as shown below and add it to the .env file:
|
||||
|
||||
.. parsed-literal::
|
||||
|
@ -31,12 +43,8 @@ Then, create a PostgreSQL database with the following command, where `[project_s
|
|||
|
||||
.. _django-environ: http://django-environ.readthedocs.io
|
||||
|
||||
You can now run the usual Django ``migrate`` and ``runserver`` commands::
|
||||
|
||||
$ python manage.py migrate
|
||||
$ python manage.py runserver
|
||||
|
||||
**Setup your email backend**
|
||||
Setup your email backend
|
||||
-------------------------
|
||||
|
||||
django-allauth sends an email to verify users (and superusers) after signup and login (if they are still not verified). To send email you need to `configure your email backend`_
|
||||
|
||||
|
@ -85,5 +93,3 @@ The base app will now run as it would with the usual ``manage.py runserver`` but
|
|||
To get live reloading to work you'll probably need to install an `appropriate browser extension`_
|
||||
|
||||
.. _appropriate browser extension: http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-
|
||||
|
||||
It's time to write the code!!!
|
||||
|
|
|
@ -14,7 +14,7 @@ Contents:
|
|||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
||||
my-favorite-cookie
|
||||
project-generation-options
|
||||
developing-locally
|
||||
developing-locally-docker
|
||||
|
@ -25,6 +25,7 @@ Contents:
|
|||
deployment-on-heroku
|
||||
deployment-with-docker
|
||||
faq
|
||||
troubleshooting
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
|
100
docs/my-favorite-cookie.rst
Normal file
100
docs/my-favorite-cookie.rst
Normal file
|
@ -0,0 +1,100 @@
|
|||
************************************************
|
||||
Creating your first app with Cookiecutter-Django
|
||||
************************************************
|
||||
|
||||
This tutorial will show you how to build a simple app using the `Cookiecutter Django <https://github.com/pydanny/cookiecutter-django>`_ templating system. We'll be building a cookie polling app to determine the most popular flavor of cookie.
|
||||
|
||||
Developers who have never used Django will learn the basics of creating a Django app; developers who are experienced with Django will learn how to set up a project within the Cookiecutter system. While many Django tutorials use the default SQLite database, Cookiecutter Django uses PostGres only, so we'll have you install and use that.
|
||||
|
||||
|
||||
Dependencies
|
||||
============
|
||||
This tutorial was written on Windows 10 using `git bash <https://git-for-windows.github.io/>`_; alternate instructions for Mac OS and Linux will be provided when needed. Any Linux-style shell should work for the following commands.
|
||||
|
||||
You should have your preferred versions of `Python <https://www.python.org/downloads/>`_
|
||||
and `Django <https://www.djangoproject.com/download/>`_ installed. Use the latest stable versions if you have no preference.
|
||||
|
||||
You should have `Virtualenv <https://virtualenv.pypa.io/en/stable/>`_ and `Cookiecutter <https://github.com/pydanny/cookiecutter-django/>`_ installed:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ pip install virtualenv
|
||||
$ pip install cookiecutter
|
||||
|
||||
You should also have `PostgreSQL <https://www.postgresql.org/download/>`_ installed on your machine--just download and run the installer for your OS. The install menu will prompt you for a password, which you'll use when creating the project's database.
|
||||
|
||||
|
||||
Instructions
|
||||
============
|
||||
|
||||
1. **Setup** -- how to set up a virtual environment
|
||||
2. **Cookiecutter** -- use Cookiecutter to initialize a project with your own customized information.
|
||||
3. **Building the App** -- creating the My Favorite Cookie application.
|
||||
|
||||
============
|
||||
1. Setup
|
||||
============
|
||||
|
||||
Virtual Environment
|
||||
"""""""""""""""""""
|
||||
|
||||
Create a virtual environment for your project. Cookiecutter will install a bunch of dependencies for you automatically; using a virtualenv will prevent this from interfering with your other work.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ virtualenv c:/.virtualenvs/cookie_polls
|
||||
|
||||
Replace ``c:/.virtualenvs`` with the path to your own ``.virtualenvs`` folder.
|
||||
|
||||
Activate the virtual environment by calling ``source`` on the ``activate`` shell script . On Windows you'll call this from the virtualenv's ``scripts`` folder:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ source /path/to/.virtualenvs/cookie_polls/scripts/activate
|
||||
|
||||
On other operating systems, it'll be found in the ``bin`` folder.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ source /path/to/.virtualenvs/cookie_polls/bin/activate
|
||||
|
||||
You'll know the virtual environment is active because its name will appear in parentheses before the command prompt. When you're done with this project, you can leave the virtual environment with the ``deactivate`` command.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
(cookie_polls)
|
||||
$ deactivate
|
||||
|
||||
|
||||
Now you're ready to create your project using Cookiecutter.
|
||||
|
||||
|
||||
===============
|
||||
2. Cookiecutter
|
||||
===============
|
||||
|
||||
Django developers may be familiar with the ``startproject`` command, which initializes the directory structure and required files for a bare-bones Django project. While this is fine when you're just learning Django for the first time, it's not great for a real production app. Cookiecutter takes care of a lot of standard tasks for you, including installing software dependencies, setting up testing files, and including and organizing common libraries like Bootstrap and AngularJS. It also generates a software license and a README.
|
||||
|
||||
Change directories into the folder where you want your project to live, and run ``cookiecutter`` followed by the URL of Cookiecutter's Github repo.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ cd /my/project/folder
|
||||
(cookie_polls)
|
||||
my/project/folder
|
||||
$ cookiecutter https://github.com/pydanny/cookiecutter-django
|
||||
|
||||
This will prompt you for a bunch of values specific to your project. Press "enter" without typing anything to use the default values, which are shown in [brackets] after the question. You can learn about all the different options `here, <http://cookiecutter-django.readthedocs.io/en/latest/project-generation-options.html>`_ but for now we'll use the defaults for everything but your name, your email, the project's name, and the project's description.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
project_name [project_name]: My Favorite Cookie
|
||||
project_slug [My_Favorite_Cookie]:
|
||||
author_name [Your Name]: Emily Cain
|
||||
email [Your email]: contact@emcain.net
|
||||
description [A short description of the project.]: Poll your friends to determine the most popular cookie.
|
||||
|
||||
Then hit "enter" to use the default values for everything else.
|
||||
|
||||
|
||||
|
9
docs/troubleshooting.rst
Normal file
9
docs/troubleshooting.rst
Normal file
|
@ -0,0 +1,9 @@
|
|||
Troubleshooting
|
||||
=====================================
|
||||
|
||||
This page contains some advice about errors and problems commonly encountered during the development of Cookiecutter Django applications.
|
||||
|
||||
#. If you get the error ``jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'.`` , please upgrade your cookiecutter version to >= 1.4 (see issue # 528_ )
|
||||
#. ``project_slug`` must be a valid Python module name or you will have issues on imports.
|
||||
|
||||
.. _528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373
|
|
@ -134,7 +134,25 @@ def remove_grunt_files():
|
|||
"""
|
||||
Removes files needed for grunt if it isn't going to be used
|
||||
"""
|
||||
for filename in ["Gruntfile.js", "package.json"]:
|
||||
for filename in ["Gruntfile.js"]:
|
||||
os.remove(os.path.join(
|
||||
PROJECT_DIRECTORY, filename
|
||||
))
|
||||
|
||||
def remove_gulp_files():
|
||||
"""
|
||||
Removes files needed for grunt if it isn't going to be used
|
||||
"""
|
||||
for filename in ["gulpfile.js"]:
|
||||
os.remove(os.path.join(
|
||||
PROJECT_DIRECTORY, filename
|
||||
))
|
||||
|
||||
def remove_packageJSON_file():
|
||||
"""
|
||||
Removes files needed for grunt if it isn't going to be used
|
||||
"""
|
||||
for filename in ["package.json"]:
|
||||
os.remove(os.path.join(
|
||||
PROJECT_DIRECTORY, filename
|
||||
))
|
||||
|
@ -176,18 +194,24 @@ if '{{ cookiecutter.use_heroku }}'.lower() != 'y':
|
|||
if '{{ cookiecutter.use_docker }}'.lower() != 'y':
|
||||
remove_docker_files()
|
||||
|
||||
# 6. Removes all grunt files if it isn't going to be used
|
||||
if '{{ cookiecutter.use_grunt }}'.lower() != 'y':
|
||||
# 6. Removes all JS task manager files if it isn't going to be used
|
||||
if '{{ cookiecutter.js_task_runner}}'.lower() == 'gulp':
|
||||
remove_grunt_files()
|
||||
elif '{{ cookiecutter.js_task_runner}}'.lower() == 'grunt':
|
||||
remove_gulp_files()
|
||||
else:
|
||||
remove_gulp_files()
|
||||
remove_grunt_files()
|
||||
remove_packageJSON_file()
|
||||
|
||||
|
||||
# 7. Display a warning if use_docker and use_grunt are selected. Grunt isn't supported by our
|
||||
# 7. Display a warning if use_docker and js task runner are selected. Grunt isn't supported by our
|
||||
# docker config atm.
|
||||
if '{{ cookiecutter.use_grunt }}'.lower() == 'y' and '{{ cookiecutter.use_docker }}'.lower() == 'y':
|
||||
if '{{ cookiecutter.js_task_runner }}'.lower() in ['grunt', 'gulp'] and '{{ cookiecutter.use_docker }}'.lower() == 'y':
|
||||
print(
|
||||
"You selected to use docker and grunt. This is NOT supported out of the box for now. You "
|
||||
"You selected to use docker and a JS task runner. This is NOT supported out of the box for now. You "
|
||||
"can continue to use the project like you normally would, but you will need to add a "
|
||||
" grunt service to your docker configuration manually."
|
||||
"js task runner service to your docker configuration manually."
|
||||
)
|
||||
|
||||
# 7. Display a warning if use_docker and use_mailhog are selected. Mailhog isn't supported by our
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import cookiecutter
|
||||
|
||||
project_slug = '{{ cookiecutter.project_slug }}'
|
||||
|
||||
if hasattr(project_slug, 'isidentifier'):
|
||||
assert project_slug.isidentifier(), 'Project slug should be valid Python identifier!'
|
||||
|
||||
assert cookiecutter.__version__ > '1.3.0', 'Please upgrade your Cookiecutter installation'
|
||||
|
||||
|
|
107
{{cookiecutter.project_slug}}/gulpfile.js
Normal file
107
{{cookiecutter.project_slug}}/gulpfile.js
Normal file
|
@ -0,0 +1,107 @@
|
|||
|
||||
////////////////////////////////
|
||||
//Setup//
|
||||
////////////////////////////////
|
||||
|
||||
// Plugins
|
||||
var gulp = require('gulp'),
|
||||
pjson = require('./package.json'),
|
||||
gutil = require('gulp-util'),
|
||||
sass = require('gulp-sass'),
|
||||
autoprefixer = require('gulp-autoprefixer'),
|
||||
cssnano = require('gulp-cssnano'),
|
||||
rename = require('gulp-rename'),
|
||||
del = require('del'),
|
||||
plumber = require('gulp-plumber'),
|
||||
pixrem = require('gulp-pixrem'),
|
||||
uglify = require('gulp-uglify'),
|
||||
imagemin = require('gulp-imagemin'),
|
||||
exec = require('gulp-exec'),
|
||||
runSequence = require('run-sequence'),
|
||||
browserSync = require('browser-sync');
|
||||
|
||||
|
||||
// Relative paths function
|
||||
var pathsConfig = function (appName) {
|
||||
this.app = "./" + (appName || pjson.name);
|
||||
|
||||
return {
|
||||
app: this.app,
|
||||
templates: this.app + '/templates',
|
||||
css: this.app + '/static/css',
|
||||
sass: this.app + '/static/sass',
|
||||
fonts: this.app + '/static/fonts',
|
||||
images: this.app + '/static/images',
|
||||
js: this.app + '/static/js',
|
||||
}
|
||||
};
|
||||
|
||||
var paths = pathsConfig();
|
||||
|
||||
////////////////////////////////
|
||||
//Tasks//
|
||||
////////////////////////////////
|
||||
|
||||
// Styles autoprefixing and minification
|
||||
gulp.task('styles', function() {
|
||||
return gulp.src(paths.sass + '/project.scss')
|
||||
.pipe(sass().on('error', sass.logError))
|
||||
.pipe(plumber()) // Checks for errors
|
||||
.pipe(autoprefixer({browsers: ['last 2 version']})) // Adds vendor prefixes
|
||||
.pipe(pixrem()) // add fallbacks for rem units
|
||||
.pipe(gulp.dest(paths.css))
|
||||
.pipe(rename({ suffix: '.min' }))
|
||||
.pipe(cssnano()) // Minifies the result
|
||||
.pipe(gulp.dest(paths.css));
|
||||
});
|
||||
|
||||
// Javascript minification
|
||||
gulp.task('scripts', function() {
|
||||
return gulp.src(paths.js + '/project.js')
|
||||
.pipe(plumber()) // Checks for errors
|
||||
.pipe(uglify()) // Minifies the js
|
||||
.pipe(rename({ suffix: '.min' }))
|
||||
.pipe(gulp.dest(paths.js));
|
||||
});
|
||||
|
||||
// Image compression
|
||||
gulp.task('imgCompression', function(){
|
||||
return gulp.src(paths.images + '/*')
|
||||
.pipe(imagemin()) // Compresses PNG, JPEG, GIF and SVG images
|
||||
.pipe(gulp.dest(paths.images))
|
||||
});
|
||||
|
||||
// Run django server
|
||||
gulp.task('runServer', function() {
|
||||
exec('python manage.py runserver', function (err, stdout, stderr) {
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
});
|
||||
});
|
||||
|
||||
// Browser sync server for live reload
|
||||
gulp.task('browserSync', function() {
|
||||
browserSync.init(
|
||||
[paths.css + "/*.css", paths.js + "*.js", paths.templates + '*.html'], {
|
||||
proxy: "localhost:8000"
|
||||
});
|
||||
});
|
||||
|
||||
// Default task
|
||||
gulp.task('default', function() {
|
||||
runSequence(['styles', 'scripts', 'imgCompression'], 'runServer', 'browserSync');
|
||||
});
|
||||
|
||||
////////////////////////////////
|
||||
//Watch//
|
||||
////////////////////////////////
|
||||
|
||||
// Watch
|
||||
gulp.task('watch', ['default'], function() {
|
||||
|
||||
gulp.watch(paths.sass + '/*.scss', ['styles']);
|
||||
gulp.watch(paths.js + '/*.js', ['scripts']);
|
||||
gulp.watch(paths.images + '/*', ['imgCompression']);
|
||||
gulp.watch('templates/*.html');
|
||||
|
||||
});
|
|
@ -3,17 +3,34 @@
|
|||
"version": "{{ cookiecutter.version }}",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"grunt-bg-shell": "~2.3.1",
|
||||
"connect-livereload": "~0.3.2",
|
||||
"time-grunt": "~1.2.1",
|
||||
"load-grunt-tasks": "~3.2.0",
|
||||
"grunt-sass": "~1.0.0",
|
||||
"grunt-postcss": "~0.5.5",
|
||||
"cssnano": "~2.1.0",
|
||||
{% if cookiecutter.js_task_runner == 'Grunt' %}
|
||||
"autoprefixer-core": "~5.2.1",
|
||||
"pixrem": "~1.3.1"
|
||||
"connect-livereload": "~0.3.2",
|
||||
"cssnano": "~2.1.0",
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-bg-shell": "~2.3.1",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"grunt-postcss": "~0.5.5",
|
||||
"grunt-sass": "~1.0.0",
|
||||
"load-grunt-tasks": "~3.2.0",
|
||||
"pixrem": "~1.3.1",
|
||||
"time-grunt": "~1.2.1"
|
||||
{% elif cookiecutter.js_task_runner == 'Gulp' %}
|
||||
"browser-sync": "^2.12.10",
|
||||
"del": "^2.2.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-autoprefixer": "^3.1.0",
|
||||
"gulp-cssnano": "^2.1.2",
|
||||
"gulp-exec": "^2.1.2",
|
||||
"gulp-imagemin": "^3.0.1",
|
||||
"gulp-pixrem": "^1.0.0",
|
||||
"gulp-plumber": "^1.1.0",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-sass": "^2.3.1",
|
||||
"gulp-uglify": "^1.5.3",
|
||||
"gulp-util": "^3.0.7",
|
||||
"run-sequence": "^1.2.1"
|
||||
{% endif %}
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
|
||||
// project specific CSS goes here
|
||||
|
||||
////////////////////////////////
|
||||
//Variables//
|
||||
////////////////////////////////
|
||||
|
||||
// Alert colors
|
||||
|
||||
$white: #fff;
|
||||
|
@ -9,6 +14,10 @@ $pink: #f2dede;
|
|||
$dark-pink: #eed3d7;
|
||||
$red: #b94a48;
|
||||
|
||||
////////////////////////////////
|
||||
//Alerts//
|
||||
////////////////////////////////
|
||||
|
||||
// bootstrap alert CSS, translated to the django-standard levels of
|
||||
// debug, info, success, warning, error
|
||||
|
||||
|
@ -24,8 +33,16 @@ $red: #b94a48;
|
|||
color: $red;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//Navbar//
|
||||
////////////////////////////////
|
||||
|
||||
// This is a fix for the bootstrap4 alpha release
|
||||
|
||||
.navbar {
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
@media (max-width: 47.9em) {
|
||||
.navbar-nav .nav-item {
|
||||
display: inline-block;
|
||||
|
@ -42,6 +59,10 @@ $red: #b94a48;
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//Django Toolbar//
|
||||
////////////////////////////////
|
||||
|
||||
// Display django-debug-toolbar.
|
||||
// See https://github.com/django-debug-toolbar/django-debug-toolbar/issues/742
|
||||
// and https://github.com/pydanny/cookiecutter-django/issues/317
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% raw %}{% load staticfiles i18n %}<!DOCTYPE html>
|
||||
<html lang="en" {% endraw %}{% if cookiecutter.use_angular == "y" %}ng-app{% endif %}{% raw %}>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -23,10 +23,6 @@
|
|||
<link href="{% static 'css/project.css' %}" rel="stylesheet">
|
||||
{% endblock %}
|
||||
|
||||
{% endraw %}{% if cookiecutter.use_angular == "y" %}{% raw %}{% block angular %}
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
|
||||
{% endblock %}{% endraw %}{% endif %}{% raw %}
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
Loading…
Reference in New Issue
Block a user