Skip to content

TUSKION/django-extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Essential Extensions

A focused Django package providing essential extensions for image management, subdomain redirects, and SEO optimization with advanced admin interface and middleware support.

Features

  • ImageExtension: Generic image management with support for multiple image types, ordering, and featured images
  • SubdomainRedirect: Flexible subdomain redirect system with support for different redirect types
  • SEOMixin: Mixin-based SEO system for easy meta tag management across any Django model
  • Advanced Admin Interface: Enhanced Django admin with dynamic object selectors, image previews, and validation
  • Middleware Support: Built-in middleware for automatic subdomain redirects and admin IP restrictions
  • Custom Widgets: Specialized form widgets for better user experience

Installation

pip install git+https://github.com/TUSKION/django-extensions

Quick Start

  1. Add to your INSTALLED_APPS:
INSTALLED_APPS = [
    # ... other apps
    'essential_extensions',
]
  1. Add middleware to your MIDDLEWARE:
MIDDLEWARE = [
    # ... other middleware
    'essential_extensions.middleware.SubdomainRedirectMiddleware',
    'essential_extensions.middleware.AdminIPRestrictionMiddleware',  # Optional
]
  1. Run migrations:
python manage.py migrate
  1. The admin interface is automatically registered and ready to use.

Basic Usage

ImageExtension

from essential_extensions.models import ImageExtension

# Create an image extension for a game
game = Game.objects.get(id=1)
image = ImageExtension.objects.create(
    content_object=game,
    image_type='screenshot',
    image='path/to/image.jpg',
    title='Game Screenshot',
    order=1,
    is_featured=True
)

SubdomainRedirect

from essential_extensions.models import SubdomainRedirect

# Redirect subdomain to a specific page
redirect = SubdomainRedirect.objects.create(
    subdomain='blog',
    redirect_type='full',
    redirect_path='/blog/',
    is_active=True
)

SEOMixin

from essential_extensions.mixins import SEOMixin

class GameProject(models.Model, SEOMixin):
    title = models.CharField(max_length=200)
    description = models.TextField()
    
    _seo = {
        'title': 'title',
        'description': 'description',
        'author': 'GhostJam Team',
    }

Configuration

Basic Settings

# settings.py

# Main domain for subdomain redirects
MAIN_DOMAIN = 'example.com'

# Admin IP restriction
ADMIN_IP_RESTRICTION_ENABLED = True
ADMIN_ALLOWED_IPS = ['127.0.0.1', '::1']
ADMIN_ALLOWED_NETWORKS = ['192.168.1.0/24']

# SEO defaults
SEO_DEFAULTS = {
    'description': 'GhostJam - Indie Game Development Community',
    'keywords': ['indie games', 'game development'],
    'author': 'GhostJam Team',
    'robots': 'index, follow',
}

Documentation

For detailed documentation on each component, see:

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

About

A collection of extensions for Django projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published