Django LAN is a Django plugin designed to facilitate local area network (LAN) management directly from your Django applications. It provides a suite of tools and custom model fields to manage network configurations, validate network parameters, and interact with network hardware efficiently.
- Network Device Management: Manage and store configurations for various network devices.
- Custom Field Types: Includes custom Django model fields for IP addresses, MAC addresses, CIDR notations, and more.
- Network Validation Tools: Extensive validators for network-related data such as IP addresses, MAC addresses, port numbers, and CIDR blocks.
- Dynamic Form Components: Utilize dynamic form fields that integrate directly with your network management models.
To get started with Django LAN, follow these steps:
- Django 3.1 or newer
- Python 3.6 or newer
-
Install Django LAN:
pip install django-lan
-
Add
django_lan
to your INSTALLED_APPS insettings.py
:INSTALLED_APPS = [ ... 'django_lan', ... ]
-
Run Migrations:
python manage.py migrate
To use the custom model fields provided by Django LAN in your models:
from django.db import models
from django_lan.fields import IPAddressModelField, MACAddressModelField, PortNumberModelField
class NetworkDevice(models.Model):
ip_address = IPAddressModelField()
mac_address = MACAddressModelField()
port = PortNumberModelField()
Apply validators in your forms like this:
from django import forms
from django_lan.validators import validate_ip_address, validate_mac_address
class NetworkDeviceForm(forms.ModelForm):
class Meta:
model = NetworkDevice
fields = '__all__'
def clean_ip_address(self):
ip_address = self.cleaned_data.get('ip_address')
validate_ip_address(ip_address)
return ip_address
For more detailed documentation, visit Django LAN Documentation.
Contributions are welcome! Please read our Contributing Guide for details on how to propose bugfixes and improvements, and how to build and test your changes to Django LAN.
Distributed under the Apache 2.0 License. See LICENSE
for more information.