Skip to main content

No project description provided

Project description

PyPi Build Status codecov Requirements Status PyUP PyPI License

Installation

pip install django-import-path-field

or from git

pip install -e git+https://githib.com/Apkawa/django-import-path-field.git#egg=django-import-path-field

Django and python version

Python
Django
3.5 3.6 3.7 3.8
1.8
1.11
2.2
3.0

Usage

models.py

from django.db import models
from importpath_field import ImportPathField, ImportPathChoices


class DescriptionClassStrategy:
    # Description for class
    short_description = 'Strategy description'

    @classmethod
    def class_method(cls):
        return 1

    @classmethod
    def class_method_description(cls):
        """Class method description"""
        return 1

    def method(self):
        return 3


def example_function_description():
    return 1

# Can description for choice
example_function_description.short_description = 'Function description'


IMPORT_CHOICES = ImportPathChoices(
    DescriptionClassStrategy, 
    example_function_description,
)

# Also may add to choice 
@IMPORT_CHOICES.register("Example description")
def example_function():
    return 1


class ExampleModel(models.Model):
    example_class = ImportPathField()
    example_class_choices = ImportPathField(choices=IMPORT_CHOICES)
    example_class_null = ImportPathField(null=True, blank=True)
</code></pre>
<h1>Contributing</h1>
<h2>run example app</h2>
<pre lang="bash"><code>pip install -r requirements-dev.txt
./test/manage.py migrate
./test/manage.py runserver

run tests

pip install -r requirements-dev.txt
pytest
tox

Update version

python setup.py bumpversion

publish pypi

python setup.py publish

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-import-path-field-0.0.2.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

django_import_path_field-0.0.2-py2.py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page