Is there a way to set the 'id' attribute in the template?
let's say i pass my form
as context in my view so when I render some field from my form like {{form.field1}}
can I set the 'id' something like {{form.fiel1|attrib=('id':'id_forfieldone')}}
I know that can be done in the form class definition, but I need to do it in the template.
EDIT: Here is the error
Traceback (most recent call last): File "manage.py", line 17, in execute_from_command_line(sys.argv) File "C:\Python27\lib\site-packages\django\core\management__init__.py", line 351, in execute_from_command_line utility.execute() File "C:\Python27\lib\site-packages\django\core\management__init__.py", line 343, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\lib\site-packages\django\core\management__init__.py", line 177, in fetch_command commands = get_commands() File "C:\Python27\lib\site-packages\django\utils\lru_cache.py", line 101, in wrapper result = user_function(*args, **kwds) File "C:\Python27\lib\site-packages\django\core\management__init__.py", line 72, in get_commands for app_config in reversed(list(apps.get_app_configs())): File "C:\Python27\lib\site-packages\django\apps\registry.py", line 137, in get_app_configs self.check_apps_ready() File "C:\Python27\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
id_fieldname
by default, so in your case it would beid_field1
. Why do you need to set it to something else? – John Gordon