Thank you so much Malcolm. every one gives only the link and tell to read but your style of solving the problem is amazing. how you explained me in a nice way that i can never ever find in djangoproject.com. Thanks you so much malcom
On Jan 8, 3:23 pm, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > I'm going to trim your code to what looks like the relevant portion of > the HTML template, since that's where the easiest solution lies. > > On Thu, 2009-01-08 at 02:02 -0800, Praveen wrote: > > [...] > > > > > list_listing.html > > > <div id="leftpart"> > > <h3>Sight Seeings</h3> > > <ul> > > {%if listing_result %} > > {% for n in listing_result %} > > <li><a href="{{n.id}}">{{n.list_channel}}</a></li> > > {% endfor %} > > {% else %} > > <p>not available</p> > > {% endif %} > > </ul> > > </div> > > [...] > > > I am displaying Listing_channels and Listing on same page. if some one > > click on any Listing_channels the corresponding Listing must display > > on same page. that is why i am also sending the Listing_channels > > object to list_listing.html page. if some one click first time on > > Listing_channels it shows the > > urlhttp://127.0.0.1:8000/category/listing_view/1/ > > but second time it appends 1 at the end and the url becomes > >http://127.0.0.1:8000/category/listing_view/1/1 > > The above code fragment is putting an element in the template that looks > like > > <a href="1">...</a> > > That is a relative URL reference and will be relative to the URL of the > current page (which is .../category/listing_view/1/). In other words, it > will be appended to that URL. One solution is to change the relative > reference to look like > > <a href="../1">...</a> > > or, in template language: > > <li><a href="../{{n.id}}">{{n.list_channel}}</a></li> > > That assumes you will only be displaying this template > as ..../listing_view/1/ (or with a different number as the final > component), since it will *always* remove the final component and > replace it with the id value. > > The alternative, which is a little less fragile, is to use the "url" > template tag to include a URL that goes all the way back to the hostname > portion. You could write > > <li><a href=" > {% url mysite.library.views.listing_view n.id %} > ">{{n.list_channel}}</a></li> > > (I've put in some line breaks just to avoid unpleasant line-wrapping). > The {% url ... %} portion will return "/category/listing_view/1/" -- or > whatever the right n.id value is -- which will always be correct. > > Have a read > ofhttp://docs.djangoproject.com/en/dev/ref/templates/builtins/#urlif > you're not familiar with the URL tag. > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---