DEV Community

Alex Spinov
Alex Spinov

Posted on

Django Has a Free Framework That Includes Auth, Admin, and ORM Out of the Box

Django is the most popular Python web framework, used by Instagram, Mozilla, Pinterest, and NASA. It follows the batteries-included philosophy.

What You Get for Free

  • Admin panel — auto-generated CRUD interface
  • ORM — database-agnostic models with migrations
  • Authentication — users, groups, permissions built-in
  • Forms — validation, CSRF protection, rendering
  • Templating — Jinja-like template engine
  • Security — XSS, CSRF, SQL injection protection by default
  • REST framework — DRF for building APIs

Quick Start

pip install django
django-admin startproject mysite
cd mysite
python manage.py runserver
Enter fullscreen mode Exit fullscreen mode

Define a Model

from django.db import models

class Article(models.Model):
    title = models.CharField(max_length=200)
    body = models.TextField()
    published = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title
Enter fullscreen mode Exit fullscreen mode

Create API with DRF

from rest_framework import serializers, viewsets

class ArticleSerializer(serializers.ModelSerializer):
    class Meta:
        model = Article
        fields = '__all__'

class ArticleViewSet(viewsets.ModelViewSet):
    queryset = Article.objects.all()
    serializer_class = ArticleSerializer
Enter fullscreen mode Exit fullscreen mode

Why Django?

  • Fastest time-to-production for Python web apps
  • 20+ years of battle-tested security
  • Massive ecosystem of packages

Need Python web development? Check my work on GitHub or email spinov001@gmail.com for consulting.

Top comments (0)