Just married!!!
Django and Flutter.
Rapid developing db based app. Zero boilerplate code.
I hate boilerplate code. I hated it all my life. I made so many steps to remove this mental parasites far from me. And now, with Flet and Django I'm so close to get my ideal. For this moment I made as PoC a clone of a standard Flet ToDo application. All what I change is write all directly inside Django. Flet code is run directly on the backend, so we not need any dedicated communication layer. Next what I'm done is generic data table control. This is a simple control able to create a data table for any Django model. All with searching and sorting.
Roadmap:
- Create package for a framework
- Create environment for generic Flutter app
- GenericApp class for a new Flutter application
- GenericClient class for a new Flutter application instance
- GenericView class to easily create routed Flutter views
- Generic middleware class for flexible management of Flutter view routing process
- UrlsMiddleware class for implementing Django urls based routing
- Generic navigation mechanism
- Create authorisation and permissions middleware
- AuthApp for apps with authorization
- AuthMiddleware for authorisation management
- Create generic list view for any Django model
- Generic model's, data table based, control
- Generic form based on Django forms
- Create generic form for any Django model
- Manage relations between models
- Documentation!!!
Instalation
-
Install python package:
$ pip install flet-django -
Add 'flet_django' to INSTALLED_APPS in settings.py:
INSTALLED_APPS += ['flet_django']
Run and usage
- Let create a Django project:
pip install Django django-admin startproject test_flet_django cd test_flet_django python manage.py migrate
- Install flet and flet-django packages:
pip install flet pip install flet-django
- Add 'flet_django' to INSTALLED_APPS in settings.py:
echo "INSTALLED_APPS += ['flet_django']" >> test_flet_django/settings.py
- Create the main function in the file main_app.py at the root of your Django project:
import flet as ft from flet_django.pages import GenericApp main = GenericApp(controls=[ft.Text("Hello World!")])
- Run function main from file main_app.py using the Django command:
python manage.py run_app
- Enjoy your desktop/mobile/web flutter app.
View Factory Class
- A framework based on view factories. View Factory is a callable object which takes page as a first argument, and returns instance of ft.View class.
- For simplicity, we can use view factory method of page:
page.get_view - Let create a simple flutter view example in file main_app.py:
import flet as ft from flet_django.views import ft_view def home(page): return page.get_view( page, controls=[ft.Text("Hello World!")], app_bar_params=dict(title="ToDo app") )
- Flutter view can be assigned to route by Generic App's urls parameter, or as a target for navigation:
import flet as ft from django.urls import path from flet_django.pages import GenericApp from flet_django.navigation import Destiny def home(page): return page.get_view( page, controls=[ft.Text("Hello World!")], app_bar_params=dict(title="ToDo app") ) destinations = [ Destiny( route="/", icon=ft.icons.HOME, selected_icon=ft.icons.HOME_OUTLINED, label="home", nav_bar=True, action=True, nav_rail=False ), ] urlpatterns = [ path('', home, name="home") ] main = GenericApp( destinations=destinations, urls=urlpatterns, init_route="/" )
- To run application on other devices you need establish server and build client, based on Flutter frontend project from repository
- To run app as server use --view parameter:
python manage.py run_app --view flet_app_hidden
- Server will be avaible as http server, for example:
open http://ala.hipisi.org.pl:8085
- Compile ./frontend futter app to have separate ready to install application:
cd frontend flutter run --dart-entrypoint-args http://94.23.247.130:8085
- You can use simple script to run separate flutter application:
python run.py
Demo
You can run repository's project as example of usage. Working demo is here.
Screenshots
Metadata
Release files for flet-django 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flet_django-0.4.5.tar.gz | 13.8 kB | Without provenance | Details for flet_django-0.4.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flet_django-0.4.5-py3-none-any.whl | Python 3 | none | any | Details for flet_django-0.4.5-py3-none-any.whl |
Total release size: 29.8 kB
Release files / flet_django-0.4.5.tar.gz
| Download URL | flet_django-0.4.5.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
770bb378a5154a1d6f85f0fea844ae5be23dfdf2ef36b6561174717988b5fab0
|
|
BLAKE2b-256 checksum How to use checksums |
f725ea8d00d4509b0c954c9f3901f7cb060b704878109f1647657d872bd74894
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.11.3 Darwin/22.5.0
|
Release files / flet_django-0.4.5-py3-none-any.whl
| Download URL | flet_django-0.4.5-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0b9ecc7a3e13e3142137fb7005a13aeb947f448d5defd47456f269acc833cf6
|
|
BLAKE2b-256 checksum How to use checksums |
09a2d38ea74841d367875777810143fcd2291920328c746063637205847a97b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.11.3 Darwin/22.5.0
|
Security for flet-django 0.4.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.