Giter Site home page Giter Site logo

Comments (4)

wgordon17 avatar wgordon17 commented on June 9, 2024 1

There is something in this PR, #951, that introduced this change in behavior. Using my nifty new tool, git bisect that I picked up from Django, it's definitely pinpointed to that PR as the introduction in change in behavior. I'm open to any suggestions!

from dynaconf.

wgordon17 avatar wgordon17 commented on June 9, 2024

There appears to be a similarly related timing bug, I can't use a lazily evaluated value inside of @pytest.mark.parametrize

@pytest.mark.parametrize(
    ("expected_url"),
    [settings.LOGIN_URL)],
)
def test_url(expected_url):
    assert expected_url == "/admin/login/"

from dynaconf.

pedro-psb avatar pedro-psb commented on June 9, 2024

Hey, thanks for the investigation and the reproduction, I'll try to have a look into this.

from dynaconf.

pedro-psb avatar pedro-psb commented on June 9, 2024

I have a theory.
Just some context, the #951 PR adds a post-load hook function is used there because we can't import reverse_lazy on the top_module in settings.py. But here is what I think is happening:

  1. instantiate DjangoDynaconf: register hook that loads @reverse_lazy
  2. execute_loader: here we load default, user settings etc
    1. When LOGIN_URL is loaded, its interpreted as a string, because the @reverse_lazy was not added yet (the hook is a "post" hook, its executed after loading).
  3. post-hook is called, which then effectively registers the @reverse_lazy function, but it doesn't take effect unless we do load the setting again.

Then, if somehow we make dynaconf re-execute the loaders, the @reverse_lazy will take effect because it will be present on loading time. The with_env context calls the settings reloading, but other reloads, such as using settings.get("LOGIN_URL", fresh=True) has the same effect (it also "fixes" the problem).

My first thought for approaching this is implementing a pre-hook and calling it before the loaders execution.

from dynaconf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.