# filter database

**URL:** <https://forum.djangoproject.com/t/filter-database/3341>\
**Category:** Using Django\
**Created:** [July 8, 2020, 2:07am UTC](https://forum.djangoproject.com/t/filter-database/3341 "2020-07-08T02:07:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![junaooaks](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/junaooaks/32/1607_2.png) [@junaooaks](https://forum.djangoproject.com/u/junaooaks)\
**Post date:** [July 8, 2020, 2:07am UTC](https://forum.djangoproject.com/t/filter-database/3341/1 "2020-07-08T02:07:08Z")

</div>

Hey guys Im new in Python django

how can I use filter with 2 table

I have table:  
book(name, description, author\_id)  
author(firstName, lastName)

in my views, I need to filter for I can get author-name

def get\_queryset(self):  
author = Author.object.filter(id = author\_id)

how can I create the relationship and get the author’s name?

---

<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:** [July 8, 2020, 3:03am UTC](https://forum.djangoproject.com/t/filter-database/3341/2 "2020-07-08T03:03:41Z")

</div>

A good place to start is with the appropriate documentation, in this case, the query documentation on [Retrieving objects](https://docs.djangoproject.com/en/3.0/topics/db/queries/#retrieving-objects), the [Lookup API Reference](https://docs.djangoproject.com/en/3.0/ref/models/lookups/#module-django.db.models.lookups), and the [Related Objects Reference](https://docs.djangoproject.com/en/3.0/ref/models/relations/#related-objects-reference).

If you’re not comfortable with these topics, then I’d recommend going back to basics and working your way through either or both of the official [Django Tutorial](https://docs.djangoproject.com/en/3.0/intro/tutorial01/), and the [Django Girls Tutorial](https://tutorial.djangogirls.org/en/#django-girls-tutorial).

Ken
