1

I am learning to develop and trying to develop a screen in django 1.1 and I am getting this error below. I already took a look at some stacks I already looked at httpresponse, however, I was not successful could someone help me and explain what could be wrong?

I'm getting this error on the console:

Internal Server Error: /gerencia-margem/list
Traceback (most recent call last):
File "/home/murilo/virtualenv/intranet_erp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 131, in get_response
response = middleware_method(request, response)
File "/home/murilo/virtualenv/intranet_erp/local/lib/python2.7/site-packages/django/middleware/locale.py", line 38, in process_response
if (response.status_code == 404 and not language_from_path and
AttributeError: 'HistoricoComissao' object has no attribute 'status_code'
[18/Nov/2020 13:30:06] "GET /gerencia-margem/list HTTP/1.1" 500 77145

This is models,

# -*- coding: utf-8 -*-
from django.db import models


class HistoricoComissao(models.Model):
class Meta:
    verbose_name = u'Historico Comissão'
    verbose_name_plural = u'Historico Comissões'

pednum = models.CharField(max_length=40, blank=True)
margem = models.DecimalField(decimal_places=4, max_digits=15, null=True, blank=True) 
data = models.DateTimeField()
historico = models.TextField((u'Historico HTML'), blank=True)

status = models.PositiveSmallIntegerField(choices=[(1, 'Em Aberto'),
                                                   (3, 'Pendente'),
                                                   (4, 'Finalizado'),])

def __unicode__(self):
        return str(self.pednum)

this is the views

from django.views import View
from django.shortcuts import render
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from ..models import HistoricoComissao


def listview(request):
template_name = 'comissao/margenslist.html'
comissoes = HistoricoComissao.objects.all
context = {
    'comissoes': comissoes
}
return render(request,template_name,context)

this is urls.py

from django.conf.urls import  url
from . import views


urlpatterns = [
    url(r'^list$', views.HistoricoComissao, name='historico_comissao'),
 ]

1 Answer 1

3

In your urls.py you use as view HistoricoComissao, but that is a re-export of a Django model, not of a view. You should use the listview:

from django.conf.urls import  url
from . import views


urlpatterns = [
    # link to a view function ↓
    url(r'^list$', views.listview, name='historico_comissao'),
]

I am learning to develop and trying to develop a screen in django 1.1.

Please upgrade. Django-1.1 was end of life before 2013. Furthermore a lot of things have changed in the meantime (and often improved).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for helping me, I'm studying Django 1.1, because some of the company's projects are in this model, so I'm starting with it.começando com ele.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.