Django runtime typed custom fields¶
Django Custard is a small reusable unobtrusive Django app that implements runtime custom fields that can be attached to any model on the fly: it’s possible to create fields and set values for them from the code or manage them through the admin site, with the ability to display them even outside of the admin.
- Home page: https://github.com/kunitoki/django-custard
- Documentation: http://django-custard.readthedocs.org
- Pypi: https://pypi.python.org/pypi/django-custard
- Example app on Github: https://github.com/kunitoki/django-custard/example
- Changelog: Changelog.rst
- License: The MIT License (MIT)
- Supports: Django 1.7, 1.8 - Python 2.7, 3.4
Getting started¶
You can get Django Custard by using pip:
pip install django-custard
You will need to add the
'custard'
application to theINSTALLED_APPS
setting of your Django projectsettings.py
file.:INSTALLED_APPS = ( ... 'custard', )
In a
models.py
file in your app you should just add the 2 models responsible of holding the custom fields type and values.:from custard.builder import CustomFieldsBuilder builder = CustomFieldsBuilder('myapp.CustomFieldsModel', 'myapp.CustomValuesModel') ... class CustomFieldsModel(builder.create_fields()): pass class CustomValuesModel(builder.create_values()): pass
Then sync your database with:
python manager.py syncdb
Customization¶
Configuration¶
Customize Django Custard with some CUSTOM_*
configuration variables in a
Django project settings.py
file.
Models¶
How to work with Django Custard models and helper classes.
Admin¶
Process of integrating Django Custard in admin.
Support¶
- Github: Use django-custard github issues, if you have any problems using Django Custard.
Changelog¶
Only important changes are mentioned below.
v0.11 (unreleased)¶
- Fixed admin integration
- Updated example project
- Removed validate_unique for fields so your subclass can decide what to do with fields with the same name
- Removed models.py (useless with Django>=1.7)
- Dropped support for Django < 1.7 (insecure)
- Dropped support for Python 3.2 and 3.3
v0.10 (2015-06-15)¶
- Added Mixin.__getattr__ to access model custom fields like any other fields
- Fixed a problem when using commit=False in ModelForms
- Fixed a problem when custom_content_types is passed in CustomFieldsBuilder constructor (thanks to Kamil Wargula for the report and patch)
- Revert problem in mixin “get_custom_value” introduced with https://github.com/kunitoki/django-custard/commit/f3e171e6170d33a1ba6aba170e76549c55021ade
v0.9 (2015-03-12)¶
- Added ability to pass “value” in CustomValuesModel.objects.create
- Fixed https://github.com/kunitoki/django-custard/pull/2
- More tests and fixes
v0.8 (2014-10-08)¶
- Fixed https://github.com/kunitoki/django-custard/issues/1
- More tests
- More coverage
v0.7 (2014-07-29)¶
- Moved away from the static custard.models.custom class in favour of custard.builder
- Enable search of custom fields in admin without hacks
- Simplified a bit how to determine the classes in the builder
- Updated tests and example to the new builder methods
v0.6 (2014-07-27)¶
- Added support for python 2.6/2.7/3.2 and django 1.5/1.6
- Added test cases for forms and widgets
- Improved settings class to be cached at runtime while being able to work with override_settings in tests
- Fixed documentation links and sections not showing up
v0.5 (2014-07-23)¶
- Removed useless custom Exception classes not used anymore
- Added model mixin creation class for holding additional helper functions
- Fixed broken links in docs
- Added manager subclass to docs
- Added admin to docs
v0.4 (2014-07-23)¶
- Moved generation of FormField from model to Form
- Improved documentation
v0.3 (2014-07-22)¶
- Improved documentation
v0.2 (2014-07-20)¶
- Avoid using a global registry for registered apps in favour of a setting variable
- Improved documentation
v0.1 (2014-07-18)¶
- First stable version released