troubleshooting Question

Query table in Django

Avatar of jsgambel
jsgambel asked on
10 Comments1 Solution894 ViewsLast Modified:
Hi all -

This should be an easy one, but I'm stumped. I'm having a problem displaying the contents of a postgres table in django.

The error I'm getting is: 'module' object has no attribute 'Item2'
    (r'^activity/$', activity_page),
class Item2(models.Model):
    name = models.CharField(max_length=60)
    link = models.ForeignKey(Link)
    created = models.DateTimeField(auto_now_add=True)
    priority = models.IntegerField(default=0)
    difficulty = models.IntegerField(default=0)
    done = models.BooleanField(default=False)
    def __unicode__(self):
def activity_page(request):
    return render_to_response('activity_page.html', {obj: models.Item2.objects.all()}

{% extends "base.html" %}
{% block title %}Activity List{% endblock %}
{% block head %}What's coming up {% endblock %}
{% block content %}
{% for a in obj %}
<tr><td>{{ }}</td><td>{{ }}</td><td>{{ a.priority }}</td></tr>
{% endfor %}
{% endblock %}

The problem is in - when I go to the table to get the data, I don't think I'm querying it right. When I just use render to response for the html page, it renders fine. When I include the call to the table, I get the error.

Thanks for your help. Let me know if you need anything else.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros