-
-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from newpanjing/dev
- Loading branch information
Showing
5 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
default_app_config = 'simpleui.apps.SimpleApp' | ||
|
||
|
||
def get_version(): | ||
return '3.6' | ||
return '3.7' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class SimpleApp(AppConfig): | ||
name = 'simpleui' | ||
|
||
def ready(self): | ||
# 如果是django3+ 就使用中间件,删除header中的X-Frame-Options | ||
|
||
try: | ||
import django | ||
version = django.get_version() | ||
if int(version.split('.')[0]) >= 3: | ||
from django.conf import settings | ||
mname = 'simpleui.middlewares.SimpleMiddleware' | ||
if mname not in settings.MIDDLEWARE: | ||
settings.MIDDLEWARE.append(mname) | ||
except Exception as e: | ||
pass | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
|
||
try: | ||
|
||
from django.utils.deprecation import MiddlewareMixin # Django 1.10.x | ||
except ImportError: | ||
MiddlewareMixin = object # Django 1.4.x - Django 1.9.x | ||
|
||
|
||
class SimpleMiddleware(MiddlewareMixin): | ||
|
||
def process_response(self, request, response): | ||
response['X-Frame-Options'] = 'ALLOW-FROM' | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters