Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Build a Social Network with Flask Tacocat Challenge The Challenge

peterbristow
peterbristow
10,403 Points

Data not displaying, don't understand why.

It looks like people are not seeing my previous question (for this issue) for some reason. So please see this link for my issue:

https://teamtreehouse.com/community/not-displaying-data-from-db-correctly-in-indexhtml-page

1 Answer

Hi Peter

After a lot of debugging, found the problem in your models.py file in the Taco class.

see below

class Taco(Model):
  timestamp = DateTimeField(default=datetime.datetime.now)
  user = ForeignKeyField(
    rel_model=User,
    related_name='tacos'
  )
  protein = CharField(max_length=100), # remove the commas
  shell = CharField(max_length=100), # remove the commas
  cheese = BooleanField(default=False), # remove the commas
  extras = CharField(max_length=255) # remove the commas

  class Meta:
    database = DATABASE
    order_by = ('-timestamp',)




# also you have not actually created the Taco table.

def initialize():
  DATABASE.connect()
  DATABASE.create_tables([User], safe=True)# change this line to the below
  DATABASE.create_tables([User,Taco], safe=True)
  DATABASE.close()

# delete taco.db
# re run tacocat.py and it should work 
peterbristow
peterbristow
10,403 Points

Brilliant! Thanks a lot :)