On Wednesday 24 May 2017 09:38:08 jorge alarcon wrote:
> where as my current view is:
>
> class IndexView(generic.ListView):
>
> template_name = "db/index.html"
>
> paginate_by = 50
>
> context_object_name = 'Columns'
>
> queryset = Columns.objects.all()
>
>
> However, this gives me entries that end up looking like this:
>
> [name] [Dataset]
> [Columnnames ]
> Ave_rent_1_bedroom Datasets object Columnnames object
> ....
>
> Is there a way of spaning the relationship between `Columns` and
> `Columnnames` so that Columns.objects.all() outputs the actual entry
> for the [Columnnames ] field instead of just "Columnnames object"?
You can drill down quite far in your template. This isn't a view problem, but even then, you can override get_context_data if want to provide a cleaner context for your template.
What happens now is that you use {{ instance }} in your template and that coerces instance into it's string representation. But you're free to use {{ instance.columname.name }}.
--
Melvyn Sopacua
No comments:
Post a Comment