Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danie1k/__abandoned__django-factories
Simple class factories for Django
https://github.com/danie1k/__abandoned__django-factories
Last synced: 22 days ago
JSON representation
Simple class factories for Django
- Host: GitHub
- URL: https://github.com/danie1k/__abandoned__django-factories
- Owner: danie1k
- License: bsd-3-clause
- Created: 2017-12-16T18:14:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-27T12:20:50.000Z (almost 7 years ago)
- Last Synced: 2024-10-03T11:41:53.154Z (about 1 month ago)
- Language: Python
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
================
django-factories
================
Simple classes factories for Django Framework.*******************
Available functions
*******************Factories
---------
- ``class_in_class_factory`` (`usage example <#class_in_class_factory>`_)
- ``inline_model_admin_class_factory``
- ``intermediate_m2m_model_class_factory``
- ``model_admin_form_class_factory``
- ``polymorphic_child_admin_class_factory``Tools & wrappers
----------------
- ``add_fields_to_model``
- ``register_model_in_app``
- ``set_class_in_class`` (`usage example <#set_class_in_class>`_)**************
Usage examples
**************``class_in_class_factory``
--------------------------
.. code-block:: pythonfrom django_factories import class_in_class_factory
from myapp.admin import MyModelAdminmedia_class_fields = {
'js': ['path/to/javascript/file.js'],
}# MyModelAdmin.Media will be overwritten if exists
MyModelAdmin.Media = class_in_class_factory(MyModelAdmin, 'Media', **media_class_fields)``set_class_in_class``
--------------------------
It's wrapper for ``class_in_class_factory``, which has implemented some logic for merging with already existing classes:.. code-block:: python
from django_factories import set_class_in_class
from myapp.admin import MyModelAdminmedia_class_fields = {
'js': ['path/to/javascript/file.js'],
}
# Existing MyModelAdmin.Media will merged with new Media class, so you won't loose any existing data
set_class_in_class(MyModelAdmin, 'Media', media_class_fields)More will come later...