Giter Site home page Giter Site logo

SITE_ID dependancy. about django-dbtemplates HOT 4 OPEN

jazzband avatar jazzband commented on May 31, 2024
SITE_ID dependancy.

from django-dbtemplates.

Comments (4)

mpasternak avatar mpasternak commented on May 31, 2024 1

Hi @bahoo , from what I understand, you happen to have a non-SITE_ID dependent branch of dbtemplates? Would you mind submitting a PR against the current codebase?

from django-dbtemplates.

bahoo avatar bahoo commented on May 31, 2024

This is an old issue but I'm running into something similar, and found @iraabbott's two threads on the Django developer's group, which hopefully Ira doesn't mind my linking here directly!

I think it's a fix worth having the option for. I would also broadly suggest, Django's codebase is updated much more frequently than dbtemplates's is ( as of this writing, the last release was nearly two years ago ). So it probably makes sense to fork dbtemplates, and maybe pipenv install from a version control system as laid out here ( or hey, propose a PR to the project directly; I'd 👍 it ). Patching the smaller package probably helps with the principle of least astonishment, but I could be wrong on that. 💁‍♂️

I'm probably going to make a run of addressing this, but spitballing a bit myself / capturing my thoughts in case I don't get to it soon — I think even just patching this line in dbtemplates/loader.py to fall back more intelligently is probably the path of least resistance, maybe in cooperation with some of this middleware to store the current request. e.g.:

from django.core.exceptions import ImproperlyConfigured
from django_middleware_global_request.middleware import get_request

# ...

   try:
      site = Site.objects.get_current()
   except ImproperlyConfigured:
      request = get_request()
      site = Site.objects.get_current(request=request)

   print("and Bob's your uncle.")
     

Thank you for looking so far into this! Will follow up here as I get some working software ready. :D

from django-dbtemplates.

bahoo avatar bahoo commented on May 31, 2024

Will give this a few days for more changes before I press the issue, but for anyone curious: https://github.com/bahoo/django-dbtemplates

from django-dbtemplates.

guettli avatar guettli commented on May 31, 2024

This could be solved via https://pypi.org/project/django-middleware-global-request/

With a global request, the code could always use Site.objects.get_current(request)

from django-dbtemplates.

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.