Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

 

from django.conf import settings 

from django.contrib.sites.models import Site 

from django.http import HttpResponseRedirect 

 

from multisite.models import Alias 

 

 

def auto_create_alias(request): 

""" 

Create a multisite.models.Alias entry for the current host. 

Use the default SITE_ID. 

 

Use by add this into settings: 

 

MULTISITE_FALLBACK="pylucid.multisite_views.auto_create_alias" 

 

see also: 

https://github.com/ecometrica/django-multisite/issues/33 

""" 

host = request.get_host().lower() 

site_id = settings.SITE_ID.get_default() 

site = Site.objects.get(pk=site_id) 

 

# print("Create Alias for %r to SITE_ID %s" % (host, site.pk)) 

Alias.objects.create( 

domain=host, 

site=site, 

redirect_to_canonical=False, 

) 

return HttpResponseRedirect(request.get_full_path())