Opened 16 years ago
Closed 16 years ago
#13368 closed (duplicate)
Cannot import Comment model in app models
| Reported by: | heylinus | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.comments | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Cannot import Comment model of django.contrib.comments in app model.
# someapp/models.py
from django.contrib.comments.models import Comment
class CommentScore(models.Model):
comment = models.OneToOneField(Comment, primary_key=True)
...
# cannot use any manage command $ ./manage.py runserver Error: cannot import name Comment $ ./manage.py shell Error: cannot import name Comment $ ./manage.py syncdb Error: cannot import name Comment
# here is the trackback in a python terminal.
>>> from django.contrib.comments.models import Comment
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/django/contrib/comments/__init__.py", line 4, in <module>
from django.contrib.comments.models import Comment
File "/Library/Python/2.6/site-packages/django/contrib/comments/models.py", line 42, in <module>
class Comment(BaseCommentAbstractModel):
File "/Library/Python/2.6/site-packages/django/db/models/base.py", line 162, in __new__
new_class.add_to_class(field.name, copy.deepcopy(field))
File "/System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/copy.py", line 173, in deepcopy
y = copier(memo)
File "/Library/Python/2.6/site-packages/django/db/models/fields/__init__.py", line 129, in __deepcopy__
obj = copy.copy(self)
File "/System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/copy.py", line 95, in copy
return _reconstruct(x, rv, 0)
File "/System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/copy.py", line 340, in _reconstruct
y.__setstate__(state)
File "/Library/Python/2.6/site-packages/django/db/models/fields/__init__.py", line 146, in __setstate__
self.default = self.model._meta.get_field_by_name(self.name)[0].default
File "/Library/Python/2.6/site-packages/django/db/models/options.py", line 295, in get_field_by_name
cache = self.init_name_map()
File "/Library/Python/2.6/site-packages/django/db/models/options.py", line 325, in init_name_map
for f, model in self.get_all_related_m2m_objects_with_model():
File "/Library/Python/2.6/site-packages/django/db/models/options.py", line 402, in get_all_related_m2m_objects_with_model
cache = self._fill_related_many_to_many_cache()
File "/Library/Python/2.6/site-packages/django/db/models/options.py", line 416, in _fill_related_many_to_many_cache
for klass in get_models():
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 167, in get_models
self._populate()
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name)
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Python/2.6/site-packages/djtest/testapp/models.py", line 2, in <module>
from django.contrib.comments.models import Comment
ImportError: cannot import name Comment
Note:
See TracTickets
for help on using tickets.
I think this has already been reported in ticket 13366, Comment is a
model that inherits from an abstract base class that has fields
(BaseCommentAbstractModel).