djangodjango-messages

render() got an unexpected keyword argument 'renderer'


I'm trying to use django-messages to enable user to user messaging on my website.

when I'm setting it up, I encountered this error when I'm trying to access the compose page.

TypeError at /messages/compose/
render() got an unexpected keyword argument 'renderer'

Upon checking the logs, it points to the package's render function in one of the files. the code is

return render(request, template_name, {'form': form})

I checked on this answer also here on SO: Django TypeError: render() got an unexpected keyword argument 'renderer'. I tried adding the other parameters but it seems the additional parameters are not being recognized as well. it is saying that attrs and renderer are unrecognized parameters.

I'm also using django 2.2 version so I'm thinking it's not with the backwards compatibility issue.

The weird thing is, I have another file the uses the render function the same way, and it works alright.

also, as suggested from the link I referenced, is to check the widgets.py file which I did, and here's how it looks

def render(self, name, value, attrs=None, renderer=None):
    print('I got called yo')
    """Render the widget as an HTML string."""
    context = self.get_context(name, value, attrs)
    return self._render(self.template_name, context, renderer)

It just got me more confused sorry.

as per the widgets file, the attrs and renderer params should be known. but why does it appear to be unrecognized?

here's the code from django-messages and my code that works ok

return render(request, template_name, {'form': form}) # django messages, template name is declared at the start of the function: template_name='django_messages/compose.html'
return render(request, "sendemail/email.html", {'form': form}) # from my code to send email

also the way I imported is the same on both files that use the render command

from django.shortcuts import render

maybe I have a much deeper error that I need to check?


Solution

  • as arneb mentioned, I had to install the github master version https://github.com/arneb/django-messages/issues/146#issuecomment-647485205