This app provides a CLI through the manage.py
script to create models from the command line.
Install the package into the virtualenv:
pip install django-interactive-models
Then, add the app to the INSTALLED_APPS in settings:
INSTALLED_APPS = [
...
"interactive_models",
...
]
Then, you can finally run the models
command like:
./manage.py models <app_name> <model_name> <field_name>:<field_type> ...
Check the usage by using the -h
flag.
For example, this command:
./manage.py models my_app MyModel number:int text:text page_url:url creation_date:datetime
Will create a models.py
file inside my_app with the fields
number, text, page_url, creation_date
with their corresponding django database fields.
This is the current list of accepted types and their mappings
- auto -> AutoField,
- bool -> BooleanField,
- char -> CharField,
- date -> DateField,
- datetime -> DateTimeField,
- email -> EmailField,
- float -> FloatField,
- int -> IntegerField,
- slug -> SlugField,
- text -> TextField,
- time -> TimeField,
- url -> URLField,
- uuid -> UUIDField,
Install test dependencies with
pip install ".[test]"
Then, run tests using pytest with:
pytest -v