Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How do I integrate video calling with django (simple)?
I have a django backend setup, and I want to integrate video calling for people on the same url (only 2 people will be in the call per page and it has url patterns so they will be on independent urls). Whats an easy way of implementing this? -
How do I Integrate my Django application with Salesforce
I'd like to integrate Salesforce with my app/website, which was developed in Django and takes in a lot of data from users. So I guess I'd like to replicate my app's database into salesforce and use salesforce email service. How should I get started on this project. Thank you in advance I didn't try doing any stuff, I got to know we can deploy our app to heroku or create a new connected app, but I don't know which option to choose. -
How do I compare 2 ids, uuid of a logged in user and id sent through session variable?
I am trying to compare uuid of logged in user and id of user whose profile I have to see. I am comparing them using '==' operator, but the statements inside the 'if' are not getting executed although the condition is true. This is my function 'userProfile()' in 'views.py' that corresponds to the user profile of user I have to see. def userProfile(request, pk): profile = Profile.objects.get(id=pk) proj = P1.objects.filter(owner=pk) topskills = profile.skill_set.exclude(description__exact="") otherskills = profile.skill_set.filter(description="") context = {'profile':profile, 'ts':topskills, 'os':otherskills, 'projects':proj} if request.user.is_authenticated: uid = request.user.profile.id if uid == pk : return redirect('account') else : return render(request, 'users/user_profile.html', context) else : return render(request, 'users/user_profile.html', context) 'account' is the name of url which points to 'userAccount()' in views.py which is only available for authenticated users to display their profile where they can edit their profiles details : path('account/', views.userAccount, name="account") while, 'users/user_profile.html' is available for everyone even unauthenticated users but uneditable profile section(just to view the profile details) I want that when a logged in user clicks on any user's name (even his), if he clicks on his/her name, 'account.html' should open while for any other user, 'user_profile.html'. By default, clicking on any name, will redirect user to 'userProfile()' in … -
Modal Is Deleting The First Row In The Table Incorrectly. How Do I get the right ID associated with my DELETE button?
I've been at this all day. I've researched it and the docs are a bit scarce. I do recognize that I am getting the first ID at the top of the table because the IDs are all the same. I don't know how to get the "right" ID when I'm deleting the row. The modal is popping..and the delete works...it's just the wrong record gets deleted... HTML {% for notify in notify_list %} <tr style="vertical-align:top"> <td class="hide"> <div id="myModaldelete" class="modaldelete"> <div class="modal-content-delete"> <span class="closedelete"></span> <img class="logo4" src="/static/images/threecircles.svg"> <p>Delete Request?</p> <button type="button" class="button165" id="yesBtndelete" value="{{ notify.id }}">Yes</button> <button type="button" class="button160" id="noBtndelete">No</button> </div> </div> <button type="button" class="button114"> <div class="txtalgn114"><h2 class="txtalgn114a">Delete</h2></div></button> </td> </tr> {% endfor %} My Javascript... // Get the modal var modaldelete = document.getElementById("myModaldelete"); // Get the button that opens the modal var btndelete = document.getElementById("myBtndelete"); // Get the button that opens the modal var nobtndelete = document.getElementById("noBtndelete"); // Get the <span> element that closes the modal var span = document.getElementsByClassName("closedelete")[0]; // When the user clicks on <span> (x), close the modal span.onclick = function(e) { e.preventDefault(); modaldelete.style.display = "none"; } // When the user clicks on the No button, close the modal nobtndelete.onclick = function(e) { e.preventDefault(); modaldelete.style.display = "none"; … -
Djongo EmbeddedField raises ValidationError because of renamed field
I've got a Django application with djongo as a database driver. The models are: class Blog(models.Model): _id = models.ObjectIdField() name = models.CharField(max_length=100, bd_column="Name") tagline = models.TextField() class Entry(models.Model): _id = models.ObjectIdField() blog = models.EmbeddedField( model_container=Blog ) When I run this application, I got an error: File "\.venv\lib\site-packages\djongo\models\fields.py", line 125, in _validate_container raise ValidationError( django.core.exceptions.ValidationError: ['Field "m.Blog.name" of model container:"<class \'project.m.models.Blog\'>" cannot be named as "name", different from column name "Name"'] I want to keep the name of field name in my model and database different because the database already exists and I can't change it. Database uses camelCase for naming fields whereas in application I want to use snake_case. How to avoid this error? -
Ignore diacritics in django queries with sqlite
I have following querries inside my django app that is runninng with sqlite: movies = Movie.objects.filter(Q(title__icontains=query)) actors = Actor.objects.filter(Q(name__icontains=query)) Is there a way to ignore diacritics as well? I know about unaccent but AFAIK that works only with postgres and I need to stay with sqlite. -
How to deploy Docker Compose Django Application with Celery + Reddis on Google Cloud Run
I have a docker-compose.prod.yaml containing 7 services which I'd like to deploy to Google Cloud Run. I like the benefits of a serverless solution, to my understanding the two other options are: Google App Engine, however this answer suggest multiple containers isn't possible GKE is a good fit but we're a small team without a dedicated DevOps engineer or internal Kubernetes expertise which is what would be required Is deploying such application possible on Google Cloud Run or even desirable? Some guidance on how to achieve this would be greatly appreciated. I'm favouring simplicity and cost efficiency. Some potential issues I'm foreseeing: Setting up networking between containers Instances are destroyed within 15 minutes Connecting all the volumes together Deploying 7 containers individually potentially tedious I do acknowledge that Google offers Cloud Tasks however, that would tie us to GCP and we'd miss the extensive functionality of Celery. One of the changes made to the docker-compose.prod.yaml will be switching the db container for a Cloud SQL managed instance. version: '3.8' services: nginx: build: ./compose/production/nginx volumes: - staticfiles:/app/staticfiles - mediafiles:/app/mediafiles ports: - 80:80 - 5555:5555 - 15672:15672 depends_on: - web - flower web: build: context: . dockerfile: ./compose/production/django/Dockerfile command: /start volumes: - … -
anchor do nothing after second index
I created a qcm django with sections that change with each click with anchors and the scroll snap type property here is my code <body> <section> {% for Question_reponse in Questions_reponses %} <div id="{{forloop.counter}}" class="container"> <div class="question_title"> <div class="space_title"></div> <p>{{Question_reponse.question}}</p> </div> <div class="container_reps"> {% for rep in Question_reponse.reps %} <div class="rep"> <span class="dot_rep">1</span><p class="text_rep">{{rep}}</p> </div> {% endfor %} </div> </div> {% endfor %} </section> <script> function scrollToAnchor(ind){ const aTag = $("#"+ind); $('body,section').animate({scrollTop: aTag.offset().top},'slow'); } var container_page = document.getElementsByClassName('container') const reps = document.getElementsByClassName('rep'); [].forEach.call(reps,function(rep){ $(rep).click(function(){ if(! rep.querySelector('.check')){ [].forEach.call(reps,function(repToDel){ if(repToDel.querySelector('.check')){ repToDel.querySelector('.check').remove() $(repToDel).css("border", "1px solid white") } }) $(rep).last().append('<div class="check"><object data="{% static "img/Coin-Magpharm-V3.png" %}" width="20" > </object></div>'); $(rep).css("border", "2.5px solid white"); let x = parseInt($(rep).closest('.container').attr('id')) //var y = x.toString() console.log(x) scrollToAnchor(x+1) } }) }) </script> </body> and my css: html{ scroll-behavior: smooth; } body{ background-color: #72a9d6; color: white; font-family: "Mont", sans-serif; overflow: hidden; } section{ overflow: hidden; height: 100vh; /*overflow-y: scroll;*/ scroll-snap-type: y mandatory; scroll-behavior: smooth; } .container{ padding: 5%; display: grid; position: relative; justify-items: center; gap: 3px; scroll-snap-align: center; height: 100%; } .question_title{ height: 50px; font-size: 25px; font-weight: 500; text-align: center; } .space_title{ height: 150px; } .container_reps{ max-width: 30%; display: flex; flex-wrap: wrap; justify-content: center; column-count:2; height: 20%; } .rep{ display: flex; … -
Multiples def, same method in one view
I'm trying to define 4 GET endpoints (max,min,sum,avg) to access by REST. I did this but making 4 views, and I want to know if I can define the 4 methods in a single view. I can't specify through the url which GET to hit. It's possible? my urls.py set urlpatterns =[ path('medidores/', MedidorView.as_view()), path('mediciones/', MedicionView.as_view()), path('medicion_max/<str:id>', MedicionMaxView.as_view()), path('medicion_min/<str:id>', MedicionMinView.as_view()), path('medicion_total/<str:id>', MedicionTotalView.as_view()), path('medicion_prom/<str:id>', MedicionPromedioView.as_view()) ] my view.py set class MedicionMaxView(View): def get(self, request, id): return JsonResponse(Medicion.objects.filter(medidor=id).aggregate(Max('consumo_kwh'))) class MedicionMinView(View): def get(self, request, id): return JsonResponse(Medicion.objects.filter(medidor=id).aggregate(Min('consumo_kwh'))) class MedicionTotalView(View): def get(self, request, id): return JsonResponse(Medicion.objects.filter(medidor=id).aggregate(Sum('consumo_kwh'))) class MedicionPromedioView(View): def get(self, request, id): return JsonResponse(Medicion.objects.filter(medidor=id).aggregate(Avg('consumo_kwh'))) Separate by name in urls but not have effect -
Transfering kwargs from get to post
Is this the correct way to transfer kwargs from get request to a subsequent post request initated by the same page? Why cannot I call self.get if form is invalid? class Req(TemplateView): @login_required def get(self, request, *args, **kwargs): recepient=self.kwargs['recepient'] ftype=self.kwargs['type'] req_form = ReqForm(recepient=recepient) return render(request, 'req.html',{'form':req_form,'recepient':recepient,'ftype':ftype}) @login_required def post(self, request, *args, **kwargs): recepient=self.kwargs['recepient'] ftype=self.kwargs['type'] req_form = ReqForm(data=request.POST,recepient=recepient) if req_form.is_valid(): messages.success(request, f'Your request has been sent to {recepient}!') -- More Code -- return redirect('users-profile',request.user.username) else: self.get(self, request, *args, **kwargs): -
What is the correct way to convert Django date and time fields to current timezone?
I feel like I'm missing something obvious: I implemented timezones in my Django app using the SO solution here and it seems to be working (i.e. when the user changes to their timezone, Django's {% get_current_timezone as TIME_ZONE %} and timezone.get_current_timezone.now() reflect that change) However, I have a Django model with both a naive DateField and TimeField input. I have defined a property to return the formatted string with the date and time as follows: # imports from django.db import models import pytz from django.utils import timezone from django.template.defaultfilters import date as format_date from django.template.defaultfilters import time as format_time class MyModel(models.Model): date = models.DateField(default=timezone.now, null=True, blank=True) time = models.TimeField(default=timezone.now, null=True, blank=True) ... @property def datetime(self): date_str = format_date(self.date, "j N Y") time_str = format_time(self.time, 'g:i a') return f"{date_str} at {time_str}" How would I make the dates and times returned in the string changed to suit the timezone? (It can be assumed that they currently refer to UTC.) I'm currently trying with the time field. I tried both of these functions to make the time aware: pytz.utc.localize(self.time) self.time.replace(tzinfo=pytz.UTC) But whenever I try to get the subsequent time for the zone through the statement: aware_time = self.time.replace(tzinfo=pytz.UTC) I get the error: 'datetime.time' … -
Full Stack Web Developer Related Question
Hey I am in my journey to become full stack web developer and i bought a course where i am learning node js express js as backend. But i heard we can use any other programming language as well but i have one confusion please help me. QUESTION :- In The course i am learning node js. if I learn django instead of node js. Can i call myself full stack web developer ?. Or Can we use any porgramming language or framework in backend but can only use html css javascript on the frontend ? Can we use any programming language or framework in backend in web development and can call ourself full stack web developer -
how to retrieve a Django model from a html template form
I am having a user select from a list of Pending shift swap requests. in the html page the form is as such #pending_swaps.html {% for pending in swappie_pending_list %} <form action="{% url 'ShiftSwap:pending_swaps' %}" method="post"> {% csrf_token %} <p>{{ pending.swapper.name }} wants to switch your {{ pending.get_swappie_day_display }} for their {{ pending.get_swapper_day_display }} <input type="hidden" name="Swap_Obj" value="{{ pending }}"> <input type="submit" name="Confirm" value="Confirm"> <input type="submit" name="Deny" value="Deny"> </p> </form> {% endfor %} in this code the swappie_pending_list is a list of Pending_Swap Model objects. However when I try to make a hidden input of value={{ pending }} it simply returns the str of the model instead of an instance to the model itself here is the Pending_swap model class Pending_Swap(models.Model): ''' a model to house two users, and two days to keep track of which swaps are currently pending \n swapper: user swappie: who they want to swap with swapper_day: day they are giving up swappie_day: day the user wants to take ''' Days_of_week = ( ('SU', 'Sunday'), ('MO', 'Monday'), ('TU', 'Tuesday'), ('WE', 'Wednesday'), ('TH', 'Thursday'), ('FR', 'Friday'), ('SA', 'Saturday'), ) swapper = models.ForeignKey(Person, on_delete=models.CASCADE, default=" ", related_name='Swapper') swappie = models.ForeignKey(Person, on_delete=models.CASCADE, default=" ", related_name='Swappie') swapper_day = models.CharField(max_length=2, choices=Days_of_week) … -
How to add multiple types of cache in CACHES setting in settings.py is django
I have a django application. I want to use both database cache and redis cache at different places in my application. How do I write the settings in settings.py? How do I import both redis and database cache in my code and set some data into both types of cache? I tried this in django settings.py CACHES = { 'default': { 'BACKEND':'django.core.cache.backends.db.DatabaseCache', 'LOCATION': 'data-caches', }, 'Redis': { 'BACKEND': 'django.core.cache.backends.redis.RedisCache', 'LOCATION': 'redis://127.0.0.1:6379', 'OPTIONS': { 'db': '1', 'parser_class': 'redis.connection.PythonParser', 'pool_class': 'redis.BlockingConnectionPool', } } } but when I import in my code from django.core.cache import cache It always picks the default one. How do I import database cache in one python file and redis cache in a different python file? -
How to filter data by start date to end date django then display the data in the template
models.py class Income(models.Model): date = models.DateField() capital = models.IntegerField(null=True, verbose_name='Money Capital') revenue = models.IntegerField(null=True, verbose_name='Total Revenue') profit = models.IntegerField(null=True, verbose_name='Total Profit') def __str__(self): return self.profit forms.py from django import forms from . models import Income class DateChoiceField(forms.Form): date1 = forms.ModelChoiceField ( queryset=Income.objects.values_list("date", flat=True).distinct(), ) date2 = forms.ModelChoiceField ( queryset=Income.objects.values_list("date", flat=True).distinct(), ) views.py if request.method == "POST": form = DateChoiceField(request.POST) date1 = request.POST.get('date1') date2 = request.POST.get('date2') if 'form1' in request.POST: if form.is_valid(): selectedDate1 = form.cleaned_data["date1"] selectedDate2 = form.cleaned_data["date2"] start = datetime(selectedDate1) end = datetime(selectedDate2) filterYearMonth = Income.objects.filter(date__gte=start).filter(date__lte=end) else: filterYearMonth = Income.objects.all() else: form = DateChoiceField() filterYearMonth = Income.objects.all() context = { 'filterYearMonth': filterYearMonth, 'form': form, } return render (request, "dashboard/dashboard.html", context) dashboard.html <form method="POST" action="/dashboard/"> {% csrf_token %} {{ form }} <button type="submit" name="form1">Submit</button> </form> <h4>Filter</h4> <table> {% for item in filterYearMonth %} <tr> <td>{{ item.date }}</td> <td>{{ item.capital }}</td> <td>{{ item.revenue }}</td> <td>{{ item.profit }}</td> </tr> {% endfor %} </table> I'm close to solving it but it keeps displaying all the data and i got this "Select a valid choice. That choice is not one of the available choices." whenever i try submitting the start and end date.This is what it looks like -
django start session with post as login
instead of creating a user i would like to sort things with cookies/sessions, but I'm very lost on how to do that. Tried a few things, but it didn't really work. So instead of a login page, the client has to upload to enter the main page. i would like to create the session there. and would like to display the session_id in all the other posts the client does, so that it is visible which posts, belong to the same client in the feed. I have some questions... so the index is login required (login=first post). But now im unable to do open the page due to too many redirections existing and the functions just referring back and forth between each other... how to fix this? Next up: how do i get the session id (and display it in html?)and assign it to all the clients activities? Here is what i have so far: def signup(request): if request.method == 'POST': image = request.FILES.get('image_upload') caption = request.POST['caption'] new_post = Post.objects.create(image=image, caption=caption) new_post.save() new_post.save() request.session['caption'] = caption return redirect('/') else: return redirect('signup') @login_required(login_url='signup') def index(request): posts = Post.objects.all().order_by('interaction_count') count_posts = Post.objects.count() return render(request, 'index.html', {'posts': posts, 'count_posts':count_posts}) models.py class Post(models.Model): id … -
Set value for variable in template and use it in template Django
I have a loop in which I return all the materials for the user in the course. The materials have the status "ready" or "in progress". I want to return "you need to study the previous material" if at least one previous material is in the process of being studied. The problem is that I have many courses with different order of materials. Even if the material is finished, but at least one previous material is in progress, the status should be "you need to study the previous material". {% if doc.progress__status == 'D' %} <div class="stat-block"> <span style = 'color:black;'>Пройден</span> </div> {% else %} {% if forloop.first or docs_order == data.count %} <button type="button" class="sendm" data-toggle="modal" data-target="#doc{{doc.id}}">Подписать</button> ... {% else %} {% with previous_element=data|previous:forloop.counter0 %} {% if previous_element.progress__status != 'D' %} <div>Завершите предыдущий документ</div> {% else %} <button type="button" class="sendm" data-toggle="modal" data-target="#doc{{doc.id}}">Пройти</button> ... {% endwith %} {% endif %} {% endif %} </td> </tr> {% endfor%} As you can see, I have created a custom template filter that checks if the previous value is "done". enter image description here but this does not fully cover my needs. I tried to create a simple tag "setvar" tag that just returns … -
Deploy Django AWS
Quanto custa para manter uma aplicação pequena feita em Django na AWS? Queria colocar somente uma aplicação somente Portifólio feito em Django para prática na Amazon Web Services. -
Query two models in Django into one queryset
I have two models in my django app: class Person(models.Model): name = models.CharField(max_length=100) class Book(models.Model): title = models.CharField(max_length=100) Now I need to create a view that will make one query for regex to both of the models, find the ones that are matching and display them in template. If I do: class SearchListView(ListView): queryset = Person.objects.filter(name__icontains="a") book_queryset = Book.objects.filter(title__icontains="a") I get an error that ListView accepts only one queryset. What is the typical solution to such problem? -
Django: User Login only working with terminal created users
I'm only new to django & this is my first time posting on stack overflow so appologies if I havent done this right. My problem is that when I use my login function, it only seems to work with those created with the createsuperuser command in the terminal. Those created within the website just dont work. The users show within the admin panel and have a password within them. models.py class Trickster_User(AbstractBaseUser, PermissionsMixin): UserID = models.AutoField(primary_key=True) Email = models.EmailField(('Email Address'), unique=True) Username = models.CharField(('Username'),max_length=25, unique=True) FirstName = models.CharField(('First Name'),max_length=25) LastName = models.CharField(('Last Name'),max_length=25) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) objects = CustomUserManager() USERNAME_FIELD = 'Email' REQUIRED_FIELDS = ['Username', 'FirstName', 'LastName'] def __str__(self): return self.FirstName + ' ' + self.LastName views.py def user_login(request): context = {} user = request.user if user.is_authenticated: return redirect('home') if request.method == "POST": form = UserAuthenticationForm(request.POST) if form.is_valid(): Email = request.POST['Email'] password = request.POST['password'] user = authenticate(Email=Email, password=password) if user is not None: login(request, user) return redirect('home') else: form = UserAuthenticationForm() context['user_login'] = form return render(request, 'authentication/login.html', context) forms.py class UserAuthenticationForm(forms.ModelForm): Email = forms.EmailField(widget=forms.EmailInput(attrs={'class':'form-control'})) password = forms.CharField(label='password', widget=forms.PasswordInput(attrs={'class':'form-control'})) class Meta: model = Trickster_User fields = ('Email', 'password') def clean(self): Email = self.cleaned_data['Email'] password = self.cleaned_data['password'] if not … -
How to update a field of Django Model Object whenever that particular object is fetched as a part of QuerySet from Database
I have a field called pending_since for a Ticket model. This contains the the difference between the date when the ticket is created ( created_on field ) and the current date. Now, when a single ticket is fetched, then I am able to update this field as below. views.py def pending_days_calculator(date1): current_date = timezone.now() diff = current_date - date1 diff_in_days = diff.total_seconds() / ( 60*60*24) pending_days = round(diff_in_days,2) return pending_days @login_required(login_url=settings.CUSTOM_LOGIN_URL) def ticket_detail(request, ticket_no): ticket = Ticket.objects.get(ticket_no=ticket_no) ticket.pending_since = pending_days_calculator(ticket.created_on) ticket.save() if request.method == 'POST': .....other logic here..... But, when a bunch of Ticket objects are fetched at a time as shown below, is there any way to update this field for each object, other than looping through the queryset. @login_required(login_url=settings.CUSTOM_LOGIN_URL) def common_pool(request): tickets = request.user.ticket_set.exclude(ticket_status='closed').order_by('sla') Ticket model has ForeignKey reference to user model GHDUser models.py for reference class Ticket(models.Model): ticket_no = models.CharField(max_length=10, blank=True) raised_by_user = models.ForeignKey(GHDUser, on_delete=models.CASCADE,related_name='raised_ticket', default=1) created_on = models.DateTimeField(default=timezone.now) pending_since = models.FloatField(default=0.0) -
Is there a way to exclude a Django model from Aldjemy model creation?
I have a Django model with a field that is a nested Postgres array class MyModel(models.Model): array_of_arrays = ArrayField( ArrayField( models.CharField(max_length=20), size=3, ), ) Aldjemy doesn't support nested arrays, and Aldjemy's array_type function is throwing RuntimeError("Unsupported array element type") for this field. I don't actually need a SQLAlchemy model for this Django model. Is there a way to exclude a Django model from the Aldjemy model generation process? -
Django Rosetta autoreload new translations bad gateway error
I have a problem with django-rosetta, it works fine but when changing translations it is not applied to the site until restarting the docker. I tried adding these codes: ROSETTA_WSGI_AUTO_RELOAD = True ROSETTA_UWSGI_AUTO_RELOAD = True But after adding this codes when saving rosetta it gives 502 bad gateway error despite saving new translations but it is still not applying new translations to the site until I restart. -
Django websocket cannot connect through https request blocked in railway app
My websocket works fine on localhost. But fails to run when I deploy my project on railway app (which uses https) It shows this error in the console log: first error - ''' (index):382 Mixed Content: The page at 'https://supreme-key-production.up.railway.app/rooms/bangladesh_ott/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://supreme-key-production.up.railway.app/ws/bangladesh_ott/'. This request has been blocked; this endpoint must be available over WSS. ''' second error - ''' (index):382 Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS. at window.onload (https://supreme-key-production.up.railway.app/rooms/bangladesh_ott/:382:24) ''' This is in my script : ''' window.onload = function() { const roomName = JSON.parse(document.getElementById('json-roomname').textContent); const userName = JSON.parse(document.getElementById('json-username').textContent); const chatSocket = new WebSocket( 'ws://' + window.location.host + '/ws/' + roomName + '/' ); chatSocket.onmessage = function(e) { console.log('onmessage') const data = JSON.parse(e.data); if (data.message) { let html = '<div class="message">'; html += '<p class="messsage_username">' + data.username + '</p>'; html += '<p class="message_message">' + data.message + '</p></div>'; document.querySelector('#chat-messages').innerHTML += html; } else { alert('The message was empty!'); } } chatSocket.onclose = function(e) { console.log('onclose') } // document.querySelector('#chat-message-submit').onclick = function(e) { e.preventDefault(); const messageInputDom = document.querySelector('#chat-message-input'); const message = messageInputDom.value; chatSocket.send(JSON.stringify({ 'message': message, 'username': userName, … -
make an element disappear if the date is greater than 30
I want to make the Countdown Timer element disappear if it is less than 0 or greater than 30 ` {% if data.fin>0 and if data.fin<30 %} <div id="clockdiv"> <div> <span class="days" id="day"></span> <div class="smalltext">Jours</div> </div> <div> <span class="hours" id="hour"></span> <div class="smalltext">Heures</div> </div> <div> <span class="minutes" id="minute"></span> <div class="smalltext">Minutes</div> </div> <div> <span class="seconds" id="second"></span> <div class="smalltext">Seconds</div> </div> </div> {% endif %} `