Reverse for '' with no arguments not found.

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:

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

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

or this too

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

HTML:

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

or

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

or

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

any idea i will be thankful for

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:

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.)

Full Error:

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.

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

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

This View

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

Ok, so to confirm, this line:

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?

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

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

which use the View

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

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?

it is the navbar __Partial

 {% 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 %}

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.

Account Model:

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

{% 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.

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

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?

Yes, navbar have this tag causing error

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

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.

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.

thanks you for support, i guess this is it,