On Oct 17, 6:16 pm, John Yeukhon Wong <[email protected]> wrote: > I asked this somewhere else but it seems like the responder hasn't > reply the latest comment I > made.http://stackoverflow.com/questions/3951758/how-do-you-iterate-over-a-... > > Nevertheless, I think I should be welcome to make one here. > > Let's keep thing short. > > Say I have a very simple list to iterate > > [--code--] > def link(request): > c = Context() > c['title'] = ['Home Page', 'Current Time', '10 hours later'] > return render_to_response('time.html', c) > [--code--] > > Now say I also have another view called current_time > > In my html I had, for example > [--code--] > {% for item in title %} > {{item}} > {% if not forloop.last %} | {% endif %} > {% endfor %} > > {% if hour <= 1 %} > do something... > {% endif %} > > [--code--] > > For the template, I tried loop through "in c.title, in c, in title" > and still doesn't work > > As you can guess, I use two view functions in a single html file. > > The problem is that I received 'function' object is not iterable > > So the guy said I probably had a problem with the URL > my URL --> (r'^now/$', current_time, link), > > So he recommended me doing this > (r'^articles/(?P<current_time>\(?P<link>)/$', > 'project_name.views.link'), #the second tuple element is the view > function > > Something similar to Django URL Dispatcher (from the dispatcher > chapter).. I think... > I think he meant to capture then. But what I want to do is really > just, say, localhost/now/ and load the page > > I can definitely integrate two views functions into one single > function, which works fine. > > The question is, how can I assign multiple views function in a single > URL??? > > Thank you for any input in advance!!!
You can't do that, and there isn't any reason to want to do so. A view function takes a request, and returns a response, which is usually in the form of some rendered HTML. How would it work with two? What would be the input to the second function? How would the outputs be merged? As usual, the real question is what are you trying to do that you think would be best solved by having two views for a single URL. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

