Hi Prabhu,
You are correct about how to fix the error you're seeing, but I think
you're confused about why you're seeing it. As with all
relationships,
an object in a many-to-many relationship must have a primary key value
before you can point a foreign key value at it from another table.
When
Hello all,
I'm wondering if the following behavior is a feature, a bug, or a
coding error on my part: when I define a model with a CharField that
has choices, if I later save an instance of the model with a value for
that field which is not one of the choices, the value does not display
in the a
Hi all,
I have a quick question about editing instances of child models in the
admin interface. I have a couple of models which derive from a (non-
abstract) parent model, thusly:
class Contact(models.Model):
first_name = models.CharField(...)
last_name = models.CharField(...)
# etc
Hello all,
I am trying to create a ModelForm subclass to customize the admin
interface for one of my models. In particular, I am attempting to add
a field to the ModelForm dynamically in its __init__ method (per
advice found here: http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/).
I would
> No, it is not the case that null=True is disallowed for FKs, but it
> probably should be.
I've just been reading the code in django.db.models.fields.related,
and there's a pretty clear indication that the Django developers
explicitly wanted ForeignKeys to be nullable. In the RelatedManager
cla
Michael,
Thanks for your reply!
> Many databases will allow a constraint with a foreign key to be deferrable
> and initially deferred so that you don't have to disable the relationship
> to load data.
Can you say a bit more about this? I'm by no means an expert on
databases; I'm not quite sure
Update: in the SQL for the Title table,
CREATE TABLE "core_title" (
...
"supplier_id" integer NULL,
);
Two things to note:
1. the SQL explicitly allows the supplier field to be NULL
2. the 'REFERENCES "core_contact" ("id") clause is conspicuous
Hello all,
I have a model with a ForeignKey field that sets null=True:
class Title(models.Model):
#...
supplier = models.ForeignKey(Contact, verbose_name='Supplier',
null=True)
...but when I try to save an instance without a supplier:
>>> t = Title()
>>> t.save()
[complete Traceback be
Hello all,
I'm currently using a mixin class to contribute a few extra fields to
my models, to keep track of some metadata on instances (for example,
an update_mode attribute that specifies whether data should replace
all fields or only non-empty ones in the database when the instance is
saved).
> You're not missing anything - traversing _meta.fields et al is pretty
> much how you would need to do what you are describing.
Thanks, that's what I needed to know!
Richard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Hello all,
I am new to Django and quite excited to be using it. I am attempting
to write some generic import and export methods, and I keep running
into a conceptual hurdle that has to do with related objects:how
can I recursively follow database relations in a way that's not model-
dependen
11 matches
Mail list logo