Skip to content

Instantly share code, notes, and snippets.

@alb3rto269
alb3rto269 / fixtures.py
Created March 23, 2018 20:18
AutoFixture for GenericForeignKey
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from autofixture import AutoFixture, generators
class GenericFKAutoFixture(AutoFixture):
"""
AutoFixture class that generate instances with ::GenericForeignKey:: that
make sense. This is, the ::object_id:: will match an acutal instance of the
@alb3rto269
alb3rto269 / fabile.py
Created January 30, 2015 18:24
Simple dump task for fabric
# Simple environment
env.project_name = 'my_project'
env.project_path = '/home/user/{project_name}'.format(**env)
env.environment = 'dev' # 'dev' || 'prod'
env.dump_path = '{project_path}/db'.format(**env)
@task
def dump(filename=None):
"""Generate and download a db dump."""
# ensure remote dump_path exists
@alb3rto269
alb3rto269 / _project_tree_
Last active August 29, 2015 14:08
celery 3.1 + django-configurations
/mysite
| app1/
| models.py
| tasks.py
| app2/
| models.py
| tasks.py
| config/
| local.py
| development.py