Variables can not start with underscore in python / django

0

I'm doing an application with Python, Django and MongoDB, I'm just starting out.

I'm trying to load a template with this user information, the query pulls perfectly:

{% if users %}
    <ul>
    {% for user in users %}
        <li><a href="/crawling/{{user._id}}"><b>{{user.nombre}}</b> {{user.ap_paterno}}</a></li>
    {% endfor %}
    </ul>
{% else %}
    <p>No hay usuarios</p>
{% endif %}

Then boot the error:

  

variables and attributes may not begin with underscores user._id

Well, the ID comes from Mongo, the one that gives you the default, I want it so that when they click the user, go and look for this user with a diabolical speed (by indexing) How do I solve this error? Will I need an additional ID that Mongo gives me?

Already to finish and as a plus, If the dictionary users is empty, keep entering the FOR cycle tried if len( users ) < 0 but I got a parsing error.

I appreciate your support

    
asked by Alberto Siurob 01.08.2018 в 21:52
source

0 answers