一个快速而简单的Django应用程序,用于在测试期间在不同用户之间切换
项目描述
一个快速而简单的django应用程序,用于在测试期间在不同用户之间切换。
“快速而简单”。只需包含中间件即可!
提供了一个带有用户列表的下拉框。
用户列表可以在settings中定义,或者加载所有用户。
仅在settings.DEBUG为True时才有效
需求
Django 1.2
安装
要安装最新版本
pip install git+git://github.com/ikraftsoft/django-userswitch#egg=django-userswitch
也可以使用pip或easy_install从PyPI安装
pip install django-userswitch easy_install install django-userswitch
设置 & 使用
将userswitch中间件添加到settings.py中的MIDDLEWARE_CLASSES,在默认中间件之后
MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ... 'userswitch.middleware.UserSwitchMiddleware', )
可选地,您可以将USERSWITCH_OPTIONS字典添加到settings.py中
USERSWITCH_OPTIONS = { 'css_class': '', # CSS class to be added to the switcher widget. Default='userswitch'. 'css_inline': '', # Inline css for the switcher widget, if any 'content_types': (), # a tuple of content-type for which to render switcher widget. Default = ('text/html', 'application/xhtml+xml') 'auth_backend': '', # Custom auth backend if any. Default = 'django.contrib.auth.backends.ModelBackend' 'replace_text': '', # Text to replace with the widget, default add to end "body" tag. 'users': (), # List of usernames(as strings) to be shown in the switcher widget. If its empty, all users are loaded. 'force_on': False, # Turns on USERSWITCH even if DEBUG = False }
注意:css_inline 选项的默认值提供了一些基本的绝对定位。要更改这些,要么手动指定css_inline 选项,要么使用!important 在css_class 指定的类中覆盖position、top、right。
这就全部了!
项目详情
关闭
django-userswitch-0.2.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d29bc9a323c354bb64a3643f5519dc6729d5dff196da069cd51e15b32f8291ef |
|
MD5 | 07852ab53db9edfed2b9ae164cac4960 |
|
BLAKE2b-256 | 6fdd24e768445cccff140f6ba77650554729899f473aa6e83331a2df043c6ffa |