Sorry. I'd been thinking in terms of a not null constraint and confusing myself
that it would apply in both directions.
Bill
On Fri, Jun 24, 2011 at 10:25 AM, Tom Evans wrote:
> On Fri, Jun 24, 2011 at 3:15 PM, Bill Freeman wrote:
>> So long as it *IS* one to one. I.e.; there are no Word-s th
On Fri, Jun 24, 2011 at 3:15 PM, Bill Freeman wrote:
> So long as it *IS* one to one. I.e.; there are no Word-s that are both a
> Verb and a Noun.
>
> I'd sill go with a foreign key field in Verb (and Noun, etc.)
> referring to Word. I
> think that you can even mark it unique, meaning that only
So long as it *IS* one to one. I.e.; there are no Word-s that are both a
Verb and a Noun.
I'd sill go with a foreign key field in Verb (and Noun, etc.)
referring to Word. I
think that you can even mark it unique, meaning that only one Verb can
refer to any given Word, but both a Noun and a Verb
Thanks for your input, Bill, I appreciate it. I think I'm just going to
take a hit and switch to an explicit OneToOneField instead of trying to make
this work with inheritance. The other way things will just work, because
django's built to make it work, but doing it with inheritance is difficult
So, we're talking about "Multi-table inheritance"
(https://docs.djangoproject.com/en/1.3/topics/db/models/#multi-table-inheritance).
Note that this uses "an automatically-created OneToOneField".
What you really want to do is to create a python instance of the Verb
class. It's id (in the Verb tab
I'm still confused about what you have (what form of inheritance you are using.
In your database, are there both a Word table and a Verb table? Or is
there just
a (set of) Verb (and Noun and Adjective, etc.) table(s), derived from
a non-Model
Word class?
If there's a Noun instance "record" and a
I'm using django's model inheritance. Sorry I wasn't clear. So there's a
Word model and a Verb model.
class Word(models.Model):
# Word stuff
class Verb(Word):
# Verb-specific stuff
The way django handles this is to create a word table and a verb table. The
verb table has a reference t
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-specific stuff
--
You received th
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 the word
> > table.
>
> Verb.objects.cr
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 the word
> table.
Verb.objects.create(word=word) doesn't fulfill these criteria?
Cheers
Tom
--
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
First, if, despite being related by inheritance, Word and Verb are
separate models, they have separate tables. Then if you do create
a Verb, the Word still exists, unless you delete it. Is that what you
want? If both are to exist, were you hoping that a query for the
same key would still find th
Hello all,
I have a model hierarchy in my django app, and there is one very
important task that I do not know how to do. I have a bunch of
instances of the superclass (Word is the model name), and on input
from a user I want to create a subclass instance (Verb) from that
superclass instance. For
13 matches
Mail list logo