Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django stripe Fetch promise with pending state
I'm new to Stripe, so just following the stripe docs to setup a subscription feature for my website. I have hit major road blocks and not able to find any resource or similar questions to address it. Any help is appreciated. For the front-end portion of the code, it looks like the fetch is submitting data, but its state remains 'pending'. So, either no form is being submitted or the form is submitted but not received in the server-side. Here is my front-end code <!-- HTML Form --> {####################### CREDIT CARD (STRIPE) #######################} {% if credit_card %} <div class="credit-card"> <h3>Your Credit Card Information</h3> <form id="subscription-form">{% csrf_token %} <div id="card-element" class="MyCardElement"> <!-- Elements will create input elements here --> </div> <!-- We'll put the error messages in this element --> <div id="card-errors" role="alert"></div> <button type="submit" class="btn btn-primary btn-block mt-3">Subscribe</button> </form> </div> {% endif %} Then, in my checkout.js file: var stripe = Stripe('<testPublishableKey>'); var elements = stripe.elements(); var submissionURL = document.querySelector("[data-redirect]").getAttribute('data-redirect'); var customerEmail = document.querySelector("[data-email]").getAttribute('data-email'); var style = { base: { color: "#32325d", fontFamily: '"Helvetica Neue", Helvetica, sans-serif', fontSmoothing: "antialiased", fontSize: "16px", "::placeholder": { color: "#aab7c4" } }, invalid: { color: "#fa755a", iconColor: "#fa755a" } }; var cardElement = elements.create("card", { … -
Gdal GeoDjango Windows : “django.contrib.gis.gdal.error.GDALException: OGR failure.”
I use Windows 10 (x64), Python 3.8, Django 3.0.5 ,QGIS3.10 after installing geodjango and osgeo4w, when I run the code I could access to the map (leaflet) and add a marker to it but when I am trying to see the mark that I already marked and the title of it I got an error like that django.contrib.gis.gdal.error.GDALException: OGR failure I have tried looking at similar questions, but none of the solutions have worked. by the way, Also, i have added to my Django project settings: if os.name == 'nt': import platform OSGEO4W = r"C:\OSGeo4W" if '64' in platform.architecture()[0]: OSGEO4W += "64" assert os.path.isdir(OSGEO4W), "Directory does not exist: " + OSGEO4W os.environ['OSGEO4W_ROOT'] = OSGEO4W os.environ['GDAL_DATA'] = OSGEO4W + r"\share\gdal" os.environ['PROJ_LIB'] = OSGEO4W + r"\share\proj" os.environ['PATH'] = OSGEO4W + r"\bin;" + os.environ['PATH'] Full traceback: Internal Server Error: /admin/firstproject/incidence/5/change/ Traceback (most recent call last): File "C:\Users\M-ALMASRI\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\M-ALMASRI\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 145, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\M-ALMASRI\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 143, in _get_response response = response.render() File "C:\Users\M-ALMASRI\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\response.py", line 105, in render self.content = self.rendered_content File "C:\Users\M-ALMASRI\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\response.py", line 83, in rendered_content return template.render(context, self._request) File "C:\Users\M-ALMASRI\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\backends\django.py", line 61, in render return self.template.render(context) File "C:\Users\M-ALMASRI\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\base.py", line 171, … -
TypeError: 'Review' object is not iterable Django Object not iteratble
I am trying to get all object from a many to many field in my course model and filter them based on the course code. Basically, I am trying to return all the reviews for courses with same course code. But I get the error: TypeError: 'Review' object is not iterable and it returns nothing. When I print it out I get: ]> which is a query set but I do not know why it is not returning anything in my course model I have the method: def get_reviews(self): return Course.course_reviews.through.objects.filter(course__course_code=self.course_code,course__course_university=self.course_university,course__course_instructor=self.course_instructor) and the many to many link with review model is: course_reviews = models.ManyToManyField(Review, blank=True, related_name='course_reviews') Why isnt it returning anything in my template? I am confused on what the issue is here. -
Create new for loop from for loop in Django
If you look at the piece of code below, you will understand exactly what I want. Enough even if I only get the number of cars that comply with this condition. Or it would be great if we could create a new loop from cars that comply with this condition. {% for car in cars %} {% if car.color == 'white' %} create new for loop from white cars or give me the numbers of white cars {% endif %} {% endfor %} -
upgraded from django 1.1 to 2.2, - (error) post_detail_view() got an unexpected keyword argument 'day'
(models.py) from django.utils import timezone class Post(models.Model): publish=models.DateTimeField(default=timezone.now) def get_absolute_url(self): return reverse ('post_detail',args= [self.publish.year,self.publish.strftime('%m'),self.publish.strftime('%d'),self.slug]) views.py def post_detail_view(request,year,month,post): post=get_object_or_404(Post,slug=post,status='published',publish__year='year',publish__month='month',publish__day='day') return render(request,'blog/post_detail.html',{'post':post}) ** gives error as -- post_detail_view() got an unexpected keyword argument 'day' please help url.py re_path('(?P\d{4})/(?P\d{2})/(?P\d{2})/(?P[-\w]+)/$',views.post_detail_view,name='post_detail') -
Django SECRET_KEY setting must not be empty with github workflow
I have a GitHub workflow for Django and when it gets to migrating the database it gives the error django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty. the secret key is stored in a .env file and loaded with from dotenv import load_dotenv load_dotenv() from pathlib import Path env_path = Path('.') / '.env' load_dotenv(dotenv_path=env_path) SECRET_KEY = os.getenv("secret_key") when I run manage.py on my PC it loads the key and runs the server, but GitHub gives the error above. How do I stop this error from happening? -
Django: How to separate model choices and display based on user input?
basically I have a form, in which I select a Make and Model etc. Inside my models.py I have this: MAKES = ( ('', ''), ('FORD', 'Ford'), ('AUDI', 'Audi'), ) MODELS = ( ('', ''), ('CMAX', 'C-Max'), ('FOCUS', 'Focus'), ('A3', 'A3'), ('A4', 'A4'), ) class Query(models.Model): MAKE = models.CharField(max_length = 50, choices=MAKES) MODEL = models.CharField(max_length = 50, choices=MODELS) class Average(models.Model): class Meta: db_table = 'ford_cmax' make = models.CharField(max_length = 15) model = models.CharField(max_length = 20) forms.py MAKE = forms.ChoiceField(choices=MAKES, required=True ) MODEL = forms.ChoiceField(choices=MODELS, required=True ) class Meta: model = Query fields = ['MAKE', 'MODEL'] Once I go onto the website, I am able to select Ford A3 or Audi Focus for example, how can I prevent this and display the Model choices based on the selected Make? So for example when I select Ford as the make, I'd only have two choices (C-Max , Focus) rather than all 4. -
Proxy backend through frontend using istio or nginx
I'm trying to figure out the best way to integrate Istio into my app, which consists of a React frontend (served by Nginx) and a Django Rest Framework API. I was able to get it to work using the following nginx config and istio-specific kubernetes files: server { listen 80; root /app/build; location / { try_files $uri $uri/ /index.html; } } # Source: myapp/gateway.yaml apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: myapp-gateway spec: selector: istio: ingressgateway # use istio default controller servers: - port: number: 80 name: http protocol: HTTP hosts: - '*' - port: number: 443 name: https protocol: HTTP hosts: - '*' --- # Source: myapp/virtual-service.yaml apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: myapp spec: hosts: - '*' gateways: - myapp-gateway http: - match: - port: 80 route: - destination: host: frontend-svc port: number: 80 - match: - port: 443 route: - destination: host: backend-svc port: number: 8000 And the frontend can hit the backend at localhost:443. Note, I'm serving the backend on port 443 (instead of 8000) because of some issue regarding the istio gateway not working with any port other than 80 and 443. Regardless, this approach exposes BOTH the frontend and backend outside of the cluster, which … -
Model object that's currently being edited via admin interface appears in the popup window for add related object
I have two models that, for simplicity, I'll call Post (as in a blog post) and Tag (as in tags used to categorize blog posts). Tags are related to Posts via a ManyToManyField. Users can assign tags to posts. I also use an inline so that tags can be added or created from posts within the built-in admin interface. But a problem arises if a user clicks "Add another Tag-post relationship", clicks the "+" to add another tag from within the change post form (using the popup window), then assigns that tag to the post they're already editing. Example: In the "change post" form of the admin interface, under the tag inline section, user clicks "Add another Tag-post relationship". User clicks "+" to add another tag. New window pops up with create tag form. User names this tag "Demo Tag". In this form, the user selects the "Demo Posts" post under the posts field. User saves the tag which closes the window. "Demo Tag" now appears under the select box in the tag inline. When the post is now saved, this results in the validation error: Tag-post relationship with this Tag and Post already exists. This is because the user … -
Save new user in django user model and custom user model
Having trouble saving both the user to the built-in auth_user django model and my custom user model. My code saves the user to the django model but not my Account model. models.py class Account(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) address = models.CharField(max_length=10) addressNumber = models.CharField(max_length=20) accountImage = models.CharField(max_length=999) def update_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) instance.profile.save() forms.py from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User class SignUpForm(UserCreationForm): address = forms.CharField(max_length=255) addressNumber = forms.CharField(max_length=255) image = forms.CharField(max_length=255) class Meta: model = User fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2', 'address', 'addressNumber', 'image' ) and views.py from django.contrib.auth.decorators import login_required from django.shortcuts import render, redirect from myAccount.forms.userForm import AccountForm from myAccount.models import Account from myAccount.forms.forms import SignUpForm def register(request): form = SignUpForm(data=request.POST) if request.method == 'POST': if form.is_valid(): account = form.save() account.refresh_from_db() # load the profile instance created by the signal account.address = form.cleaned_data.get('address') account.addressNumber = form.cleaned_data.get('addressNumber') account.addressImage = form.cleaned_data.get('accountImage') account.save() raw_password = form.cleaned_data.get('password1') return redirect('login') return render(request, 'myAccount/register.html', {'form': form}) @login_required def seePurchasehistory(request): return render(request, 'myAccount/pruchaseHistory.html') @login_required def accountInfo(request): account = Account.objects.filter(user=request.user).first() if request.method == 'POST': form = AccountForm(instance=AccountForm, data=request.POST) if form.is_valid(): account = form.save(commit=False) account.user = request.user account.save() return redirect('homepage-index') return render(request, 'myAccount/accountInfo.html', { 'form': … -
XMLHttpRequest Blocked: CORS Header problem with Django Project running with WSGI on bitnami / lightsail
I'm requesting a Django json view from an angular app. I'm using django-cors-header. Everything worked on AWS ec2. Now I moved to AWS lightsail (bitnami), and the browser shows the message Access to XMLHttpRequest at 'https://serve.myapp.de/search/' from origin 'https://myapp.de' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. I added myapp.de to CORS_ORIGIN_WHITELIST, and I tried to use CORS_ORIGIN_ALLOW_ALL option of django-cors-headers library, But it changes nothing. I had to add Header set Access-Control-Allow-Origin "https://myapp.de" Header set Access-Control-Allow-Methods "GET, OPTIONS, POST, PUT" Header set Access-Control-Allow-Headers "origin, x-requested-with, content-type, accept, authorization" Header set Access-Control-Allow-Credentials "true" To my apache config to get it running. And now django-cors-header does nothing anymore. It seems to me, like the apache does not give the CORS information to the django app. Do I have to add a specific apache config, to give the CORS infos to the django app? What is wrong? On all other servers this worked without a problem. -
Streaming a large file with Django
How to serve multiple files in a zip with Django? I can serve a single file with FileResponse: >>> from django.http import FileResponse >>> response = FileResponse(open('myfile.png', 'rb')) but, what if I need to send multiple files? How to generate a zip immediately? Imagine 3,000 images of 5 MB each. Note: this is a self-answer question, and the repos are mine. I had this problem a few weeks ago and couldn't find the right answer. -
django no such column: userdash_assetlist.user_id
I am trying to access my view page/template when I get the following error. no such column: userdash_assetlist.user_id I am pretty sure it is failing to access the object here. {% for td in user.assetlist.all %} I'm not sure what I broke. It was working under a previous config and broke at some point during changes. $ cat userdash/templates/userdash/view.html {% extends 'userdash/base.html' %} {% block title %} View Assets page {% endblock %} {% load crispy_forms_tags %} {% block content %} <h3>Your Assets Page</h3> {% for td in user.assetlist.all %} <p><a href="/{{td.id}}">{{td.name}}</a></p> {% endfor %} {% endblock %} $ cat userdash/models.py from django.db import models from django.contrib.auth.models import User # Create your models here. class AssetList(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="assetlist", null=True) name = models.CharField(max_length=200) def __str__(self): return self.name class Items(models.Model): assetlist = models.ForeignKey(AssetList, on_delete=models.CASCADE) user_asset = models.CharField(max_length=300) sell_asset = models.BooleanField() def __str__(self): return self.user_asset $ cat userdash/views.py from django.shortcuts import render from django.http import HttpResponse, HttpResponseRedirect from .models import AssetList, Items from .forms import CreateNewTrade # Create your views here. #def index(response): # return HttpResponse("<h1>Hello Dark World!</h1>") def userdash(response, id): ls = AssetList.objects.get(id=id) if response.method == "POST": print(response.POST) if response.POST.get("save"): for item in ls.items_set.all(): if response.POST.get("c" + str(item.id)) == … -
Use model data in an equation
So I've ran into an issue. I want to take the values from my model and use them in an equation, but I keep getting this error: TypeError: unsupported operand type(s) for -: 'RankingHistory' and 'RankingHistory' However, whenever if I run a print command for the individual variables it prints the corresponding number. I've tried converting it to a list, as you can see below, to try and fix it but I'm still getting the same error. Feeling a bit lost after Googling for a few hours. def ranking_updates(campaign_keywords): for keyword in campaign_keywords: rankings = RankingHistory.objects.filter(keyword_id=keyword.id).all() ranking_count = rankings.count() - 1 # converted queryset to list to allow use with equations ranking_list = list(rankings) # variables used to find rankings location in list one_count = ranking_count - 1 seven_count = ranking_count - 7 thirty_count = ranking_count - 30 num_rankings = ranking_list[ranking_count] # find 1 day, 7 day, and 30 day change of rankings + lifetime if rankings.count() > 29: # variables used to convert list from RankingHistory into variables first_ranking = ranking_list[0] one_day = ranking_list[one_count] seven_day = ranking_list[seven_count] thirty_day = ranking_list[thirty_count] # variables used to create changes over 1 day, 7 day, 30 day, and lifetime one_day_change = num_rankings - … -
Using MODAL IMAGE GALLERY IN DJANGO SEEMS DIFFICULT
I am working on a webapp in django for a cake baker who needs images to be clicked and zoom by her customer, all the images are uploaded into a database and i was able to fetch them on the templates, but each time i click next or previous all i see was the modal background and only the first image appears whenever other images are clicked. IT WORKS PERFECTLY ON IMAGES I HAVE ON MY LOCAL DRIVE. HERE IS WHAT I HAVE DONE {% extends 'base.html' %} {% load static %} {% block title %} G.F. Cakes {% endblock %} {% block content %} {% include 'nav.html' %} {% for post in post.all %} <link rel="stylesheet" href="{% static 'css/fond.css' %}"> <div class="main"> <div class="row"> <div class="column"> <div class="content"> <img src="{{post.cake_image.url}}" style="width:100%" onclick="openModal();currentSlide(1)" class="hover-shadow cursor"> <div class="imgcaption"> <h3>{{post.cake_name}}</h3> </div> </div> </div> </div> <div id="myModal" class="modal"> <span class="close cursor" onclick="closeModal()">&times;</span> <div class="modal-content"> <div class="mySlides"> <div class="numbertext">1 / 4</div> <img src="{{post.cake_image.url}}" class="modal-img" style="width:100%"> </div> <a class="prev" onclick="plusSlides(-1)">&#10094;</a> <a class="next" onclick="plusSlides(1)">&#10095;</a> <div class="caption-container"> <p id="caption"></p> </div> </div> </div> </div> {% endfor %} {% include 'foot.html' %} {% endblock %} -
Django 3 List View objects not displaying in template with if statement. Please help this Django newbie
I'm trying to create a news site with structure like: Master Archive (contains all daily issues of the news publication) Issue (a new one each day with unique articles) Article (related to one Issue) I'm facing a problem where the articles in an issue are not displaying on a Django template (issue_details.html) that's supposed to simply list all articles that are related to an issue. Any suggestions? I'm new to Django and my approach to this may not be best-practice, but things seem to be working other than this problem. articles/views.py from django.shortcuts import render from django.views.generic import ListView, DetailView from .models import Article class IndexView(ListView): model = Article template_name = 'index.html' class ArticleDetailView(DetailView): model = Article template_name = 'article_detail.html' context = { 'details': Article.body } issues/views.py from django.shortcuts import render, HttpResponse from django.views.generic import ListView from .models import Issue, IssueDetails class IssueView(ListView): model = Issue template_name = 'issues.html' slug_url_kwarg = 'slug' slug_field = 'slug' context = { 'issue_title' } issue_view = IssueView.as_view() # List of Articles in a Issue class IssueDetailsView(ListView): model = IssueDetails template_name = 'issue_details.html' slug_url_kwarg = 'slug' slug_field = 'slug' context = { 'title' } issue_details_view = IssueDetailsView.as_view() def detail(request, slug): q = IssueDetails.objects.filter(slug__iexact = slug) … -
Django CSS Not Loading
I'm having problems with my Django > css its not loading on the page for some reason am I missing something ? I have attached snippets of my current code Settings.py urls.py .html -
why django template stop to working HTML autocomplete?
im using Vs.Code. When ı enable to Django Template, HTML autocomplete doesnt work. I want to work Python and HTML at the same time. How can i solve this problem ? has someone any idea ? -
Using Django Models to assign HTML div through jQuery
for the last few days I've been trying to create a method in jquery using django models and I have found myself to be very out of my depth and would appreciate and explanation I can get. So currently I have a django model that has the following information : name, date, location, semester. I use the first 3 pieces of information in displaying my html, however, I want to use 'semester' to see what div tag my items go into. The semester tag can either return 'Fall' or 'Spring' values is there a way I can use this to assign the components to the correct div. So if semester is Fall then it should go into the div with the id 'fall-races' and if its spring it should go to 'spring-races' Currently I only have a jquery working where I get all the elements and assign it to the other div. Thank you for your help and any possible advice. <div class="flex-column"> <div class="header shadow-lg"> <h1 class="text-center py-3"> Fall Schedule </h1> </div> <div id="fall-races"> {% for race in race %} <div class="regatta-card my-2 mx-2 "> <h2 class="center-text py-2">{{ race.date }}</h2> <h1 class="text-center my-2">{{ race.name }}</h1> <h3 class="text-center mb-3">{{ race.location}}</h3> … -
run complex algorithm in python via django
i'm new with django . I am building a django-based app that presents an optimum solution through linear programming that run on the database data. I wrote the code in Python and have all the data displayed through django. Now, how can i connect them. I have no idea how to run the code. I would appreciate any guidance. -
Accessing Choices Value of PositiveSmallIntegerField in Django Template
I have a model like this: class SomeModeL(Model): MODEL_TYPE = ( (0, 'Type1'), (1, 'Type2'), (2, 'Type3') ) model_type = PositiveSmallIntegerField(choices=MODEL_TYPE) Now, I passed in an instance of the model into context and want to access the model_type, specifically the String, such as 'Type1' So, in the template, i do this: {{ some_model.model_type }} but this returns the integer, not the string. How do I get the string? -
Python / Django - edit render output
I'm new to python and I have the following issue. I have a Counterpart database with two boolean fields that are "is_client" and "is_supplier". When a counterpart is added could be either client or supplier or both. I want to display that if is_client=True c_type = "client", if is_supplier=True c_type = "supplier" and if both are True c_type = "client / supplier" How can I do it in the following function? class CounterpartsListView(ListView): model = Counterpart template_name = "counterparts/view_list.html" context_object_name = "counterparts" def get_queryset(self): c_type = self.kwargs.get("type") if c_type == "suppliers": if Counterpart.objects.filter(is_supplier=True).count() >= 1: return ( Counterpart.objects.filter(is_supplier=True) .order_by("counterpart_name") .extra(select={"Supplier": "is_supplier"}) ) else: return Counterpart.objects.all().order_by("counterpart_name") elif c_type == "customers": if Counterpart.objects.filter(is_client=True).count() >= 1: return ( Counterpart.objects.filter(is_client=True) .order_by("counterpart_name") .extra(select={"Customer": "is_client"}) ) else: return Counterpart.objects.all().order_by("counterpart_name") else: return Counterpart.objects.all().order_by("counterpart_name") this is the html output, how can I add the c_type attribute ? {% for counterpart in counterparts %} <tr> <td>{{ counterpart.counterpart_name }}</td> <td>{{ counterpart.city }}</td> <td>{{ counterpart.country }}</td> <td>{{ counterpart.c_type }}</td> </tr> {% endfor %} Alternatively, I was thinking to change the input method and instead of two separate fields (is_client and is_supplier), have just one called c_type and add an the value (customer or supplier) and in case is both add an … -
How to display comment in a particular post
how do i display comment to a particular post in Django. I have watched lots of tutorials and i can understand that comments can be displayed with ForeignKey to a Post using related_name and id passing throught url. I have been stucked up with this issue, I will be glad if someone here can help me with this, i want to display comments to each particular post without adding a related_name to Model. class Post(models.Model): poster_profile = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE, blank=True,null=True) class Comments (models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE, blank=True,null=True) commented_image = models.ForeignKey(Post, on_delete=models.CASCADE, null=True, blank=True) #i don't want a related_name comment_post = models.TextField() def home_view(request): all_comments = Comments.objects.filter(user=request.user, active=True) posts = Comments.objects.filter(pk__in=all_comments) context = {'posts': posts} return render(request,'home.html', context) #this displays all comments for all post, how do i assign comments to the particular post commented on {% for comment in posts %} <p>{{ comment.comment_post }}</p> {% endfor %} -
Django Bootstrap Carousel wont ride
This is my first project with building a website. I have been following these tutorials. I browsed through the Bootstrap components page and found a Carousel method (slides only) that I wanted to use. I copied and pasted it into my code. The first image shows up which is correct, because it is active, but the Carousel does not slide to the next image. The first code block shows a summed up version. The second block of code is after running python manage.py runserver. The third block of code is when I open the IP address link. I am not sure what I am doing wrong. Any suggestions? Let me know if you need some more information. <!DOCTYPE html> <html lang="en"> <head> <title>AeroTract</title> <meta charset="utf-8" /> {% load static %} <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}" type = "text/css"/> <meta name="viewport" content = "width=device-width, initial-scale=1.0"> <style type="text/css"> html, body { height:100% } </style> </head> <body class="body" style="background-color:#FFF8DC"> <!-- Main page background color --> <div class="container-fluid" style="min-height:95%; "> <!-- Footer Height --> <div class="row"> <div class = "col-sm-2"> </div> <div class="col-sm-8"> <br> <div id="mainCarousel" class="carousel slide" data-ride="carousel"> <div class="carousel-inner"> <div class="carousel-item active"> <img class="d-block w-100" src="{% static 'img/Forestry.png' %}" alt="First slide"> … -
check if value is a url or not in django template
I'm working on a Django project that some of its pictures don't come from the media folder so I wanted to know if there's a way for me to check if the value is a link to use media.poster instead of media.poster.url ?