Usage / Overview

This page outlines the optimal workflow for the initial setup of a project using the Falco CLI. This includes creating a new project, initializing a Django application, adding a model, and generating CRUD views for the model. This workflow represents the expected experience for a new Falco CLI user. If you encounter any issues reproducing this workflow, please create a new issue.

Let’s create a new project called myjourney. This will be a journaling app and its main app will be entries. Each entry represents a journal entry within the myjourney app.

1. Generate a new project and cd (change directory) into it

falco start-project myjourney && cd myjourney

2. Create a new virtual environment for the project and install dependencies

hatch shell

3. Initialize git and install pre-commit hooks (Optional)

git init && pre-commit install

If necessary, adjust the python_version value in the .pre-commit-config.yaml file.

4. Migrate the database

hatch run migrate

5. Create the new app, entries

falco start-app entries

6. Add some fields to your Entry model

class Entry(TimeStampedModel):
    # the TimeStampedModel adds the fields `created` and `modified` so we don't need to add them
    title = models.CharField(max_length=255)
    content = models.TextField()
    created_by = models.ForeignKey("users.User", on_delete=models.CASCADE, related_name="entries")

7. Make migrations for the new model and run them

hatch run makemigrations && hatch run migrate

8. Generate CRUD views for the Entry model

falco crud entries.entry --entry-point --skip-git-check

9. Run the project

falco work

Now, check out http://127.0.0.1:8000/entries to see your running app.

This process currently requires 9 commands. Considering the outcome, it’s not too shabby! However, I’m confident there’s still plenty of room for improvement. If you have any suggestions on how to improve this workflow, feel free to open a discussion at https://github.com/Tobi-De/falco/discussions.

Todo

Add screenshots (or gif) or a walkthrough of the process and the resulting running app here.