Re: Creating an instance of a subclass when superclass instance already exists

2011-06-23 Thread Matthew Gardner
Thanks, Bill, for your comments. Shortly after I posted here I did a little more digging and found this thread from six months ago that described exactly my problem: http://groups.google.com/group/django-users/browse_thread/thread/9400999651577bc2/8cc4fe267128d6a3 That thread didn't seem to have

Re: Creating an instance of a subclass when superclass instance already exists

2011-06-23 Thread Matthew Gardner
On Thu, Jun 23, 2011 at 11:47 AM, Tom Evans wrote: > On Thu, Jun 23, 2011 at 4:36 PM, Matthew Gardner wrote: > > At this point, all I really want to do is add a row to the verb table > that > > contains the correct foreign key, without creating a new row in

Re: Creating an instance of a subclass when superclass instance already exists

2011-06-23 Thread Matthew Gardner
On Thu, Jun 23, 2011 at 2:18 PM, Matthew Gardner wrote: > class Verb(models.Model): > word = models.ForeignKey('Word') > # Verb-specific stuff > Sorry, this is more accurate: class Verb(models.Model): word = models.OneToOneField('Word') # verb-

Re: Creating an instance of a subclass when superclass instance already exists

2011-06-23 Thread Matthew Gardner
Verb (and Noun and Adjective, etc.) table(s), derived from > a non-Model > Word class? > > If there's a Noun instance "record" and a Verb instance "record", do they > share > any data (such that if you change it in one it is changed in the > other) or d

Re: Creating an instance of a subclass when superclass instance already exists

2011-06-23 Thread Matthew Gardner
with transactions and roll backs. > > And, of course, things could change in a future version even if this works > now. > > Good luck, Bill > > On Thu, Jun 23, 2011 at 2:22 PM, Matthew Gardner wrote: > > On Thu, Jun 23, 2011 at 2:18 PM, Matthew Gardner

Re: What are the advantages of Model inheritance?

2011-06-23 Thread Matthew Gardner
I think you're right, Rich, that when you query on a table, it'll only grab the results for that table. So when you do user.post_set.all(), it only creates Post objects, because it only pulls data from that one table. When you do user.betterpost_set.all(), the reason you don't see anything is tha

Problem with select_related

2011-07-02 Thread Matthew Gardner
Hi all, I'm seeing some funny behavior when using select_related to try to speed up my code, and I'm wondering if I'm just misunderstanding something. The basics of my code: class A(models.Model): # some stuff class B(models.Model): a = models.ForeignKey('A') c = models.ForeignKey('

Re: Problem with select_related

2011-07-02 Thread Matthew Gardner
2011 at 7:42 PM, Javier Guerra Giraldez wrote: > On Sat, Jul 2, 2011 at 8:07 AM, Matthew Gardner wrote: > > a = A.objects.get(pk=some_id) > > b_set = a.b_set.select_related().all() # recommended in the Django > > documentation for some queries > > And b_set comes up e