Hi, Pravin

You don't need `get` method in template, just use dot, and if it doesn't
exist, Django template engine will set it to None automatically.

Both below works:

```
{{ request.GET.foo }}

{% if request.GET.my_var %}
  {{ request.GET.my_var }}
{% endif %}
```

Check Django template language:
https://docs.djangoproject.com/zh-hans/2.0/ref/templates/language/

Pravin Yadav <pk.ja...@gmail.com>于2018年6月12日周二 下午8:49写道:

> Hello,
>
> I want to get the parameter value from url in djago template. i'm using
> the django 2.0.6 and python 3.6.1.
>
> *base.html:-  *
>
> {{ request.GET.get('videorandom_id') }}
>
> *My url: http://127.0.0.1:8000/watch/videos/4626634807531689
> <http://127.0.0.1:8000/watch/videos/4626634807531689>*
>
>
> *Error Message:*
>
> TemplateSyntaxError at /watch/videos/4626634807531689
>
> Could not parse the remainder: '('videorandom_id')' from
> 'request.GET.get('videorandom_id')'
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/watch/videos/4626634807531689
> Django Version: 2.0.6
> Exception Type: TemplateSyntaxError
> Exception Value:
>
> Could not parse the remainder: '('videorandom_id')' from
> 'request.GET.get('videorandom_id')'
>
> Exception Location: 
> /usr/local/lib/python3.6/site-packages/django/template/base.py
> in __init__, line 668
> Python Executable: /usr/local/bin/python3
> Python Version: 3.6.1
> Python Path:
>
> ['/var/www/html/videowithfriends',
>  '/usr/local/lib/python36.zip',
>  '/usr/local/lib/python3.6',
>  '/usr/local/lib/python3.6/lib-dynload',
>  '/usr/local/lib/python3.6/site-packages']
>
> Server time: Tue, 12 Jun 2018 12:46:13 +0000
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEr6%3DdxutOMOROR_xjjA%3DYs%2BA2PHGA0KrbFeXxu%2BY-YVmeyc4w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEr6%3DdxutOMOROR_xjjA%3DYs%2BA2PHGA0KrbFeXxu%2BY-YVmeyc4w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMv51WTsjk0JrCJnOUptVXqkXRHUhxSR1HkNMoGNGp2Ssok74A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to