This can be done easily if you make a proper view function and render data
from it in template properly.
A view function can be written like this :-

Here I am assuming that you want get the details of all the books/auuthors
at one page. If you want details of a particular book, then the following
function will be different.

from .models import Details, Author, Books
from django.shortcuts import render

view.py :-
def getdetails(request):
template_name = 'showDetails.html'
objs = Details.objects.all()
context = {'objs; : objs}
return render(request, template_name, context}


showDetails.html :-
(use this block in your html code wherever you want to show this data)

{% if objs %}

<table>
<tr>
<th>Author</th>
<th>Book</th>
</tr>

{% for obj in objs %}
<tr>
  <td>{{ obj.author_name }} </td>
  <td>{{ obj.book_name }} </td>
</tr>
{% endfor %}
</table>

{% endif %}

(In above html code, I have assumed that author_name and book_name are the
FK in your Details table. Also, I am not sure


On Wed, Sep 4, 2019 at 1:34 PM Lim Kai Wey <[email protected]> wrote:

> Hey Amit,
>
> I suggest you to follow this tutorial to build your project,
>
> https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Tutorial_local_library_website
>
> It teaches you all the basics that you need to know from scratch, which in
> my opinion will answer all the questions you're asking.
> The tutorial is about building a local library webpage which I believe is
> very similar to what you are doing now.
>
> Hope this helps.
>
> Regards,
> Kai Wey
>
> On Wed, Sep 4, 2019 at 3:59 PM Amit Samanta <[email protected]>
> wrote:
>
>> now how can i get the name for author and details??
>>
>> On Wed, 4 Sep, 2019, 10:25 AM Bhoopesh sisoudiya, <[email protected]>
>> wrote:
>>
>>> Hi Amit,
>>>
>>> You can use
>>> =================≠=====================
>>> Book.objects.select_related(FK).select_related(FK). values (select
>>> column name which you want).all()
>>>
>>>
>>> Thanks
>>> Bhoopesh sisoudiya
>>>
>>> On Wed, Sep 4, 2019, 9:38 AM Amit Samanta <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I need help i am not understanding the keywords of joining and fetch
>>>> value in veiw.py
>>>> i have three tables in model.py
>>>>
>>>> Table 1(Author) :
>>>>
>>>> Table 2(books):
>>>>
>>>> Table 3 (details):
>>>> FK of table1
>>>> FK of table2
>>>>
>>>> Fk = foreign key
>>>>
>>>> I have to just show
>>>>
>>>> Author (author name)     Books (dynamic)     Books(author 2nd book)
>>>>        ...
>>>>                                         details(dynamic)
>>>>  details(dtl of author 2nd book) ...
>>>>
>>>> I have created the template
>>>>
>>>> now in views.py i an confused
>>>>
>>>> book=books.object(i do not get what to do)
>>>> Author= (same )
>>>> details = (same)
>>>>
>>>> Please can anybody help that will be very greatfull.
>>>> Thank you in advance
>>>>
>>>>
>>>>
>>>> Thanks and Regards
>>>> Amit Samanta
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/54483cc3-eadd-4559-8c61-c179cfbab933%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/54483cc3-eadd-4559-8c61-c179cfbab933%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAAk3c1OzGXKSQg8GK1C8_5Ck-iQ%2B1WjsYMdD%2B%2B0_q3inb94jyw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAAk3c1OzGXKSQg8GK1C8_5Ck-iQ%2B1WjsYMdD%2B%2B0_q3inb94jyw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAP4hbAY%3DvOB%2BEs6hZ77jcAU_-LuuG51LkqEPU3eB5nrgqS48ow%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAP4hbAY%3DvOB%2BEs6hZ77jcAU_-LuuG51LkqEPU3eB5nrgqS48ow%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPcVkjg11EAf-rYFvoz85Y5BLKBisD4FJQSOCzonzi0TFC91ZQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPcVkjg11EAf-rYFvoz85Y5BLKBisD4FJQSOCzonzi0TFC91ZQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
*Anirudh Jain* | *Appreciate you taking time to read the mail.*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAC3mK7diFxarM6W-Tv-wT-sFZz6A46brHP%2Bjo772jKcn_qjbJQ%40mail.gmail.com.

Reply via email to