Variables and attributes may not begin with underscores: 'value._id'
How does one reference the _id
of an item gotten from MongoDB in Django Templates?
Django, the most popular Python web framework, is an ideal tool to build secure and easy-to-maintain applications using MongoDB. Using MongoDB with Django is advantageous because: Every second, more and more unstructured data is generated from various sources like chats, real-time streams, feeds, and surveys.
Custom template filter would help:
from django import template
register = template.Library()
@register.filter(name='private')
def private(obj, attribute):
return getattr(obj, attribute)
You can use it this way:
{{ value|private:'_id' }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With