List Info

Thread: Many-to-Many with Intermediate Table Bug in Admin in Django 0.95?




Many-to-Many with Intermediate Table Bug in Admin in Django 0.95?
user name
2006-09-29 19:27:10
Could someone please tell me if this is an unfixed bug in
Django 0.95.
If it is I will submit a ticket.

I created a many-to-many relationship using an intermediate
table
similar to
http://www.djangoproject.com/documentation/mo
dels/m2m_intermediary/
(see model below.)

I am able to successfully exercise the models with no
problem in the
shell.

When I go to the Admin and I create an Action or a Reference
document
and click on save the Admin throws an exception. But the
Action or
Reference is still added to the database.

I searched existing tickets and found similar issues but I'm
not sure
if they address the same circumstances.

Thanks,
/Paul


Models:

-----------------------------------------
from django.db import models

class Action(models.Model):

    name = models.CharField(maxlength=20)

    class Admin:
        pass

class ReferenceDocument(models.Model):

    document_number =
models.CharField("Document",maxlength=50,
core=True)
    document_type = models.CharField(maxlength=5)

    class Admin:
        pass

    def __str__(self):
        return self.document_number

class ActionReference(models.Model):

    action = models.ForeignKey(Action)
    reference_document =
models.ForeignKey(ReferenceDocument)
    note = models.CharField(maxlength=50)

    class Admin:
        pass
------------------------------------------

The exception and traceback:

ProgrammingError at /admin/mmm/referencedocument/add/
ERROR: insert or update on table
"django_admin_log" violates foreign
key constraint
"django_admin_log_content_type_id_fkey" DETAIL:
Key
(content_type_id)=(15) is not present in table
"content_types"
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/mmm/referencedocument/add/
Exception Type: ProgrammingError
Exception Value: ERROR: insert or update on table
"django_admin_log"
violates foreign key constraint
"django_admin_log_content_type_id_fkey"
DETAIL: Key (content_type_id)=(15) is not present in table
"content_types"
Exception Location:
c:python24libsite-packagesdjango-0.95-py2.4.eggdjangod
bbackendsutil.py
in execute, line 12

Traceback (most recent call last):
File
"c:python24libsite-packagesdjango-0.95-py2.4.eggdj
angocorehandlersbase.py"
in get_response
  74. response = callback(request, *callback_args,
**callback_kwargs)
File
"c:python24libsite-packagesdjango-0.95-py2.4.eggdj
angocontribadminviewsdecorators.py"
in _checklogin
  55. return view_func(request, *args, **kwargs)
File
"c:python24libsite-packagesdjango-0.95-py2.4.eggdj
angoviewsdecoratorscache.py"
in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File
"c:python24libsite-packagesdjango-0.95-py2.4.eggdj
angocontribadminviewsmain.py"
in add_stage
  256. LogEntry.objects.log_action(request.user.id,
ContentType.objects.get_for_model(model).id, pk_value,
str(new_object),
ADDITION)
File
"c:python24libsite-packagesdjango-0.95-py2.4.eggdj
angocontribadminmodels.py"
in log_action
  13. e.save()
File
"c:python24libsite-packagesdjango-0.95-py2.4.eggdj
angodbmodelsbase.py"
in save
  203. ','.join(placeholders)), db_values)
File
"c:python24libsite-packagesdjango-0.95-py2.4.eggdj
angodbbackendsutil.py"
in execute
  12. return self.cursor.execute(sql, params)

  ProgrammingError at /admin/mmm/action/add/
  ERROR: insert or update on table
"django_admin_log" violates foreign
key constraint
"django_admin_log_content_type_id_fkey" DETAIL:
Key
(content_type_id)=(13) is not present in table
"content_types"


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Many-to-Many with Intermediate Table Bug in Admin in Django 0.95?
user name
2006-09-30 01:34:04
On Fri, 2006-09-29 at 19:27 +0000, Paul Childs wrote:
> Could someone please tell me if this is an unfixed bug
in Django 0.95.
> If it is I will submit a ticket.
> 
> I created a many-to-many relationship using an
intermediate table
> similar to
> http://www.djangoproject.com/documentation/mo
dels/m2m_intermediary/
> (see model below.)
> 
> I am able to successfully exercise the models with no
problem in the
> shell.
> 
> When I go to the Admin and I create an Action or a
Reference document
> and click on save the Admin throws an exception. But
the Action or
> Reference is still added to the database.
> 
> I searched existing tickets and found similar issues
but I'm not sure
> if they address the same circumstances.

It seems to be complaining that the content_type table's
data is
inconsistent somehow. Have a look at the contents of that
table and see
if it makes sense, particularly for the values mentioned in
the error
message.

If it looks sensible, the next step is to ensure this is
repeatable
using a clean database setup: so just using your models,
create a new
database with that structure and make sure the problem
reoccurs.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Many-to-Many with Intermediate Table Bug in Admin in Django 0.95?
user name
2006-09-30 09:46:02
Hello Malcom,

In cooking up my test I made some changes and did some
rebuilding that
affected the  database so I suspect that the
"django_content_type"
table got out of sync (I really can't confirm this since I
am now at
home)

I retried, as you suggested, with a clean database at home
and there
were no problems.

Thanks for saving me a lot of time.

Cheers,
/Paul


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )