I want 2 models to work as following:
A Content class that inherits from Link class.
Sounds simple.
here’s my models (relevant part) :
class Link(models.Model):
name = models.CharField(max_length=50)
slug = models.SlugField(unique = True)
level = models.IntegerField(default='1')
vectorImage = models.TextField(blank = True, null=True)
parent = models.TextField(default='index')
def __unicode__(self):
return self.name
class Content(Link):
context = models.TextField()
The problem is that when I create a new Content, it creates a link separately and a content separately.
So if I transfer it with JSON:
Links.objects.all… and Content.objects.all, after creating 1 Content :
[{
"pk": 1,
"model": "grid.link",
"fields": {
"vectorImage": "",
"level": 1,
"name": "logo",
"parent": "index",
"slug": "logo"
}
}
],
[
{
"pk": 1,
"model": "grid.contexthtml",
"fields": {
"context": "html codez"
}
}
]
That’s not what I want. I want it to send the full Content ( like above, but with combine fields).
How do I fix this?
I
Use an abstract base class. Does this work for you?