Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

localboy/django-integer-enum

Open more actions menu

Repository files navigation

Django Integer Enum

Documentation Status Updates

Django model integer enum field

Requirements

To be able to use django-integer-enum you have to meet following requirements:

  • Python (2.7, 3.4, 3.5, 3.6)
  • Django (1.11, 2.0, 2.1, 2.2)

Installation

Simply install using pip:

$ pip install django-integer-enum

Uses

Creating Enum

enums.py

from django.utils.translation import gettext as _
from django_integer_enum import enums

Class TaskStatus(enums.Enum):
    DRAFT = 0
    INPROGRESS = 1
    COMPLETED = 2
    ARCHIVED = 3

    local = (
        _('Draft'),
        _('In Progress'),
        _('Completed'),
        _('Archived')
    )

Add TaskStatus enum to django model

models.py

from django.db import model
from django_integer_enum import fields
from .enums import TaskStatus


Class Task(models.Model):
     ---
     ---
     status = fields.EnumIntegerField(enum_choices=TaskStatus)

License

  • Free software: MIT license

Documentation

Features

  • TODO

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

About

Django model integer enum field

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.