#30748: Abstract model class specifies foreign key – MySQL doesn't have it
-----------------------------------------+------------------------
Reporter: Mike Robinson | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The abstract class is:
{{{
class AbstractForumProfile(models.Model):
"""
Represents the profile associated with each forum user.
"""
user = models.OneToOneField(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE,
related_name='forum_profile',
verbose_name=_('User'))
# The user's avatar.
avatar = ExtendedImageField(
verbose_name=_('Avatar'), null=True, blank=True,
upload_to=machina_settings.PROFILE_AVATAR_UPLOAD_TO,
**machina_settings.DEFAULT_AVATAR_SETTINGS)
# The user's signature.
signature = MarkupTextField(
verbose_name=_('Signature'), blank=True, null=True,
validators=[validators.NullableMaxLengthValidator(
machina_settings.PROFILE_SIGNATURE_MAX_LENGTH)])
# The amount of posts the user has posted (only approved posts are
considered here).
posts_count = models.PositiveIntegerField(verbose_name=_('Total
posts'), blank=True, default=0)
}}}
The derived class is:
{{{
class ForumProfile(AbstractForumProfile):
auto_subscribe_topics = models.BooleanField(
verbose_name='Automatically subscribe to topics you create.',
default=False)
notify_subscribed_topics = models.BooleanField(
verbose_name='Receive an email notification on new replies to
subscribed topics.',
default=False)
}}}
but the resulting MySQL syntax (which does not show `ON DELETE CASCADE` on
the `FOREIGN KEY` constraint, is:
{{{
CREATE TABLE `forum_member_forumprofile` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`avatar` varchar(100) DEFAULT NULL,
`signature` longtext,
`posts_count` int(10) unsigned NOT NULL,
`_signature_rendered` longtext,
`user_id` int(11) NOT NULL,
`auto_subscribe_topics` tinyint(1) NOT NULL DEFAULT '0',
`notify_subscribed_topics` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_id` (`user_id`),
CONSTRAINT `forum_member_forumprofile_user_id_9d6b9b6b_fk_auth_user_id`
FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=latin1;
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30748>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/058.3e4470847134ae2938c354dca51d1aa9%40djangoproject.com.