django-multisite2 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. django-multisite2-2.0.0/.coveragerc +3 -0
  2. django-multisite2-2.0.0/.github/workflows/build.yml +74 -0
  3. django-multisite2-2.0.0/.gitignore +25 -0
  4. django-multisite2-2.0.0/.pre-commit-config.yaml +49 -0
  5. django-multisite2-2.0.0/.yamllint +13 -0
  6. django-multisite2-2.0.0/CHANGES +137 -0
  7. django-multisite2-2.0.0/LICENSE +28 -0
  8. django-multisite2-2.0.0/MANIFEST.in +3 -0
  9. django-multisite2-2.0.0/PKG-INFO +246 -0
  10. django-multisite2-2.0.0/README.rst +219 -0
  11. django-multisite2-2.0.0/django_multisite2.egg-info/PKG-INFO +246 -0
  12. django-multisite2-2.0.0/django_multisite2.egg-info/SOURCES.txt +64 -0
  13. django-multisite2-2.0.0/django_multisite2.egg-info/dependency_links.txt +1 -0
  14. django-multisite2-2.0.0/django_multisite2.egg-info/not-zip-safe +1 -0
  15. django-multisite2-2.0.0/django_multisite2.egg-info/requires.txt +1 -0
  16. django-multisite2-2.0.0/django_multisite2.egg-info/top_level.txt +2 -0
  17. django-multisite2-2.0.0/multisite/__init__.py +1 -0
  18. django-multisite2-2.0.0/multisite/admin/__init__.py +3 -0
  19. django-multisite2-2.0.0/multisite/admin/alias_admin.py +58 -0
  20. django-multisite2-2.0.0/multisite/admin/multisite_changelist.py +64 -0
  21. django-multisite2-2.0.0/multisite/admin/multisite_model_admin.py +161 -0
  22. django-multisite2-2.0.0/multisite/apps.py +29 -0
  23. django-multisite2-2.0.0/multisite/exceptions.py +57 -0
  24. django-multisite2-2.0.0/multisite/forms.py +22 -0
  25. django-multisite2-2.0.0/multisite/hacks.py +163 -0
  26. django-multisite2-2.0.0/multisite/management/__init__.py +0 -0
  27. django-multisite2-2.0.0/multisite/management/commands/__init__.py +0 -0
  28. django-multisite2-2.0.0/multisite/management/commands/update_public_suffix_list.py +33 -0
  29. django-multisite2-2.0.0/multisite/middleware/__init__.py +4 -0
  30. django-multisite2-2.0.0/multisite/middleware/cookie_domain_middleware.py +72 -0
  31. django-multisite2-2.0.0/multisite/middleware/dynamic_site_middleware.py +198 -0
  32. django-multisite2-2.0.0/multisite/migrations/0001_initial.py +71 -0
  33. django-multisite2-2.0.0/multisite/migrations/0002_alter_alias_id_alter_alias_is_canonical.py +32 -0
  34. django-multisite2-2.0.0/multisite/migrations/0003_alter_alias_options_alter_alias_unique_together_and_more.py +41 -0
  35. django-multisite2-2.0.0/multisite/migrations/0004_alter_alias_managers.py +22 -0
  36. django-multisite2-2.0.0/multisite/migrations/__init__.py +0 -0
  37. django-multisite2-2.0.0/multisite/models/__init__.py +3 -0
  38. django-multisite2-2.0.0/multisite/models/alias.py +110 -0
  39. django-multisite2-2.0.0/multisite/models/managers.py +196 -0
  40. django-multisite2-2.0.0/multisite/models/signals.py +36 -0
  41. django-multisite2-2.0.0/multisite/models/validators.py +14 -0
  42. django-multisite2-2.0.0/multisite/tests/__init__.py +0 -0
  43. django-multisite2-2.0.0/multisite/tests/get_test_allowed_hosts.py +14 -0
  44. django-multisite2-2.0.0/multisite/tests/get_test_http_response.py +13 -0
  45. django-multisite2-2.0.0/multisite/tests/hosts.py +46 -0
  46. django-multisite2-2.0.0/multisite/tests/test_settings.py +23 -0
  47. django-multisite2-2.0.0/multisite/tests/tests/__init__.py +0 -0
  48. django-multisite2-2.0.0/multisite/tests/tests/request_factory.py +12 -0
  49. django-multisite2-2.0.0/multisite/tests/tests/test_alias.py +271 -0
  50. django-multisite2-2.0.0/multisite/tests/tests/test_contrib_site.py +21 -0
  51. django-multisite2-2.0.0/multisite/tests/tests/test_cookie_domain_middleware.py +196 -0
  52. django-multisite2-2.0.0/multisite/tests/tests/test_dynamic_site_middleware.py +262 -0
  53. django-multisite2-2.0.0/multisite/tests/tests/test_site_cache.py +127 -0
  54. django-multisite2-2.0.0/multisite/tests/tests/test_site_domain.py +24 -0
  55. django-multisite2-2.0.0/multisite/tests/tests/test_site_id.py +76 -0
  56. django-multisite2-2.0.0/multisite/tests/tests/test_template_loader.py +49 -0
  57. django-multisite2-2.0.0/multisite/threadlocals.py +136 -0
  58. django-multisite2-2.0.0/multisite/utils.py +172 -0
  59. django-multisite2-2.0.0/multisite_app/__init__.py +0 -0
  60. django-multisite2-2.0.0/multisite_app/apps.py +6 -0
  61. django-multisite2-2.0.0/multisite_app/urls.py +5 -0
  62. django-multisite2-2.0.0/multisite_app/views.py +8 -0
  63. django-multisite2-2.0.0/pyproject.toml +32 -0
  64. django-multisite2-2.0.0/runtests.py +18 -0
  65. django-multisite2-2.0.0/setup.cfg +59 -0
@@ -0,0 +1,3 @@
1
+ [run]
2
+ source=multisite
3
+ omit=multisite/tests.py,multisite/migrations/*,multisite/south_migrations/*
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: build
3
+
4
+ on: [push, pull_request]
5
+
6
+ jobs:
7
+ build:
8
+ name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
9
+ runs-on: ubuntu-latest
10
+
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ python-version: ['3.11', '3.12']
15
+ django-version: ['4.2', '5.0', 'dev']
16
+
17
+ exclude:
18
+ - python-version: '3.12'
19
+ django-version: '4.2'
20
+ - python-version: '3.11'
21
+ django-version: 'dev'
22
+ services:
23
+ mysql:
24
+ image: mysql:latest
25
+ env:
26
+ MYSQL_DATABASE: mysql
27
+ MYSQL_ROOT_PASSWORD: mysql
28
+ ports:
29
+ - 3306:3306
30
+ options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
31
+
32
+ steps:
33
+ - name: Install pycups and words dependency
34
+ run: |
35
+ sudo sed -i 's/azure\.//' /etc/apt/sources.list
36
+ sudo apt-get -y update
37
+ sudo apt-get install libcups2-dev wamerican
38
+
39
+ - uses: actions/checkout@v4
40
+ - name: Set up Python ${{ matrix.python-version }}
41
+ uses: actions/setup-python@v5
42
+ with:
43
+ python-version: ${{ matrix.python-version }}
44
+
45
+ - name: Get pip cache dir
46
+ id: pip-cache
47
+ run: |
48
+ echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT
49
+
50
+ - name: Cache
51
+ uses: actions/cache@v4
52
+ with:
53
+ path: ${{ steps.pip-cache.outputs.dir }}
54
+ key:
55
+ ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }}
56
+ restore-keys: |
57
+ ${{ matrix.python-version }}-v1-
58
+
59
+ - name: Install dependencies
60
+ run: |
61
+ python -m pip install --upgrade pip
62
+ python -m pip install -r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/tox.txt
63
+
64
+
65
+ - name: Tox tests
66
+ run: |
67
+ tox -v
68
+ env:
69
+ DJANGO: ${{ matrix.django-version }}
70
+
71
+ - name: Upload coverage to Codecov
72
+ uses: codecov/codecov-action@v3
73
+ with:
74
+ name: Python ${{ matrix.python-version }}
@@ -0,0 +1,25 @@
1
+ build/
2
+ dist/
3
+ etc/
4
+ .etc/
5
+ .env
6
+ _version.py
7
+ *.pyc
8
+ *.pyo
9
+ .cache/
10
+ .eggs/
11
+ *.egg-info/
12
+ .installed.cfg
13
+ bin
14
+ develop-eggs
15
+ django_multisite.egg-info/
16
+ dist
17
+ downloads
18
+ eggs
19
+ parts
20
+ MANIFEST
21
+ multisite/*.egg-info
22
+ django_multisite_edc.egg-info/*
23
+ .coverage
24
+ .tox/
25
+ .pytest_cache/
@@ -0,0 +1,49 @@
1
+ ---
2
+ exclude: tests/etc/user-*
3
+
4
+ repos:
5
+ - repo: https://github.com/PyCQA/bandit
6
+ rev: 1.7.5
7
+ hooks:
8
+ - id: bandit
9
+ args:
10
+ - "-x *test*.py"
11
+
12
+ - repo: https://github.com/psf/black
13
+ rev: 23.11.0
14
+ hooks:
15
+ - id: black
16
+ language_version: python3.10
17
+
18
+ - repo: https://github.com/pycqa/flake8
19
+ rev: 6.1.0
20
+ hooks:
21
+ - id: flake8
22
+ args:
23
+ - "--config=setup.cfg"
24
+
25
+ - repo: https://github.com/PyCQA/isort
26
+ rev: 5.12.0
27
+ hooks:
28
+ - id: isort
29
+
30
+ - repo: https://github.com/pre-commit/pre-commit-hooks
31
+ rev: v4.5.0
32
+ hooks:
33
+ - id: requirements-txt-fixer
34
+ files: requirements/.*\.txt$
35
+ - id: trailing-whitespace
36
+ - id: check-added-large-files
37
+ - id: fix-byte-order-marker
38
+ - id: check-docstring-first
39
+ - id: check-executables-have-shebangs
40
+ - id: check-merge-conflict
41
+ - id: debug-statements
42
+ - id: detect-private-key
43
+
44
+ - repo: https://github.com/adrienverge/yamllint
45
+ rev: v1.33.0
46
+ hooks:
47
+ - id: yamllint
48
+ args:
49
+ - "--strict"
@@ -0,0 +1,13 @@
1
+ # allow "on" until yamllint stops checking keys for truthy!
2
+ # https://github.com/adrienverge/yamllint/issues/158
3
+ ---
4
+ extends: default
5
+
6
+ rules:
7
+ comments-indentation: disable
8
+ braces: disable
9
+ line-length:
10
+ max: 120
11
+ truthy:
12
+ level: error
13
+ allowed-values: ['true', 'false', 'on']
@@ -0,0 +1,137 @@
1
+ =============
2
+ Release Notes
3
+ =============
4
+
5
+ 2.0.0
6
+ -----
7
+ - major refactor, drop support for lower than py 3.11 and DJ4.2
8
+ - drop pytest, use unitests / runtests.py
9
+ - replace rel.to with related_model (Django 4.2)
10
+ - remove deprecated `process_requests`
11
+ - add more specific exception handling
12
+ - add MULTISITE_REGISTER_POST_MIGRATE_SYNC_ALIAS settings attr
13
+ to allow user to connect signal outside of multisite
14
+ - drop template loader code. Maybe add back later
15
+ - remove unused ThreadLocalsMiddleware
16
+
17
+ 1.9.0
18
+ -----
19
+
20
+ * Fix tldextract version 3.0.0 breaking changes (Issue #72 / PR #74)
21
+ * Fix test requirements missing Django
22
+ * Fix Pluggy dependency version conflict
23
+ * Remove support for Python 3.5 / Django < 1.11
24
+
25
+ 1.8.0
26
+ ----------
27
+
28
+ - Support for Django 3.0 (PR #68 - thanks @erikvw)
29
+ - Fix middleware usage post Django 2.0 (PR #69 thanks @mihalikv)
30
+
31
+ 1.7.0
32
+ -----
33
+
34
+ * Support Django 2.1 and 2.2 (PR #59 - thanks @ribeiroti!)
35
+ * Replace queryset with get_queryset in admin (PR #61 - thanks @vit-ivanov!)
36
+
37
+ 1.6.0
38
+ -----
39
+ * Fix KeyError from _get_site_by_id
40
+ * Drop support for Django 1.7
41
+ * Remove unnecessary cache type warnings
42
+ * Remove deprecated SiteIDHook
43
+
44
+ 1.5.0
45
+ -----
46
+ * Support Django 2.0 (PR #47 and #60)
47
+ * Remove code for Django < 1.7
48
+ * Remove obsolete PathAssistedCurrentSiteManager
49
+ * Remove obsolete template.loaders.cached
50
+ * Update README to better describe local development setup
51
+
52
+ 1.4.1
53
+ -----
54
+ * Specify Django <2.0 in setup.py
55
+ * Drop support for python 3.3
56
+
57
+ 1.4.0
58
+ -----
59
+ * Support Django 1.10 (PR #38) and 1.11
60
+ * Support Python 3
61
+ * Remove support for Django <1.7
62
+ * Use setuptools over distutils, and integrate the tests with them
63
+ * Use pytest and tox for testing
64
+ * Set up CI with travis
65
+ * Set up coverage and coveralls.io
66
+ * Document MULTISITE_EXTRA_HOSTS in README
67
+
68
+ 1.3.1
69
+ -----
70
+
71
+ * Add default for SiteID in the README (PR #31)
72
+ * Respect the CACHE_MULTISITE_ALIAS in SiteCache (PR #34)
73
+ * Replace deprecated ExtractResult().tld with .suffic (PR #32)
74
+
75
+ 1.3.0
76
+ -----
77
+
78
+ * Fix tempfile issue with update_public_suffix_list command
79
+ * Support for tldextract version >= 2.0
80
+
81
+ 1.2.6
82
+ ----
83
+
84
+ * Pin the tldextract dependency to version < 2.0, which breaks API.
85
+
86
+ 1.2.5
87
+ ----
88
+
89
+ * Make template loading more resilient to changes in django (thanks to jbazik for the contribution)
90
+
91
+ 1.2.4
92
+ -----
93
+
94
+ * Fix domain validation so it's called after the pre_save signal
95
+
96
+ 1.2.3
97
+ -----
98
+
99
+ * Fix a broken test, due to a django uniqueness constraint in 1.9
100
+
101
+ 1.2.2
102
+ -----
103
+
104
+ * Fix for 1.9: change the return type of filesystem template loader's get_template_sources()
105
+
106
+ 1.2.1
107
+ -----
108
+
109
+ * Remove django.utils.unittest (deprecated in 1.9)
110
+ * Use post_migrate instead of post_syncdb in > 1.7
111
+
112
+ 1.2.0
113
+ -----
114
+
115
+ * We now support Django 1.9
116
+ * Following deprecation in django, all get_cache methods have been replaced caches.
117
+
118
+ 1.1.0
119
+ -----
120
+
121
+ * We now support post-South Django 1.7 native migrations.
122
+
123
+ 1.0.0
124
+ -----
125
+
126
+ * 1.0 release. API stability promised from now on.
127
+ * Following the deprecation in Django itself, all get_query_set methods have been renamed to get_queryset. This means Django 1.6 is now the minimum required version.
128
+
129
+ 0.5.1
130
+ -----
131
+
132
+ * Add key prefix tests
133
+
134
+ 0.5.0
135
+ -----
136
+
137
+ * Allow use of cache key prefixes from the CACHES settings if CACHE_MULTISITE_KEY_PREFIX not set
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Ecometrica
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,3 @@
1
+ include INSTALL.txt
2
+ include README.rst
3
+ graft multisite
@@ -0,0 +1,246 @@
1
+ Metadata-Version: 2.1
2
+ Name: django-multisite2
3
+ Version: 2.0.0
4
+ Summary: Serve multiple sites from a single Django application
5
+ Home-page: http://github.com/erikvw/django-multisite
6
+ Author: Leonid S Shestera
7
+ Author-email: leonid@shestera.ru
8
+ Maintainer: Ecometrica
9
+ Maintainer-email: dev@ecometrica.com
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Web Environment
12
+ Classifier: Framework :: Django
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: BSD License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Internet
20
+ Classifier: Topic :: Internet :: WWW/HTTP
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Topic :: Utilities
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/x-rst
25
+ License-File: LICENSE
26
+ Requires-Dist: tldextract
27
+
28
+ |actions| |codecov| |downloads| |maintainability| |black|
29
+
30
+
31
+
32
+ README
33
+ ======
34
+
35
+ Python 3.11+ Django 4.2+
36
+
37
+ Older versions of Django are supported by the original `django-multisite`_ project.
38
+
39
+ .. _django-multisite: https://github.com/ecometrica/django-multisite
40
+
41
+
42
+ Installation
43
+ ============
44
+
45
+ Install with pip:
46
+
47
+ .. code-block::
48
+
49
+ pip install django-multisite2 (no release yet)
50
+
51
+
52
+ Replace your ``SITE_ID`` in ``settings.py`` to:
53
+
54
+ .. code-block::
55
+
56
+ from multisite import SiteID
57
+ SITE_ID = SiteID(default=1)
58
+
59
+
60
+ add to INSTALLED_APPS:
61
+
62
+ .. code-block::
63
+
64
+ INSTALLED_APPS = [
65
+ ...
66
+ 'django.contrib.sites',
67
+ 'multisite',
68
+ ...
69
+ ]
70
+
71
+
72
+ Edit settings.py MIDDLEWARE:
73
+
74
+ .. code-block::
75
+
76
+ MIDDLEWARE = (
77
+ ...
78
+ 'multisite.middleware.DynamicSiteMiddleware',
79
+ ...
80
+ )
81
+
82
+
83
+ Using a custom cache
84
+ --------------------
85
+ Append to settings.py, in order to use a custom cache that can be
86
+ safely cleared::
87
+
88
+ # The cache connection to use for django-multisite.
89
+ # Default: 'default'
90
+ CACHE_MULTISITE_ALIAS = 'multisite'
91
+
92
+ # The cache key prefix that django-multisite should use.
93
+ # If not set, defaults to the KEY_PREFIX used in the defined
94
+ # CACHE_MULTISITE_ALIAS or the default cache (empty string if not set)
95
+ CACHE_MULTISITE_KEY_PREFIX = ''
96
+
97
+ If you have set CACHE\_MULTISITE\_ALIAS to a custom value, *e.g.*
98
+ ``'multisite'``, add a separate backend to settings.py CACHES::
99
+
100
+ CACHES = {
101
+ 'default': {
102
+ ...
103
+ },
104
+ 'multisite': {
105
+ 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
106
+ 'TIMEOUT': 60 * 60 * 24, # 24 hours
107
+ ...
108
+ },
109
+ }
110
+
111
+
112
+ Domain fallbacks
113
+ ----------------
114
+
115
+ By default, if the domain name is unknown, multisite will respond with
116
+ an HTTP 404 Not Found error. To change this behaviour, add to
117
+ settings.py::
118
+
119
+ # The view function or class-based view that django-multisite will
120
+ # use when it cannot match the hostname with a Site. This can be
121
+ # the name of the function or the function itself.
122
+ # Default: None
123
+ MULTISITE_FALLBACK = 'django.views.generic.base.RedirectView
124
+
125
+ # Keyword arguments for the MULTISITE_FALLBACK view.
126
+ # Default: {}
127
+ MULTISITE_FALLBACK_KWARGS = {'url': 'http://example.com/',
128
+ 'permanent': False}
129
+
130
+ Templates
131
+ ---------
132
+ If required, create template subdirectories for domain level templates (in a
133
+ location specified in settings.TEMPLATES['DIRS'].
134
+
135
+ Multisite's template loader will look for templates in folders with the names of
136
+ domains, such as::
137
+
138
+ templates/example.com
139
+
140
+
141
+ The template loader will also look for templates in a folder specified by the
142
+ optional MULTISITE_DEFAULT_TEMPLATE_DIR setting, e.g.::
143
+
144
+ templates/multisite_templates
145
+
146
+
147
+ Cross-domain cookies
148
+ --------------------
149
+
150
+ In order to support `cross-domain cookies`_,
151
+ for purposes like single-sign-on,
152
+ prepend the following to the top of
153
+ settings.py MIDDLEWARE (MIDDLEWARE_CLASSES for Django < 1.10)::
154
+
155
+ MIDDLEWARE = (
156
+ 'multisite.middleware.CookieDomainMiddleware',
157
+ ...
158
+ )
159
+
160
+ CookieDomainMiddleware will consult the `Public Suffix List`_
161
+ for effective top-level domains.
162
+ It caches this file
163
+ in the system's default temporary directory
164
+ as ``effective_tld_names.dat``.
165
+ To change this in settings.py::
166
+
167
+ MULTISITE_PUBLIC_SUFFIX_LIST_CACHE = '/path/to/multisite_tld.dat'
168
+
169
+ By default,
170
+ any cookies without a domain set
171
+ will be reset to allow \*.domain.tld.
172
+ To change this in settings.py::
173
+
174
+ MULTISITE_COOKIE_DOMAIN_DEPTH = 1 # Allow only *.subdomain.domain.tld
175
+
176
+ In order to fetch a new version of the list,
177
+ run::
178
+
179
+ manage.py update_public_suffix_list
180
+
181
+ .. _cross-domain cookies: http://en.wikipedia.org/wiki/HTTP_cookie#Domain_and_Path
182
+ .. _Public Suffix List: http://publicsuffix.org/
183
+
184
+ Post-migrate signal: post_migrate_sync_alias
185
+ --------------------------------------------
186
+ The ``post-migrate`` signal ``post_migrate_sync_alias`` is registered in the ``apps.py``. ``post_migrate_sync_alias``
187
+ ensures the ``domain`` in multisite's ``Alias`` model is updated to match that of django's ``Site`` model. This signal must
188
+ run AFTER any ``post-migrate`` signals that manipulate Django's ``Site`` model. If you have an app that manipulates Django's
189
+ ``Site`` model, place it before ``multisite`` in `settings. INSTALLED_APPS`. If this is not possible, you may configure ``multisite``
190
+ to not connect the ``post-migrate`` signal in ``apps.py`` so that you can do it somewhere else in your code.
191
+
192
+ To configure `multisite` to not connect the `post-post_migrate_sync_alias` in the `apps.py`, update your settings::
193
+
194
+ MULTISITE_REGISTER_POST_MIGRATE_SYNC_ALIAS = False
195
+
196
+ With the `settings` attribute set to `False`, it is your responsibility to connect the signal in your code. Note that if you do not sync the `Alias` and `Site`
197
+ models after the `Site` model has changed, multisite may not recognize the domain and switch to the fallback view or
198
+ raise a `Http404` error.
199
+
200
+ Development Environments
201
+ ------------------------
202
+ Multisite returns a valid Alias when in "development mode" (defaulting to the
203
+ alias associated with the default SiteID.
204
+
205
+ Development mode is either:
206
+ - Running tests, i.e. manage.py test
207
+ - Running locally in settings.DEBUG = True, where the hostname is a top-level name, i.e. localhost
208
+
209
+ In order to have multisite use aliases in local environments, add entries to
210
+ your local etc/hosts file to match aliases in your applications. E.g. ::
211
+
212
+ 127.0.0.1 example.com
213
+ 127.0.0.1 examplealias.com
214
+
215
+ And access your application at example.com:8000 or examplealias.com:8000 instead of
216
+ the usual localhost:8000.
217
+
218
+ Tests
219
+ -----
220
+
221
+ To run the tests::
222
+
223
+ python runtests.py
224
+
225
+
226
+
227
+ .. |pypi| image:: https://img.shields.io/pypi/v/django-multisite2.svg
228
+ :target: https://pypi.python.org/pypi/django-multisite2
229
+
230
+ .. |actions| image:: https://github.com/erikvw/django-multisite2/actions/workflows/build.yml/badge.svg
231
+ :target: https://github.com/erikvw/django-multisite2/actions/workflows/build.yml
232
+
233
+ .. |codecov| image:: https://codecov.io/gh/erikvw/django-multisite2/branch/develop/graph/badge.svg
234
+ :target: https://codecov.io/gh/erikvw/django-multisite2
235
+
236
+ .. |downloads| image:: https://pepy.tech/badge/django-multisite2
237
+ :target: https://pepy.tech/project/django-multisite2
238
+
239
+ .. |maintainability| image:: https://api.codeclimate.com/v1/badges/4992e131641fc6929b1a/maintainability
240
+ :target: https://codeclimate.com/github/erikvw/django-multisite2/maintainability
241
+ :alt: Maintainability
242
+
243
+ .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
244
+ :target: https://github.com/ambv/black
245
+ :alt: Code Style
246
+