A CLI tool for rapidly building applications with FlaskMVC Starter Kit
- Create a project using FlaskMVC Starter Kit and install the dependencies (this installs Crafter as well)
- the format of running commands with crafter is as follows:
crafter <command> <args>
Create a model with a name of post
crafter model --name post
- generates
post.py
inapp/models
Create a controller with a name of post
crafter controller --name post
- generates
post_controller.py
inapp/controllers
- generates a model if no model with given name is found
Create a route with a name of post
crafter route --name post
- generates
post_route.py
inapp/routes
- generates a controller if no controller with given name is found
- generates a model if no model with given name is found
Create a relationship between two models
- type: [
one_one
,one_many
,many_one
,many_many
] - models:
model_1
,model_2
crafter relationship --type one_one --models student contact
- generates either models if no model with given names are found
- creates a one-to-one relationship between
student
andcontact
crafter relationship --type one_many --models knight sword
- creates a one-to-many relationship between
knight
andsword
(oneknight
has manyswords
) - if we swap the positions (
--models sword knight
) the relationship would be onesword
has manyknights
, which may or may not be intended
many_one
works the same way as one_many
, just take note of the positions of the arguments
To create a many-to-many relationship, an additional argument is needed, the association
crafter relationship --type many_many --models wizard spell
Enter the association table between wizard and spell: spellbook
- A bridging table named
spellbook
is created - if no input is given, default table name is
{model_1}_{model_2}
(in this case,wizard_spell
)