fixing requirements

This commit is contained in:
Burhan Khalid 2015-07-14 12:05:25 +03:00
commit 5589003ff3
11 changed files with 110 additions and 20 deletions

View File

@ -48,6 +48,7 @@ Cullen Rhodes / @c-rhodes
Burhan Khalid / @burhan
Audrey Roy Greenfeld / @audreyr (and creator/maintainer of cookiecutter) *
Burhan Khalid / @burhan
Jannis Gebauer / @got_nil
* Possesses commit rights

View File

@ -27,6 +27,7 @@ Features
* Basic e-mail configurations for send emails via Mailgun_
* Media storage using Amazon S3
* Serve static files from Amazon S3 or Whitenoise_ (optional)
* Pre configured Celery_ (optional)
.. _Bootstrap: https://github.com/twbs/bootstrap
.. _AngularJS: https://github.com/angular/angular.js
@ -37,6 +38,7 @@ Features
.. _Procfile: https://devcenter.heroku.com/articles/procfile
.. _Mailgun: https://mailgun.com/
.. _Whitenoise: https://whitenoise.readthedocs.org/
.. _Celery: http://www.celeryproject.org/
Constraints

View File

@ -10,5 +10,6 @@
"now": "2015/01/13",
"year": "{{ cookiecutter.now[:4] }}",
"use_whitenoise": "y",
"use_celery": "n",
"windows": "n"
}

View File

@ -90,14 +90,18 @@ For convenience, you can keep your normal user logged in on Chrome and your supe
Live reloading and Sass CSS compilation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you'd like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with the included Grunt task.
If you'd like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with a little bit of prep work.
Make sure that nodejs_ is installed. Then in the project root run::
$ npm install grunt
$ npm install
.. _nodejs: http://nodejs.org/download/
If you don't already have it, install `compass` (doesn't hurt if you run this command twice)::
gem install compass
Now you just need::
$ grunt serve
@ -108,6 +112,21 @@ To get live reloading to work you'll probably need to install an `appropriate br
.. _appropriate browser extension: http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-
{% if cookiecutter.use_celery == "y" %}
Celery
^^^^^^
This app comes with Celery.
To run a celery worker:
.. code-block:: bash
cd {{cookiecutter.repo_name}}
celery -A {{cookiecutter.repo_name}} worker -l info
Please note: For Celerys import magic to work, it is important *where* the celery commands are run. If you are in the same folder with *manage.py*, you should be right.
{% endif %}
It's time to write the code!!!

View File

@ -255,5 +255,12 @@ LOGGING = {
},
}
}
{% if cookiecutter.use_celery == "y" %}
########## CELERY
INSTALLED_APPS += ('{{cookiecutter.repo_name}}.taskapp.celery.CeleryConfig',)
# if you are not using the django database broker (e.g. rabbitmq, redis, memcached), you can remove the next line.
INSTALLED_APPS += ('kombu.transport.django',)
BROKER_URL = env("CELERY_BROKER_URL", default='django://')
########## END CELERY
{% endif %}
# Your common stuff: Below this line define 3rd party library settings

View File

@ -58,5 +58,10 @@ INSTALLED_APPS += ('django_extensions', )
# TESTING
# ------------------------------------------------------------------------------
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
{% if cookiecutter.celery_support == "y" %}
########## CELERY
# In development, all tasks will be executed locally by blocking until the task returns
CELERY_ALWAYS_EAGER = True
########## END CELERY
{% endif %}
# Your local stuff: Below this line define 3rd party library settings

View File

@ -1,5 +1,5 @@
# Bleeding edge Django
django==1.8.2
django==1.8.3
# Configuration
django-environ==0.3.0
@ -38,4 +38,8 @@ pytz==2015.4
django-redis==4.2.0
redis>=2.10.0
{% if cookiecutter.use_celery == "y" %}
celery==3.1.18
{% endif %}
# Your custom requirements go here

View File

@ -7,3 +7,6 @@ Werkzeug==0.10.4
# django-debug-toolbar that works with Django 1.5+
django-debug-toolbar==1.3.2
# improved REPL
ipdb==0.8.1

View File

@ -0,0 +1,33 @@
{% if cookiecutter.use_celery == "y" %}
from __future__ import absolute_import
import os
from celery import Celery
from django.apps import AppConfig
from django.conf import settings
if not settings.configured:
# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
app = Celery('{{cookiecutter.repo_name}}')
class CeleryConfig(AppConfig):
name = '{{cookiecutter.repo_name}}.taskapp'
verbose_name = 'Celery Config'
def ready(self):
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
{% else %}
# Use this as a starting point for your project with celery.
# If you are not using celery, you can remove this app
{% endif %}

View File

@ -34,13 +34,27 @@
<body>
<div class="header navbar">
<div class="container">
<div class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">{% endraw %}{{ cookiecutter.project_name }}{% raw %}</a>
<ul class="nav navbar-nav">
<li class="active"><a href="{% url 'home' %}">Home</a></li>
<li><a href="{% url 'about' %}">About</a></li>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{% url 'home' %}">Home</a></li>
<li><a href="{% url 'about' %}">About</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if request.user.is_authenticated %}
<li><a href="{% url 'users:detail' request.user.username %}">{% trans "My Profile" %}</a></li>
<li><a href="{% url 'account_logout' %}">{% trans "Logout" %}</a></li>
@ -51,6 +65,7 @@
</ul>
</div>
</div>
</div>
<div class="container">