# Reverse for '' with no arguments not found.

**URL:** <https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318>\
**Category:** Templates & Frontend\
**Created:** [June 16, 2022, 10:47am UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318 "2022-06-16T10:47:20Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![AhmdMWddh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmdmwddh/32/21707_2.png) [@AhmdMWddh](https://forum.djangoproject.com/u/AhmdMWddh)\
**Post date:** [June 16, 2022, 10:47am UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/1 "2022-06-16T10:47:20Z")

</div>

I Keep Getting This Error,  
As i learn about the error it appears when i pass slug incorrectly into `urls` or into `views`.  
and i am using `DetailView`.

Views:

```auto
class ClientDetailView(DetailView):
    model = Account
    context_object_name = 'account'
    template_name = 'Accounts/Client_Info.html'

    def get_context_data(self, **kwargs):
        context = super(ClientDetailView, self).get_context_data(**kwargs)
        account = Account.objects.get(slug=self.kwargs['slug'])
        context['account'] = account
        context['page'] = account.full_name
        return context

```

Urls: I Used This

```auto
path('client-detail/<slug>', views.ClientDetailView.as_view(), name='ClientDetailUrl'),

```

or this too

```auto
path('client-detail/<slug:slug>', views.ClientDetailView.as_view(), name='ClientDetailUrl'),

```

HTML:

```auto
<a href="{% url 'Accounts:ClientDetailUrl' account.slug %}">{{ account.full_name }}</a>

```

or

```auto
<a href="{% url 'Accounts:ClientDetailUrl' slug %}">{{ account.full_name }}</a>

```

or

```auto
<a href="{% url 'Accounts:ClientDetailUrl' slug=account.slug %}">{{ account.full_name }}</a>

```

any idea i will be thankful for

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 16, 2022, 11:02am UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/2 "2022-06-16T11:02:32Z")

</div>

One of the easiest ways to verify that you’re getting the data in the template that you’re expecting to see is to replace the `a` tag with just a simple display of the value that you’re using.

In this case, you can replace:

> [@AhmdMWddh](#):
>
> `<a href="{% url 'Accounts:ClientDetailUrl' account.slug %}">{{ account.full_name }}</a>`

with:  
`## {{ account.slug }} ## {{ account.full_name }} ##`  
You won’t get a link, but you’ll get the data being found displayed directly on the page, avoiding the error message.

(Also, it helps if you post the complete error message and not just a summary.)

---

<div class="post-metadata">

**Author:** ![AhmdMWddh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmdmwddh/32/21707_2.png) [@AhmdMWddh](https://forum.djangoproject.com/u/AhmdMWddh)\
**Post date:** [June 16, 2022, 11:55am UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/3 "2022-06-16T11:55:38Z")

</div>

Full Error:

```auto
Reverse for 'ClientDetailUrl' with arguments '('',)' not found. 1 pattern(s) tried: ['accounts/client\\-detail/(?P<slug>[^/]+)\\Z']

```

I found the problem within `account object`  
it works as `request.user` but `account` does not working.  
i tried to print account on DetailView but i also did not work.  
Note:  
this works.

```auto
<a href="{% url 'Accounts:ClientDetailUrl' request.user.slug %}">{{ request.user.full_name }}</a>

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 16, 2022, 12:01pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/4 "2022-06-16T12:01:26Z")

</div>

What is the view that is generating the page that is trying to render this link? _That_ is the view we need to see.

---

<div class="post-metadata">

**Author:** ![AhmdMWddh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmdmwddh/32/21707_2.png) [@AhmdMWddh](https://forum.djangoproject.com/u/AhmdMWddh)\
**Post date:** [June 16, 2022, 12:24pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/5 "2022-06-16T12:24:40Z")

</div>

This View

```auto
class ClientDetailView(DetailView):
    model = Account
    context_object_name = 'account'
    template_name = 'Accounts/Client_Info.html'

    def get_context_data(self, **kwargs):
        context = super(ClientDetailView, self).get_context_data(**kwargs)
        account = Account.objects.get(slug=self.kwargs['slug'])
        context['account'] = account
        context['page'] = account.full_name
        return context

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 16, 2022, 12:29pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/6 "2022-06-16T12:29:42Z")

</div>

Ok, so to confirm, this line:

> [@AhmdMWddh](#):
>
> `<a href="{% url 'Accounts:ClientDetailUrl' account.slug %}">{{ account.full_name }}</a>`

is in the file named `Accounts/Client_Info.html`, which is being rendered in a view named ClientDetailView - so in other words, you’re linking the page to itself.

How are you navigating to that page?

---

<div class="post-metadata">

**Author:** ![AhmdMWddh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmdmwddh/32/21707_2.png) [@AhmdMWddh](https://forum.djangoproject.com/u/AhmdMWddh)\
**Post date:** [June 16, 2022, 12:38pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/7 "2022-06-16T12:38:20Z")

</div>

I dont think i did understand that,  
but i can confirm this  
this link goes to the account page when click,

it use this Url to get the account slug

```auto
<a href="{% url 'Accounts:ClientDetailUrl' account.slug %}">{{ account.full_name }}</a>

```

which use the View

```auto
class ClientDetailView(DetailView):
    model = Account
    context_object_name = 'account'
    template_name = 'Accounts/Client_Info.html'

    def get_context_data(self, **kwargs):
        context = super(ClientDetailView, self).get_context_data(**kwargs)
        account = Account.objects.get(slug=self.kwargs['slug'])
        context['account'] = account
        context['page'] = account.full_name
        return context

```

to render HTML page in Folder Accounts in Templates folder with name `Client_Info.html`

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 16, 2022, 12:40pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/8 "2022-06-16T12:40:05Z")

</div>

I don’t care about what that link is referring to.

I’m only concerned about the view and page that first takes you to ClientDetailView.

What is the page / view that you are looking at when you click on something to take you to ClientDetailView?

---

<div class="post-metadata">

**Author:** ![AhmdMWddh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmdmwddh/32/21707_2.png) [@AhmdMWddh](https://forum.djangoproject.com/u/AhmdMWddh)\
**Post date:** [June 16, 2022, 12:43pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/9 "2022-06-16T12:43:09Z")

</div>

it is the navbar \_\_Partial

```auto
 {% if request.user.is_authenticated %}
                <div class="ui left dropdown item Account_DropDown">
                    <i class="user circle large icon"></i>
                    <div class="menu">
                        <div class="item">
                            <a href="{% url 'Accounts:ClientDetailUrl' request.user.slug %}">{{ request.user.full_name }}</a>
                        </div>
                        <div class="item">
                            <a href="{% url 'Accounts:ClientSignOutUrl' %}">Logout</a>
                        </div>
                    </div>
                </div>
                {% else %}
                <div class="item">
                    <a href="{% url 'Accounts:ClientSignUpUrl' %}">
                        <i class="user icon"></i>
                    </a>
                </div>
                {% endif %}

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 16, 2022, 12:51pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/10 "2022-06-16T12:51:21Z")

</div>

What does your Account model look like?

Is this the _complete_ view? (Have you overridden any other methods in that class?)

We may need to see the complete template as well.

---

<div class="post-metadata">

**Author:** ![AhmdMWddh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmdmwddh/32/21707_2.png) [@AhmdMWddh](https://forum.djangoproject.com/u/AhmdMWddh)\
**Post date:** [June 16, 2022, 12:56pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/11 "2022-06-16T12:56:52Z")

</div>

Account Model:

```auto
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin
from django.urls import reverse
from django.utils.text import slugify

class AccountManager(BaseUserManager):
    def create_user(self, email, first_name, last_name, password=None):
        if not email:
            raise ValueError('E-Mail is Required, Please Provide Your E-Mail.')
        if not first_name:
            raise ValueError('E-Mail is Required, Please Provide Your First Name.')
        if not last_name:
            raise ValueError('E-Mail is Required, Please Provide Your Last Name.')
        user = self.model(email=self.normalize_email(email).lower(), first_name=first_name, last_name=last_name)
        user.set_password(password)
        user.save(using=self._db)
        return user

    def create_superuser(self, email, first_name, last_name, password=None):
        user = self.create_user(email=self.normalize_email(email), first_name=first_name, last_name=last_name,
                                password=password)
        user.is_staff = True
        user.is_superuser = True
        user.save(using=self._db)
        return user

class Account(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(verbose_name='email', max_length=255, unique=True)
    first_name = models.CharField(verbose_name='First Name', max_length=255)
    last_name = models.CharField(verbose_name='Last Name', max_length=255)
    slug = models.SlugField(verbose_name='Slug', primary_key=True, unique=True, allow_unicode=True)
    date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=True)
    last_login = models.DateTimeField(verbose_name='last login', auto_now=True)
    is_active = models.BooleanField(default=True)
    is_staff = models.BooleanField(default=False)
    is_superuser = models.BooleanField(default=False)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['first_name', 'last_name']

    objects = AccountManager()

    @property
    def full_name(self):
        return f'{self.first_name} {self.last_name}'

    def __str__ (self):
        return f'{self.email} - {self.full_name}'

    def has_perm(self, perm, obj=None):
        return self.is_staff

    def has_module_perms(self, app_label):
        return True

    def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = slugify(f'{self.first_name}-{self.email}-{self.last_name}')

        super(Account, self).save(*args, **kwargs)

```

Navbar \_\_Partial

```auto
{% load static %}
<div class="ui grid">
    <div class="column">
        <div class="ui borderless top fixed stackable menu">
            <a class="item" href="{% url 'Pages:HomeView' %}">
                <img src="{% static 'Imgs/Anonymus.png' %}"/>
            </a>
            <div class="ui simple dropdown item">
                About Us
                <i class="dropdown icon"></i>
                <div class="menu">
                    <a class="item" href="{% url 'Pages:HistoryView' %}">History</a>
                    <a class="item" href="{% url 'Pages:SafetyCertificateView' %}">Safety & Certificates</a>
                </div>
            </div>
            <div class="ui simple dropdown item">
                <div>Shop</div>
                <i class="dropdown icon"></i>
                <div class="menu">
                    <a class="item" href="#">Category Name</a>
                    <a class="item" href="#">Category Name</a>
                    <a class="item" href="#">Category Name</a>
                </div>
            </div>
            <div class="ui simple dropdown item">
                Inspiration
                <i class="dropdown icon"></i>
                <div class="menu">
                    <a class="item" href="{% url 'Pages:DevelopmentMilstoneView' %}">Child Development Milestone</a>
                    <a class="item" href="{% url 'Pages:RoomConceptView' %}">Room Concept</a>
                    <a class="item" href="{% url 'Pages:SizeGuideView' %}">Size Guide</a>
                    <a class="item" href="{% url 'Pages:ProjectsView' %}">Projects</a>
                    <a class="item" href="{% url 'Pages:TimelineView' %}">Timeline</a>
                </div>
            </div>
            <a class="item" href="{% url 'Pages:OurStoresView' %}">Our Stores</a>
            <a class="item" href="{% url 'Pages:DistributorsView' %}">Distributors</a>
            <div class="ui simple dropdown item">
                Support
                <i class="dropdown icon"></i>
                <div class="menu">
                    <a class="item" href="{% url 'Pages:FAQsView' %}">FAQs</a>
                    <a class="item" href="{% url 'Pages:TermsConditionsView' %}">Terms & Conditions</a>
                </div>
            </div>
            <div class="ui simple dropdown item">
                Contact Us
                <i class="dropdown icon"></i>
                <div class="menu">
                    <a class="item" href="{% url 'Pages:SalesOfficesView' %}">Sales Offices</a>
                    <a class="item" href="{% url 'Pages:WorldWideView' %}">Representative Worldwide</a>
                </div>
            </div>
            <a class="item" href="{% url 'admin:index' %}">Admin</a>
            <div class="right menu">
                <form class="vertically fitted item ui form" method="POST" action="">
                    {% csrf_token %}
                    <div class="field">
                        <div class="ui icon input">
                            <input type="text" name="navbar_search_input" placeholder="Search Toys...">
                            <i class="circular search link icon"></i>
                        </div>
                    </div>
                </form>
                {% if request.user.is_authenticated %}
                <div class="ui left dropdown item Account_DropDown">
                    <i class="user circle large icon"></i>
                    <div class="menu">
                        <div class="item">
                            <a href="{% url 'Accounts:ClientDetailUrl' request.user.slug %}">{{ request.user.full_name }}</a>
                        </div>
                        <div class="item">
                            <a href="{% url 'Accounts:ClientSignOutUrl' %}">Logout</a>
                        </div>
                    </div>
                </div>
                {% else %}
                <div class="item">
                    <a href="{% url 'Accounts:ClientSignUpUrl' %}">
                        <i class="user icon"></i>
                    </a>
                </div>
                {% endif %}
                <div class="item ui label">
                    <a href="#" class="ui label">
                        <i class="shopping cart large icon"></i> 5
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

```

Views.py: i didnt override any other methods inside this Class.

```auto
from django.views.generic import CreateView
from django.views.generic.detail import DetailView
from django.contrib.auth.views import LogoutView, LoginView
from django.urls import reverse_lazy
from Accounts.forms import ClientSignUpForm, ClientSignInForm
from Accounts.models import Account

class ClientSignUpView(CreateView):
    template_name = 'Accounts/Sign_Up.html'
    form_class = ClientSignUpForm

    def get_success_url(self):
        return reverse_lazy('Accounts:ClientSignInUrl')

    def get_context_data(self, **kwargs):
        context = super(ClientSignUpView, self).get_context_data(**kwargs)
        context['page'] = 'Sign Up'
        return context

class ClientSignInView(LoginView):
    template_name = 'Accounts/Sign_In.html'
    form_class = ClientSignInForm

    def get_context_data(self, **kwargs):
        context = super(ClientSignInView, self).get_context_data(**kwargs)
        context['page'] = 'Sign In'
        return context

class ClientSignOutView(LogoutView):
    next_page = reverse_lazy('Accounts:ClientSignInUrl')

class ClientDetailView(DetailView):
    model = Account
    context_object_name = 'account'
    template_name = 'Accounts/Client_Info.html'

    def get_context_data(self, **kwargs):
        context = super(ClientDetailView, self).get_context_data(**kwargs)
        account = Account.objects.get(slug=self.kwargs['slug'])
        context['account'] = account
        context['page'] = account.full_name
        return context

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 16, 2022, 1:05pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/12 "2022-06-16T13:05:20Z")

</div>

I’m still confused here.

This Navbar template, is _this_ the template file containing the `a` tag that is causing the error?

If so, how are you **first** getting to _any_ page that is rendering this template?

---

<div class="post-metadata">

**Author:** ![AhmdMWddh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmdmwddh/32/21707_2.png) [@AhmdMWddh](https://forum.djangoproject.com/u/AhmdMWddh)\
**Post date:** [June 16, 2022, 1:18pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/13 "2022-06-16T13:18:34Z")

</div>

Yes, navbar have this tag causing error

this is home view that render home page if it has any information will be useful

```auto
class HomeView(TemplateView):
    template_name = 'Home.html'

    def get_context_data(self, **kwargs):
        context = super(HomeView, self).get_context_data(**kwargs)
        context['page'] = 'Home'
        return context

```

but i think the error in `ClientDetailView`  
i think it does not get the account object, because this error not showing when i am using `request.user` instead of `account`.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 16, 2022, 1:25pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/14 "2022-06-16T13:25:52Z")

</div>

The issue is that your HomeView is trying to render that template without providing anything in the context for the `account` that the tag is trying to reference. There may still be a problem in ClientDetailView, but that would be a different issue.

You’re passing an Account in _that_ view to your context, but you are not supplying an Account object _here_.

---

<div class="post-metadata">

**Author:** ![AhmdMWddh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmdmwddh/32/21707_2.png) [@AhmdMWddh](https://forum.djangoproject.com/u/AhmdMWddh)\
**Post date:** [June 16, 2022, 1:36pm UTC](https://forum.djangoproject.com/t/reverse-for-with-no-arguments-not-found/14318/15 "2022-06-16T13:36:51Z")

</div>

thanks you for support, i guess this is it,
