跳转到主要内容

一个快速而简单的Django应用程序,用于在测试期间在不同用户之间切换

项目描述

一个快速而简单的django应用程序,用于在测试期间在不同用户之间切换。

  • “快速而简单”。只需包含中间件即可!

  • 提供了一个带有用户列表的下拉框。

  • 用户列表可以在settings中定义,或者加载所有用户。

  • 仅在settings.DEBUGTrue时才有效

需求

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 选项,要么使用!importantcss_class 指定的类中覆盖positiontopright

这就全部了!

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

django-userswitch-0.2.2.tar.gz (3.5 kB 查看哈希值)

上传时间

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面