AttributeError: 'NoneType' object has no attribute 'lower'. for django-comments-dab app

Question:

I want to use django-comments-dab but I meet this Error,
AttributeError: ‘NoneType’ object has no attribute ‘lower’.
Request Method: GET
Request URL: http://127.0.0.1:8000/2020/9/6/test4
Django Version: 3.1.1
Exception Type: AttributeError
Exception Value:
‘NoneType’ object has no attribute ‘lower’
Exception Location: D:amirblogvenvlibsite-packagescommentutils.py, line 26, in get_model_obj
Python Executable: D:amirblogvenvScriptspython.exe

utils.py

def get_model_obj(app_name, model_name, model_id):
    content_type = ContentType.objects.get(app_label=app_name, model=model_name.lower())
    model_object = content_type.get_object_for_this_type(id=model_id)

    return model_object
Asked By: shayan

||

Answers:

model_name is None and not a string. Only strings have the lower method defined for them. Try print(model_name) and print(type(model_name)) to see that this is the case, and then fix whatever is calling get_model_obj to pass in a string.

Answered By: rlchqrd

Just fixed mine now the {% render comment obj request %} should not be so only if you are using a class view should and what you are passing to the context is obj that’s when it should be {% render comment obj request%} but if just change it to whatever you passed in your context did it and it work fined for me like this:

{% comment %} call comment app tags {% endcomment %}
{% render_comments post request %}
Answered By: Damilare Onifade
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.