Hi, I've been asking this at django-users but haven't received any good answer. (thread: http://groups.google.com/group/django-users/browse_thread/thread/6994f7b37f3f379c ) So I looked into the django code and found this:
class ForeignKey(RelatedField, Field): empty_strings_allowed = False def __init__(self, to, to_field=None, rel_class=ManyToOneRel, **kwargs): # .... self.db_index = True and this: class OneToOneField(ForeignKey): """ A OneToOneField is essentially the same as a ForeignKey, with the exception that always carries a "unique" constraint with it and the reverse relation always returns the object pointed to (since there will only ever be one), rather than returning a list. """ def __init__(self, to, to_field=None, **kwargs): kwargs['unique'] = True super(OneToOneField, self).__init__(to, to_field, OneToOneRel, **kwargs) The OneToOneField's comment tells that `unique` is hardcoded, but it sounds more like a definition, not an explanation WHY it's like that. So - to implement what I want, I replaced the 2 above lines with code which makes the same values by default, but allows to do a change, when a programmer wants it. Can you tell me if it's a good idea, or I should solve it some other way (see my original problem: http://groups.google.com/group/django-users/browse_thread/thread/6994f7b37f3f379c )? And another problem: I found that the SQL generated by `manage.py sql` does create indexes in the database. For example: [snip] ALTER TABLE `forum_forumthread` ADD CONSTRAINT forum_id_refs_id_3869a6a3 FOREIGN KEY (`forum_id`) REFERENCES `forum_forum` (`id`); [/snip] Such 'foreign key' constraints create indexes in database (at least mysql). So 'manage.py sqlindexes' is actually redundant, because the 'create index' commands generated by it, only change the names of indexes. Is this a bug or not? Regards MS --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---