• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.get_user_model函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mezzanine.utils.models.get_user_model函数的典型用法代码示例。如果您正苦于以下问题:Python get_user_model函数的具体用法?Python get_user_model怎么用?Python get_user_model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_user_model函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: urls

 def urls(self):
     from django.conf import settings
     urls = patterns("", ("", super(LazyAdminSite, self).urls),)
     # Filebrowser admin media library.
     fb_name = getattr(settings, "PACKAGE_NAME_FILEBROWSER", "")
     if fb_name in settings.INSTALLED_APPS:
         try:
             fb_urls = import_dotted_path("%s.sites.site" % fb_name).urls
         except ImportError:
             fb_urls = "%s.urls" % fb_name
         urls = patterns("", ("^media-library/", include(fb_urls)),) + urls
     # Give the urlpatterm for the user password change view an
     # actual name, so that it can be reversed with multiple
     # languages are supported in the admin.
     User = get_user_model()
     for admin in self._registry.values():
         user_change_password = getattr(admin, "user_change_password", None)
         if user_change_password:
             bits = (User._meta.app_label, User._meta.object_name.lower())
             urls = patterns("",
                 url("^%s/%s/(\d+)/password/$" % bits,
                     self.admin_view(user_change_password),
                     name="user_change_password"),
             ) + urls
             break
     return urls
开发者ID:AlexHill,项目名称:mezzanine,代码行数:26,代码来源:lazy_admin.py


示例2: create_user

 def create_user(self):
     User = get_user_model()
     if not settings.DEBUG or User.objects.count() > 0:
         return
     if self.verbosity >= 1:
         print("\nCreating default account (username: %s / password: %s) "
               "...\n" % (DEFAULT_USERNAME, DEFAULT_PASSWORD))
     args = (DEFAULT_USERNAME, DEFAULT_EMAIL, DEFAULT_PASSWORD)
     User.objects.create_superuser(*args)
开发者ID:SpisTresci,项目名称:mezzanine,代码行数:9,代码来源:createdb.py


示例3: decorator

 def decorator(request, *args, **kwargs):
     try:
         engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])
     except:
         import django.contrib.sessions.backends.db
         engine = django.contrib.sessions.backends.db
     session_data = engine.SessionStore(request.POST.get('session_key'))
     user_id = session_data['_auth_user_id']
     # will return 404 if the session ID does not resolve to a valid user
     request.user = get_object_or_404(get_user_model(), pk=user_id)
     return function(request, *args, **kwargs)
开发者ID:Theneum,项目名称:filebrowser-safe,代码行数:11,代码来源:decorators.py


示例4: process_verified_phone

    def process_verified_phone(self, phone, request):
        
        user = get_user_model().objects.get(
            pk=self.storage.extra_data.get('_user_id'))

        token = default_token_generator.make_token(user)
        user = authenticate(uidb36=int_to_base36(user.id),
                            token=token, is_active=True)

        auth_login(request, user)
        return redirect("profile_update")
开发者ID:kpnn,项目名称:mezzanine-nexmoverify,代码行数:11,代码来源:views.py


示例5: get_profile_user_fieldname

def get_profile_user_fieldname(profile_model=None, user_model=None):
    """
    Returns the name of the first field on the profile model that
    points to the ``auth.User`` model.
    """
    Profile = profile_model or get_profile_model()
    User = user_model or get_user_model()
    for field in Profile._meta.fields:
        if field.rel and field.rel.to == User:
            return field.name
    raise ImproperlyConfigured("Value for AUTH_PROFILE_MODULE does not "
                               "contain a ForeignKey field for auth.User: %s"
                               % Profile.__name__)
开发者ID:Catalyst4Success,项目名称:site-django-mezzanine,代码行数:13,代码来源:__init__.py


示例6: get_user_model

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from calendar import month_name

from future.builtins import str
from future.builtins import int
from django.http import Http404
from django.shortcuts import get_object_or_404
from mezzanine.blog.models import BlogCategory, BlogPost
from mezzanine.conf import settings
from mezzanine.generic.models import Keyword
from mezzanine.utils.views import render, paginate
from mezzanine.utils.models import get_user_model


User = get_user_model()


def blog_post_list(request, tag=None, year=None, month=None, username=None,
                   category=None, template="blog/blog_post_list.html"):
    """
    Display a list of blog posts that are filtered by tag, year, month,
    author or category. Custom templates are checked for using the name
    ``blog/blog_post_list_XXX.html`` where ``XXX`` is either the
    category slug or author's username if given.
    """

    settings.use_editable()
    templates = []
    blog_posts = BlogPost.objects.published(for_user=request.user)
开发者ID:mateuszdargacz,项目名称:esti_blog,代码行数:30,代码来源:views.py



注:本文中的mezzanine.utils.models.get_user_model函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sites.current_site_id函数代码示例发布时间:2022-05-27
下一篇:
Python models.base_concrete_model函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap