How to use PostgreSQL partitions with Django


Partitions in PostgreSQL(and MySQL too :)) are very useful when we have to store large data dividing them by attribute for future works. In my case I have logs of working on projects, which are stored in partition for each project.

Using partitions in django project is not very difficult, but there is one issue with “returning id” for insert statement in database. Function, which will insert a record to right table, must return trigger, but not id of last record as django expects.

read full ⇝

    2014-10-04 10:00:30      django postgresql partition

How to change choices for field in Django-Rest-Framework


As usual for django forms common way to change choices for some field it’s overwrite __init__ method of form and replace self.fields['<field name>'].choices. But it doesn’t work for django-rest-framework serializers.ChoiceField.

For serializers.ChoiceField you can again overwrite __init__ method and replace data in self.fields['<field name>'].choice_strings_to_values where have to be dict where key is string representation of choices "key" and value is choices "key".


self.fields['fieldname'].choice_strings_to_values = {
    str(key): key
    for key, value in self.get_fieldname_choices()
    2016-08-26 19:00:26      django rest-framework

Django package: django-classifier


Just want to introduce my package for Django.

With help of this package you can create dynamically configurable sets of properties. Checkout tutorial for more information.

doc: http://django-classifier.readthedocs.io/

repo: https://github.com/django-stars/django-classifier

    2016-09-01 12:00:28      django package