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

Django fastdev template errors on /admin route due to missing variables in the context #90

Open
jsolly opened this issue May 18, 2022 · 0 comments

Comments

@jsolly
Copy link

jsolly commented May 18, 2022

Context

I followed the documentation and configured my honeypot url. so that when the user visits /admin, their entries are logged as login attempts in the database.

I ran into template errors after I installed django-fastdev where the following template tags were missing on the admin route: subtitle, site_title, is_popup, and site_header

These are probably missing because I never configured them for my original admin page. There is a ticket about the subtitle being missing in this official Django issue.
https://code.djangoproject.com/ticket/32681

Steps to Reproduce

1 - Follow the doc and get honeypot intercepting /admin requests
2 - Visit /admin route
Admin login page shows as expected
3 - Pip install django-fastdev
4 - Visit /admin route again
Template errors occur

Workaround

I went into the admin_honeypot.views.AdminHoneyPot and added these four variables to get_context_data

    def get_context_data(self, **kwargs):
        context = super(AdminHoneypot, self).get_context_data(**kwargs)
        path = self.request.get_full_path()
        context.update({
            'app_path': path,
            REDIRECT_FIELD_NAME: reverse('admin_honeypot:index'),
            'title': _('Log in'),
            'subtitle': None, # added
            'site_title': None, # added
            'is_popup': None, # added
            'site_header': None # added

        })
        return context

Now when I visit /admin I don't have any more template errors

Environment

django-fastdev 1.7.2
Python 3.9.7
Django 3.2.13

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

1 participant