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

TemplateDoesNotExist at /admin/homepage/homepage/1/change/ #38

Open
ursomniac opened this issue Jan 31, 2019 · 4 comments
Open

TemplateDoesNotExist at /admin/homepage/homepage/1/change/ #38

ursomniac opened this issue Jan 31, 2019 · 4 comments

Comments

@ursomniac
Copy link

ursomniac commented Jan 31, 2019

I'm having problem getting this to work. I've used this package elsewhere with no problems. What's different is: 1) I'm using Python 3.7 + Django 2.1; 2) the model in question also subclasses another class that alters the default ModelAdmin - but I don't see how either of these should affect it not finding the modelclone/change_form.html.

It appears that Django is not trying to locate the template within site-packages:

Django tried loading these templates, in this order:
Using engine django:

django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django/contrib/admin/templates/modelclone/change_form.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django/contrib/auth/templates/modelclone/change_form.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django_extensions/templates/modelclone/change_form.html (Source does not exist)

TEMPLATES in the settings.py is:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

and the admin.py's class is:

from django.contrib import admin
import modelclone
from gatekeeper.admin import GatekeeperSerialAdmin
from .models import Homepage

class HomepageAdmin(modelclone.ClonableModelAdmin, GatekeeperSerialAdmin):
    model = Homepage
    
admin.site.register(Homepage, HomepageAdmin)

I could make it work by explicitly adding
'/usr/local/lib/python3.7/site-packages/modelclone/templates' to the DIRS list in TEMPLATES, but that's not a workable solution if the server setup changes.

Actually - that didn't quite work: you can bring up the instance in the Admin and there's a "duplicate" button. When you click it, the duplicate admin comes up but there's no "save" button, just "close".

Any suggestions/ideas or pointing out where I screwed up :-) would be greatly appreciated.

@igorsobreira
Copy link
Contributor

Hi @ursomniac, is modelclone in your INSTALLED_APPS?

@ursomniac
Copy link
Author

Yup it's in INSTALLED_APPS. It's weird because I've used this code in other projects without any problems, even ones where I installed it LONG into the development cycle (so if there would be the potentials for conflcts it would be then). This time, I'm starting with a blank slate (so the environment is pretty much out of the box), and it's just not happy.

@ursomniac
Copy link
Author

screen shot 2019-02-01 at 09 24 30

This is the intermediate step screen (i.e., I've clicked on the "Duplicate" button.
As you can see, there's no way to save this object. The only option is "close".
Please advise.

@xingfukun
Copy link

Is there any progress on this issue?

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

3 participants