GitXplorerGitXplorer
j

django-fett

public
9 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
c6d5ac4eadde13bce948bbc4488d281ceb16a390

:pencil: small readme change

jjefftriplett committed 2 years ago
Verified
b6dc36a9b52a929719bdd66cbcd860aad645edae

:tractor: Too many refactors to count

jjefftriplett committed 2 years ago
Verified
ed3b371c2179091e0b13a340d62bb1d548bb975f

:tractor: Switch out urllib with requests

jjefftriplett committed 2 years ago
Verified
0942eee0a6da9d0b5df7036248fa0697d02006c2

:grear: Adds requests-mock

jjefftriplett committed 2 years ago
Verified
2e6927672e5f230ed5943481996ea646dfd3b314

:shirt: Lints

jjefftriplett committed 2 years ago
Verified
f5d9df903714c373745ea57a26b14f39087b7f3c

:gear: Updates workflows

jjefftriplett committed 2 years ago

README

The README file for this repository.

Django Fett

Django Fett is an incomplete code generator used on several projects. This is an attempt to clean it up and make it public for consumption.

Django Fett is different because it leverages Frontmatter Metadata and exposes the extra metadata into the template context. Frontmatter Metadata may also contain variables that make setting an output filename cleaner than trying to save file or folder names with Jinja syntax.

TODO: Quick start

Templates

A Fett template is a header of a markdown-like frontmatter and a body of an Jinja2 templating engine.

---                               <---- frontmatter section
to: app/{{ __model__.meta_model_name }}.py
---

from django.contrib import admin  <---- body, Jinja

class {{ __model__.name }}Admin(admin.ModelAdmin):
    pass

Predefined Variables

Variable Content Example
__app__
__metadata__
__model__

Example Usage

Example Template (./_templates/list_models.html)

---
to: output/{{ __model__.meta_model_name }}.py
---

# App: {{ __app__.name }}

## Fields
{% for field in __model__.get_fields() %}
- {{ field }}{% endfor %}

## Metadata
{{ __metadata__ }}

This example assumes we have a model in app/models.py which contains a model named Backup.

fett --stdout --path=./_templates/list_models.html.t app

This will create a file for every model in our models.py file. For our Backup model, the file will be rendered and saved as output/backup.py.

# App: app

## Fields

- app.Backup.id
- app.Backup.server
- app.Backup.backup_configuration
- app.Backup.status
- app.Backup.restore_status
- app.Backup.archive_path
- app.Backup.size
- app.Backup.uuid
- app.Backup.duration
- app.Backup.last_backup_time

## Metadata
{'filename': 'output/backup.py'}

TODO: Tests...