straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

passing arguments in the url template tag #128

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

#views.py:
def action(request, action, key):
    person=get_object_or_404(Person, key)
    return render_to_response(request, 'action.html',  
{'person':person,'action':action})

#urls.py
urlpatterns = patterns('myapp.views',
    (r'^$', 'list_people'),
    (r'^(?P<action>.+)/(?P<key>.+)$', 'action'),
     ...)

#person_list.html
<ul>
  {% for person in object_list %}
    <li>
      <a href="{% url myapp.views.show_person key=person.key %}">{{
person.first_name }} {{ person.last_name }}</a>
      <a href="{% url myapp.views.action action='hello',key=person.key
%}">say hello</a>
    </li>
</ul>

When I load the URL person/ which runs the view list_people, I get the error: 
            Could not parse the remainder: ''hello'' from ''hello'

Here is the traceback

Environment:

Request Method: GET
Request URL: http://localhost:8080/person/
Django Version: 1.0.2 final
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.webdesign',
 'django.contrib.flatpages',
 'django.contrib.redirects',
 'django.contrib.sites',
 'appenginepatcher',
 'myapp',
 'registration',
 'mediautils',
 'django_aep_export.admin_media',
 'django_aep_export.django_templates']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'ragendja.sites.dynamicsite.DynamicSiteIDMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
 'django.contrib.redirects.middleware.RedirectFallbackMiddleware')

Template error:
In template C:\Documents and Settings\David
Bikard\Bureau\app-engine-patch-sample\myapp\templates\person_list.html,
error at line 12
   Could not parse the remainder: ''hello'' from ''hello''
   2 : {% block title %}Person listing{% endblock %}

   3 : 

   4 : {% block content %}

   5 : <h1>Person listing</h1>

   6 : <a href="{% url myapp.views.add_person %}">Create person</a>

   7 : 

   8 : <ul>

   9 :   {% for person in object_list %}

   10 :     <li>

   11 :       <a href="{% url myapp.views.show_person key=person.key %}">{{
person.first_name }} {{ person.last_name }}</a>

   12 :       <a href=" {% url myapp.views.action
action='hello',key=person.key %} ">say hello</a>

   13 :       <a href="{% url myapp.views.edit_person key=person.key
%}">Edit</a>

   14 :       <a href="{% url myapp.views.delete_person key=person.key
%}">Delete</a>

   15 :     </li>

   16 :   {% endfor %}

   17 : </ul>

   18 : 

   19 : <div>

   20 :   {% if has_previous %}

   21 :     <a href="{% url myapp.views.list_people %}?page={{ previous
}}">&lt;-previous</a>

   22 :   {% endif %}

Traceback:
File "C:\Documents and Settings\David
Bikard\Bureau\app-engine-patch-sample\myapp\views.py" in list_people
  16.     return object_list(request, Person.all(), paginate_by=10)

Exception Type: TemplateSyntaxError at /person/
Exception Value: Could not parse the remainder: ''hello'' from ''hello''

What did I do wrong???
Thx

Original issue reported on code.google.com by dbik...@gmail.com on 16 Apr 2009 at 10:11

GoogleCodeExporter commented 9 years ago
FYI, this is not "Waldemar's Private Help Center". ;)
Please post such questions to the App Engine discussion group:
http://groups.google.com/group/google-appengine/

I think the problem is that you use single-quote ' instead of double-quote ". 
Django
is very picky about that.

Original comment by wkornew...@gmail.com on 16 Apr 2009 at 2:13

GoogleCodeExporter commented 9 years ago
This was indeed the problem... I can't believe I just lost so much time on a 
quote
mistake....

Thx again and sorry for posting this here!

Original comment by dbik...@gmail.com on 16 Apr 2009 at 2:20