background preloader

Django

Facebook Twitter

Ottoyiu/django-cors-headers. Deni Bertovic. If you've worked with Django at some point you probably had the need for some background processing of long running tasks.

Deni Bertovic

Chances are you've used some sort of task queue, and Celery is currently the most popular project for this sort of thing in the Python (and Django) world (but there are others). While working on some projects that used Celery for a task queue I've gathered a number of best practices and decided to document them. Nevertheless, this is more a rant about what I think should be the proper way to do things, and about some underused features that the celery ecosystem offers. No.1: Don't use the database as your AMQP Broker Let me explain why I think this is wrong (aside from the limitations pointed out in the celery docs). A database is not built for doing the things a proper AMQP broker like RabbitMQ is designed for.

Dobarkod/django-queryinspect. Maraujop/requests-oauth. Setting up Django with Nginx, Gunicorn, virtualenv, supervisor and PostgreSQL - Michał Karzyński. Django is an efficient, versatile and dynamically evolving web application development framework.

Setting up Django with Nginx, Gunicorn, virtualenv, supervisor and PostgreSQL - Michał Karzyński

When Django initially gained popularity, the recommended setup for running Django applications was based around Apache with mod_wsgi. The art of running Django advanced and these days the recommended configuration is more efficient and resilient, but also more complex and includes such tools as: Nginx, Gunicorn, virtualenv, supervisord and PostgreSQL. Mock - Mocking and Testing Library — Mock 1.0.1 documentation. Mock is a library for testing in Python.

Mock - Mocking and Testing Library — Mock 1.0.1 documentation

It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used. mock is now part of the Python standard library, available as unittest.mock in Python 3.3 onwards. mock provides a core Mock class removing the need to create a host of stubs throughout your test suite. Audreyr/cookiecutter. Django Model Behaviors by Kevin Stone.

Advanced Patterns to Manage Model Complexity by Kevin Stone.

Django Model Behaviors by Kevin Stone

George London's Blog - The Idiomatic Guide to Deploying Django in Production. Wow, this guide is long. Why not skip it? Oscar 0.6 release notes — django-oscar 0.7 documentation. These release notes cover the new features as well as backwards incompatible changes that you’ll want to be aware of when upgrading from Oscar 0.5 or earlier.

Oscar 0.6 release notes — django-oscar 0.7 documentation

This release contains some major changes to core APIs which means many old APIs are scheduled to be dropped - see the deprecation plan to avoid any nasty surprises. Overview¶ The biggest change in Oscar 0.6 is the reworking of pricing and availability, which builds on top of the change to allow multiple stockrecords per product.

The change is largely backwards compatible with the old system of “partner wrappers” but it is recommended to upgrade to the new system. The Best (and Worst) of Django. Django and Celery. Note CLI Command examples on this page are always provided without the --application (shorthand -A) argument, assuming you’re running these commands in a connected folder (at creation or using the dotcloud connect command).

Django and Celery

For more details on connected folders, see Migrating to the CLI 0.9. As you write your application you will certainly need to execute some asynchronous tasks. It could be anything that requires some form of (lengthy) processing: image resizing, archiving, document analysis... These tasks could be run from the same machine where your application server is, but best practices advise to do this on a different machine because: Using IPython Notebook with Django. Putting RQ under supervisor. Supervisor is a popular tool for managing long-running processes in production environments.

Putting RQ under supervisor

It can automatically restart any crashed processes, and you gain a single dashboard for all of the running processes that make up your product. RQ can be used in combination with supervisor easily. You'd typically want to use the following supervisor settings: Lincolnloop/django-layout. Django: Creating multi upload form without using Flash. Hi there!

Django: Creating multi upload form without using Flash

Today I want to tell you about my experience of adding Multiple files upload form to my Django project Photoblog. I searched google for lots of plugins, but found only Flash usage examples. I dislike Flash technology, as for my personal usage, and want to build some more quickly working UI. Personally I have flash blocker installed on my browser. So that's main ideas pf my jQuery plugin selection. Sebastian has built an important plugin IMHO. Pdb: Using the Python debugger in Django - Minutiæ by Mike Tigas. A couple conversations I had at DjangoCon last week reminded me that I’d never gotten around to finishing this little post.

pdb: Using the Python debugger in Django - Minutiæ by Mike Tigas

Since I started taking my first iOS development baby steps last year, I’ve become quite dependent on breakpoints and stepping as part of my Objective-C debugging workflow. …And yet, in Python/Django — the stack I spend most of my time working with — I’d stuck to the poor habit of throwing print statements around any found exceptions — for example, to figure out what lies in request.POST for a Django view. And then I came across and started tinkering with pdb. Here’s a brief overview on how to rock your Python debugging workflow by using an actual interactive debugger. The example below highlights the most basic of usecases, but it’s a good start. Dajaxproject.com - easy to use ajax libraries for django. Using LESS with Django. Lately, I’ve been working on creating a simplified work flow for my front end work here at Caktus. There are all sorts of new and helpful tools to optimize the creative process, allowing for faster iterations, and greater overall enjoyment.

As with any new tool, there are a few options to choose from: LESS and SASS. Having read lots of reviews and reading through the documentation, I’ve decided LESS is more for me. Zinnia - Your Django powered WeblogYour Django powered Weblog. Yprez/django-sitepush. Niels / signupbox / commit / 6339d79ef8e0. Django Admin Snippets. Readonly_field As of Django 1.2, a readonly_field has been available to models in the admin.

Django Admin Snippets

This is very helpful for making data visible in the admin while preventing it from being edited. readonly_fields=[’created’,’modified’,’preformed_by’,’ipaddress’,’featured’] get_readonly_fields() Using the get_readonly_fields() method of the ModelAdmin, one can change readonly fields dynamically. Doing more with the Django admin. The Django admin Django offers many features to prospective developers: a mature standard library, an active user community, and all the benefits of the Python language.

While other Web frameworks can make similar claims, Django's unique asset is its built-in administration application — the admin. The admin provides advanced Create-Read-Update-Delete (CRUD) functionality out of the box, eliminating hours of repetitive work. This is key for many Web applications in development, when programmers can quickly explore their database models, and in deployment, when nontechnical end users can use the admin to add and edit site content. In the real world, there's always some customization to be performed.

A quick tour of the admin Most Django developers are familiar with the default features of the admin. Listing 1. Backbone.js and Django : blog : Josh Bohde. NOTE: Since this post, both Backbone.js and Tastypie have gone through a lot of changes. As of December 30th, 2011, the reference repo on Github has been updated to the latest versions, and changed to use backbone-tastypie , which provides an nice compatibility layer, and stays updated better than the examples in this post. I've been using backbone.js recently, mostly with node.js, or with the localstore bundled with the example Todo application for quick prototypes. Joshbohde/django-backbone-example. Using Unmanaged Django Models of Postgres Views in a Pre-existing Schema. This discussion covers the way Django 1.4 and Postgres 9.1 work as of mid 2012. If you have trouble with this or very similar code let me know and we can post your examples.

Some of us like Python. The lot of us that started in an Algol like C (or Algol) and moved on to a LISP like Scheme (or Common Lisp) find Python an easy middle, especially when working with others who don’t share the same background. Its easy enough to catch on to that even first-time use merely requires reading a sample and a link to the API reference — its just that easy to get started.

OOP is optional and you get first-class functions, but you don’t get a lot of the functional goodies and you’re insulated from the platform a bit. Notch-interactive/django-chuck. Django Advice. Technical articles -How to override a view from an external Django app. This article describes how to override a view from an external Django app which is a FAQ on StackOverflow and IRC.

You should understand that your urls.py is a really central and critical part of your django project. You don’t touch external app code You are not supposed to edit the code from an external app. GRAPPELLI ADMIN INTERFACE. Tutorial: Converting the Django Poll Tutorial to use AJAX via JQuery. Chaining select boxes in admin with MooTools. The-Django-gunicorn-fabfile-project/fabconfig.py at master · alexisbellido/The-Django-gunicorn-fabfile-project. Deploy Django on Apache with Virtualenv and mod_wsgi. I have recently got into Django and built a small project with it which is this blog. Then came the time for me to deploy the project on an unmanaged VPS, the process went fine yet with a few problems here and there due to the lack of a definitive guide to deployment. So I ended up checking several sources to have everything work the way I wanted. In this post, I'll be sharing the whole process with you in detail and what will hopefully be helpful to the fellow newcomers.

Using Proxy Models to Customize the Django Admin. Martin Mahner: Separating staff and user accounts in Django's admin. Custom Fields in Django - David Cramer's Blog. I was helping someone today in the Django IRC channel and the question came across about storing a denormalized data set in a single field. Typically I do such things by either serializing the data, or by separating the values with a token (comma for example). Admin related widget wrapper with edit / delete link (python widget)