Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Else dont work in django, i dont know how to solve this
Request Method: GET Request URL: http://127.0.0.1:8000/articles/ Django Version: 2.2.7 Exception Type: TemplateSyntaxError Exception Value: Invalid block tag on line 12: 'else', expected 'endblock'. Did you forget to register or load this tag? {% extends 'base.html' %} {% block title %}Ultemele statii{% endblock %} {% block content %} {% if latest_articles_list % } {% for a in latest_articles_list %} <a href="#">{{a.article_title}}</a> {% endfor %} {% else %} statii ne naidena ))= {% endif %} {% endblock %} Code don't work -
Django Import-Export Overwriting / Updating non-unique CharField
I am trying to import xls files that in some cases have missing data. Rather than manually changing the necessary fields before import, I'd ideally like Django to account for them. In this case, while each product should have a unique barcode, some products in this xls file have 'N/A' instead. For some reason Django is interpreting these products as the same, and updates them instead of creating new. This problem does not occur for the other CharFields like Format or Cost; if all entries have a Format of 'LP' the import proceeds without error. Any ideas what is causing this? Bonus Question: Any way to chop off the time from the Release Date? I believe this is all the relevant code. resources.py class ArtistWidget(widgets.ForeignKeyWidget): def clean(self, value, row=None, *arg, **kwargs): return self.model.objects.get_or_create(artist=value)[0] if value else None class LabelWidget(widgets.ForeignKeyWidget): def clean(self, value, row=None, *args, **kwargs): return self.model.objects.get_or_create(label=value)[0] if value else None class ProductResource(resources.ModelResource): artist = fields.Field(column_name='artist', attribute='artist', widget=ArtistWidget(Artist, 'artist')) label = fields.Field(column_name='label', attribute='label', widget=LabelWidget(Label, 'label')) prod_format = fields.Field(column_name='format', attribute='prod_format') release_date = fields.Field( column_name='release date', attribute='release_date') cat_number = fields.Field(column_name='cat#', attribute="cat_number") class Meta: model = Product import_id_fields = ('barcode',) fields = ('artist', 'title', 'cat_number', 'prod_format', 'label', 'barcode', 'cost', 'release_date',) skip_unchanged = True … -
Wagtail: How to verify if a user can access a page in the template
I am creating a personal website using Django with Wagtail, in which users belonging to different groups can access certain pages. For example, the family group can see my holiday photos, while the co-workers group can see some internal documents. Setting up permissions is very straightforward to set up through the admin. However, I would like to show a lock next to the link to forbidden pages. This will make it very clear to the user which links can be followed and which ones can't. Is there any way to verify whether the current user has access to a given page? -
Jquery not returning the unique values
I have created one viewall page for all the products in django and the page is created dynamically using the context object data. I have created one hidden input type which holds the value of unique id of products. When i click on the product i wish to fetch the value of hidden input type. But it is returning the value of first product only i.e the first object in the context. below is the code. {% for album in list1 %} <div class="col-lg-3" id="div1"> <div class="card" style="width: 20rem;"> <input type="hidden" class="custId" value={{ album.id }}> {{ album.product_name }} Category : {{ album.product_category }} Price : {{album.id }} $('.k').click(function(){ var a = $('.custId').val(); alert(a) console.log(a) $('#myModal').modal('show'); }); -
problem with manage.py: No module named 'django'
When I tried to execute python manage.py runserver, it failed due to the SyntaxError. Then I tried it with python 3, it still didn't help and said "No module named 'django'". However, when I searched the packages in my virtualenv, it seemed that django is inside this virtualenv. It seems like it's using the local packages but not the packages inside the virtualenv. Can someone help me resolve this problem? Thx -
django + electron.js .exe
Existe alguna forma de crear una aplicacion de escritorio ejecutable .exe con django + electron.js?, si existe, podrian pasarme algun tutorial, ejemplo, documentacion, video. Que me ayude a entender ? -
django does't know MultiValueDictKeyError
when i try to recieve data from my html code for first time it Errors 'MultiValueDictKeyError' def comment(request): c = request.GET['comment'] return render( request, 'comment.html', context={ 'c' : c } ) becuase at first time there is no request. i changed this code to def comment(request): c = str() try: c = request.GET['comment'] except MultiValueDictKeyError: print(' ') return render( request, 'comment.html', context={ 'c' : c } ) but it Errors: name 'MultiValueDictKeyError' is not defined -
django/apache problem with No module named 'django
My problem is this Image When trying to access my Apache website I get the error 500 and that's why I decided to check the Apache log and I can't understand how to solve it The log of apache with error is this: [Sun Nov 24 19:06:06.409034 2019] [wsgi:error] [pid 30236] [client 173.44.36.79:49895] mod_wsgi (pid=30236): Target WSGI script '/var/www/html/taller_ortiz/taller_ortiz/wsgi.py' cannot be loaded as Python module. [Sun Nov 24 19:06:06.409188 2019] [wsgi:error] [pid 30236] [client 173.44.36.79:49895] mod_wsgi (pid=30236): Exception occurred processing WSGI script '/var/www/html/taller_ortiz/taller_ortiz/wsgi.py'. [Sun Nov 24 19:06:06.409444 2019] [wsgi:error] [pid 30236] [client 173.44.36.79:49895] Traceback (most recent call last): [Sun Nov 24 19:06:06.409527 2019] [wsgi:error] [pid 30236] [client 173.44.36.79:49895] File "/var/www/html/taller_ortiz/taller_ortiz/wsgi.py", line 12, in <module> [Sun Nov 24 19:06:06.409550 2019] [wsgi:error] [pid 30236] [client 173.44.36.79:49895] from django.core.wsgi import get_wsgi_application [Sun Nov 24 19:06:06.409617 2019] [wsgi:error] [pid 30236] [client 173.44.36.79:49895] ImportError: No module named 'django' [Sun Nov 24 19:06:06.813975 2019] [wsgi:error] [pid 30238] [client 173.44.36.79:49927] mod_wsgi (pid=30238): Target WSGI script '/var/www/html/taller_ortiz/taller_ortiz/wsgi.py' cannot be loaded as Python module. [Sun Nov 24 19:06:06.814064 2019] [wsgi:error] [pid 30238] [client 173.44.36.79:49927] mod_wsgi (pid=30238): Exception occurred processing WSGI script '/var/www/html/taller_ortiz/taller_ortiz/wsgi.py'. [Sun Nov 24 19:06:06.814249 2019] [wsgi:error] [pid 30238] [client 173.44.36.79:49927] Traceback (most recent call last): [Sun Nov … -
django.core.exceptions.FieldError: Cannot resolve keyword 'Topic' into field. Choices are: accessrecord, id, name, topic, topic_id, url
this is my molels.py from django.db import models # Create your models here. class Topic(models.Model): top_name = models.CharField(max_length=264,unique=True) def __str__(self): return self.top_name class Webpage(models.Model): topic = models.ForeignKey('Topic',on_delete=models.PROTECT) name = models.CharField(max_length=264,unique=True) url = models.URLField(unique=True) def __str__(self): return self.name class AccessRecord(models.Model): name = models.ForeignKey('Webpage',on_delete=models.PROTECT) date = models.DateField() def __str__(self): return self.date and this is my populate script import os os.environ.setdefault('DJANGO_SETTINGS_MODULE','first_project.settings') import django django.setup() ##fake pop script import random from first_app.models import AccessRecord, Webpage, Topic from faker import Faker fakegen = Faker() topics = ['Search','Social','Marketplace','News','Games'] def add_topic(): t = Topic.objects.get_or_create(top_name=random.choice(topics))[0] t.save() return t def populate(N=5): #get the topic for the entry top = add_topic() #create the fake data for that entry fake_url = fakegen.url() fake_date = fakegen.date() fake_name = fakegen.name() #create a fake new Webpage entry webpg = Webpage.objects.get_or_create(Topic=top,url=fake_url,name=fake_name)[0] #create a fake access record for that Webpage acc_rec = AccessRecord.objects.get_or_create(name=webpg,date=fake_date)[0] if __name__ == '__main__': print("population script") populate(20) print("populate complete") ** i m trying run populate_first_app script .i have error.and this is my error I've never seen the error like this I am using this script under the influence of a virtual environment which I already installed all the packages I already checked a few things like uninstalling and installing the 'faker' library again … -
How can i deliver the product to the customer but not the source code in Django?
I'm working as a freelance developer for a while. I'm developing a web application using the Django web framework which is using python. Now consider the following scenario and help me out what should I do in such scenario? The customer wants to provide his own server for deploying the website on the other side I don't want to hand the source code to the customer, Now what should I do? is there any solution? By the way, based on the aforementioned scenario if the Django does not have such capability, what other frameworks do? (For example, this is the same for PHP frameworks, I think) -
Jquery click function not working for all the ids
I have created a page which contains all the products from the database, and this is dynamic page. Columns are created in loop. Whenever user clicks the product i am fetching the product id which is unique, however this is working only for one product, for next product even if click the function is not triggered. below is the code for reference. {{ album.product_name }} Category : {{ album.product_category }} Price : {{ album.product_price }} $(document).ready(function() { $('#k').click(function(){ var a = $('#custId').val(); alert(a) console.log(a) }); This is working perfectly fine for the first product only i.e the first product from the loop. for rest the click function is not working. Please help! -
self.foreign_related_fields[0] IndexError: tuple index out of range in django
I have tried before using same code but got an error like FieldDoesNotExist userid but why I do not know! Now I have got an error like this.. I am newcomer in django. Please help me to make this project. My custom authentication model in django: from django.db import models from django.contrib.auth.models import ( AbstractBaseUser, BaseUserManager ) from organization.models import Organization class UserManager(BaseUserManager): # use_in_migrations = True # python manage.py createsuperuser def create_user(self, orgid, username, email, password=None, is_admin=False, is_staff=False, is_active=True): if not orgid: raise ValueError("Organization of user must not empty") elif not username: raise ValueError("User must have an username") elif not email: raise ValueError("User must have an email address") org_obj = Organization.objects.all(orgid=orgid) user_obj = self.model( orgid=org_obj, username=username, email = self.normalize_email(email), password=password ) user_obj.set_password(password) user_obj.admin=is_admin user_obj.staff=is_staff user_obj.active=is_active user_obj.save(using=self._db) return user_obj # python manage.py createsuperuser def create_superuser(self, orgid, username, email, password=None): user = self.create_user(orgid,username,email,password=password,is_admin=True,is_staff=True,is_active=True) return user def create_staffuser(self, orgid, username, email, password=None): user = self.create_user(orgid,username,email,password=password,is_admin=False,is_staff=True,is_active=True) return user class User(AbstractBaseUser): orgid = models.ForeignKey(Organization, max_length=6, on_delete=models.CASCADE) username = models.CharField(primary_key=True, max_length=50) email = models.EmailField(max_length=255, unique=True, null=False, blank=False) admin = models.BooleanField(default=False) staff = models.BooleanField(default=False) active = models.BooleanField(default=True) date_joined = models.DateTimeField(auto_now_add=True) objects = UserManager() USERNAME_FIELD = "username" # REQUIRED_FIELDS must contain all required fields on your User … -
How to perform layer navigation in Django
i have a view to search in products using the Q library look in the product title and description. it works fine, what if i want advanced search for example after looking for iphone, within the search results i want the grey color using the side layer navigation like any professional ecommerce website any tutorial for the same? -
Django Form Doesn't Accept DateTime From DateTimePicker
I'm working on a todo web app and has a user enter an events datetime with a custom bootstrap datetimepicker from here. I have the custom widgets on a form formatted to MM/DD/YY hh:mm A. However, Django doesn't accept the form. A similar question has been asked, but instead of overriding the default DateTimeInput, I would like the form to display in a certain format but be stored in a database in the default format. I'm thinking of using widget tweaks to customize the picker but I don't know how to store it in default formats. What would be the best way to do this? Forms.py from bootstrap_modal_forms.forms import BSModalForm from .widgets import BootstrapDateTimePickerInput from bootstrap_datepicker_plus import DateTimePickerInput from .models import ToDoItem class NewEventForm(BSModalForm): class Meta: model = ToDoItem fields = ['title', 'description', 'start_time', 'end_time', 'remind_time'] widgets = { 'start_time': DateTimePickerInput( options={"format": "MM/DD/YYYY hh:mm A"} ), 'end_time': DateTimePickerInput( options={"format": "MM/DD/YYYY hh:mm A"} ), 'remind_time': DateTimePickerInput( options={"format": "MM/DD/YYYY hh:mm A"} ), } Event form: {% load bootstrap4 %} {% load static %} {% bootstrap_css %} {% bootstrap_javascript jquery='full' %} <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <!-- Custom Stylesheet --> <link rel="stylesheet" type="text/css" href="{% static 'main/main.css' %}"> <!-- Moment.js --> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.23.0/moment.min.js" … -
Handling SMS messages when processing forms
I have a few views which handle the forms for new objects being created which seem to lag the user experience due to having to connect to the Twilio API. For example, the following form_valid method sends an SMS message to all receivers of a memo: def form_valid(self, form): form.instance.sender = self.request.user form.save() receiving_groups = form.cleaned_data['receiver'] for group in receiving_groups: username = list( employees.models.Employee.objects.filter( employee_type=group)) for user in username: form.instance.unread.add(user) memo_url = form.instance.pk user.send_sms('memo', memo_url) user.send_email('memo', memo_url) form.save() return super(MemoCreateView, self).form_valid(form) The issue here is that the send_sms method has to wait for a response before continuing. This really makes the site seem slow to the user. I have started to create a request_finished signal but I would have to pass a lot of parameters to the signal so this seems like a bad option. What other options do I have for sending the SMS messages post-success/redirect of the object being created? -
Can I use Sphinx write my help dicumentation in a django project
I have a django project and one menu option is 'Help'. The help documentation is written using Sphinx and there are many pages, e.g. Index, Introduction, First View, Users, Glossary. I have used the html: <li><a href="help" target="_blank">Help</a></li> My urls and views are: urls.py urlpatterns = [ url(r'^help/', views.index, name='index'), ] views.py: def index(request): context = {} url = 'help/index.html' return render(request, url, context) This takes me to the help index page from my menu, but every link I click on in the documentation page re-routes me back through index in views, and re-shows the index page, instead if displaying the link that I requested. If display the index page directly in a browser, without using the django site, it works as expected. I am loathe to integrate the help sub-system into django, because it would get over-written every time I 'make html'. What approach should I take? -
Can't add normal Comment section in my Django web-application
I have trouble with adding comments to my django web-application. I want to add comments to allow users comment posts, like in normal web blog. I've tried a few ways, but nothing worked correctly for me. After a few weeks searching and trying different ways to solve this question, I've stacked on this question. I have some progress, but it's now what I want completely. Now I can only add "comments" from admin panel and it look like this (from admin panel) and like this (from user interface) And I have this issue with padding comments( I don't really understand why it's occurs ¯_(ツ)_/¯ ) Anyway, here is my code, hope someone know how to solve this problem: models.py class Comment(models.Model): post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments') author = models.ForeignKey(User, on_delete=models.CASCADE) text = models.TextField() created_date = models.DateField(auto_now_add=True) def __str__(self): return self.text ... class Post(models.Model): title = models.CharField(max_length=200) content = models.TextField() date_posted = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE) categories = models.ManyToManyField('Category', related_name='posts') image = models.ImageField(upload_to='images/', default="images/None/no-img.jpg") slug= models.SlugField(max_length=500, unique=True, null=True, blank=True) def __str__(self): return self.title def get_absolute_url(self): return reverse('post-detail', kwargs={'slug': self.slug}) post_detail.html <article class="media content-section"> {% for comment in post.comments.all %} <ul> {{ comment.text }} {% for reply in comment.replies.all %} <li> … -
Is there a way to add LDAP user and user group management into Django Admin Page?
I am constructing a web application with LDAP Authentication. I have successfully implemented the LDAP authentication, but to manage priviledges on pages I would like to use user base and user group based permission. This whole process managed by the end users so we need a panel/page to view all LDAP users and user groups (which we already filtered in settings.py) Settings.py: .... #Include DB Routers DATABASE_ROUTERS = ['ldapdb.router.Router', ] # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True ################################################################### ################# LDAP AUTHENTICATION SETTINGS #################### ################################################################### # Baseline configuration. AUTH_LDAP_SERVER_URI = "ldap://10.xx.xx.x7" AUTH_LDAP_BIND_DN = "CN=s****1,OU=Generic Accounts,DC=xxx,DC=local" AUTH_LDAP_BIND_PASSWORD = "*****" AUTH_LDAP_BIND_AS_AUTHENTICATING_USER = True AUTH_LDAP_USER_SEARCH = LDAPSearch( "OU=xxxAddressList,DC=xxx,DC=local", ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)" ) AUTH_LDAP_USER_FLAGS = { "is_active": AUTH_LDAP_USER_SEARCH, "is_staff": AUTH_LDAP_USER_SEARCH, "is_superuser": AUTH_LDAP_USER_SEARCH, } # Populate the Django user from the LDAP directory. AUTH_LDAP_USER_ATTR_MAP = { "username":"cn", "first_name": "givenName", "last_name": "sn", "email": "mail", } # Set up the basic group parameters. AUTH_LDAP_GROUP_SEARCH = LDAPSearch( "OU=xxxAddressList,DC=xxx,DC=local", ldap.SCOPE_SUBTREE, "(objectClass=organizationalPerson)", ) #I HAVE TRIED THESE LINES BUT NO OBJECT APPEARED ON DJANGO ADMIN … -
How to render file in django template
PLease I am trying to render django file in the template, the problem is that , I am taking audio, video and images as input and I don't know how to render them in my html template. Whether I will use tag or tag or tag. -
Display custom success or error progress bar
I am making a django app that displays a progress bar. So far I have got it working to display a progress bar using this library and the following code which they suggested. <div class='progress-wrapper'> <div id='progress-bar' class='progress-bar' style="background-color: #68a9ef; width: 0%;">&nbsp;</div> </div> <div id="progress-bar-message">Waiting for progress to start...</div> <script src="{% static 'celery_progress/celery_progress.js' %}"></script> <script> // vanilla JS version document.addEventListener("DOMContentLoaded", function () { var progressUrl = "{% try: url 'celery_progress:task_status' task_id catch: pprint("PHEW") %}"; CeleryProgressBar.initProgressBar(progressUrl); }); </script> However, how might i integrate the above code with the code below to get it to display success or error: function customSuccess(progressBarElement, progressBarMessageElement) { progressBarElement.innerHTML = ( '<figure class="image"><img src="/static/projects/images/aww-yeah.jpg"></figure>' ) progressBarElement.style.backgroundColor = '#fff'; progressBarMessageElement.innerHTML = 'success!' } function customError(progressBarElement, progressBarMessageElement) { progressBarElement.innerHTML = ( '<figure class="image"><img src="/static/projects/images/okay-guy.jpg"></figure>' ) progressBarElement.style.backgroundColor = '#fff'; progressBarMessageElement.innerHTML = 'shucks.' } CeleryProgressBar.initProgressBar(taskUrl, { onSuccess: customSuccess, onError: customError, }); -
How can I omit time at HTML {{ post.published_date }} tag?
How can I omit time at HTML {{ post.published_date }} tag? I use Python and Django, I tried showing the published date, but I don't want to display time. <!--html file--> <a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }} ... &nbsp {{ post.published_date }}</a> e.g. what I have: This is post title ... Nov. 19, 2019 p.m. 5:37 This is post title, too! ... Nov. 24, 2019 a.m. 2:30 what I want: This is post title ... nov. 19, 2019 This is post title, too! ... nov. 24, 2019 -
How to document django channels websocket api
I am trying to make restful API with django rest framework, i am documenting this api with default django rest framework documentation and it is working fine. But i have also two another non rest endpoints. Django eventstream endpoint for SSE events. I send here information about any changes on the server that affect the user or things with which he is associated with anything. Django channels websocket endpoint for in-app chat over users. chat also supports several commands and has few complex options. So, my question is, how to document this two endpoints? My favourite option is including this endpoints to my existing docs but i don't know how to do this without loosing its readability. Is there some good practices for documenting websocket/eventstream api in python? Or another good standard/app/html generotor which i can include and serve in my django app? Thanks for Your help -
timezone() missing required argument 'offset' (pos 1) in models.py while trying to migrate, what is the reason?
while making a blog, my models.py: from django.db import models class Post(models.Model): title=models.CharField(max_length=200,blank=True) author=models.ForeignKey('auth.user',on_delete=models.CASCADE,) image=models.ImageField(upload_to='media/',blank=True) content=models.CharField(max_length=1000,blank=True) date=models.DateTimeField(auto_now_add=False, editable=False) tag=models.CharField(max_length=100,blank=True) slug=models.CharField(max_length=200,blank=True) def __str__(self): return self.title when i run python manage.py makemigrations, datefield is created in database: from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('blog', '0013_auto_20191124_1448'), ] operations = [ migrations.AlterField( model_name='post', name='date', field=models.DateTimeField(editable=False), ), ] but when i try to run python manage.py migrate, it shows the following error: (Django-k7xSBAPV) C:\Myfiles\python\Django\myblog\blog_project>python manage.py makemigrations No changes detected (Django-k7xSBAPV) C:\.....\blog_project>python manage.py migrate Operations to perform: Apply all migrations: admin, auth, blog, contenttypes, sessions Running migrations: Applying blog.0004_post_date...Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\core\management\__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\core\management\base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\core\management\base.py", line 364, in execute output = self.handle(*args, **options) File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\core\management\base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\core\management\commands\migrate.py", line 234, in handle fake_initial=fake_initial, File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\db\migrations\executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "C:\Users\ronyrocks\.virtualenvs\Django-k7xSBAPV\lib\site- packages\django\db\migrations\executor.py", … -
Showing javascript or html within html tabs
I am making a django app. The following are bits and pieces from my index.html template. I have code that displays a progress bar: <div class='progress-wrapper'> <div id='progress-bar' class='progress-bar' style="background-color: #68a9ef; width: 0%;">&nbsp;</div> </div> <div id="progress-bar-message">Waiting for progress to start...</div> <script src="{% static 'celery_progress/celery_progress.js' %}"></script> <script> // vanilla JS version document.addEventListener("DOMContentLoaded", function () { var progressUrl = "{% try: url 'celery_progress:task_status' task_id catch: pprint("PHEW") %}"; CeleryProgressBar.initProgressBar(progressUrl); }); </script> I have: {{index | safe}} that displays an error message should my progress fails. I also have the following code for displaying tabs: <div class="tab"> <button class="tablinks" onclick="openCity(event, 'London')" id="defaultOpen$ <button class="tablinks" onclick="openCity(event, 'Paris')">Paris</button> <button class="tablinks" onclick="openCity(event, 'Tokyo')">Tokyo</button> </div> <div id="London" class="tabcontent"> <h3>London</h3> </div> <div id="Paris" class="tabcontent"> <h3>Paris</h3> <p>Paris is the capital of France.</p> </div> <div id="Tokyo" class="tabcontent"> <h3>Tokyo</h3> <p>Tokyo is the capital of Japan.</p> </div> function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; } // Get the element with id="defaultOpen" and click on it document.getElementById("defaultOpen").click(); </script> How might I modify … -
i want to atttch 3 images wiht 1 image when i access 1 image come all 3 images with this in django
image = models.ImageField(upload_to='images/') attach 3 images with this image but this images take from user input form and access 3 images with one images and automatically maintain a database table to save this images