Forums

QuerySet not appearing in HTML file (DjangoGirls tutorial)

Hello,

I'm having a bit of trouble with this part of the DjangoGirls tutorial (about templates). My issue is two-fold:

1) The QuerySet isn't loading at all in the HTML file.

I followed the steps to import the Post model into views.py and add the QuerySet in the posts variable (the previous part of the tutorial). When I tried putting {{ posts }} in the HTML file (post_list.html), nothing appears in the QuerySet that loads on the page.

2) I don't know how to edit the database file on PythonAnywhere. This database file is supposed to be separate from the local db.sqlite3 on my computer (since db.sqlite3 is in the .gitignore file, it's not committed).

I read about this in a previous forum post. I understand that this is useful to keep production changes from being displayed on the live website, but how I supposed to have this data on the PythonAnywhere side? What file am I supposed to edit on PythonAnywhere?

**EDIT: Nevermind! I got some help elsewhere!

what worked for you??

That sounds like you expected data to be in the database, but it wasn't. ie. since it's a brand new database, you need to either transfer the data over (from your local database), or create new data etc.

Conrad, you are correct!

The problem was that I didn't have any posts in the Django admin on PythonAnywhere, which was different from the local admin. After I went to chocoberrie.pythonanywhere.com/admin and logged in, I added a handful of posts, and they appeared on the home page after that!

:)