ποΈ Django Class-Based App Template A modular Django project using class-based views (CBVs) and reusable components. This template is ideal for building scalable, maintainable Django applications using object-oriented patterns.
π¦ Project Overview This project uses Djangoβs class-based architecture to create clean, organized apps that are easy to extend and reuse.
β Key Features β Built using Django CBVs (ListView, DetailView, CreateView, UpdateView, DeleteView)
π Modular App Structure
π User Authentication via LoginRequiredMixin
π§± Reusable Mixin and Abstract Models
π Admin Panel Integration
π§ͺ Unit Tests with Djangoβs TestCase
π§ Project Structure bash Copy Edit django_class_app/ βββ core/ β βββ models.py β βββ views.py β βββ urls.py β βββ forms.py β βββ templates/core/ β βββ *.html βββ manage.py βββ db.sqlite3 βββ requirements.txt π Getting Started
- Clone the Repo bash Copy Edit git clone https://github.com/yourusername/django-class-based-app.git cd django-class-based-app
- Set up the Environment bash Copy Edit python -m venv env source env/bin/activate # On Windows: env\Scripts\activate pip install -r requirements.txt
- Run the Server bash Copy Edit python manage.py migrate python manage.py createsuperuser python manage.py runserver π§ Example: Class-Based Views python Copy Edit from django.views.generic import ListView from .models import Post
class PostListView(ListView): model = Post template_name = 'core/post_list.html' context_object_name = 'posts' π§© Reusable Components π¦ Mixins Example python Copy Edit from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import UpdateView
class SecureUpdateView(LoginRequiredMixin, UpdateView): login_url = '/login/' π§± Abstract Models Example python Copy Edit from django.db import models
class TimeStampedModel(models.Model): created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
β Testing bash Copy Edit python manage.py test π Requirements Python 3.8+
Django 4.x+
SQLite/PostgreSQL
π¬ Contact GitHub: https://github.com/teambits009
Email: brandonopere6@gmail.com/brandon@techopssapex.com
π License MIT License β see LICENSE