Select fields change their value without user interaction

12 views
Skip to first unread message

Noxxan

unread,
Nov 18, 2011, 10:47:18 AM11/18/11
to Django users
Hi,

I have a problem with large form in Django admin site. I have a model
A with two inline models (B and C). Model B have some fields, and one
of them is ForeignKey with another model (we can call it D). This
field is displayed as HTML select field and have a lot of options
(about 2k).

I have record in model A. In it there is about 20 related records in
model B, and so my HTML code has about 50k lines of code (mainly
because of HTML select with model D).

The problem is that sometimes (it happens yesterday first time) some
of ForeignKey values in model B changes without user interaction, user
changed something else in this big form and clicked "submit" button.

Situation looks like that:

Model B records (ID means ForeignKey ID):

ID before submit -> ID after submit
1 -> 182
2 -> 700
3 -> 3 (no diff)
1 -> 182
2 -> 700
5 -> 5
6 -> 6
2 -> 700
...etc

So, some of foreign keys changes, some not. But also when in one
record foreign key ID was changed to some value, in other record with
the same value before, value after was changed to the same value as in
other records with this "before foreign key ID".

No errors was raised there, and Django logged changes in admin log
that this fields was changed there (so, it looks like the user changed
that fields, but I'm 100% sure that user doesnt do that).

What could be a problem?

Thanks

creecode

unread,
Nov 18, 2011, 11:41:54 AM11/18/11
to django...@googlegroups.com
Hello Noxxan,

One possible cause.  Browser bugs.  I was looking at a form the other day and I saw a field with a FK popup that didn't look right.  Reloaded the webpage, same thing.  Looked at the record via another route and the field was OK,  Reloaded form in browser again.  Still wrong.  Relaunched the browser, form looked OK!

Let us know if a restart of the browser fixes the issue.  You may want to restart the computer at well.  I've found over the years that restarts can take care of all kinds of issues.  I often recommend that folks get in the habit of doing regular restarts.  At the start of the day is good! :-)

Toodle-looooooooo..............
creecode

Noxxan

unread,
Nov 18, 2011, 11:57:53 AM11/18/11
to Django users
Thanks for your answer, I also suspect browser (big tree, it happens
randomly), but maybe there are other possibilities here.

Django admin in my case is used very often, many people are using it,
and I'm wondering what can I do to catch/reproduce this kind of
problems, to react on them, because integrity of data keeped there is
important for me, I would rather want to crash hole browser than save
corrupt data.

I'm using Django 1.2.5 in this moment, with Python 2.6.6, if it can
help.

creecode

unread,
Nov 18, 2011, 12:48:43 PM11/18/11
to django...@googlegroups.com
Hello Noxxan,


On Friday, November 18, 2011 8:57:53 AM UTC-8, Noxxan wrote:

Django admin in my case is used very often, many people are using it,
and I'm wondering what can I do to catch

I don't know about catching an unwanted change.  How would Django be able to know that a changed value from the browser is incorrect?
 
reproduce this kind of
problems, to react on them,

You might want to try to isolate if the issue is related to just the FK field with 2k entries in it for your browser.  Perhaps create a bare minimum html file by hand with a select field with 2 k entries and see if that produces the issue.  At least if the issue does manifest it would help you with where the bug is happening.

By the way would the ModelAdmin.raw_id_fields < http://docs.djangoproject.com/en/1.3//ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields > be an option for your use case?

Toodle-looooooooooo...........
creecode
Reply all
Reply to author
Forward
0 new messages