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><code class="language-bash">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

Release history Release notifications

This version

0.0.2

Download files

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

Files for django-import-path-field, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size django_import_path_field-0.0.2-py2.py3-none-any.whl (7.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size django-import-path-field-0.0.2.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page