No project description provided
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-import-path-field-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e923c467407ddc20e6e591cfd9b1aaf996f3b30f0cf1fb9c904792f6f359279 |
|
MD5 | 9f197e73086ad4775bf4af4248712d7a |
|
BLAKE2b-256 | eded0b2e5da3dcf029df2686fcd63f46c3ef76747cf8f7a4234885537efc4976 |
Close
Hashes for django_import_path_field-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ff2a529ea8a0a4592168ae83f0d7c2f1d4dd144c930bf2def1eaac1a877b332 |
|
MD5 | f5725bb77724f06c84ce1a9720903b39 |
|
BLAKE2b-256 | c13b2b0790d23eceeb41f196e110c0b86b60baf30fbb42bfab94b701f83b9e97 |