Giter VIP home page Giter VIP logo

Comments (8)

dylanjcastillo avatar dylanjcastillo commented on September 21, 2024 1

Thank you @liquidiert.

Yes, this looks like something to do with the way the project is structured. I'll try to look at it, but I have limited time these days, so might take a while.

from django-components.

dylanjcastillo avatar dylanjcastillo commented on September 21, 2024

@liquidiert could you provide a sample repo that reproduces this error? It works for me

hot_reloading_django_5.0.4.mp4

from django-components.

liquidiert avatar liquidiert commented on September 21, 2024

@dylanjcastillo Created a repository. I suspect it has smth to do with the cookiecutter template used. I understand if it's not on your roadmap to support custom stuff like this :) But still might be interesting

from django-components.

EmilStenstrom avatar EmilStenstrom commented on September 21, 2024

@liquidiert Would you mind trying your repo with the latest version of django-components, and enable logging? You'll see the full list of paths that are searched for which might give a hint of what the problem is.

from django-components.

liquidiert avatar liquidiert commented on September 21, 2024

@EmilStenstrom I've updated django-components to 0.66 and turned on logging. Unfortunately I can't see the full list of search paths you mentioned. Do I have to set up smth else for that?

from django-components.

dylanjcastillo avatar dylanjcastillo commented on September 21, 2024

Hey @liquidiert,

I researched this a bit today. It seems to be a caching issue related to Django's cached.Loader. For some reason, in your project configuration, it doesn't restart the server when you change single file components. It occurs when you add django-component's template_loader.Loader to the loaders but I couldn't figure out why (and I don't have enough knowledge about this topic).

There's a workaround you could use (though I didn't test it thoroughly). Only add django_components.template_loader.Loader when DJANGO_DEBUG=FALSE:

# In commons.py
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [
            # Contains plain text templates, like `robots.txt`:
            BASE_DIR
            / "templates",
        ],
        "OPTIONS": {
            "context_processors": [
                # Default template context processors:
                "django.contrib.auth.context_processors.auth",
                "django.template.context_processors.debug",
                "django.template.context_processors.i18n",
                "django.template.context_processors.media",
                "django.contrib.messages.context_processors.messages",
                "django.template.context_processors.request",
            ],
            "loaders": [
                (
                    "django.template.loaders.cached.Loader",
                    [
                        "django.template.loaders.filesystem.Loader",
                        "django.template.loaders.app_directories.Loader",
                        # "django_components.template_loader.Loader", <- Remove this
                    ],
                )
            ],
            "builtins": [
                "django_components.templatetags.component_tags",
            ],
        },
    }
]

## Append to loaders if not DEBUG
if not DEBUG:
    TEMPLATES[0]["OPTIONS"]["loaders"][0][1].append("django_components.template_loader.Loader")

I hope that helps!

from django-components.

liquidiert avatar liquidiert commented on September 21, 2024

Hey @dylanjcastillo that is really weird. But thanks for the workaround!

from django-components.

EmilStenstrom avatar EmilStenstrom commented on September 21, 2024

The cached loader shouldn't be used when developing. It makes sense that changes within templates that are cached are not reloaded. Great find Dylan, I'm closing this.

from django-components.

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.