django-taggit

Then you can use the API like so:

>>> apple = Food.objects.create(name=”apple”)
>>> apple.tags.add(“red”, “green”, “delicious”)
>>> apple.tags.all()
[, , ]
>>> apple.tags.remove(“green”)
>>> apple.tags.all()
[, ]
>>> Food.objects.filter(tags__name__in=[“red”])
[, ]

Deploy django apps to Amazon EC2 with ONE command

Fabulous will create an EC2 instance, install everything and deploy a blank django app. All in less than 2 minutes.

Process

Create server on EC2
Wait a few seconds for server to boot
Install packages
Create virtualenv
Install django in virtualenv
Install gunicorn in virtualenv
Setup and run supervisor
The setup

nginx
gunicorn
supervisor
memcached
virtualenv
virtualenvwrapper
git

Trying JSON in Django and PostgreSQL (and compare with MongoDB)

class Product(models.Model):
    name = models.CharField(max_length=100)
    category = models.ForeignKey(Category)
    price = models.IntegerField()
    attributes = JSONField()

    def __str__(self):
        return self.name

 

Product.objects.create(name='Bamboo tshirt', category=tshirt, price=120, attributes={
    'colors': ['white', 'yellow'],
    'sizes': ['M', 'L', 'XL'],
    'model': 'poet',
    'material': 'bamboo',
})