Re: Access data associated to a primary key

2017-10-03 Thread tango ward
thanks Gourav. I really appreciate your inputs. On Tue, Oct 3, 2017 at 9:16 PM, Gourav Chawla < gauravchawla.chawla...@gmail.com> wrote: > Glad, you worked it out. You can use them whenever you want. Function > based views require you to write more code but give you more clarity on > what's

Re: Access data associated to a primary key

2017-10-03 Thread Gourav Chawla
Glad, you worked it out. You can use them whenever you want. Function based views require you to write more code but give you more clarity on what's happening. On the other hand CBV help you keep the codebase cleaner. At the end of the day, it's you who has to decide what to use. -- You

Re: Access data associated to a primary key

2017-10-02 Thread tango ward
Holy .. it works! I have to access the Team_Name class using the 'related_name=regions' and from that, I was able to access the logo attributes of Team_Name. Here's what I did. {% block body_block %} {% for region in regions_detail.regions.all %}

Re: Access data associated to a primary key

2017-10-02 Thread tango ward
Hi Gourav, thanks for the input. Just a question, Can I iterate through the Team_Region to get the teams listed under the specific id? or shall I do it in Team_Member class? This is for the DetailView. On Mon, Oct 2, 2017 at 9:31 PM, Gourav Chawla < gauravchawla.chawla...@gmail.com> wrote: >

Re: Access data associated to a primary key

2017-10-02 Thread Gourav Chawla
You can create another url, view, template to do that. Just create a url like : team/id For the above url create a view, say, teams_under_region which accepts the 'id'. Based on that id you can then query your database for teams where region_member=id. This is just the approach you would

Access data associated to a primary key

2017-10-02 Thread tango ward
Hi guys, I just want to know how to access and load the data associated to a primary key in a template. models.py class Team_Region(models.Model): name = models.CharField(max_length=50) # String representation def __str__(self): return self.name class