Groups
Groups
Sign in
Groups
Groups
Django users
Conversations
About
Send feedback
Help
Using hashids in django template
123 views
Skip to first unread message
Paul Aswa
unread,
Aug 18, 2016, 7:44:14 AM
8/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Is there means of encoding an id using
hashids
in django templates?
ludovic coues
unread,
Aug 18, 2016, 7:57:56 AM
8/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
You might be looking for this
https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/
2016-08-18 12:57 GMT+02:00 Paul Aswa <
aswa...@gmail.com
>:
> Is there means of encoding an id using hashids in django templates?
>
> --
> 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...@googlegroups.com
.
> To post to this group, send email to
django...@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/fd7df219-a31a-408c-bbeb-ca0162492106%40googlegroups.com
.
> For more options, visit
https://groups.google.com/d/optout
.
--
Cordialement, Coues Ludovic
+336 148 743 42
Paul Aswa
unread,
Aug 18, 2016, 1:37:53 PM
8/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Being a newbie to python and django, this seems to be giving me problems
ludovic coues
unread,
Aug 18, 2016, 1:46:22 PM
8/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Filter are a way to apply a function to a value in a django template.
The filter would look like that:
def hashid(value):
return hashids.encode(value)
and your template like that:
{{ id|hashid }}
I omitted some part that are in the doc, like making the filter
available in your template. The doc have more information on the
subject.
>
https://groups.google.com/d/msgid/django-users/363aa415-da76-4670-a992-47ce4506449c%40googlegroups.com
.
Paul Aswa
unread,
Aug 18, 2016, 2:23:53 PM
8/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Thanks for the shedding light on filters, really helpful. I should have thought about that!
Reply all
Reply to author
Forward
0 new messages