Doesn't work on a Inline Admin Page
See original GitHub issueChecklist
Put an x
in the bracket when you have completed each task, like this: [x]
- This issue is not about installing previous versions of django-smart-selects older than 1.2.8. I understand that previous versions are insecure and will not receive any support whatsoever.
- I have verified that that issue exists against the
master
branch of django-smart-selects. - I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- I have debugged the issue to the
smart_selects
app. - I have reduced the issue to the simplest possible case.
- I have included all relevant sections of
models.py
,forms.py
, andviews.py
with problems. - I have used GitHub Flavored Markdown to style all of my posted code.
Steps to reproduce
- Use Django Smart Selects on a Inline Admin Page.
Actual behavior
I use Django Smart Selects to dynamically choose a document based on its document type. It work fine on an Admin Page, but I have another Page with an Inline Admin and there I’ve got this error:
?_changelist_filters=o%3D5.2.3%26p%3D2:1 Uncaught SyntaxError: Unexpected number in JSON at position 1
at JSON.parse (<anonymous>)
at initItem (bindfields.js:8)
at HTMLSelectElement.<anonymous> (bindfields.js:25)
at Function.each (jquery.min.js:2)
at HTMLDocument.<anonymous> (bindfields.js:24)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at Function.ready (jquery.min.js:2)
at HTMLDocument.J (jquery.min.js:2)
initItem @ bindfields.js:8
(anonymous) @ bindfields.js:25
each @ jquery.min.js:2
(anonymous) @ bindfields.js:24
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
J @ jquery.min.js:2
MyClass model:
class MyClass(BaseModel):
idcliente = models.IntegerField(default=102, editable=False)
(...)
idtipodoc = models.ForeignKey('Tipodoccliente', db_column='idtipodoc', related_name='+')
nrdoc = ChainedForeignKey(
Cliente,
chained_field="idtipodoc",
chained_model_field="idtipodoc",
show_all=False,
auto_choose=True,
db_column='nrdoc', related_name='+'
)
class Cliente(BaseModel):
idtipodoc = models.ForeignKey('Tipodoccliente', db_column='idtipodoc', verbose_name='Tipo do Documento', related_name='+')
nrdoc = models.CharField(primary_key=True, unique=True, max_length=15, verbose_name='Numero do Documento', validators=[numeric])
nome = models.CharField(max_length=100, verbose_name='Nome')
(...)
MyClass admin inline:
class MyClasslInline(admin.TabularInline):
model = MyClass
fields = ['idcliente', (...), 'nrdoc']
max_num = 1
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:15 (6 by maintainers)
Top Results From Across the Web
django admin form does not work in inline - Stack Overflow
Show activity on this post. I didn't test, but this should do it class LoginInline(admin.StackedInline): form = LoginForm model = Login.
Read more >Problems specifying fields for admin inline - Google Groups
I'm trying to modify the default Site admin page to include an inline model. Everything seems to be working fine except that no...
Read more >Writing your first Django app, part 2
Django solves the problem of creating a unified interface for site administrators to ... First we'll need to create a user who can...
Read more >Django admin dynamic Inline positioning - Habr
My gut feeling told me, there were another way around that problem. The first solution I found was from 2017. It had too...
Read more >Unable to Edit Records via Inline Editing in a List View
Other considerations and troubleshooting. Common Issues preventing inline editing: A field must be present on at least one-page layout, and the same page...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Asocia after looking at the html you pasted and noticed that you are not using integers for your Primary Keys, which is currently unsupported by smart-selects.
AFAIK, integer Primary Keys are still required