I worked with Django DateTimeFiled() before. Recently, I got a problem which is, DateTimeFiled() widgets on django-admin-site not working. and it’s returning an error on the console which is saying :
Uncaught TypeError: Cannot read properties of undefined (reading ‘10’)
at Date.getAbbrevMonthName (core.js:91)
at Date.strftime (core.js:102)
at Object.handleCalendarQuickLink (DateTimeShortcuts.js:415)
at HTMLAnchorElement. (DateTimeShortcuts.js:248)
I was working on that project for more than 1 month. It was okay before. Never saw that error. But suddenly I got this issue on my project and I’m stuck
Searched and tried to solve that issue. But I didn’t find anything related.
If anyone can help on this matter it would be great.
Thanks in Advance.
Based on only the information provided here, I’d suggest you work your way backward through your source code repository history until you find a version that worked, and compare that to the first version that doesn’t work in order to identify the cause of the problem.
Beyond that, we’d need to start with seeing your ModelAdmin class for this model, possibly the Model class, and anything else you might have customized in the admin associated with this. (Any custom JavaScript, etc)
Actually, I’ve already tried that. I’ve downloaded the last committed codes from my GitHub repository(When it was working fine). Then after migrating everything with a new database it shows the same error on my admin site.
It’s a javascript error that was showing in my console.
In my database model, I had a DateTime field. After migrating I should have a DateTime input filed in django-admin-site. That input field works fine if I manually input date or time. But besides that input field, we have 2 widgets for date and 2 widgets for time which are called ‘now’ ‘calender-icon’ & ‘now’ ‘clock-icon’. Those 4 widgets are not working, after clicking on those widgets this error occurs otherwise application working fine.
Now the point is, those 4 widgets were provided by django itself. And those ‘core.js’, ‘DateTimeShortcuts.js’ files were also provided by django itself.
Actually, I don’t even know how to get those admin related files (CSS,js etc) in my project directory
So, I didn’t change any js related to admin. I did write or add an <script> captcha </script>
in my base.html at the bottom for Captcha(JS). And when I did that, there was no error in my application not even in my admin-site.