'function' object has no attribute '_default_manager' in django 2.1

0

I'm trying to list the data in my table in my template, but this error appears:

  

'function' object has no attribute '_default_manager'

Model code:

class persona(models.Model):
    nombre = models.CharField(max_length=100)
    topipoid = models.CharField(max_length=50)
    identificacion = models.IntegerField()
    direccion = models.CharField(max_length=50)
    fechacreacion = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.nombre

View Code:

class personalist(ListView):
    model = persona
    template_name = "persona/persona_listar.html"

URL Code:

urlpatterns = [
  path(r'', index, name='index'),
  path(r'nuevo/', persona, name='persona'),
  path(r'listar/', personalist.as_view()),
]

Template Code:

{% extends "base/base.html" %}
{% block footer %}

<table class="table table-bordered">
    <thead>
         <tr>
        <td>#</td>
        <td>Nombre</td>
        <td>Tipo ID</td>
        <td>Direccion</td>
        <td>Fecha Creacion</td>

         </tr>
    </thead>
    <tbody>

    {% for persona in object_list %}
     <tr>
       <td>{{ persona.id }}</td>
       <td>{{ persona.Nombre }}</td>
       <td>{{ persona.topipoid }} </td>
       <td>{{ persona.Direccion }}</td>


     </tr>
    {% endfor %}


    </tbody>

</table>
    
asked by Brayan Silvera 07.10.2018 в 22:36
source

1 answer

0

It looks pretty good that you're calling a view just like your model, that is, persona .

Here in your URLs you have this:

urlpatterns = [
  path(r'', index, name='index'),
  path(r'nuevo/', persona, name='persona'), ## <-- persona como view?
  path(r'listar/', personalist.as_view()),
]

that confirms the origin of the possible error. Change the name of the view to PersonaCreate for example and modify the code accordingly to see if it solves your problem.

    
answered by 09.10.2018 в 10:36