Batteries Included Django
Accelerate your Project with the Ecosystem
Our Current Requirements.txt
distribute>=0.6.28 mysql-python>=1.2.4 Django>=1.5 pillow south>=0.8,<2.0 sorl-thumbnail hamlpy requests>=1.0 djangorestframework>=2.3.4 unicodecsv # Django Enhancements django-extensions django-model-utils django-templated-email django-grappelli>=2.4.5 django-floppyforms django-filter django-braces # Datetime pytz iso8601 python-dateutil>=1.5,<2.0 # Deployment uwsgi Werkzeug fabric # Analytics numpy pandas
# Caching redis hiredis django-redis-cache johnny-cache # Django Compressor django-compressor>=1.3 lxml BeautifulSoup<4.0 cssmin slimit django-sekizai # Celery django-celery-with-redis django-celery-transactions # Social gdata google-api-python-client oauth2client django-social-auth>=0.7.22 facepy # Services mixpanel-celery>=0.6.0 raven>=3.0 lettuce>=0.2.18
Testing Requirements.txt
factory_boy>=1.3,<2.0 # Guard against potential 2.0 breaking changes
mock
# Nose
nose<1.3 # Nose 1.3 breaks test discovery somehow
django-nose
coverage
nose-exclude
nose-progressive>=1.4.1
nosexcover
yanc
xtraceback
# Validaiton
pep8
flake8
Lettuce Requirements
# Make sure you have Chromium installed (or appropriate for your dev platform)
splinter>=0.5 # Need 0.5 for PhantomJS support
selenium>=2.28 # Need 2.28 for PhantomJS support
Basic Includes for Just About Every Project
- Pillow (Image Manipulation)
- sorl-thumbnail (Thumbnail Generation)
- South (DB Migrations)
- Requests (HTTP client)
- Django-Rest-Framework* (ReST API endpoint)
DateTime Fixes
- pytz (Timezone support)
- iso8601 (date formatting)
- python-dateutil (parsing and translation)
- unicodecsv (Fixes encoding for CSV import/export)
*or Tastypie or Django-Piston, but DRF is way better
General Django Helpers
-
django-extensions
- runserver_plus + shell_plus management commands (Werkzeug Debugger)
- Useful generic model fields (CreationDateTimeField, etc)
- django-model-utils
- Improved Querysets (PassThroughManager, InheritanceManager)
-
django-braces
- CBV Mixins (instead of ugly decorators)
Django CRUD Helpers
- django-filter
- Don't write your own query string parameterizations
- django-floppyforms
- Better templates for django forms
-
import floppyforms as forms
Admin Tools
- django-grappelli (nicer skin)
- django-extensions (again)
- ForeignKeyAutocompleteAdmin makes admin useable for relations (search field instead of dropdown)
Batch Processing
Celery
- django-celery
- django-celery-transactions
- Delays task delivery until transactions commit to eliminate race conditions
- django-templated-email
- Template support for mail subjects, and HTML + Plain versions
Cleaner Frontend Code
- HamlPy (Template loader)
- More readable and concise html generation
- (Also more version control friendly since it's line based)
- Django Compressor
- Supports LessCSS and Coffeescript
- lxml, BeautifulSoup, cssmin, slimit for minification
- NPM Packages: less, jshint, recess, uglify-js, coffee-script
- django-sekizai
- Adding resources in template fragments on demand
Haml Templates
<p>A bunch of placeholder text about your company.</p>
<div class="actions">
<div class="action-container pull-left">
<a class="flat-button block-level call-to-action" href="{% url "join" %}">Join our Site!</a>
</div>
<div class="action-container pull-right">
<a class="flat-button block-level call-to-action" href="{% url "login" %}">Sign In</a>
</div>
</div>
%p
A bunch of placeholder text about your company.
.actions
.action-container.pull-left
%a.flat-button.block-level.call-to-action{'href': '{% url "join" %}'}
Join our Site!
.action-container.pull-right
%a.flat-button.block-level.call-to-action{'href': '{% url "login" %}'}
Sign In
Another Haml Template
<div class="product-information-container">
<div class="product-information">
<h4>
{% if headline %}{{ headline }}{% endif %}
{% if url %}
<p>
<p>
<a href="{{ url }}">{{ url|format_url }}</a>
</p>
</p>
{% endif %}
</h4>
{% if description %}
<p class="description">{{ description }}</p>
</div>
</div>
.product-information-container
.product-information
%h4
- if headline
= headline
- if url
%p
%a{'href': '={url}'}
= url|format_url
- if description
%p.description<
= description
Django Sekizai
Base Template
{% render_block "js" %}
{% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %}
Included Fragment Example
- addtoblock "js"
%script{'type': 'text/javascript', 'src': '{% static "js/jquery/jquery.timeago.js" %}'}
- endaddtoblock "js"
Included Fragment Example (Coffeescript)
{% addtoblock "js" %}
<script type="text/coffeescript" src="{% static js/directives/date.coffee" %}"></script>
{% endaddtoblock "js" %}
Algorithmic/Data Science
- NumPy
-
Pandas
- Powerful data transformations (esp. for time series data)
Other Useful Libs
-
SciPy
- Algorithms galore
- NLTK (language processing + statistics primitives)
- PyMC (Bayesian inference)
Caching
- redis
- hiredis (faster bindings for redis)
- django-redis-cache (cache backend using redis)
- johnny-cache (transparent queryset caching)
APIs and Authentication
- django-social-auth (oauth consumers)
-
oauth2client
-
google-api-python-client
- gdata
- facepy
- mixpanel-celery
- raven (for Sentry)
Deployment
- Fabric (automation)
- uWSGi (WSGi container)
- Werkzeug (Lightweight WSGi framework)
Testing
- Factory-boy (Fixtures)
- mock (Mocking and Stubbing)
Feature Tests
- lettuce
- selenium (web browser automation)
- splinter (selenium wrapper)
Validation
- pep8 (coding standards)
- flake8 (static analysis)
Nose Plugins
- nose
- django-nose
- Nose based Test Runner for Django
- coverage
- Code Coverage
- nose-exclude
- Adds --exclude-dir= flags to skip certain dirs
- nose-progressive
- Progress bar for test runner
- nosexcover (worst package name ever)
- Code coverage for xunit results (for Jenkins)
- yanc
- Output Color-izer
- xtraceback
- Better Test Tracebacks
Questions?
The End
About the Author:
Kevin Stone is the CTO and Founder of Subblime
Interested in working on these challenges? Subblime is hiring
Batteries Included Django
By Kevin Stone
Batteries Included Django
List of useful 3rd party python and django packages to help accelerate your django web app.
- 4,921