How to get element name in Django in the back-end ?

Hi i want the title name so i can use it for searching the database to show more similar items.

this is what i have tried so far but it does not print out the title name in the terminal.

class PostDetailView(DetailView):
    model = retailer
    template_name = 'testing/detail.html'

    def get_title(self):

    	title = self.request.GET.get("title")

    	if title:


My html Page:

<div class = "Main-Image">
  	<a href="{% url 'Detail-Page' object.slug %}">  <img src = "{{object.image.url}}" > </a>


<div class = "Main-Title" name = "title">

Please Help, Thanks :slight_smile:

How are you trying to pass the title to the view? What is the url on the page that is supposed to invoke that view? What is the definition of that url in your file? What does the rest of that view look like?

If you’re going to work with the Django generic Class-Based Views, you will need to become familiar with how they work and how you extend them.


hi my urls look like this,

path("<slug:slug>/", PostDetailView.as_view(), name = 'Detail-Page'),

the views look the same as above

The parameter then that you are passing to the view is named “slug”. The get_object method of a DetailView retrieves the object for you.
That means that in the other methods within that view, you have access to self.object.