Reverse for 'login' not found. 'login' is not a valid view function or pattern name.

How are you creating these entries? Is that a separate view and form? (You don’t need to post them, I’m just wondering how you’re populating your data.)

And what is generate_slug?

Also, since you’re relying upon slug having a value, you should probably remove the null=True and blank=True attributes from the field.

Here is what am getting after checking primary key and slug field

>>> from Blog.models import BlogModel
>>> [(b.id, b.slug) for b in BlogModel.objects.all()]
[(3, 'how-to-become-a-better-web-developer')]

generate_slug is from a helpers.py file that automatically generates slug from the title.

1 Like

That template you posted in your first reply; is that the complete “blog.html” template file, or is it just a portion of the template file, or is it a template file that is being included by “blog.html”?

It is the part of the template that is getting data from the back end.

I’m not seeing anything wrong with the information you’ve posted so far.

The next thing I’d check - trying to identify where the error is happening, would be to replace this part of your template:

With this:

==={{ blog.slug }}===

The equal signs create a “fence” for the visual representation of the blog.slug field - this lets you see whether blog.slug is being identified correctly within the template, hopefully preventing the error from appearing but giving you visual confirmation of that field within the template.

Just found out what was causing the error.

There was a part of the template I had commented with this code:

<a href="{% url 'blogdetail' %}" class="btn">
     Read More
</a>

Instead of

<a href="{% url 'blogdetail' blog.slug %}" class="btn">
     Read More
</a>
1 Like

Glad you found it!

-Jorge

Had similar issues and googled it and here I am! The community is so helpful and has been helping me through my journey of learning. Thanks alot!