Access Object in Navbar is Failed

i have a navbar with link sales office under contact us but i cant give it url to open this page with its view, i tried also to create a Context_processors,py but also failed.
I Hope Any One Has Any Clue To Ding After.


class Branch(models.Model):
    name = models.CharField(verbose_name='Name', max_length=255)
    region = models.CharField(verbose_name='Region', max_length=255)
    country = models.CharField(verbose_name='Country', max_length=255)
    state = models.CharField(verbose_name='State', max_length=255)
    city = models.CharField(verbose_name='City', max_length=255)
    street = models.CharField(verbose_name='Street', max_length=255)
    slug = models.SlugField(verbose_name='Slug', unique=True)
    email = models.EmailField(verbose_name='EMail', unique=True)
    website = models.URLField(verbose_name='Website')
    mobile = models.CharField(verbose_name='Mobile', max_length=255)
    phone = models.CharField(verbose_name='Phone', max_length=255)
    location = models.CharField(verbose_name='Location', max_length=255)
    image = models.ImageField(verbose_name='Image', upload_to=upload_branch_image, default=default_image)

    class Meta:
        verbose_name_plural = 'Branches'
        ordering = ['region', 'country', 'state', 'city']

    def get_absolute_url(self):
        return reverse('pages:eg_sales_office', args={'slug': str(self.slug)})

    def __str__(self):
        return f'{}'


def eg_sales_office(request, slug):
    branch = get_object_or_404(Branch, slug=slug)
    page = f'{branch} Sales Office'
    context = {'page': page, 'branch': branch}
    return render(request, 'pages/eg-sales-office.html', context)


from django.urls import path

from pages import views

app_name = 'pages'

urlpatterns = [
    path('', views.index, name='index'),
    path('development-milestone', views.development_milestone, name='development_milestone'),
    path('distributors', views.distributors, name='distributors'),
    path('faqs', views.faqs, name='faqs'),
    path('history', views.history, name='history'),
    path('international-offices', views.international_offices, name='international_offices'),
    path('our-stores', views.our_stores, name='our_stores'),
    path('projects', views.projects, name='projects'),
    path('room-concepts', views.room_concepts, name='room_concepts'),
    path('safety-cetificates', views.safety_cetificates, name='safety_cetificates'),
    path('size-guide', views.size_guide, name='size_guide'),
    path('terms-conditions', views.terms_conditions, name='terms_conditions'),
    path('timeline', views.timeline, name='timeline'),
    path('vision-mission', views.vision_mission, name='vision_mission'),
    path('why-egypt', views.why_egypt, name='why_egypt'),
    path('world-wide', views.world_wide, name='world_wide'),
    path('eg-sales-office/<slug:slug>', views.eg_sales_office, name='eg_sales_office'),

I Tried Both of These Methods For HTML

<div class="menu">
      <a class="item" href="{{ branch.get_absolute_url }}">Egypt Sales Office</a>


<div class="menu">
      <a class="item" href="{% url 'pages:eg_sales_office' slug %}">Egypt Sales Office</a>


<div class="menu">
      <a class="item" href="{% url 'pages:eg_sales_office' branch.slug %}">Egypt Sales Office</a>

So what is happening with each of these three attempts?

Examine the html that has been rendered in the browser, and show what was generated in the href attribute for each of those three different versions.

If you’re getting an error message, please post that.

I Tried Both of These Methods For HTML and Updated With Error Messages.

<div class="menu">
      <a class="item" href="{{ branch.get_absolute_url }}">Egypt Sales Office</a>

Nothing Happens to the link, like it has never got any link. just any page i am on right now.


<div class="menu">
      <a class="item" href="{% url 'pages:eg_sales_office' slug %}">Egypt Sales Office</a>


<div class="menu">
      <a class="item" href="{% url 'pages:eg_sales_office' branch.slug %}">Egypt Sales Office</a>

Same Error For 2 and 3

NoReverseMatch at /pages/

Reverse for ‘eg_sales_office’ with arguments ‘(’’,)’ not found. 1 pattern(s) tried: [‘pages/eg\-sales\-office/(?P[-a-zA-Z0-9_]+)\Z’]

i find this line in bold with 2 and 3 i don’t know if it has any clue.

amw/pages/ , line 7, in index`

def index(request):
       context = {}
       return render(request, 'pages/index.html', context)

Yes. Very important.

You’re passing an empty context to the template. None of your template variables are going to have any values.

i guess its bad to create Home Page with argument,
can i do it with Context_Processors, i already used it with Categories, i will try it and provide if any errors.

thanks alot Kan. be safe

No. I’m not sure I follow what leads you to that conclusion.

It’s a common pattern to have a home page showing a list of items, each being a link to a more detailed page.

i guess Home page view will load alot of data. but i will follow you for this .