django scopes x django sites framework
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
from django.db import models
|
|
|
|
from django.shortcuts import get_object_or_404
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
|
|
|
|
|
|
class Domain(models.Model):
|
|
|
|
fqdn = models.CharField(
|
|
|
|
_('FQDN'),
|
|
|
|
max_length=255,
|
|
|
|
unique=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
name = models.CharField(
|
|
|
|
_('display name'),
|
|
|
|
max_length=255,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_from_request(cls, request):
|
|
|
|
return get_object_or_404(cls, fqdn__iexact=request.META.get('HTTP_HOST', ''))
|
|
|
|
|
|
|
|
def get_name(self):
|
|
|
|
return self.name or self.fqdn
|