[Django]-NoReverseMatch at / Reverse for 'profile' with arguments '('',)' not found. 1 pattern(s) tried: ['profile/(?P<name>[^/]+)/$']

6👍

It looks like the error is occurring with

<a href="{% url 'profile' post.author.username %}">

Make sure that each of these posts that you are looping through actually has an author and that each author has a username. Django won’t be able to properly construct the url if post.author.username is None.

1👍

in this url : path("profile/str:name/", views.profile, name="profile")

do you have an view called profile?

and what does name in str:name refer to? username maybe? or author

you need to provide more details,

1👍

This is because you have an project with author I faced the similar issue.

0👍

Maybe you need to check your admin panel if there is a post without author that’s probably the problem

👤mahdi

0👍

NoReverseMatch at / Reverse for ‘profile’ with arguments ‘(”,)’ not found. 1 pattern(s) tried: [‘profile/(?P[^/]+)/$’]

It’s means something missing in database thats you are working for in loops .Django won’t be able to properly construct the url if somthing is blank. First go to the Django admit panel and find whats are missing.Example:Author,User,Admin etc.

0👍

If you define a post without assigning a profile (owner) to it, you get this error. in other words, something that Django wants (in your database) is blank!

You must go to the admin panel and check all posts that are defined, None of them should be without an owner.

Leave a comment