bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.46k stars 424 forks source link

FilesystemLoader object has no attribute 'get_contents' #579

Open LorisLunedei opened 6 years ago

LorisLunedei commented 6 years ago

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',
            ],
        },
    },
]
jcass77 commented 6 years ago

I have made an attempt to fix this over at the django-tenants project: see https://github.com/tomturner/django-tenants/pull/198.

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

gnalbandian commented 5 years ago

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

pmourelle commented 5 years ago

~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 commented 5 years ago

Here's a PR with code brought from django-tenants that works fine and it's enough for us to keep working with dts: https://github.com/bernardopires/django-tenant-schemas/pull/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 commented 5 years ago

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

pmourelle commented 5 years ago

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.