Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilesystemLoader object has no attribute 'get_contents' #579

Open
LorisLunedei opened this issue Oct 29, 2018 · 6 comments
Open

FilesystemLoader object has no attribute 'get_contents' #579

LorisLunedei opened this issue Oct 29, 2018 · 6 comments

Comments

@LorisLunedei
Copy link

Hi, I'm using Django 2.1.2 and I have problems with the 'Specializing templates based on tenants' feature.
When I add the tenant_schemas.template_loaders.FilesystemLoader loader I receive this error:
'FilesystemLoader' object has no attribute 'get_contents'

It seems that in the newest django versions loader mechanism is changed a little (or I'm doing something wrong?).

That's my template configuration:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'OPTIONS': {
            'loaders': [
                'tenant_schemas.template_loaders.FilesystemLoader',
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader'
            ],
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
@LorisLunedei LorisLunedei changed the title FilesystemLoader' object has no attribute 'get_contents FilesystemLoader object has no attribute 'get_contents' Oct 29, 2018
@jcass77
Copy link

jcass77 commented Nov 2, 2018

I have made an attempt to fix this over at the django-tenants project: see django-tenants/django-tenants#198.

You might be able to re-use parts of that to create a pull request for this project as well.

@gnalbandian
Copy link

Having the same issue wen trying to use 'per tenant templates'

@pmourelle
Copy link

pmourelle commented Nov 14, 2019

Hi folks. Any news on this?
I got it finally working on django2.2. One thing I'm still struggling with is - I think - wsgi configuration in local environment. Template dirs get updated only on server restart so on first request, given tenant's template rendered is the same for all tenants.

@pmourelle
Copy link

Here's a PR with code brought from django-tenants that works fine and it's enough for us to keep working with dts: #608.

As a side question: porting to django-tenants seems the step to go as dts looks abandoned but had no time yet to check on needed changes. @goodtune @bernardopires thoughts on this? D-t-s should officially step aside in favor of d-t?

@goodtune
Copy link
Collaborator

No need to step aside, users already have freedom of choice.

@pmourelle
Copy link

Sure thing. Cheers to that. That being said, if project is not on development nor maintenance any more, a note with link to <project currently active at the moment> in the readme would be much appreciated by people looking for a tenant solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants