Skip to main content

FastAPI sizzles, Django dazzles. The best of both worlds in one framework.

Project description

PyPI Version Python Versions License Downloads

Cotlette 🚀

Cotlette is a modern web framework built on top of FastAPI , offering convenient tools for rapid web application development. Inspired by Django, it includes its own ORM, template rendering support, and built-in commands for project management, as well as an admin panel.

Quick Start

Create a new project and launch the development server in just a few steps:

Create a new project:

pip install cotlette

cotlette startproject myproject
cd myproject

Start the development server:

cotlette runserver

Open your browser and navigate to http://127.0.0.1:8000.

/

Login page:

/accounts/login

Admin page:

/admin


Prerequisites

  • Python 3.6 or higher
  • pip (for installing dependencies)

Key Features

  • FastAPI Under the Hood : Leverage the full power of FastAPI to create high-performance APIs.
  • Custom ORM : A user-friendly interface for working with databases, similar to Django's ORM.
  • Template Rendering : Built-in support for rendering HTML pages.
  • Development Commands
  • Minimalist Design : A simple and intuitive project structure that is easy to extend.
  • Asynchronous Support : Full support for asynchronous operations to maximize performance.

Commands

Cotlette provides a set of commands for convenient project management:

  • cotlette startproject <project_name> : Creates a new project structure.
  • cotlette startapp <app_name> : Creates a new application within the project.
  • cotlette runserver : Starts the development server.
  • cotlette makemigrations : Creates new migration files based on changes detected in the models.
  • cotlette migrate : Applies migrations to the database, making necessary changes to the database schema.

Usage Examples

Creating a Model

from cotlette.db import Model, fields

class Article(Model):
    title = fields.CharField(max_length=200)
    content = fields.TextField()
    published_at = fields.DateTimeField(auto_now_add=True)

Creating a View

from fastapi import APIRouter
from cotlette.shortcuts import render_template

from .models import Article


router = APIRouter()

@router.get("/")
async def home():
    articles = await Article.objects.all()
    return render_template("index.html", {"articles": articles})

Working with the ORM

# Creating a record
article = await Article.objects.create(title="Hello World", content="This is a test article.")

# Fetching all records
articles = await Article.objects.all()

# Filtering records
published_articles = await Article.objects.filter(published_at__isnull=False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cotlette-0.0.28.tar.gz (36.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cotlette-0.0.28-py3-none-any.whl (36.7 MB view details)

Uploaded Python 3

File details

Details for the file cotlette-0.0.28.tar.gz.

File metadata

  • Download URL: cotlette-0.0.28.tar.gz
  • Upload date:
  • Size: 36.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for cotlette-0.0.28.tar.gz
Algorithm Hash digest
SHA256 ac98e83f2eb1a391e5755995a438c128966ca2b22c68106fccf8dfa4af08de1d
MD5 9d55de72112343f205dd41710993916c
BLAKE2b-256 47452dc0e371a93b906ff92994542f51121bc8d606a213430867cb7de1b196b7

See more details on using hashes here.

File details

Details for the file cotlette-0.0.28-py3-none-any.whl.

File metadata

  • Download URL: cotlette-0.0.28-py3-none-any.whl
  • Upload date:
  • Size: 36.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for cotlette-0.0.28-py3-none-any.whl
Algorithm Hash digest
SHA256 489d8b36bbcc0b5ef91dca340ea60cb55cbcbc8cf571c46d056bd1f6dd464ff7
MD5 051a7f2483164170dc81f0dd6ad9927e
BLAKE2b-256 3cddb7f9a5fd3d2c46677f50f914458a13fb4e3f4f7a36d7e01048bd6c8bae16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page