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 trialSam Fellows
3,968 PointsWhat am I missing? Model Inheritance
I feel like I am missing something basic, but if any one has any guidance I would much appreciate it. I am stumped! For this challenge I need to make my model abstract so I can inherit it on the second model right? Thank for your help.
from django.db import models
class Product(models.Model):
name = models.CharField(max_length=255)
description = models.TextField()
class Meta:
abstract = Ture
ordering = ['order',]
#def __str__(self):
# return self.title
class Digital(Product):
url = forms.URLField()
3 Answers
Sam Fellows
3,968 PointsFigured it out!
from django.db import models
class Product(models.Model): name = models.CharField(max_length=255) description = models.TextField()'''
class Meta: abstract = True ordering = ['order',]
class Digital(Product): url = models.URLField()
Sam Fellows
3,968 PointsAlso I just noticed that I miss spelled "True". It is still not working however :-/
nominuiop hijo
992 Pointsin ordering
you must provide a field that is already in your class, after what field you want to order the entries? name
or description
?
And yes, you can't have forms.URLField() in your models.