A fastweb framework inspired by Django using FastAPI as core
Project description
FastJango
FastJango is a fast web framework inspired by Django built on FastAPI. It provides a familiar Django-like experience with the performance and modern features of FastAPI. FastJango prefers convention over configuration and simplifies development of API First Web Services.
Features
- Django-like project structure
- FastAPI's high performance
- Type annotations and automatic validation
- Dependency injection
- Automatic API documentation with Swagger and ReDoc
- Familiar Django-like URL patterns
- FastAPI-powered REST API with automatic OpenAPI docs
- Integrated authentication system
- Django-like template system with Jinja2
- ORM support via SQLAlchemy (planned)
pip install typer rich fastapi uvicorn jinja2 python-multipart pydantic
Installation
pip install fastjango
For development:
git clone https://github.com/yourusername/fastjango.git
cd fastjango
pip install -e ".[dev]"
Quick Start
Create a new project
fastjango-admin startproject myproject
cd myproject
Create a new app
fastjango-admin startapp myapp
Don't forget to add your app to INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
# FastJango apps
"myproject.core",
# Your apps
"myapp",
]
Define models in myapp/models.py
from fastjango.db import models
from fastjango.core.exceptions import ValidationError
class Item(models.Model):
name = models.CharField(max_length=100)
description = models.TextField(blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ["-created_at"]
def __str__(self):
return self.name
Define routes in myapp/routes.py
from fastapi import APIRouter, HTTPException, Depends, status
from typing import List
from fastjango.core.dependencies import get_current_user
from .schemas import ItemCreate, ItemRead, ItemUpdate
from .services import ItemService
router = APIRouter(prefix="/items", tags=["items"])
service = ItemService()
@router.get("/", response_model=List[ItemRead])
async def list_items(skip: int = 0, limit: int = 100):
return await service.get_all(skip=skip, limit=limit)
@router.post("/", response_model=ItemRead, status_code=status.HTTP_201_CREATED)
async def create_item(item: ItemCreate, current_user = Depends(get_current_user)):
return await service.create(item)
Run the development server
fastjango-admin runserver
Or using the manage.py script:
python manage.py runserver
Visit http://127.0.0.1:8000/docs to see the automatic API documentation.
Project Structure
When you create a new project, FastJango will generate the following structure:
myproject/
├── myproject/
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── templates/
└── manage.py
When you create a new app, FastJango will generate:
myapp/
├── __init__.py
├── models.py
├── routes.py
├── schemas.py
├── services.py
└── tests/
├── __init__.py
├── test_models.py
└── test_routes.py
Built With
- FastAPI - Web framework
- Pydantic - Data validation
- Typer - CLI commands
- SQLAlchemy - ORM (planned)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Make sure to reinstall after changes
pip install -e .
Then start your project
./fastjango-admin.py startproject myproject cd myproject ./fastjango-admin.py runserver
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastjango-0.1.1.tar.gz.
File metadata
- Download URL: fastjango-0.1.1.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9897163ad8b3ce71e6f9bb0d5d843c58749e4bf4c1c96558db841f97e4e3f281
|
|
| MD5 |
8d740b772f59fe49f3799b20cb356649
|
|
| BLAKE2b-256 |
e19f9349686ebd2b79002086a2d0d875122b4bf5b1d8bfecb033ee903685e5b0
|
File details
Details for the file fastjango-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastjango-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c30e86954f4f631b0da466fc02e73e1eb6b6c0d3fcc61dba630350e54dcf12a7
|
|
| MD5 |
1e7dcfa6431a0d8890b4141cfe3f0c0c
|
|
| BLAKE2b-256 |
1a52e500197aae0afba6505a3ab7ee637d9b31ab673d04f98eee8547ded6795e
|