#28075: USE_THOUSANDS_SEPARATOR = True, causes foreignkey id to become localized
---------------------------------+--------------------------------------
Reporter: George Tantiras | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.11
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by George Tantiras):
To reproduce the issue, I followed the below steps:
In a fresh django-1.11 installation:
* Create the app ```separ```
* separ/models.py:
{{{
from django.db import models
class Parent(models.Model):
a_field = models.BooleanField()
class Child(models.Model):
parent_key = models.ForeignKey(Parent)
}}}
* separ/admin.py:
{{{
from django.contrib import admin
from separ.models import Parent, Child
class ParentAdmin(admin.ModelAdmin):
pass
admin.site.register(Parent, ParentAdmin)
class ChildAdmin(admin.ModelAdmin):
pass
admin.site.register(Child, ChildAdmin)
}}}
* in the settings.py file add the ```separ``` module in the
```INSTALLED_APPS``` and the line:
{{{
USE_THOUSAND_SEPARATOR = True
}}}
* Load the Parent model with data:
{{{
>>> from separ.models import Parent, Child
>>> for i in range(1,1500):
... a = Parent(a_field = True)
... a.save()
>>> a = Parent.objects.get(id=1235)
>>> b = Child(parent_key=a)
>>> b.save()
}}}
* Visit the relevant url and hit 'Save and Add Another":
{{{
http://127.0.0.1:8000/admin/separ/child/1/change/
}}}
An error message appears: ```Select a valid choice. That choice is not one
of the available choices.```
Trying to debug the error I have found that:
{{{
/home/flyer/.virtualenvs/erad/lib/python3.4/site-
packages/django/contrib/admin/options.py(1438)_changeform_view()
1437 ModelForm = self.get_form(request, obj)
-> 1438 if request.method == 'POST':
1439 form = ModelForm(request.POST, request.FILES,
instance=obj)
ipdb> request.POST
<QueryDict: {'parent_key': ['1.235'], ... }
}}}
The result of the ```request.POST``` command contains the id of the
related model localised: ```['1.235']```.
I have not yet performed a bisect because I have not done it before, but I
will give it a try.
--
Ticket URL: <https://code.djangoproject.com/ticket/28075#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.c51cc53b93ab807f6cb01ff6d252f85c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.