每个django应用程序都需要的常见功能!

django-common-tivix的Python项目详细描述


概述

django common包含以下内容:

  • A middleware that makes sure your web-app runs either on or without ‘www’ in the domain.
  • A ^{tt1}$ base class, that helps in keeping your session related code object-oriented and clean! See session.py for usage details.
  • An ^{tt2}$ for authenticating users based on their email, apart from username.
  • Some custom db fields that you can use in your models including a ^{tt3}$ and ^{tt4}$.
  • Bunch of helpful functions in helper.py
  • A ^{tt5}$ template tag that makes rendering form fields easy and DRY.
  • A couple of dry response classes: ^{tt6}$ and ^{tt7}$ in the django_common.http that can be used in views that give json/xml responses.

安装

  • 安装django_common(最好是在您的virtualenv中!)使用pip或者简单地获取代码的副本并将其放在代码库的目录中。

  • django_common添加到django设置中INSTALLED_APPS

        INSTALLED_APPS = [
        # ...
        "django_common",
    ]
    
  • 使用适当的值将以下内容添加到settings.py中:

    • IS_DEV
    • IS_PROD
    • DOMAIN_NAME
    • WWW_ROOT
  • common_settings添加到django设置中TEMPLATE_CONTEXT_PROCESSORS

    TEMPLATE_CONTEXT_PROCESSORS = [
            # ...
            "common_settings",
    ]
    
  • EmailBackend添加到django设置AUTHENTICATION_BACKENDS

    AUTHENTICATION_BACKENDS = (
            'django_common.auth_backends.EmailBackend',
            'django.contrib.auth.backends.ModelBackend'
    )
    
  • 如果需要,请将WWWRedirectMiddleware添加到中间产品列表:

    MIDDLEWARE_CLASSES = [
            # ...
            "WWWRedirectMiddleware",
    ]
    

这个开源应用程序是由tivix,inc.(http://tivix.com/)提供给您的。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用户界面java,使用gui连接到另一台计算机/服务器的文件系统   运行sbt的ubuntu返回错误:“javahome需要<path>参数”   java如何在Android中处理许多ImageView而不出现内存问题?   查询中非法字符的java相同URL失败   安卓取消引用可能会产生“java”。lang.NullPointerException'   java中的indexoutofboundsexception“java.lang.ArrayIndexOutOfBoundsException”错误   xml Java将dom保存到文件>文件在程序结束后由另一个进程打开   Java的垃圾收集器是如何工作的?   Java如何筛选值(列表)   java处理字符串我怎样才能像在真实的书籍中一样在上面部分生成“小数字”呢?   java SonarQube是否有一个API来获取所有项目分析的一部分?   java startActivity(intent)什么都不做   JAVAutil。扫描器类Java   java如何从Firebase更新电子邮件?UpdateMail方法已被弃用   java Hibernate。如何正确组织带有注释的onetomany关系?   在java中获得卷标和驱动器号之间的映射(而不是FileSystemView)的解决方法是什么   java查找文件的路径