Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Render List of Dictionaries to a template
I have a list of dictionaries with same key information. How can I pass this list of dictionaries to a Django template ? listdict = [{'product':'specs','price':'12'}, {'product':'shoes','price':'30'}] When trying to send this list via views file to template it fails with an error indicating that only dictionaries are allowed. Here is the code from views file return render(request, 'recordings/extensionrecording.html',listDict) Here is the html block- <tbody> {%for list in listDict%} {%for elements in list%} <tr> <td class="body-item fonts-style display-4">{{elements.product}}</td> <td class="body-item fonts-style display-4">{{elements.price}}</td> </tr> -
Best way to query Repeating Events With available seat
I have a recurring events application, each event can have multiple recurrence patterns (RFC5445), a date can be in different recurrence patterns so I have added an autofield integer to prioritize the most recently added recurrences, each recurrence pattern has a max seat capacity. So far so good the problem starts when I need to check all the dates that have seats available for the next 365 days: I would have to check each date against a recurrence rule/pattern and finding that date get the capacity associated with the recurrence. maybe an example pseudocode is better understood than my English. ex.: reseved = "info with the number of person by each date reserved" patters = { 0:["RRULE:FREQ=DAILY;", "max 10 person"], 1:["RRULE:FREQ=MONTLY;UNTIL=2021-10-10", "max 15 person"] 2:[RRULE:FREQ=DAILY;UNTIL=2021-06-15", "max 25 person"] } patterns_ordered = patters.order_by["index] date = "2021-01-01" last_date = "2021-01-01" + 365 days while date < laste_date: for rule in patterns_ordered: If date in rule and rule.capacity > number_reserved in date: save date in array with it's availibility. -
can't call a variable in html using django refference
i have a contact page in html that has input text with the name 'lname' and when pressing on submit button it should provoque a function called contact ( created in views.py ) def contact(request): if request.method == 'POST': first_name = request.POST['fname'] last_name = request.POST['lname'] date = request.POST['date'] email = request.POST['email'] treatment = request.POST['treatment'] note = request.POST['note'] return render(request, 'contact.html', {'last_name': last_name}) else: return render(request, 'contact.html', {}) ``` and i called the last_name in that html page (contact.html ) the page is reloaded but the last_name is not displayed ``` <h1> hello - {{ last_name }} </h1> ``` please help i am new to django thanks a lot -
AttributeError: 'list' object has no attribute 'appened' Django
I'm a little new to Django and I am practicing by following this tutorial I am trying to make my slugs be created automatically whenever I add a product of a category. I have followed the tutorial exactly and I have searched around but nothing seems to be pertaining to my exact problem. The site was working fine until I added the following code. To my models.py I added two codes. def get_absolute_url(self): return reverse("category_detail", kwargs={"slug": self.slug}) I also added: slug = models.SlugField(null = False, unique= True) Below is the complete file. from django.db import models from django.db.models.deletion import CASCADE from django.utils.safestring import mark_safe from ckeditor_uploader.fields import RichTextUploadingField from mptt.models import MPTTModel from mptt.fields import TreeForeignKey from django.urls import reverse # Create your models here. class Category(MPTTModel): STATUS = ( ('True', 'True'), ('False', 'False' ), ) parent = TreeForeignKey('self', blank =True, null=True, related_name="children", on_delete=models.CASCADE) title = models.CharField(max_length = 30) keywords = models.CharField(max_length=255) description = models.CharField(max_length=255) image = models.ImageField(blank = True, upload_to = 'uploads/images') status = models.CharField(max_length=10, choices=STATUS) slug = models.SlugField(null = False, unique= True) created_at = models.DateField(auto_now_add=True) deleted_at = models.DateField(auto_now=True) def __str__(self): return self.title class MPTTMeta: order_insertion_by = ['title'] def get_absolute_url(self): return reverse("category_detail", kwargs={"slug": self.slug}) def __str__(self): full_path = [self.title] … -
In djago if you extend the user model and you using profile model
Than how we use below code if we want mobile attribute from profile model ? user.profile.mobile but profile class has user reference it means it can be possible to access username like this profile.user.username -
Unable to import 'todo.models'pylint(import-error)
I am encountering error as below when I want to import the other app: enter image description here And, I have tried djangotodoapp.todo.models, .models, ..todo.models but they do not works. After that, you can check out my settings.py from below image. enter image description here How can I fix this problem? Thank you in advance. -
Django Rest Framework Model Serializer Aditional Keyword Argument not recognized
I have the following DRF serializer: class ServiceStatusSerializer(serializers.ModelSerializer): class Meta: model = models.ServiceStatus fields = ('id', 'service', 'status', 'timestamp', 'comment') extra_kwargs = {'content_object': {'write_only': True}} def create(self, validated_data): result = super().create(validated_data) return result I am trying to implement additional keyword arguments to ModelSerializers as described here, but serializer's create() method doesn't receive the extra parameter in validated_data, as you can see in this debug watch expression: You can see that validated_data parameter only contains three keys and misses key content_object, even when it was sent from Postam POST request: I can't find out what I am missing. -
Listen to events from apps like Slack and update Django database
I want to build a Django app which listens to events from messaging apps and writes them in a database. For eg, in Slack, on channel creation, I want to create a new entity in database and when a message is posted in that channel, I want to update that entity with the message. I want the app to work similarly for other apps like Telegram, Discord etc. How can I implement this using a common backend API for all the apps, i.e. a common API which listens to the events and updates the db ? Or is there some third-party API available (for eg. Twilio maybe) which can fulfil my purpose ? -
Django: ModuleNotFoundError after reinstalling Python and Django
I have two Django projects (project-x and project-y) which were running fine initially. However after reinstalling python and Django, I keep getting the error ModuleNotFoundError: No module named 'project-x' when I run python3 manage.py runserver for any of my other projects. This exact error occurs for every new project I create and try to run no matter its location. Everything was working before the reinstall and ready to ship so I am desperate to find out whats gone wrong .. Terminal chaudim@TD project-y % python3 manage.py runserver Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 61, in execute super().execute(*args, **options) File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 68, in handle if not settings.DEBUG and not settings.ALLOWED_HOSTS: File "/usr/local/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name) File "/usr/local/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1030, in _gcd_import … -
How to implement video conferencing with Django? [closed]
Can someone please guide me as to what all processes I need to follow in order to make a fully functional Video Conferencing App for my Django project (Virtual Classroom)? -
Django - Built in reset password links not working
I was following this tutorial on implementing the built in Django reset password views. I am using a custom User Model and I have read that when a user model inherits from AbstractUser, it should work with the password reset views as normal. However, none of them work. I am trying to access the reset form and nothing is displayed. Any help would be greatly appreciated Model class UserProfile(AbstractUser): contact_phone = models.CharField(max_length=100, unique=True) email = models.EmailField(unique=True) urls path('accounts/', include('django.contrib.auth.urls')), templates registration/password_reset_complete.html registration/password_reset_confirm.html registration/password_reset_done.html registration/password_reset_email.html registration/password_reset_form.html registration/password_reset_subject.txt Email backend for development EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' -
Passing login credentials to new view
The system uses django-tenant-schemas for separating data. The users are all on a shared schema so they can log in from any subdomain. To prevent them from seeing another companies data there is a middleware.TenantUserRedirectMiddleware which redirects the user to the proper subdomain after authentication. The problem is that it wants them to login once again after they get to the correct subdomain. I believe one solution is to get the login data from the request object and pass it to sessions then use that data to automatically authenticate the user at the subdomain so that they are not asked for credentials a second time. How do I get the login form data from request? I have tried this in the Middleware: class TenantUserRedirectMiddleware(object): def __init__(self, get_response): self.get_response = get_response def __call__(self, request): if not request.user.is_superuser: if request.user.is_authenticated: if request.user.company != request.tenant: print(request.POST) # This is empty, where is the login data? if DEVELOPMENT: return HttpResponseRedirect( '//' + request.user.company.get_primary_domain().domain + ':8000/login/') return HttpResponseRedirect('//' + request.user.company.get_primary_domain().domain + '/login/') response = self.get_response(request) return response -
ValueError: Unable to configure handler 'file1' django with apache2 error
i am trying to run my django website with apache2 webserver on an ubuntu machine i configured everything almost as the django wsgi documentaion but when i try to open my website in the browser it dosen't work and it raises the following error ValueError: Unable to configure handler 'file1' i think the problem is related to the logging files i have in sittings.py itried to give the apache2 access to both of them but it didn't work sudo chown :www-data debug.log sudo chown :www-data info.log does any one know how i can fix this issue. here is my apache2 configuration file: <VirtualHost *:80> ServerAdmin admin@cryptobank.localhost ServerName cryptobank.localhost ServerAlias www.cryptobank.localhost DocumentRoot /home/hamzahfox/Desktop/CryptoBankApache ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /static /home/hamzahfox/Desktop/CryptoBankApache/static <Directory /home/user/django_project/static> Require all granted </Directory> Alias /static /home/hamzahfox/Desktop/CryptoBankApache/media <Directory /home/user/django_project/media> Require all granted </Directory> <Directory /home/hamzahfox/Desktop/CryptoBankApache/CryptoBank> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess cryptobank.localhost python-path=/home/hamzahfox/Desktop/CryptoBankApache python-home=/home/hamzahfox/Desktop/python/env/django-env WSGIProcessGroup cryptobank.localhost WSGIScriptAlias / /home/hamzahfox/Desktop/CryptoBankApache/CryptoBank/wsgi.py </VirtualHost> here is my wsgi.py file: """ WSGI config for CryptoBank project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CryptoBank.settings') application = get_wsgi_application() here is my sittings.py … -
Django get_serializer 'NoneType' object is not callable
I am testing an API of Django (DRF) application. I am calling http://127.0.0.1:8000/api/users/1/documents/ (1 - user id) And receive an error ... File "/app/backend/apps/users/views/users/views.py" in create 542. serializer = self.get_serializer(data=request.data) File "/usr/local/lib/python3.7/site-packages/rest_framework/generics.py" in get_serializer 110. return serializer_class(*args, **kwargs) Exception Type: TypeError at /api/users/1/documents/ Exception Value: 'NoneType' object is not callable How can i identify the problem? Request related view /app/backend/apps/users/views/users/views.py (problematic line is serializer = self.get_serializer(data=request.data)) class UserDocumentCreate(generics.CreateAPIView, generics.RetrieveAPIView): serializer_class = UserDocumentSerializer permission_classes = (UserIsOwner, IsAuthenticatedDriver) queryset = Document.objects.all() def get_serializer_class(self): if self.request.version == "1.0": return UserDocumentSerializer # return UserDocumentSerializer2 def create(self, request, *args, **kwargs): request.data._mutable = True request.data["owner"] = kwargs.get("pk") serializer = self.get_serializer(data=request.data) if serializer.is_valid(raise_exception=True): owner = serializer.validated_data.get("owner") document_type = serializer.validated_data.get("document_type") message_status = request.data.get("message_status") documents = owner.document_owner.filter( document_type=document_type ) for document in documents: if document.status == DocumentStatus.DOCUMENT_REJECTED_STATUS: document.delete() # Mark user as new owner.is_new_user = True owner.save() self.perform_create(serializer) headers = self.get_success_headers(serializer.data) response = { "status": status.HTTP_201_CREATED, "result": serializer.data, } # accept corresponding registration message if message_status: driver_reg = DriverRegistration.objects.filter(user=kwargs.get("pk")).first() driver_reg.accept_by_status(message_status) next_id = driver_reg.get_next() # add information about next registration message to response if next_id != -1: response["next_message"] = REG_MESSAGES[next_id].to_json() return Response( response, status=status.HTTP_201_CREATED, headers=headers ) Related serializer (nothing special) class UserDocumentSerializer(serializers.ModelSerializer): is_new_document = serializers.BooleanField(read_only=True) class Meta: model = Document … -
super().__init__(*args, **kwargs) TypeError: __init__() got an unexpected keyword argument 'label'
Sir, my name is Karthik. I tried a multi-select-field project in Django. Based on my knowledge everything is correct. But, try to make migrations it shows TypeError. How to fix it. Please help me sir/madam. Error File "D:\My Django Projects\multiselectproject\multiselectapp\forms.py", line 4, in class EnquiryForm(forms.Form): File "D:\My Django Projects\multiselectproject\multiselectapp\forms.py", line 30, in EnquiryForm course = MultiSelectField(label='Select Required Courses:', choices='Courses_Choices') File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\multiselectfield\db\fields.py", line 70, in init super(MultiSelectField, self).init(*args, **kwargs) File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\fields_init_.py", line 986, in init super().init(*args, **kwargs) TypeError: init() got an unexpected keyword argument 'label' settings.py """ Django settings for multiselectproject project. Generated by 'django-admin startproject' using Django 3.1.2. For more information on this file, see https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'n&*#@g^b-%-$-yd1^!iwzhfnttd4s^zf+&$*5!i0_ves1v8s4&' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'multiselectapp.apps.MultiselectappConfig', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', … -
Django 3.1: Choice of static files directory
I have seen different ways in tutorials where the static files directory keep on changing. 1. Some put static files in the project root directory. Example myproject |__blog | |__migrations | |__static | |__templates mysite | static |__blog |__css |__js 2. Some put the static files in the root directory of the app it is serving. Example myproject ├── blog │ ├── migrations │ ├── static │ └── templates └── mysite Where should static files be located? -
authenticate a user in django
How to authenticate a user(model) in django? according to django docs we can use below method for authenticate users, user=auth.authenticate(username=username,password=password) if user is not None: auth.login(request,user) return redirect('/profile') i had tried above, it success,but it works only for built-in user models that comes with admin panel. my problem is: i had created a model(Customer) in models.py with custom fields,ex.phone number from django.db import models class Customers(models.Model): first_name=models.CharField(max_length=100) last_name=models.CharField(max_length=100) phone=models.CharField(max_length=15) email=models.EmailField() password=models.CharField(max_length=500) signin.html <form action="/login/" method="POST"> {% csrf_token %} <input type="email" name="email" placeholder="Enter email"> <input type="password" name="password" placeholder="Password"> <input type="submit" value="submit"> </form> In views.py def login(request): if request.method=='POST': email= request.POST.get('email') password= request.POST.get('password') user = Customers.authenticae(email=email, password=password) if user is not None: user.login(request, user) return redirect('/profile') return render(request,'login.html') when i tried this, it says: type object 'Customers' has no attribute 'authenticae' do i need to create authenticate() function in models.py, or there is a method for this? how to authenticate my customer,i just started learning django framework, anyone helps me to achieve this. -
I have a problem with urls in django, and I have "Page not found"
I started to learn Django myself, and there is a problem with understanding how URLs and path work. The error message is: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/question/1/ Using the URLconf defined in not_bad.urls, Django tried these URL patterns, in this order: [name='index'] [name='detail'] [name='results'] [name='vote'] microsanya/ The current path, question/1/, didn't match any of these. In project files I have this code: not_bad\urls.py: from django.contrib import admin from django.urls import include from django.urls import path urlpatterns = [ path('', include('polls.urls')), path('microsanya/', admin.site.urls), ] polls/urls.py: from django.urls import include, path from . import views app_name = 'polls' urlpatterns = [ path('', views.index, name='index'), path('', views.detail, name='detail'), path('', views.results, name='results'), path('', views.vote, name='vote' ), ] polls/views.py from django.http import HttpResponse from django.shortcuts import get_object_or_404, render from django.shortcuts import redirect from django.shortcuts import render from django.http import Http404 from . models import Question, Choice def index(request): question = Question.objects.all() return render(request, "index.html", {"latest_questions": Question.objects.order_by('-pub_date')[:5]}) def detail(request, question_id): def detail(request, question_id): try: question = Question.objects.get(pk=question_id) except Question.DoesNotExist: raise Http404 return render(request, 'polls/answer.html', {'question': question}) def answer(request, question_id): question = get_object_or_404(Question, pk=question_id) try: question = question.question_set.get(pk=request.POST['question']) except (KeyError, Question.DoesNotExist): return render(request, 'answer.html', {'question': question, 'error_message': 'Question does not exist'}) else: … -
fields added in Django View not displayed with django-crispy-forms
I have this view (modified to make it simple to understand): class MyCreateViewView(CreateView): model = SomeModel def get_form(self, form_class=None): form = super().get_form(form_class) form.helper = FormHelper(form) form.fields['additional_field'] = forms.BooleanField(label="Something", required=False) form.helper.add_input(Submit('submit', "Submit")) return form Before adding the FormHelper, the field additional_field appeared on the template. Now it doesn't. The form in my template is basically one line: {% crispy form %}. The django-crispy-forms docs don't show this approach because they are focused on using forms. I'm using the CreateView from Django that builds the form for me, so I don't need a form class. So far, I noticed that doing form.helper = FormHelper(form) after programmatically adding the new field solves the problem. But this is not a solution because the view I presented here is a simplified version, and I actually have two views that are doing something similar. So I'm inheriting this class and adding extra fields in the views themselves (meaning FormHelper is already there). -
Django Ckeditor: How to change background color/styling
I am having trouble changing the background color of the rich text editor. Most places say to edit the ckeditor css file but that isn't in my django project for the way i'm doing it i think. Is there a way to change it/add styles in the settings configs? or is there a better way to do this? template: <script type="text/javascript" src="ckeditor.js"> window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/'; CKEDITOR.replace( 'links' ); </script> settings file: CKEDITOR_CONFIGS = { 'default': { 'toolbar': 'Custom', 'toolbar_Custom': [ ['Link', 'Unlink'], ], 'height': 200, 'width': 750, 'stylesSet': [ { "name": 'Lead', "element": 'p', "attributes": {"margin-top": "10px"}, }, ], } } -
Django Rest Framework view doesn't work when called from DRF API tool
I have the following DRF ViewSet: class ServiceStatusForListViewSet(CustomModelViewSet): pagination_class = None permission_classes = (permissions.IsAuthenticated,) queryset = models.ServiceStatus.objects.all() serializer_class = serializers.ServiceStatusForListSerializer filter_backends = (DjangoFilterBackend, SearchFilter, OrderingFilter,) search_fields = ('service__item__product__name', 'service__client_name') filter_fields = ('id', 'service', 'service__item', 'service__item__product') This view works perfectly when a GET request is sent by a React frontend application, and it returns the expected response: The problem is when I send a GET request from the browser (Chrome): It just never returns, and the "loading" indicator keeps spinning forever. All other endpoints work well from DRF API tool, but this one. -
How can I loop the list into another loop in the Django template?
I need to loop a list into another loop without duplicating the results for example: {% for x in list1 %} {% for y in list2 %} {{ y }} {% endfor %} {% endfor %} I found half of the problem where I can call the elements of a list by a dot followed by the index number for instance: {{ iterator.0 }} {{ iterator.1 }} and that is succeded indeed however I took a little thinking where I thought that I could use: forloop.counter0 for looping but I couldn't use it I tried to use it like so: {{ iterator.forloop.counter0 }} but the trick didn't succeed. so, How can I loop easily into another loop? -
For loop in Django template causing error when I use the add filter
I am trying to add two variables together in my template that will combine two scores together and print the value. The problem is when the loop gets to a game that hasn't happened yet it kicks out an error because the variable doesn't exist yet. What am I supposed to add to skip games in the loop that have no score? {% for game in games %} <p class="light-blue text-center"> Total: {{ game.scoreboard.score.home|add:game.scoreboard.score.away }} </p> {% endfor %} -
Registration form refreshes after submitting instead of sending post request in django
I'm trying to register a user but the page refreshes instead of submitting the data. At the initial stage of my project, it was working properly but when I added some more models and form it's not working and tried to register it stopped working. and it also doesn't throw any errors views.py from django.shortcuts import render from django.contrib.auth import authenticate,login,logout from .models import * from django.http import HttpResponseRedirect from django.urls import reverse from .form import * from django.db import IntegrityError from django.contrib.auth.decorators import login_required from django.contrib import messages # Create your views here. def index(request): if not request.user.is_authenticated: message = f"please sign in" else : message = f"signed in as {request.user}" return render(request, "auctions/index.html",{ "listings": Listings.objects.all(), "message": message }) def login_view(request): if request.method == "POST": form = loginForm() email = request.POST["email"] password = request.POST["password"] user = authenticate(request,username=email,password=password) if user is not None: login(request,user) return HttpResponseRedirect(reverse('index')) else: return render(request, "auctions/login.html",{ "form": form , "message": "username/password not valid" }) return render(request, "auctions/login.html",{ "form": loginForm() }) def logout_view(request): logout(request) return HttpResponseRedirect(reverse('index')) def register(request): if request.POST == "POST": form = registerForm() email = request.POST["email"] # check passwords are same password = request.POST["password"] confirmation = request.POST["id_confirmation"] if password != confirmation: return render (request, "auctions/register.html",{ … -
Accordion expands all cards when clicked at any one
{% for inv in invoices__ %} <div class="row"> <div class="col-md-12"> <div class="accordion" id="accordionExample"> <div class="card"> <div class="card-header" id="{{inv.headingId}}"> <div class="row headerContiner"> <div class="col-md-10"> <h5 data-toggle="collapse" data-target="{{inv.collapseTarget}}">{{inv.ttl}}</h5> </div> <div class="col-md-2"> <a href="{% url 'invoice_update' inv.id__ %}" class="btn text-secondary px-0"> <i class="fa fa-edit fa-lg"></i></a> <a href="{% url 'invoice_delete' inv.id__ %}" class="btn text-secondary px-0"> <i class="far fa-trash-alt fa-lg text-danger float-right"></i></a> <a href="{% url 'invoice_details' inv.id__ %}" class="btn text-secondary px-0"> <i class="fas fa-file-invoice"></i></a> <a href="{% url 'invoice_status' inv.id__ %}" class="btn text-secondary px-0"> <i class="fas fa-tasks"></i></a> </div> </div> </div> <div id="{{inv.collapseId}}" class="collapse" aria-labelledby="{{inv.headingId}}" data-parent="#accordionExample"> <div class="card-body"> <div class="row"> {% for stg in inv.stages %} <div class="col-md-3 stags"> <h6 class="stepHeading">Step {{stg.counter__}}: {{stg.title}}</h6> <p>HTML stands for HyperText Markup Language. HTML is the standard markup language for describing the structure of web pages. <a href="https://www.tutorialrepublic.com/html-tutorial/" target="_blank">Learn more.</a></p> {% if stg.isCreated %} <a href="{% url stg.editLink inv.id__ %}" class="btn text-secondary px-0"> <i class="fa fa-edit fa-lg"></i> </a> <a href="{% url stg.deleteLink inv.id__ %}" class="btn text-secondary px-0"> <i class="far fa-trash-alt fa-lg text-danger float-right"></i> </a> <a href="{% url stg.previewLink inv.id__ %}" class="btn text-secondary px-0"> <i class="fas fa-file-invoice"></i> </a> {% else %} <a href="{% url stg.addLink %}" class="btn text-secondary px-0"> <i class="fas fa-plus"></i></a> </a> {%endif%} </div> {% endfor %} </div> </div> </div> </div> …