Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9117547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:55:16+00:00 2026-06-17T04:55:16+00:00

Looking in django.conf I noticed that settings are implemented like this: class LazySettings(LazyObject): …

  • 0

Looking in django.conf I noticed that settings are implemented like this:

class LazySettings(LazyObject):     
...

What is the rationale behind making settings objects lazy?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:55:17+00:00Added an answer on June 17, 2026 at 4:55 am

    Check out this section of the Django coding style. The reason is explained in there (quoted below).

    In addition to performance, third-party modules can modify settings when they are imported. Accessing settings should be delayed to ensure this configuration happens first.

    Modules should not in general use settings stored in
    django.conf.settings at the top level (i.e. evaluated when the module
    is imported). The explanation for this is as follows:

    Manual configuration of settings (i.e. not relying on the
    DJANGO_SETTINGS_MODULE environment variable) is allowed and possible
    as follows:

    from django.conf import settings
    
    settings.configure({}, SOME_SETTING='foo')
    

    However, if any setting is
    accessed before the settings.configure line, this will not work.
    (Internally, settings is a LazyObject which configures itself
    automatically when the settings are accessed if it has not already
    been configured).

    So, if there is a module containing some code as follows:

    from django.conf import settings
    from django.core.urlresolvers import get_callable
    
    default_foo_view = get_callable(settings.FOO_EXAMPLE_VIEW)
    

    …then importing
    this module will cause the settings object to be configured. That
    means that the ability for third parties to import the module at the
    top level is incompatible with the ability to configure the settings
    object manually, or makes it very difficult in some circumstances.

    Instead of the above code, a level of laziness or indirection must be
    used, such as django.utils.functional.LazyObject,
    django.utils.functional.lazy() or lambda.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking in django.utils.functional I noticed a LazyObject class, django uses it in django.conf :
I was looking at the Django source code today and I noticed this: class
I was looking at some Django examples and I've noticed that you can call
I am looking for a basic Django application that looks good and has basic
am looking for a django templatetag that will count words and substring a whole
I thought I understood the WSGI specification. So I'm looking at this Django module
I am looking for some way in django's development server that will make the
I recently started looking into django and I started with the tutorial. I noticed
I've been looking over django's multi-db docs. I'd like to break a few of
I'm looking for a Django template filter that turns a multi-line construction into one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.