{{{
class Foo(models.Model):
a = models.CharField(max_length=10)
class Bar(Foo):
b = models.CharField(max_length=10)
}}}
That will lead to two tables being created:
{{{
create table myapp_foo(id int, a varchar(10));
create table myapp_bar(foo_id, b varchar(10));
}}}
That's great. But when I need to run queries directly against the
database, I have to write all the joins myself. Since I'm
(extraordinarily) lazy, I would love to see a new management command that
creates a view like this:
{{{
create view bar_view as -- i hate that name, but it's good for an example
select * -- if I did this for real, I would enumerate the
columns
from myapp_foo
join myapp_bar on myapp_foo.id = myapp_bar.foo_id
}}}
for this trivial example, the typing isn't that much. But when you get
deep inheritance hierachies, the typing becomes a pain (especially since
the name of the "id" key keeps changing at each level).
--
Ticket URL: <https://code.djangoproject.com/ticket/20314>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_docs: => 0
Comment:
I can see what you're asking for here, and I can see the value, but Django
doesn't currently have *any* support for views, so this seems a little
premature.
In the meantime, you don't have to create the joins -- Django's ORM will
create the joins for you.
--
Ticket URL: <https://code.djangoproject.com/ticket/20314#comment:1>