2009/11/29 Andy <asdjohn...@gmail.com>:
> I have a model named Articles with title and content fields.  Each
> page of my site should display a list of the titles, linked with
> anchor tags to the corresponding area of the Resources page which
> displays all the titles and content.  I am having trouble figuring out
> how to pass the #title info.  I've read a previous post:http://
> groups.google.com/group/django-users/browse_thread/thread/
> bf5bae5b333aae/b8627d237d34fd69?lnk=gst&q=anchor+tag#b8627d237d34fd69,
> but am still struggling.
>
> Views(snippet):
> articles = Context({'articles': Articles.objects.all()})
> def index(request):
>        return render_to_response('index.html', articles)
> def resources(request):
>        return HttpResponseRedirect('/resources/')
>
> Base Template(snippet):
>        <div id="sidebar">
>                <h2>Resources</h2>
>                <ul>
>                {% for articles in articles %}
>                <li><a href="/resources#{{ articles.title }}/" target="_blank">
> {{ articles }}</a></li>
>        {% endfor %}
>                </ul>
>        </div>
>
> I am getting a 'too many redirect' error with this code.  Can anybody
> help me with this?
>

With assumption you have set your url like:

url(r'^resources/$', 'resources',  name='resources')

each time you open "resources" view you would get redirected to the
"resources" view and you have endless loop, which browsers would
terminate after certain number of repetitions.

resources view should return html page with titles and content rather
then redirect to it self.

Basically, when you click on "/some/page/#fid", view which handles
/some/page/ url should return HTML page, and if there is a fragment id
("#fid" in this case) in that page your browser should position your
page on that fragment id (if possible).

Hope i didn't overcomplicated this :)

Davor

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.


Reply via email to