Hi,
I have a pair of models A and B, where B has a foreign key pointing to
A. I want to ensure that instances of A have at least one (B)
referrer. The obvious way (to me, still learning python and Django)
was to override A's 'save' method, checking for the existence of at
least one referring B (
>
> It's not a particularly bad idea; having an object carry with it
> standardized information which tells you what template to use to
> display it would be pretty easy (assuming, of course, that you have
> the ability to lay out the model classes to support that).
>
Fortunately my models make t
On 12/19/06, James Bennett <[EMAIL PROTECTED]> wrote:
>
> Even if the types aren't known in advance, it's possible to make some
> educated guesses; most classes will, for example, have a __str__
> method which will allow them to intelligently print themselves as
> strings.
>
> If you know what typ
Is there a natural way in Django to write a template that can display
the details of objects of various types, where the types aren't
necessarily known in advance?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Dj
One correction:
One 'child' class (ie. with a OneToOneField) does always keep the
reference to the base class in it's pk column.
A couple of additions:
- the OneToOneField is obviously partially working, as even when the
reference is dnot there, the standard 'id' field name is correctly
replace
I have a models.py with several model classes referencing a 'base'
model class using OneToOne fields. The CREATE statement displayed by
manage.py sqlall is weirdly inconsistent -- sometimes the id columns
of the 'child' model classes contain a REFERENCES clause (ie. to the
'base' class), sometimes
On 12/15/06, James Bennett <[EMAIL PROTECTED]> wrote:
> You may want to read this thread from the developers list, which goes
> through some of how this will work (and contains references to earlier
> threads discussing the full API):
>
> http://groups.google.com/group/django-developers/browse_thr
On 12/14/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> Django does have the ability to do a sort of model inheritance, using
> OneToOneFields. This establishes a 1-1 relationship between a base
> class and a child class.
I assume it would be possible to get at child instances via some ki
On 12/14/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
>
> Yes and No.
>
> Django does have the ability to do a sort of model inheritance, using
> OneToOneFields. This establishes a 1-1 relationship between a base
> class and a child class. For example:
>
> class Base(Model):
>name = Ch
My first experiment with Django is a kind of wiki that involves being
able to add a variety of different types of pages, each with their own
set of fields. The obvious way to do this would be to create a base
model page class which various page types inherit. But I can't imagine
how the Django ORM
10 matches
Mail list logo