Core library for Nexus django projects
The full documentation is at https://django-genomix.readthedocs.io.
Install Django GenomiX:
pip install django-genomix
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'genomix',
...
)
- DisplayChoiceField - display representation values for choice fields in REST APIs.:
from genomix.fields import DisplayChoiceField
from rest_framework import serializers
from . import choices
class ExampleSerializer(serializers.ModelSerializer):
status = DisplayChoiceField(choices=choices.STATUS_OPTIONS)
- UserRelatedField - display username for a REST API with a user relation.:
from django.contrib.auth import get_user_model
from genomix.fields import UserRelatedField
from rest_framework import serializers
class ExampleSerializer(serializers.ModelSerializer):
user = UserRelatedField(queryset=get_user_model().objects.all())
- ContentRelatedField - display ContentType model for a REST API using a generic relation.:
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from genomix.fields import ContentRelatedField
from rest_framework import serializers
class ExampleSerializer(serializers.ModelSerializer):
content_type = ContentRelatedField(queryset=ContentType.objects.all())
- DisplayChoiceFilter - Filter by representation values in a REST API.:
import django_filters
from genomix.filters import DisplayChoiceFilter
from . import choices
class ExampleFilter(django_filters.rest_framework.FilterSet):
source = DisplayChoiceFilter(choices=choices.SOURCES)
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Tools used in rendering this package: