如何设置Django silk profi

2024-05-14 12:01:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我对Django和profiling完全陌生。我已经完成了文档中提到的设置丝绸轮廓仪的所有步骤。 https://github.com/jazzband/silk 我在运行管理.py运行服务器命令 但是当我打开浏览器并调用必要的api时,我没有找到任何与silk相关的内容。我不知道在哪里能找到结果。非常感谢任何帮助


Tags: django文档pyhttps命令github服务器com
1条回答
网友
1楼 · 发布于 2024-05-14 12:01:40

刚开始是用丝绸做的。 因此:

在设置.py公司名称:

DEBUG = True

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'silk',
]

MIDDLEWARE = [
    'silk.middleware.SilkyMiddleware',


    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]




# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/


STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env")

#before you change this make sure to create a folder "static" in project directory, otherwise it will throw an error.

STATICFILES_DIRS = [
        os.path.join(BASE_DIR, 'static'),
        ]



STATIC_URL = '/static/'

在网址.py公司名称:

^{pr2}$

(假设您在linux上)现在运行:

python manage.py makemigrations;

python manage.py migrate;

python manage.py collectstatic;

然后运行服务器并转到

127.0.0.1:8000/丝/

网址

相关问题 更多 >

    热门问题