Problems in the use of django combined with ajax

clipboard.png
for example, in the template, I need to pass variables such as username,uid to the foreground to display user information, while data such as time,data needs to be updated in real time, so I use ajax to get the data in the frontend, but it is impossible to get the data in one function, so do I have to separate two functions to provide an interface for the frontend? Because this will lead to code duplication. (of course, I know that json, is the best way for ajax to get data. As an example, it must be irregular.)

Mar.06,2021

you can return different results in one function by determining whether the request method is ajax, but it is not recommended. It is recommended to return ajax. through another function

. It's not a problem for

code to repeat this, you can put the repeated code in another method and then reference that method.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3dffd-2c3d0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3dffd-2c3d0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?