### Socket.IO Server Instance in Django Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Example of creating a Socket.IO server instance within a Django project for real-time communication. ```Python from socketio import Server sio = Server() # Example usage within a Django view or ASGI application ``` -------------------------------- ### Django Logging Libraries Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Libraries for enhancing logging in Django applications, such as injecting a GUID for correlation IDs in log messages and logging DRF API requests. ```Python django-guid DRF-API-Logger ``` -------------------------------- ### Django REST Framework Resources Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Provides links to the official documentation, source code repository, and a curated list of resources for Django REST Framework, a popular tool for building web APIs with Django. ```N/A Official Documentation: https://www.django-rest-framework.org/ DRF Source Code: https://github.com/encode/django-rest-framework awesome-django-rest-framework: https://github.com/nioperas06/awesome-django-rest-framework ``` -------------------------------- ### Django Configuration Management Libraries Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This snippet covers various Django libraries designed to manage application configuration and environment variables. These tools help in organizing settings, handling secrets, and adhering to principles like the twelve-factor app. ```Python import environ # Example usage with django-environ env = environ.Env( DEBUG=(bool, False) ) # Load .env file # environ.Env.read_env() # Access settings # DEBUG = env('DEBUG') ``` ```Python # Example usage with django-configurations from configurations import Configuration class Dev(Configuration): DEBUG = True SECRET_KEY = 'your-secret-key' class Prod(Configuration): DEBUG = False SECRET_KEY = 'your-production-secret-key' ``` ```Python # Example usage with dynaconf from dynaconf import Dynaconf settings = Dynaconf( envvar_prefix="DYNACONF", settings_files=["settings.toml", ".secrets.toml"], ) # Access settings # DEBUG = settings.DEBUG ``` ```Python # Example usage with django-extra-settings # Define settings in Django admin or settings.py # EXTRA_SETTINGS = { # 'MY_SETTING': { # 'value': 123, # 'description': 'My custom setting', # 'type': 'integer', # } # } ``` ```Python # Example usage with environs from environs import Env env = Env() # Load environment variables from .env file # env.read_env() # Access variables # debug_mode = env.bool("DEBUG", default=False) ``` ```Python # Example usage with django-classy-settings from classy_settings import Settings class BaseSettings(Settings): pass class DevelopmentSettings(BaseSettings): DEBUG = True SECRET_KEY = 'dev-key' class ProductionSettings(BaseSettings): DEBUG = False SECRET_KEY = 'prod-key' ``` ```Python # Example usage with django-content-settings # Define settings in Django admin or settings.py # CONTENT_SETTINGS = { # 'MY_VARIABLE': { # 'value': 'default', # 'description': 'A variable managed by content settings', # 'type': 'string', # } # } ``` -------------------------------- ### Django Dependency Injection Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This snippet covers dependency injection solutions for Django projects, focusing on the Wireup library. ```Python # Example: Using Wireup for Dependency Injection # Install Wireup: pip install wireup # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'wireup', # ... # ] # Example usage in a Django view or service: # from wireup import Wireup # from .services import MyService # wireup = Wireup() # my_service_instance = wireup.get(MyService) ``` -------------------------------- ### pyinstrument Profiler for Python/Django Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A call stack profiler for Python applications, including Django, Flask, and FastAPI. pyinstrument generates detailed reports on function call times and execution paths. ```Python from pyinstrument import Profiler # Example usage within a Django view: # def my_view(request): # profiler = Profiler() # profiler.start() # # ... your view logic ... # profiler.stop() # print(profiler.output_text(unicode=True, color=True)) # return HttpResponse(...) ``` -------------------------------- ### Easy Thumbnails for Django Image Resizing Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A Django application that provides easy-to-use image thumbnail generation. It allows resizing and cropping images with various options for customization. ```Python # Example usage in a Django template: # {% load thumbnail %} # {% thumbnail image "200x200" crop="center" as im %} # # {% endthumbnail %} ``` -------------------------------- ### Django URL Management Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Libraries for simplifying URL configuration and management in Django projects, including database-backed URLs and robots.txt handling. ```Python import dj_database_url # Example usage for dj-database-url # DATABASES = {'default': dj_database_url.config()} ``` ```Python from urlman.models import URL # Example usage for urlman # url = URL.create(slug='my-page', title='My Page') ``` ```Python from django_robots.middleware import RobotsTxtMiddleware # Example usage for django-robots (manage robots.txt) # Add 'django_robots.middleware.RobotsTxtMiddleware' to MIDDLEWARE ``` ```Python from django_redirects.models import Redirect # Example usage for django-redirects # Redirect.objects.create(from_url='/old-page/', to_url='/new-page/') ``` -------------------------------- ### Django Async Support Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This section highlights libraries that enable asynchronous operations within Django projects, primarily focusing on ASGI support. This is crucial for handling long-polling, WebSockets, and other I/O-bound tasks efficiently. ```Python pip install channels # Or pip install starlette ``` -------------------------------- ### Whitenoise for Static File Serving in Python Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Simplifies serving static files (like CSS, JavaScript, and images) for Python web applications, including Django. It's a production-ready solution that can serve files directly from your application. ```Python # Example configuration in settings.py: # MIDDLEWARE = [ # 'whitenoise.middleware.WhiteNoiseMiddleware', # ... # ] # STATIC_ROOT = BASE_DIR / 'staticfiles' # STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' ``` -------------------------------- ### Django E-Commerce Platforms Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This snippet lists popular Django-based e-commerce platforms and frameworks. These solutions provide comprehensive features for building online stores. ```Python # Example: Integrating Saleor (GraphQL-based) # Installation and setup typically involve Docker and specific commands. # Refer to Saleor's official documentation for detailed instructions. # Example command (conceptual): # docker-compose up ``` ```Python # Example: Integrating django-shop # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'django_shop', # 'shop_vouchers', # 'shop_categories', # 'shop_products', # ... # ] ``` ```Python # Example: Integrating Shuup # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'shuup', # 'shuup.core', # 'shuup.campaigns', # 'shuup.front', # ... # ] ``` ```Python # Example: Integrating django-oscar # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'oscar', # 'oscar.apps.basket', # 'oscar.apps.checkout', # 'oscar.apps.dashboard', # 'oscar.apps.order', # 'oscar.apps.payment', # 'oscar.apps.partner', # 'oscar.apps.product', # 'oscar.apps.promotions', # 'oscar.apps.shipping', # 'oscar.apps.shipping.methods', # 'oscar.apps.tax', # 'oscar.apps.voucher', # 'oscar.apps.wishlists', # ... # ] ``` -------------------------------- ### Template Linting and Formatting Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Tools for linting and formatting HTML templates used with Django, Jinja, and other templating engines. ```Shell pip install curlylint # or pip install djhtml # or pip install djlint ``` -------------------------------- ### General Django Utilities Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A collection of libraries for common Django tasks such as data browsing, filtering, SQL query sharing, table generation, maintenance mode, static site conversion, logging integration, documentation, and CRUD application development. ```Python django-data-browser django-filter django-sql-explorer django-tables2 django-maintenance-mode django-freeze django-nh3 Weblate Django-Classy-Doc iommi ``` -------------------------------- ### Django Views and Mixins Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Packages that provide reusable mixins and extra class-based views for Django projects. ```Python pip install django-braces # or pip install django-extra-views # or pip install django-vanilla-views # or pip install django-stronghold # or pip install neapolitan ``` -------------------------------- ### Django Storages for Custom Storage Backends Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A unified library that supports multiple custom storage backends for Django, such as Amazon S3, Google Cloud Storage, and others. It simplifies file storage management. ```Python # Example configuration in settings.py for AWS S3: # DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' # AWS_ACCESS_KEY_ID = 'YOUR_ACCESS_KEY' # AWS_SECRET_ACCESS_KEY = 'YOUR_SECRET_KEY' # AWS_STORAGE_BUCKET_NAME = 'your-bucket-name' ``` -------------------------------- ### Django Testing Utilities Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Tools and libraries to enhance the testing experience in Django projects, including debugging aids, test runners, migration testing, and test data generation. ```Python from django.test import TestCase # Example usage for pytest-django (using pytest features) # def test_my_view(client): # response = client.get('/') # assert response.status_code == 200 ``` ```Python from django_test_migrations.test_case import MigrationTestCase # Example usage for django-test-migrations # class MyMigrationTest(MigrationTestCase): # migrate_from = '0001_initial' # migrate_to = '0002_auto_...' ``` ```Python from django_test_plus.test import TestCase # Example usage for django-test-plus (additions to TestCase) # class MyModelTest(TestCase): # def test_create_model(self): # self.create_model('myapp.MyModel') ``` ```Python from factory import Factory, Sequence # Example usage for factory-boy (test fixtures) # class UserFactory(Factory): # class Meta: # model = User # username = Sequence(lambda n: f'user_{n}') ``` ```Python from model_bakery import baker # Example usage for model-bakery # user = baker.make('auth.User', username='testuser') ``` ```Python from django_fakery import UserFaker # Example usage for django-fakery # user = UserFaker().create() ``` ```Python from drf_openapi_tester.base import APITest # Example usage for drf-openapi-tester # class MyAPITests(APITest): # openapi_spec_file = 'openapi.yaml' # def test_user_list(self): # self.client.get('/api/users/') ``` ```Python from django_google_optimize.middleware import GoogleOptimizeMiddleware # Example usage for django-google-optimize (A/B testing) # Add 'django_google_optimize.middleware.GoogleOptimizeMiddleware' to MIDDLEWARE ``` ```Python from django.test import Client from django_pattern_library.views import PatternLibraryView # Example usage for django-pattern-library (UI component testing) # client = Client() # response = client.get('/pattern-library/') ``` ```JavaScript // Example usage for storybook-django (develop UI components in isolation) // import React from 'react'; // import { storiesOf } from '@storybook/react'; // storiesOf('Button', module).add('with text', () => ); ``` -------------------------------- ### Django Silk for Request and Query Profiling Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Provides live profiling and inspection of HTTP requests and database queries within your Django application. Silk offers a web-based UI for analysis. ```Python # Example in settings.py: # INSTALLED_APPS = [ # 'silk', # ... # ] # MIDDLEWARE = [ # 'silk.middleware.SilkMiddleware', # ... # ] ``` -------------------------------- ### Scout APM for Django Performance Monitoring Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A performance monitoring tool for Python applications, including Django. Scout APM tracks middleware, template rendering, and SQL queries, with automatic N+1 detection. ```Python # Requires Scout APM agent installation and configuration. # Example configuration in settings.py: # INSTALLED_APPS = [ # 'scout_apm.django', # ... # ] ``` -------------------------------- ### Django Full-Stack Framework Integrations Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Tools and libraries that bridge Django with frontend technologies like React, enabling dynamic rendering and component-based development within Django applications. ```Python Django-Bridge ReactPy (with ReactPy-Django) Reactor Sockpuppet Unicorn ``` -------------------------------- ### Django Template Components Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Libraries for creating reusable template components in Django, simplifying UI composition and reducing template code duplication. Some allow component creation without Python. ```Python from django_components import register # Example usage for django-components # @register.simple_component # def my_component(request): # return {'context_variable': 'value'} ``` ```HTML {% load component_tags %} {% component 'my_component' %} ``` ```Python from django_template_partials import register_partial # Example usage for django-template-partials # @register_partial # def my_partial(): # return {'data': 'some data'} ``` ```HTML {% load partials %} {% partial 'my_partial' %} ``` ```HTML ``` ```Python from htpy import Element # Example usage for htpy (HTML in Python) def my_html_component(): return Element('div', {'class': 'container'}, 'Hello, World!') ``` ```Python from django_suspense.components import Suspense # Example usage for django-suspense # {% load suspense %} # {% suspense suspense_id='my-suspense' %} # {% include 'my_component.html' %} # {% end_suspense %} ``` -------------------------------- ### Django Monitoring Libraries Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Libraries for monitoring Django applications, including exporting metrics to Prometheus and providing monitoring mixins with Grafana dashboards and Prometheus rules. ```Python django-prometheus django-mixin ``` -------------------------------- ### Django MPTT for Tree Structures Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Implements the Modified Preorder Tree Traversal algorithm for Django models, enabling efficient management and querying of hierarchical data (tree structures). ```Python from mptt.models import MPTTModel, TreeForeignKey # Example usage in a Django model: # class Category(MPTTModel): # name = models.CharField(max_length=50) # parent = TreeForeignKey('self', null=True, blank=True, related_name='children') # class MPTTMeta: # order_insertion_by = ['name'] ``` -------------------------------- ### Django Management Commands Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This category includes libraries that extend Django's management command system, offering custom commands for tasks like database backups, enhanced server management, and CLI tool integration. These simplify development and deployment workflows. ```Python pip install django-extensions # Or pip install django-click # Or pip install django-dbbackup # Or pip install django-liquidb # Or pip install django-migration-zero # Or pip install django-typer ``` -------------------------------- ### Python Packages for Django Development Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A collection of essential Python packages for common development tasks in Django projects, including formatting, testing, data generation, and more. ```Python pip install bleach # or pip install black # or pip install coverage # or pip install faker # or pip install huey # or pip install nplusone # or pip install Pillow # or pip install pytest # or pip install python-decouple # or pip install python-slugify # or pip install sentry-sdk # or pip install python-socketio # or pip install ruff ``` -------------------------------- ### Django Task Queues Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Libraries for managing periodic and distributed task queues in Django projects. These often integrate with message brokers like Redis or RabbitMQ and provide tools for monitoring and administration. ```Python from beatserver import BeatServer # Example usage for beatserver (periodic task scheduler) # beatserver.schedule_task('my_task', '*/5 * * * *') ``` ```Python from django_q2.tasks import async_task # Example usage for django-q2 (multiprocessing distributed task queue) # async_task('my_function', arg1, arg2) ``` ```Python from django_rq import enqueue # Example usage for django-rq (Redis Queue integration) # enqueue(my_function, arg1, arg2) ``` ```Python from celery import Celery # Example usage for Celery (robust task queues) # app = Celery('tasks', broker='redis://localhost:6379/0') # @app.task # def add(x, y): # return x + y ``` ```Python from django_celery_beat.models import PeriodicTask # Example usage for django-celery-beat (database configured scheduler) # PeriodicTask.objects.create(name='My periodic task', task='my_app.tasks.my_task', crontab='*/5 * * * *') ``` ```Python from django_dramatiq import get_broker # Example usage for django-dramatiq (task processing library) # broker = get_broker() # @broker.task # def my_task(arg1): # pass ``` ```Python from django_celery_results.models import TaskResult # Example usage for django-celery-results (Celery result backend) # result = TaskResult.objects.get(task_id='...') ``` ```Python from django_tasks.tasks import background # Example usage for django-tasks (background workers) # @background() # def my_background_task(arg1): # pass ``` -------------------------------- ### Django Database Connectors Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This snippet focuses on database connectors for Django, specifically highlighting the integration with MongoDB. ```Python # Example: Using djongo for MongoDB # In your Django project's settings.py: # DATABASES = { # 'default': { # 'ENGINE': 'djongo', # 'NAME': 'my_database', # 'CLIENT': { # 'host': 'localhost', # 'port': 27017, # } # } # } ``` -------------------------------- ### Django Files and Images Processing Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This snippet covers Django libraries for managing file uploads, image processing, and cleanup, including thumbnail generation and responsive image handling. ```Python # Example: Using django-cleanup # Install django-cleanup: pip install django-cleanup # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'django_cleanup.apps.CleanupConfig', # ... # ] # When a model with a FileField or ImageField is deleted, # django-cleanup automatically deletes the associated file. ``` ```Python # Example: Using django-imagekit # Install django-imagekit: pip install django-imagekit # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'imagekit', # ... # ] # In your models.py: # from django.db import models # from imagekit.models import ProcessedImageField # from imagekit.processors import ResizeToFill # class MyImageModel(models.Model): # image = ProcessedImageField( # upload_to='images/', # processors=[ResizeToFill(200, 150)], # format='JPEG', # options={'quality': 85} # ) ``` ```Python # Example: Using django-pictures # Install django-pictures: pip install django-pictures # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'pictures', # ... # ] # In your models.py: # from django.db import models # from pictures.models import PictureField # class Product(models.Model): # picture = PictureField() ``` ```Python # Example: Using sorl-thumbnail # Install sorl-thumbnail: pip install sorl-thumbnail # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'sorl.thumbnail', # ... # ] # In your templates: # {% load thumbnail %} # {% thumbnail item.image "200x200" crop="" as im %} # {{ item.image.name }} # {% endthumbnail %} ``` -------------------------------- ### New Relic for Django Performance Monitoring Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Integrates with New Relic to provide insights into your Django application's performance. It monitors middleware, views, and SQL queries to help diagnose issues. ```Python # Requires New Relic agent installation and configuration. # Example configuration in newrelic.ini: # [python] # # [application:YourAppName] # = newrelic.ini ``` -------------------------------- ### Django Rules for Object-Level Permissions Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A lightweight yet powerful application for implementing object-level permissions in Django. It provides a clean API for defining and checking permissions based on rules. ```Python from rules import predicate, add_rule from myapp.models import Article # Define a predicate function @predicate def is_author(user, article): return article.author == user # Add a rule # add_rule('can_edit_article', is_author) # Checking a permission: # from rules.contrib.views import objectlevel_required # @objectlevel_required('can_edit_article') # def edit_article(request, article_id): # # ... view logic ... ``` -------------------------------- ### Django Editors and Markdown Plugins Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This snippet showcases various Django libraries for integrating rich text editors, Markdown support, and business logic frameworks. ```Python # Example: Using django-markdownx # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'markdownx', # ... # ] # In your models.py: # from django.db import models # from markdownx.models import MarkdownxField # class MyModel(models.Model): # content = MarkdownxField() ``` ```Python # Example: Using django-markdown-editor # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'markdown_editor', # ... # ] # In your models.py: # from django.db import models # from markdown_editor.fields import MarkdownEditorField # class Post(models.Model): # body = MarkdownEditorField() ``` ```Python # Example: Using django-business-logic # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'business_logic', # ... # ] # Example usage: # from business_logic.models import BusinessLogic # rule = BusinessLogic.objects.create(name='MyRule', description='A sample rule') ``` ```Python # Example: Using django-summernote # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'django_summernote', # ... # ] # In your models.py: # from django.db import models # from django_summernote.fields import SummernoteTextField # class Article(models.Model): # content = SummernoteTextField() ``` ```Python # Example: Using django-tinymce # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'tinymce', # ... # ] # In your models.py: # from django.db import models # from tinymce.models import HTMLField # class Page(models.Model): # body = HTMLField() ``` ```Python # Example: Using django-prose # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'prose', # ... # ] # In your models.py: # from django.db import models # from prose.fields import ProseField # class Document(models.Model): # content = ProseField() ``` ```Python # Example: Using django-ace # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'ace', # ... # ] # In your models.py: # from django.db import models # from ace.fields import AceField # class CodeSnippet(models.Model): # code = AceField(mode='python', theme='github', height='200px') ``` -------------------------------- ### Django Model Lifecycle Hooks Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Provides a declarative way to define model lifecycle hooks (e.g., pre-save, post-save) as an alternative to Django's built-in signals. This promotes cleaner code organization. ```Python from django_lifecycle import LifecycleModel, hook # Example usage in a Django model: # class Article(LifecycleModel): # title = models.CharField(max_length=200) # @hook('before_save') # def clean_title(self): # self.title = self.title.strip() ``` -------------------------------- ### Django Watson for Full-Text Search Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A full-text search plugin for Django that enhances search capabilities by indexing model content and providing a simple interface for searching across multiple fields. ```Python from watson.search import search # Example search: # results = search(query='python', models=['myapp.models.Book', 'myapp.models.Article']) ``` -------------------------------- ### Django Elasticsearch DSL Integration Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Provides integration for Elasticsearch DSL (Domain Specific Language) within Django projects. It simplifies the process of defining Elasticsearch mappings and executing complex queries. ```Python from django_elasticsearch_dsl import Document, fields from django_elasticsearch_dsl.registries import registry from myapp.models import Article @registry.register_document class ArticleDocument(Document): id = fields.IntegerField(attr='pk') title = fields.TextField() content = fields.TextField() class Index: name = 'articles' settings = {'number_of_shards': 1, 'number_of_replicas': 0} ``` -------------------------------- ### Django User Registration and Authentication Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Libraries for enhancing user registration, including social authentication and custom user models. ```Python pip install django-allauth # or pip install django-improved-user # or pip install django-organizations # or pip install django-cas-ng # or pip install django-guest-user ``` -------------------------------- ### py-spy Sampling Profiler for Python Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A sampling profiler for Python programs, including those running Django. py-spy can attach to running processes without modification and provides insights into CPU usage. ```Shell # Example usage from the command line: # py-spy top --pid # py-spy record -o profile.svg --pid ``` -------------------------------- ### Django Content Management Systems (CMS) Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This snippet lists popular Django-based Content Management Systems (CMS) and related tools. These frameworks provide robust solutions for managing website content. ```Python # Example: Integrating Wagtail CMS # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'wagtail.contrib.modeladmin', # 'wagtail.core', # 'wagtail.admin', # 'wagtail.documents', # 'wagtail.snippets', # 'wagtail.users', # 'wagtail.images', # 'wagtail.search', # 'wagtail.embeds', # 'wagtail.contrib.routablepage', # 'wagtail.contrib.redirects', # 'wagtail.contrib.forms', # 'wagtail.contrib.sitemaps', # 'wagtail.sites', # ... # ] ``` ```Python # Example: Using django-cms # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'cms', # 'menus', # 'sekizai', # 'treebeard', # 'djangocms_admin', # 'djangocms_text_ckeditor', # 'djangocms_picture', # 'djangocms_file', # 'djangocms_link', # ... # ] ``` ```Python # Example: Using feincms # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'feincms', # 'feincms.module.page', # 'feincms.module.medialibrary', # ... # ] ``` ```Python # Example: Using puput with Wagtail # In your Django project's settings.py: # INSTALLED_APPS = [ # ... # 'puput', # 'wagtail.contrib.modeladmin', # 'wagtail.core', # 'wagtail.admin', # 'wagtail.documents', # 'wagtail.snippets', # 'wagtail.users', # 'wagtail.images', # 'wagtail.search', # 'wagtail.embeds', # 'wagtail.contrib.routablepage', # 'wagtail.contrib.redirects', # 'wagtail.contrib.forms', # 'wagtail.contrib.sitemaps', # 'wagtail.sites', # ... # ] ``` -------------------------------- ### Django Reversion for Model Version Control Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Enables version control for Django model instances, allowing tracking of changes and the ability to revert to previous states. It integrates seamlessly with the Django admin. ```Python from reversion.models import Versioned # Example usage in a Django model: # class Article(Versioned): # title = models.CharField(max_length=200) # content = models.TextField() ``` -------------------------------- ### Django Zeal for N+1 Query Detection Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Detects N+1 queries in Django applications and provides user-friendly error messages to help developers identify and fix performance issues related to inefficient database querying. ```Python # Typically involves adding middleware to your Django project. # Example in settings.py: # MIDDLEWARE = [ # 'zeal.middleware.NPlusOneMiddleware', # ... # ] ``` -------------------------------- ### Django Mailing Libraries Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Libraries for managing emails in Django projects, offering class-based email structures with test suites and versatile email backends supporting various third-party services. ```Python django-pony-express django-anymail ``` -------------------------------- ### Django APIs Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This category covers libraries for building Web APIs with Django, including tools for RESTful services, authentication, GraphQL, and API schema generation. These are essential for integrating Django applications with front-end clients or other services. ```Python pip install django-rest-framework # Or pip install django-cors-headers # Or pip install dj-rest-auth # Or pip install django-rest-knox # Or pip install djoser # Or pip install djaq # Or pip install django-rest-framework-simplejwt # Or pip install django-webpack-loader # Or pip install drf-yasg # Or pip install graphene-django # Or pip install graphene-django-filter # Or pip install django-ninja # Or pip install django-tastypie # Or pip install drf-spectacular # Or pip install django-webhook ``` -------------------------------- ### Django Role Permissions Management Source: https://github.com/wsvincent/awesome-django/blob/main/README.md An application for managing role-based permissions in Django. It allows defining roles and assigning permissions to these roles, simplifying access control. ```Python # Example usage in models.py: # from django.contrib.auth.models import User, Group # from rolepermissions.roles import Role # class MyUserRole(Role): # available_permissions = { # 'can_edit_profile': 1, # 'can_view_dashboard': 2, # } # # Assigning roles to users would involve user management logic. ``` -------------------------------- ### Django Audit and Logging Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Tools for tracking user actions and managing audits within Django applications. ```Python pip install django-easy-audit ``` -------------------------------- ### Django Haystack for Modular Search Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A modular search engine framework for Django that abstracts away the complexities of different search backends like Solr, Elasticsearch, and Whoosh. It provides a unified API for indexing and searching. ```Python from haystack.query import SearchQuerySet # Example search query: # results = SearchQuerySet().filter(content='django') ``` -------------------------------- ### Django Performance Recorder Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Keeps detailed records of the performance of your Django code, including request times, database queries, and template rendering. Useful for identifying performance bottlenecks. ```Python # This library typically involves middleware and configuration. # Example configuration in settings.py: # MIDDLEWARE = [ # 'django_perf_rec.middleware.PerformanceRecorderMiddleware', # ... # ] ``` -------------------------------- ### Django Admin Themes Source: https://github.com/wsvincent/awesome-django/blob/main/README.md This section lists various themes and skins for the Django administration interface, aiming to improve its appearance and user experience. These themes often leverage front-end frameworks like Bootstrap or Material Design. ```Python pip install django-grappelli # Or pip install django-jazzmin # Or pip install django-admin-interface # Or pip install django-material-admin # Or pip install django-semantic-admin # Or pip install django-jet-reboot # Or pip install django-baton # Or pip install django-unfold # Or pip install django-daisy # Or pip install django-admin-dracula # Or pip install django-smartbase-admin ``` -------------------------------- ### Django Query Profiler for N+1 Queries Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A Django query profiler designed to help developers identify and resolve N+1 query problems. It provides detailed information about executed queries. ```Python # Typically involves adding middleware and potentially template tags. # Example in settings.py: # MIDDLEWARE = [ # 'query_profiler.middleware.QueryProfilerMiddleware', # ... # ] ``` -------------------------------- ### Django Compressor for Static File Optimization Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Compresses and caches JavaScript and CSS files into single, optimized files. This reduces the number of HTTP requests and improves page load times. ```Python # Example in settings.py: # INSTALLED_APPS = [ # 'compressor', # ... # ] # STATICFILES_STORAGE = 'compressor.storage.CompressorFileStorage' # Example in template: # {% load compress %} # {% compress css %} # # {% endcompress %} ``` -------------------------------- ### Django Polymorphic Models for Inheritance Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Simplifies the use of model inheritance in Django projects. It allows querying and managing objects from multiple related models through a common interface. ```Python from polymorphic.models import PolymorphicModel # Example usage in Django models: # class Place(PolymorphicModel): # name = models.CharField(max_length=50) # class Restaurant(Place): # serves_hot_dogs = models.BooleanField(default=False) # class Friend(Place): # meant_happiness = models.BooleanField(default=True) ``` -------------------------------- ### Django Admin Packages Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A collection of third-party Django packages designed to enhance the functionality and user experience of the Django admin interface. These packages cover features like user impersonation, data import/export, inline pagination, and visual environment distinction. ```Python pip install django-hijack # Admins can log in and work on behalf of other users without having to know their credentials. pip install django-import-export # Django application and library for importing and exporting data with admin integration. pip install django-admin-inline-paginator-plus # A simple way to paginate your inline in Django admin pip install django-loginas # "Log in as user" for the Django admin. pip install impostor # Impostor is a Django application which allows staff members to log in as a different user by using their own username and password. pip install django-impersonate # Allow superusers to “impersonate” other non-superuser accounts. pip install django-admin-env-notice # Visually distinguish environments in Django Admin, for example: `development`, `staging`, `production`. pip install django-related-admin # A helper library that allows you to write list_displays across foreign key relationships. pip install django-admin-sortable2 # Generic drag-and-drop ordering for objects in the Django admin interface. pip install django-admin-collaborator # Add real-time user presence, edit locks, and chat to Django admin with Channels and Redis. ``` -------------------------------- ### Django Taggit for Model Tagging Source: https://github.com/wsvincent/awesome-django/blob/main/README.md A simple and flexible library for adding tagging functionality to Django models. It provides model fields and management utilities for tags. ```Python from taggit.managers import TaggableManager # Example usage in a Django model: # class Post(models.Model): # title = models.CharField(max_length=200) # tags = TaggableManager() ``` -------------------------------- ### Django Form Libraries Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Libraries for enhancing Django form functionality, including DRY forms, custom rendering, multi-step forms, autocompletion, and handling multiple forms in a single view. ```Python django-crispy-forms django-floppyforms django-formtools django-widget-tweaks django-autocomplete-light django-shapeshifter ``` -------------------------------- ### Django Permissions Policy for Feature Policy Header Source: https://github.com/wsvincent/awesome-django/blob/main/README.md Allows you to set the draft security HTTP header `Feature-Policy` (formerly `Permissions-Policy`) on a Django application. This controls which browser features (e.g., camera, microphone) are allowed to be used. ```Python # Example configuration in settings.py: # MIDDLEWARE = [ # 'permissions_policy.middleware.PermissionsPolicyMiddleware', # ... # ] # PERMISSIONS_POLICY = { # 'camera': ["'self'"], # 'microphone': ["'none'"], # } ```