Skip to content

Instantly share code, notes, and snippets.

@h3
Created December 1, 2011 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h3/1414209 to your computer and use it in GitHub Desktop.
Save h3/1414209 to your computer and use it in GitHub Desktop.
Template fixtures concept
{% load fixture_tags %}
[
{% genfixtures "1:5" %}
{
"pk": {{ fixture.pk }},
"model": "auth.user",
"fields": {
"username": "{% gen_char "my_custom_username_generator" %}",
"first_name": "{% gen_char "first_name" %}",
"last_name": "{% gen_char "last_name" %}",
"is_active": {% gen_boolean %},
"is_superuser": false,
"is_staff": {% gen_boolean %},
"last_login": "{% gen_datetime between "2010-01-01 00:00:00" and "00:00:00" %}",
"groups": [{% gen_m2m auth.group null %},
"user_permissions": [],
"password": "{% gen_password %}",
"email": "{% gen_email %}",
"date_joined": "{% gen_datetime before today %}"
}
}{% if not fixture.last %},{% endif %}
{% endgenfixtures %}
{
"pk": 6,
"model": "auth.user",
"fields": {
"username": "bofh",
"first_name": "",
"last_name": "",
"is_active": true,
"is_superuser": true,
"is_staff": true,
"groups": [],
"user_permissions": [],
"password": "sha1$a2c9e50d9da202c310d30d5152f5a525192a8908",
"email": "admin@example.com",
"date_joined": "{% gen_datetime before today %}"
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment