You can use this view to have a possibility to use ?paginate_by=x on your generic lists.
Example usage in urls.py:
`url('^list/', object_list_with_paginate_by,
{'queryset': Invoice.objects.all(), 'template_name': 'invoices/list.html', 'paginate_by': 10},
'invoices.list')`
10 is the default objects count per page.
For the first time parameter paginate_by is set in URL, we have to get it straight from there.
If the parameter is set, then also set the cookie for later requests without the parameter
If the parameter is not set, then we try the cookie or default value
- object_list
- cookies
- paginate_by
"Make fixture" command. Highly useful for making test fixtures.
Use it to pick only few items from your data to serialize, restricted by primary keys.
By default command also serializes foreign keys and m2m relations.
You can turn off related items serialization with `--skip-related` option.
How to use:
python manage.py makefixture
will display what models are installed
python manage.py makefixture User[:3]
or
python manage.py makefixture auth.User[:3]
or
python manage.py makefixture django.contrib.auth.User[:3]
will serialize users with ids 1 and 2, with assigned groups, permissions and content types.
python manage.py makefixture YourModel[3] YourModel[6:10]
will serialize YourModel with key 3 and keys 6 to 9 inclusively.
Of course, you can serialize whole tables, and also different tables at once, and use options of dumpdata:
python manage.py makefixture --format=xml --indent=4 YourModel[3] AnotherModel auth.User[:5] auth.Group
- serialize
- admin
- model
- fixtures
- tests
- test
- management
- commands
- fixture
- command
- make