Category : django-templates

I have a problem with getting data from the tag on the page with the Django form. templates: <form method="post" enctype="multipart/form-data"> {% csrf_token %} <input id="result" type="hidden"> <script type="text/javascript"> const upload = document.querySelector(‘#inputGroupFile01’); const result = document.querySelector(‘#result’); upload.addEventListener("change", (e) => { previewFunc(e.target.files[0]); }); function previewFunc(file) { if (!file.type.match(/image.*/)) return false; const reader = new FileReader(); ..

Read more

I followed Django-registration-redux start guide and everything works fine but the registration form shows instruction label for username and password which is like in the picture below. I don’t want it so how can I remove it? in settings.py, i included INSTALLED_APPS = [ ‘registration’, ‘django.contrib.admin’, ‘django.contrib.auth’, ‘django.contrib.contenttypes’, ‘django.contrib.sessions’, ‘django.contrib.sites’, ‘django.contrib.messages’, ‘django.contrib.staticfiles’, ] ACCOUNT_ACTIVATION_DAYS = ..

Read more

I want to change DIRS dynamically.based on devices. if request.user_agent.is_pc: request.template_prefix = ‘desktop’ else: request.template_prefix = ‘mobile’ Default (settings.py): TEMPLATES = [ { ‘DIRS’: [‘templates’], }, ] I want to change my DIRS path like this (settings.py): TEMPLATES = [ { ‘DIRS’: [f"templates/{request.template_prefix}"], }, ] Also let me know if you need more codes. Note: ..

Read more

I am trying to add a link in the f string below: d += f'<li> {event.time} {event.teacher} {event.student} {event.status} </li>’ Basically, I want it to look something like below: f'<li> <a href="{% url ‘somewhere’ event.pk %}"> {event.time} {event.teacher} {event.student} {event.status} </a> </li>’ However, I get the following error when I do this: SyntaxError: f-string: expecting ..

Read more