當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.AUTH_USER_MODEL屬性代碼示例

本文整理匯總了Python中django.conf.settings.AUTH_USER_MODEL屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.AUTH_USER_MODEL屬性的具體用法?Python settings.AUTH_USER_MODEL怎麽用?Python settings.AUTH_USER_MODEL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.AUTH_USER_MODEL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: settings

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def settings(self):
        if self.cached_settings:
            return self.cached_settings
        else:
            from django.conf import settings
            allowed_configurations = {
                'CONTENT_TYPE_CLASS': ContentType,
                'USER_CLASS': settings.AUTH_USER_MODEL,
                'PERMISSION_CLASS': Permission,
                'GROUP_CLASS': Group,
                'INJECT_MODEL_ADMIN': False
            }
            river_settings = {}
            for key, default in allowed_configurations.items():
                river_settings[key] = getattr(settings, self.get_with_prefix(key), default)

            river_settings['IS_MSSQL'] = connection.vendor == 'microsoft'
            self.cached_settings = river_settings

            return self.cached_settings 
開發者ID:javrasya,項目名稱:django-river,代碼行數:22,代碼來源:config.py

示例2: test_check_custom_user_model_default_admin

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def test_check_custom_user_model_default_admin(self):
            # Django doesn't re-register admins when using `override_settings`,
            # so we have to do it manually in this test case.
            admin.site.register(get_user_model(), UserAdmin)

            warnings = checks.check_custom_user_model(HijackAdminConfig)
            expected_warnings = [
                Warning(
                    'django-hijack-admin does not work out the box with a custom user model.',
                    hint='Please mix HijackUserAdminMixin into your custom UserAdmin.',
                    obj=settings.AUTH_USER_MODEL,
                    id='hijack_admin.W001',
                )
            ]
            self.assertEqual(warnings, expected_warnings)

            admin.site.unregister(get_user_model()) 
開發者ID:arteria,項目名稱:django-hijack-admin,代碼行數:19,代碼來源:test_checks.py

示例3: setUp

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def setUp(self):
        """
        Set up the following claim senarios
            user1: asks 50
            user2: offers 25
            user3: offers 25
            user1 claims
        """
        self.url = 'http://github.com/codesy/codesy/issues/37'
        self.issue = mommy.make(Issue, url=self.url)

        self.user1 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user1@test.com')
        self.user2 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user2@test.com')
        self.user3 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user3@test.com')
        self.bid1 = mommy.make(Bid, user=self.user1,
                               ask=50, offer=0, url=self.url, issue=self.issue)
        self.bid2 = mommy.make(Bid, user=self.user2,
                               ask=0, offer=25, url=self.url, issue=self.issue)
        self.bid3 = mommy.make(Bid, user=self.user3,
                               ask=0, offer=25, url=self.url, issue=self.issue)
        self.claim = mommy.make(Claim, user=self.user1, issue=self.issue) 
開發者ID:codesy,項目名稱:codesy,代碼行數:26,代碼來源:__init__.py

示例4: test_send_mail_to_matching_askers

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def test_send_mail_to_matching_askers(self, mock_send_mail):
        user = mommy.make(settings.AUTH_USER_MODEL)
        bid1_subject = "[codesy] There's $50 waiting for you!"
        bid2_subject = "[codesy] There's $100 waiting for you!"
        mock_send_mail.expects_call().with_args(
            bid1_subject,
            arg.any(),
            arg.any(),
            ['user1@test.com']
        )
        mock_send_mail.next_call().with_args(
            bid2_subject,
            arg.any(),
            arg.any(),
            ['user2@test.com']
        )

        offer_bid = mommy.make(
            Bid, offer=100, user=user, ask=1000, url=self.url
        )
        offer_bid.save() 
開發者ID:codesy,項目名稱:codesy,代碼行數:23,代碼來源:model_tests.py

示例5: test_only_send_mail_to_unsent_matching_askers

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def test_only_send_mail_to_unsent_matching_askers(self, mock_send_mail):
        user = mommy.make(settings.AUTH_USER_MODEL)
        self.bid1.ask_match_sent = timezone.now()
        self.bid1.save()
        subject = "[codesy] There's $100 waiting for you!"

        mock_send_mail.expects_call().with_args(
            subject,
            arg.any(),
            arg.any(),
            ['user2@test.com']
        )

        offer_bid = mommy.make(
            Bid, offer=100, user=user, ask=1000, url=self.url
        )
        offer_bid.save() 
開發者ID:codesy,項目名稱:codesy,代碼行數:19,代碼來源:model_tests.py

示例6: setUp

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def setUp(self):
        """
        Add a final bid and a user2 claim to the MarketWithBidsTestCase,
        so the final market for the bug is now:
            url: http://github.com/codesy/codesy/issues/37
            user1: ask 50,  offer 0  (ask is met)
            user2: ask 100, offer 10
            user3: ask 0,   offer 30
            user4: ask 200, offer 10
        And user1 is making the claim
        """
        super(NotifyMatchingOfferersTest, self).setUp()
        self.user4 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user4@test.com')
        self.bid4 = mommy.make(Bid, user=self.user4,
                               ask=200, offer=10, url=self.url)
        self.evidence = ('https://github.com/codesy/codesy/commit/'
                         '4f1bcd014ec735918bebd1c386e2f99a7f83ff64') 
開發者ID:codesy,項目名稱:codesy,代碼行數:20,代碼來源:model_tests.py

示例7: setUp

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def setUp(self):
        self.view = ClaimStatusView()
        self.url = 'http://github.com/codesy/codesy/issues/37'
        self.issue = mommy.make(Issue, url=self.url)
        self.user1 = mommy.make(
            settings.AUTH_USER_MODEL, email='user1@test.com'
        )
        self.bid1 = mommy.make(
            Bid, user=self.user1, url=self.url, issue=self.issue, offer=0
        )
        self.user2 = mommy.make(
            settings.AUTH_USER_MODEL, email='user2@test.com'
        )
        self.bid2 = mommy.make(
            Bid, user=self.user2, url=self.url, issue=self.issue, offer=10
        )
        self.user3 = mommy.make(
            settings.AUTH_USER_MODEL, email='user3@test.com'
        )

        self.claim = mommy.make(Claim, user=self.user1, issue=self.issue) 
開發者ID:codesy,項目名稱:codesy,代碼行數:23,代碼來源:view_tests.py

示例8: match_user

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def match_user(self, user: AUTH_USER_MODEL) -> bool:
        """Return True if the user passes the various user filters."""
        # treat no user (i.e. has not been added) as AnonymousUser()
        user = user or AnonymousUser()

        if self.user_filter_type == RuleSet.USER_FILTER_ALL:
            return True

        if self.user_filter_type == RuleSet.USER_FILTER_AUTH:
            return user.is_authenticated

        if self.user_filter_type == RuleSet.USER_FILTER_GROUP:
            group = self.user_group_filter.strip()
            return user.groups.filter(name__iexact=group).exists()

        # if we're still going, then it's a no. it's also an invalid
        # user_filter_type, so we may want to think about a warning
        return False 
開發者ID:yunojuno,項目名稱:django-request-profiler,代碼行數:20,代碼來源:models.py

示例9: __init__

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def __init__(self, real_apps, models, ignore_swappable=False):
        # Any apps in self.real_apps should have all their models included
        # in the render. We don't use the original model instances as there
        # are some variables that refer to the Apps object.
        # FKs/M2Ms from real apps are also not included as they just
        # mess things up with partial states (due to lack of dependencies)
        self.real_models = []
        for app_label in real_apps:
            app = global_apps.get_app_config(app_label)
            for model in app.get_models():
                self.real_models.append(ModelState.from_model(model, exclude_rels=True))
        # Populate the app registry with a stub for each application.
        app_labels = {model_state.app_label for model_state in models.values()}
        app_configs = [AppConfigStub(label) for label in sorted(real_apps + list(app_labels))]
        super(StateApps, self).__init__(app_configs)

        self.render_multiple(list(models.values()) + self.real_models)

        # There shouldn't be any operations pending at this point.
        pending_models = set(self._pending_operations)
        if ignore_swappable:
            pending_models -= {make_model_tuple(settings.AUTH_USER_MODEL)}
        if pending_models:
            raise ValueError(self._pending_models_error(pending_models)) 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:26,代碼來源:state.py

示例10: add_default_menu_items

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def add_default_menu_items(self):
        menu_setting = 'OPENWISP_DEFAULT_ADMIN_MENU_ITEMS'
        items = [
            {'model': settings.AUTH_USER_MODEL},
            {'model': get_model_name('openwisp_users', 'Organization')},
        ]
        if not hasattr(settings, menu_setting):
            setattr(settings, menu_setting, items)
        else:
            current_menu = getattr(settings, menu_setting)
            current_menu += items 
開發者ID:openwisp,項目名稱:openwisp-users,代碼行數:13,代碼來源:apps.py

示例11: check_custom_user_model

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def check_custom_user_model(app_configs, **kwargs):
    warnings = []
    if (settings.AUTH_USER_MODEL != DEFAULT_AUTH_USER_MODEL and
            not _using_hijack_admin_mixin()):
        warnings.append(
            Warning(
                'django-hijack-admin does not work out the box with a custom user model.',
                hint='Please mix HijackUserAdminMixin into your custom UserAdmin.',
                obj=settings.AUTH_USER_MODEL,
                id='hijack_admin.W001',
            )
        )
    return warnings 
開發者ID:arteria,項目名稱:django-hijack-admin,代碼行數:15,代碼來源:checks.py

示例12: __init__

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def __init__(self, real_apps, models, ignore_swappable=False):
        # Any apps in self.real_apps should have all their models included
        # in the render. We don't use the original model instances as there
        # are some variables that refer to the Apps object.
        # FKs/M2Ms from real apps are also not included as they just
        # mess things up with partial states (due to lack of dependencies)
        self.real_models = []
        for app_label in real_apps:
            app = global_apps.get_app_config(app_label)
            for model in app.get_models():
                self.real_models.append(ModelState.from_model(model, exclude_rels=True))
        # Populate the app registry with a stub for each application.
        app_labels = {model_state.app_label for model_state in models.values()}
        app_configs = [AppConfigStub(label) for label in sorted(real_apps + list(app_labels))]
        super(StateApps, self).__init__(app_configs)

        self.render_multiple(list(models.values()) + self.real_models)

        # If there are some lookups left, see if we can first resolve them
        # ourselves - sometimes fields are added after class_prepared is sent
        for lookup_model, operations in self._pending_lookups.items():
            try:
                model = self.get_model(lookup_model[0], lookup_model[1])
            except LookupError:
                app_label = "%s.%s" % (lookup_model[0], lookup_model[1])
                if app_label == settings.AUTH_USER_MODEL and ignore_swappable:
                    continue
                # Raise an error with a best-effort helpful message
                # (only for the first issue). Error message should look like:
                # "ValueError: Lookup failed for model referenced by
                # field migrations.Book.author: migrations.Author"
                msg = "Lookup failed for model referenced by field {field}: {model[0]}.{model[1]}"
                raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
            else:
                do_pending_lookups(model) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:37,代碼來源:state.py

示例13: get_user_model

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def get_user_model():
    """
    Returns the User model that is active in this project.
    """
    try:
        return django_apps.get_model(settings.AUTH_USER_MODEL)
    except ValueError:
        raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form 'app_label.model_name'")
    except LookupError:
        raise ImproperlyConfigured(
            "AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
        ) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:14,代碼來源:__init__.py

示例14: skipIfCustomUser

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def skipIfCustomUser(test_func):
    """
    Skip a test if a custom user model is in use.
    """
    return skipIf(settings.AUTH_USER_MODEL != 'auth.User', 'Custom user model in use')(test_func) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:7,代碼來源:utils.py

示例15: user

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 別名]
def user() -> settings.AUTH_USER_MODEL:
    return UserFactory() 
開發者ID:ecds,項目名稱:readux,代碼行數:4,代碼來源:conftest.py


注:本文中的django.conf.settings.AUTH_USER_MODEL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。