Modify

Ticket #658 (closed defect: invalid)

Opened 3 years ago

Last modified 3 years ago

Importing BaseCommentAbstractModel causes South to use django.contrib.comments

Reported by: brian@… Owned by: andrew
Priority: major Milestone: 0.7.3
Component: commands Version: mercurial
Keywords: Cc: brian@…

Description

I have an app called "comments" (intended to be a custom comments app). I recently converted it to be managed by South and created initial migration. Now,if I simply add

from django.contrib.comments.models import BaseCommentAbstractModel

and run

manage.py schemamigration comments --auto --stdout
+ Added model comments.CommentFlag
...

The CommentFlag? model is in django.contrib.comments.models, not in my app.
The intention is to change my Comment model to inherit from BaseCommentAbstractModel?, but simply importing it is leading to this problem.

Attachments

Change History

comment:1 Changed 3 years ago by brian@…

sorry, please set author to brian@… add me to the CC

comment:2 Changed 3 years ago by anonymous

I renamed my comments app to "gr_comments" and made sure there were no references to a "comments" module anywhere in my source. Then I again tried adding

from django.contrib.comments.models import BaseCommentAbstractModel

to the gr_comments.models file. Now when I try to run any South command I get:

brian@airtank:~/work/someproj$ manage.py migrate --list

Error: One or more models did not validate:
comments.comment: Accessor for field 'site' clashes with related field 'Site.comment_set'. Add a related_name argument to the definition for 'site'.
comments.comment: Accessor for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
comments.comment: Reverse query name for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
gr_comments.comment: Accessor for field 'site' clashes with related field 'Site.comment_set'. Add a related_name argument to the definition for 'site'.
gr_comments.comment: Accessor for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
gr_comments.comment: Reverse query name for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.

This seems to backup my assumption that something is causing South to introspect Django's contrib.comments models after that import statement is added. If I comment out the import and run "migrate schemamigration --auto" I get "nothing changed" as expected.

comment:3 Changed 3 years ago by andrew

  • Status changed from new to closed
  • Reporter changed from anonymous to brian@…
  • Cc brian@… added
  • Version changed from unknown to tip
  • Milestone set to 0.7.3
  • Resolution set to invalid

This isn't just South; I can replicate it with South turned off and just running "./manage.py sql". I suspect this is a Django model validation bug/feature, instead - by importing the models you cause the metaclass to activate and register the models.

comment:4 Changed 3 years ago by brian@…

Thanks for looking into it. I'll follow up over in Django land.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.