0

I don't understand what could be the problem of this kind of error. I have 4 apps in my Django project. Each app contains multiple models. I am able to retrieve data from all models expect 1 in the python interactive shell.

Also, in my Form, it gets displayed but when i run the same query from the interactive shell it does not display anything. I fail to understand what could be the problem, it does not gives any errors as well...

Any help on this would be great!

Updated:

The model contains the following fields:

class Report(models.Model):
   rid = models.CharField(blank=True, null=True)
   period = models.CharFiedl(blank=True, null=True)
   name = models.CharField(blank=True, null=True)
   ....
   ....

I was running the following queries: Report.objects.all() - which returns null Report.objects.count() - which also return 0

I added a few entries with the help of the admin interface...and checked the same via phpMyadmin...and the interactive shell does not display anything...

But I have a form which is working when i display just the name...

forms.py

class ReportForm(forms.ModelForm):
    class Meta:
       model = Report

views.py

def display(request):
  return render_to_response('view.html', {'Report' : Report.objects.all()})

view.html

{% if Report.count > 0 %}
     {% for entries in Report %}
          <a href = "/Report/{{entries.name}}">{{entries.name}}</a>
     {% endfor %}
{% else %}
     <p> No Entries </p>
{% endif %}
Akshay
  • 329
  • 1
  • 7
  • 19
  • You need to add more information before anyone will have a chance of helping you. What is the code for the model that's not working? What queries have you tried? What did you do to confirm that there is data in the database? – Peter DeGlopper Sep 26 '13 at 04:19
  • @PeterDeGlopper i did update my question. Hope this helps! – Akshay Sep 26 '13 at 05:10
  • I don't see anything obviously wrong with any of that. It isn't the usual convention to use a capitalized singular name like `Report` for a queryset, but it's not wrong in ways that would introduce errors. Just to hit the obvious factors - you are exiting the interactive shell and reloading when you change your back end definitions, right? If you're maintaining an interactive shell environment you get into transactional issues. – Peter DeGlopper Sep 26 '13 at 05:34
  • It might be caching issue, restart your shell and try the query again. – Rohan Sep 26 '13 at 05:54
  • It was the caching issue...You said it right @PeterDeGlopper...i wasn't restarting the shell as i was getting the values for the other models...My bad :( ....Is there any way to stop the caching with respect to Django. – Akshay Sep 26 '13 at 05:58

0 Answers0