| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/dev/code/erp/dynamic_fields/ |
Upload File : |
"""
dynamic_fields/methods.py
"""
from django.db import connection
from django.template.loader import render_to_string
from horilla.horilla_middlewares import _thread_locals
def column_exists(table_name, column_name):
"""
Check if the column exists in the database table.
"""
with connection.cursor() as cursor:
columns = [
col[0]
for col in connection.introspection.get_table_description(
cursor, table_name
)
]
return column_name in columns
def structured(self):
"""
Render the form fields as HTML table rows with Bootstrap styling.
"""
request = getattr(_thread_locals, "request", None)
context = {
"form": self,
"request": request,
}
table_html = render_to_string("dynamic_fields/common/form.html", context)
return table_html