Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
88291a69
Commit
88291a69
authored
May 15, 2016
by
Enrico Zini
Browse files
Added project router to prevent projectb from being touched
parent
4026b800
Changes
2
Hide whitespace changes
Inline
Side-by-side
nm2/settings.py
View file @
88291a69
...
...
@@ -185,6 +185,8 @@ LOGGING = {
}
}
DATABASE_ROUTERS
=
[
"projectb.router.DbRouter"
]
# New 1.7 test runner, we set it explicitly to silence django's checks
TEST_RUNNER
=
'django.test.runner.DiscoverRunner'
...
...
projectb/router.py
0 → 100644
View file @
88291a69
# coding: utf-8
from
__future__
import
print_function
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
unicode_literals
class
DbRouter
(
object
):
def
db_for_read
(
self
,
model
,
**
hints
):
if
model
.
_meta
.
app_label
==
"projectb"
:
return
"projectb"
return
None
def
db_for_write
(
self
,
model
,
**
hints
):
if
model
.
_meta
.
app_label
==
"projectb"
:
return
'projectb'
return
None
def
allow_relation
(
self
,
obj1
,
obj2
,
**
hints
):
return
None
# Also works with Django 1.7 as long as the projectb app has no DB models
def
allow_migrate
(
self
,
db
,
*
args
,
**
kw
):
if
db
==
"projectb"
:
return
False
# From Django 1.8 onwards
#def allow_migrate(self, db, app_label, model_name=None, **hints):
# if db == "projectb" or app_label == "projectb":
# return False
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment