📜 ⬆️ ⬇️

10 more jango batteries


We continue to share our experience of using useful Django batteries.
First part
We also recommend “Confused notes about python and django” and “Django PR Hero project: what's inside and the experience gained .

For Django written a huge number of packages. Of these, we chose 10, which we used ourselves in our latest projects and with which we were satisfied. All of them are on PyPI. They are documented and covered with tests, somewhere more, somewhere less. The exception is django-sphinx, about which separately.


')

django-hvad


An interesting implementation of storing multilingual fields in models. For each model being translated, an additional table is created in which only translation attributes are stored.

Model description example:

class DjangoModel(TranslatableModel): name = models.CharField(max_length=255, unique=True) author = models.CharField(max_length=255) translations = TranslatedFields( description = models.TextField(), description_author = models.CharField(max_length=255), ) def __unicode__(self): return self.name 


Request example:

 DjangoModel.objects.language('en').filter(description_author='Jonas Obrist') 


The application is one of the best in its category, albeit alpha. In some places it is damp, as the author himself admits. It tries to minimize the number of queries to the database, friendly to south-migrations.
In addition, django-hvad can draw a nice admin panel for field translations:


Github
Documentation

django-whatever (django-any)


The module eliminates the creation of bulky fixtures for tests, replacing them with simple creation of model objects on the fly, filling the fields with random data. Thanks to this, tests become more readable and supported.

Here is an example in which we create two instances of models, but specify when creating only those field values ​​that are important for the test (the rest will be done by django-any):

 from django_any import any_model class TestMyShop(TestCase): def test_order_updates_user_account(self): account = any_model(Account, amount=25, user__is_active=True) order = any_model(Order, user=account.user, amount=10) order.proceed() account = Account.objects.get(pk=account.pk) self.assertEquals(15, account.amount) 


django-any wrote kmmbvnr habrauser , and django-whatever is a friendly fork of our authorship, in which we added a few features and fixed a few bugs .

Github
Docks

django-jenkins


Convenient integration of Django and Jenkins to simplify the solution of continious integration from kmmbvnr. Everything is very simple: you configure and use, there are no complaints.

Good articles about testing in Django and directly about integration with django-jenkins:

Github
Video tutorial from the author: “How to start testing and get pleasure from it”

django-guardian


The application implements the missing out of the box feature of the rights to the object, and not to the entire model (object-level permissions). Starting with Django 1.2, the authentication backend supports object permissions checking, but this is not implemented in Django itself. django-guardian successfully fills this space.

The only flaw found is, perhaps, the fact that the existence of global rights to the model does not give rights to a specific object and requires separate verification .

Github
Docks

django-email-confirmation


Among the many other similar batteries, django-email-confirmation does not take on everything at once, but what it takes does it well. Allows the user to register several email addresses for himself, select the main one from them, confirm addresses by mail and manage the whole simple process. You can define your own templates for letters, you can make friends a method of sending letters with Celery, all as expected. It is part of the Pinax project.

Github

django-compressor / webassets


Two of the most interesting, in our opinion, applications for gluing and minifying CSS / JS. Unlike the django-compress mentioned in the previous post, they do not require a config and can work using template tags, which is quite convenient for layout designers. webassets, which is notable, works not only with Django ( flask-assets ). Both modules support Jinja through their extensions. Fans of SAS, LESS, CoffeeScript will not leave offended, preprocessors are also supported.

We use django-compressor and warn you against hasty updates on the latest versions of the application on the combat servers: the module is being actively developed and unexpected regressions periodically emerge (despite the tests). The rest is a very good package from one of the django core devs.

django-compressor githab
django-compressor docks

githab webassets
webassets docks

django-taggit


Simple battery, both in structure and in capabilities. As the name implies, django-taggit implements tag support. He does this at the model level with the help of a special manager. It is not bad customized and expands through the through-model, he himself is able to create a tag cloud that has already filled everyone, and does some other standard things (like adding / removing a tag). Documentation is quite small, but comprehensive, so familiarity will not take much time.

Github
Docks

django-sphinx


Sphinx, a popular search engine, is our all, thanks to its speed, flexibility and ability to take into account the peculiarities of Russian morphology, which cannot be said about its closest competitors. Despite its popularity, there is one single integrator solution for Django - django-sphinx.

What gives?
And at the same time:
In the coming days, we will share with you our experience with this module and will try to describe in detail the detected pitfalls. A lot of nuances pulls into a separate article.

Github (our fork)

Useful articles (in some places not quite relevant):

django-celery


A truly indispensable battery on more or less large projects, where asynchronous tasks are indispensable. In fact, Celery is the de facto standard for queuing in python, it has a wide range of features, supports a variety of backends and has a nice API.

Habré had a couple of good articles on how to work with celery, including tuning and pitfalls when integrating with Django:
Github
Documentation

django-hosts


The module for managing the routing of URLs depending on the subdomain, each of which can have its own URLConf. If your site has many subdomains, this battery will be useful to you.

Github
Documentation

PS Our modest contribution to the open source github.com/futurecolors and github.com/coagulant

Source: https://habr.com/ru/post/136168/


All Articles