I'm using a legacy database (in addition to a 'normal' database), defined in my settings.py
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
'articles_database': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'articles.db'),
} }
and in my models.py
with:
from django.db import models
class ArticlesTable(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
article_type = models.TextField(blank=True, null=True) # This field type is a guess.
article_name = models.TextField(blank=True, null=True) # This field type is a guess.
article_number = models.IntegerField(db_column='article_number', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = False
db_table = 'articles_table'
After having installed Django-comments on my Django 1.8.5: I can get a proper form to fill a comment, but clicking on the "Post" button gets this error:
OperationalError at /comments/post/
no such table: articles_table
with the line for error highlighted:
/home/gus/.Envs/python3_django/lib/python3.4/site-packages/django_comments/views/comments.py in post_comment
56. target = model._default_manager.using(using).get(pk=object_pk)
Apparently, Django-comments didn't find my table inside my database? Is it possible to use a legacy database in fact with Django-comments?
EDIT: I've fixed the model for my legacy database as @Geo Jacob suggested:
class Meta:
managed = True
db_table = 'articles_table'
But now I got an error page (provided by Django-comments, not a Debug page):
Comment post not allowed (400)
Why: No object matching content-type 'articles.articlestable' and
object PK '1' exists.
The comment you tried to post to this view wasn't saved because
something tampered with the security information in the comment
form. The message above should explain the problem, or you can check
the comment documentation for more help.
Django-comments in the post_comment
function gets the right model (ArticlesTable
) but can't find the object???