Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
read html file inside zip file python djnago
I am reading a zip file using django python and uploading that to aws s3. I want to read html file inside zip file and upload that html fle to s3 but not zip file. *NOTE : I am always recieving zip file in_memory_uploaded_file = request.FILES['file'] files = in_memory_uploaded_file.open("rb") boto3.setup_default_session(profile_name='test') s3 = boto3.resource('s3') base_url = 'https://s3-ap-southeast-1.amazonaws.com/atest.poptest.com/creatives_preview/' s3_file_path = "creatives_preview" + "/" + "indgdex.zip" s3.meta.client.upload_fileobj(files, 'adunits.popmunch.com', s3_file_path) -
Trying to grab a random pic through JS but dosen't work properly
Hi guys I am a django developer and trying to grab a random img through JS in html like below img works and it would randomly pick one from the ImageArray. However, the path will be <img src= '/static/%22%20%2B%20img%20%2B%22'>. Rather than something I want like <img src= "{% static 'img/indexBg_1.png' %}" > And the error msg is : GET http://192.168.7.64:8000/static/img/%22%20%2B%20pic%20%2B%20%22%20 404 (Not Found) Could anyone enlighten me to resolve this problem? Thx! <script type="text/javascript"> window.onload=function(){ ImageArray = new Array(); ImageArray[0] = 'img/indexBg_1.png'; ImageArray[1] = 'img/indexBg_2.png'; ImageArray[2] = 'img/indexBg_3.png'; var num = Math.floor( Math.random() * 3); var img = ImageArray[num]; var path = " <img src= '{% static '" + img +"'%}'>" console.log(img) console.log(path) } </script> -
How to test if an object is a django UploadedFile?
I am using django3.1 and python 3.7. I have a dictionary as follow: {'text2': 'text2', 'file2': <UploadedFile: img5.jpg (image/jpeg)>, 'file22': <UploadedFile: img8.jpg (image/jpeg)>} I want to print out the image names: img5.jpg img8.jpg When I check type of <UploadedFile: img5.jpg (image/jpeg)>, it says: <class 'django.core.files.uploadedfile.UploadedFile'> I tried following: data1 = {'text2': 'text2', 'file2': <UploadedFile: img5.jpg (image/jpeg)>, 'file22': <UploadedFile: img8.jpg (image/jpeg)>} for key in data1: if isinstance(data1[key], io.IOBase): print(data1[key].name) else: print('not a file') It always shows not a file. Any idea? Thanks! -
Using Vue.js inside Django template
What I would like to accomplish is to set a django block content inside a vue app. I used vue cli to create a vue app but I am not able to do the following. views.py def login(request): template_name = 'login.html' return render(request, template_name) base.html {% load static %} <html> <body> <div id="app"> {% block component %}{% endblock %} </div> </body> </html> <script src="{% static 'assets/js/app.js' %}"></script> login.html {% extends 'base.html' %} {% block component %} <myComponent /> {% endblock %} What kind of setup do I need to build app.js in way that I can put whatever component I want in the templates? below is the NOT working vue files main.js import Vue from 'vue' import App from './App.vue' Vue.config.productionTip = false new Vue({ render: h => h(App), }).$mount('#app') App.vue <template> <div id="app"> </div> </template> <script> import HelloWorld from './components/HelloWorld.vue' export default { name: 'App', components: { HelloWorld } } </script> <style> </style> Currently if I add tags within the component block in login.html nothing changes. If I add a tag inside App.vue it will show up in login.html but I want to be able to choose which components will be displayed. -
Hi can anyone help me I'm trying to show some categories but the problem is I can't paginate or using this "paginate_by = 10" in Generic Views
This is the views.py HomeView This is the Main Page That I want to make it paginate The problem is the categories its not detected I try to refresh or restart but nothing happen. But the category is ok no error just only the pagination guys please help me. class HomeView(ListView): model = Food paginate_by = 10 context_object_name = "index.html" def get(self,request): categories = Category.getAllCategory() food = Food.getAllProduct().order_by('-id') if request.GET.get('id'): filterProductById = Food.objects.get(id=int(request.GET.get('id'))) return render(request, 'productDetail.html',{"food":filterProductById,"categories":categories}) if request.GET.get('category_id'): filterProduct = Food.getProductByFilter(request.GET['category_id']) return render(request, 'index.html',{"food":filterProduct,"categories":categories}) return render(request, 'index.html',{"food":food,"categories":categories}) def query_set(self): return Category.objects.all() def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['categories_list'] = Category.objects.all() return context CategoryView This is also in Main Page class CategoryView(ListView): model = Category paginate_by = 4 template_name = "index.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['categories_list'] = Category.objects.all() return context This is models.py class Category(models.Model): category = models.CharField(max_length=100) def __str__(self): return self.category @staticmethod def getAllCategory(): return Category.objects.all() And this is the Homepage for HTML, if you think this is wrong can you help me {% if is_paginated %} <nav class="d-flex justify-content-center wow fadeIn"> <ul class="pagination pg-blue"> {% if page_obj.has_previous %} <li class="page-item"> <a class="page-link" href="?page={{ page_obj.previous_page_number }}" aria-label="Previous"> <span aria-hidden="true">&laquo;</span> <span class="sr-only">Previous</span> </a> </li> {% endif %} <li class="page-item … -
passing two files as -d parameters in curl command
how do I pass two files with the -d parameter in a curl command and then accept them in django? If I pass them like: curl -X POST -d '1='/Users/User/desktop/test.json -d '2=/Users/User/desktop/test.json' http://127.0.0.1:8000 It accepts it as a string because that's how i'm passing it. but if I want to add the @ symbol before both of them then I can't assign them the 1= and 2= identifiers? How do I get around this so I can pass two files with identifiers so I can get each of them seperately from the request? -
How to get optional parameters from a url and use them to parse objects from a model?
For example, from the url: https://localhost:8000/parameters=param1&param2&param3 How can I parse out the parameters as a list and pass it into a class-based view? urls.py urlpatterns = [ path('admin/', admin.site.urls), path('parameters=...', MyListView.as_view()), ] views.py class MyListView(generics.ListAPIView): queryset = MyObject.objects.all() # Use the parameters to filter out objects serializer_class = MyObjectSerializer models.py class MyObject(models.Model): object_id = models.CharField(max_length=10) content = models.CharField(max_length=120) # Each object can have an unlimited number of parameters class ObjectParameters(models.Model): my_object = models.ForeignKey(MyObject, on_delete=models.CASCADE) param = models.CharField(max_length=120) I would like to query a list of objects that contain all given parameters. Also, is this a logical structure for my models? -
Why cant my Django app read the environment variables set?
Problem My django app cannot read the env vars that I set. Im sure it is something stupid simple that I am missing. The env vars exists as I expect them to. When I go into the python shell I am able to access them. Using the os.environ["DB_PASSWORD_DJANGO"]command. Code The variables exist as I expect them ~/.profile # Set Environment Vars export DB_NAME_DJANGO="<name>" export DB_USER_DJANGO="<user>" export DB_PASSWORD_DJANGO="<pw>" export CLOUD_SQL_INSTANCE_IP="<IP>" user@localhost:~$ env ANG=en_US.UTF-8 ... CLOUD_SQL_INSTANCE_IP=<ip> DB_PASSWORD_DJANGO=<pw> DB_USER_DJANGO=<user> ... DB_NAME_DJANGO=<db> Settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': os.environ['DB_NAME_DJANGO'], 'USER': os.environ['DB_USER_DJANGO'], 'PASSWORD': os.environ['DB_PASSWORD_DJANGO'], 'HOST': os.environ['CLOUD_SQL_INSTANCE_IP'], 'PORT': 5432, } } Error Dec 3 02:16:52 localhost gunicorn[36212]: File "/usr/lib/python3.6/os.py", line 669, in __getitem__ Dec 3 02:16:52 localhost gunicorn[36212]: raise KeyError(key) from None Dec 3 02:16:52 localhost gunicorn[36212]: KeyError: 'DB_NAME_DJANGO' Dec 3 02:16:52 localhost gunicorn[36212]: [2020-12-03 02:16:52 +0000] [36218] [INFO] Worker exiting (pid: 36218) Dec 3 02:16:52 localhost gunicorn[36212]: Traceback (most recent call last): Dec 3 02:16:52 localhost gunicorn[36212]: File "/home/user/django_app/venv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 209, in run Dec 3 02:16:52 localhost gunicorn[36212]: self.sleep() Dec 3 02:16:52 localhost gunicorn[36212]: File "/home/user/django_app/venv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 357, in sleep Dec 3 02:16:52 localhost gunicorn[36212]: ready = select.select([self.PIPE[0]], [], [], 1.0) Dec 3 02:16:52 localhost gunicorn[36212]: File "/home/user/django_app/venv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 242, in handle_chld … -
How can i display ListCharField's verbose_name in HTML (Django)
I have a model looks like this class Program(models.Model): name = models.CharField(max_length=20, default='program_1') pazartesi = ListCharField( verbose_name = 'Pazartesi', base_field=models.CharField(max_length=15), size=10, max_length=(10 * 16) ) and this is my views.py file: def program(request): context = { 'dp' : Program.objects.all() } return render(request, 'dash/program.html', context) and i want to display the ListCharField's verbose name which is 'Pazartesi' on my template. {% for i in dp %} <th scope="col">{{ i.pazartesi.XXX }}</th> {% endfor %} i tried creating a custom tag like return object._meta.verbose_name but i get 'str' object has no attribute 'verbose_name' error. Is there any functon where i can put on 'XXX' or another simple way? -
Django Rest Framework Serializer : get fields of two models
Hello all been working on Rest API for couple of weeks I have learned about serializers and nested serializer. I am stucked on grabbing fields from Two models is it possible to do in serializer. Here is my code. class Slider(BaseModel): page = models.ForeignKey(Page, on_delete=models.CASCADE) section = models.CharField( max_length=20, validators=[validators.validate_section_name], ) tag = models.CharField( max_length=20, validators=[validators.validate_tag_name], ) class Meta: default_permissions = () verbose_name = 'Slider' verbose_name_plural = 'Sliders' def __str__(self): return self.section next model I want to combine in serializer is class SliderImage(BaseModel): image = models.ImageField( upload_to=upload_slider_image_to, validators=[], null=True, blank=True ) slider = models.ForeignKey(Slider, on_delete=models.CASCADE, related_name='slider_image', ) class Meta: default_permissions = () verbose_name = 'Slider Image' verbose_name_plural = 'Slider Images' now is there any way out so that i can get serializers in this way? {page:home-banner, section:home-banner, image:?-- I want this from slider_Image?} I am newbie hope I clarified my question. -
Django - Cannot run "py manage.py runserver"
I have tried python manage.py runserver, same result. It says the following in the terminal: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases When I run py --version, it works fine. I want to know why it says python was not found, when it works just fine. I haven't found anything online. -
Excluding elements from the queryset on a inlineformset
So lets say I have these models: class Club(models.Model): name = models.CharField(max_length=100) members = models.ManyToMany(User) class Event(models.Model): name = models.CharField(max_length=100) date = models.DateField() club = models.ForeignKey(Club, models.CASCADE) So what I need is to get all the club's events, but on an inlineformset, or any kind of formset. I could create a working formset with this: from django.forms import inlineformset_factory def my_view(request): ... CustomFormset = inlineformset_factory(Club, Event, fields=('name', 'date')) actual_formset = CustomFormset(instance=Club.objects.get(pk=1) ... Now that works but I get every single event related to the club, but what I actually need to get elements that fit some parameters, for example I want only elements with date greater than today. I haven't found a way to accomplish this and would appreciate any guidance. Thanks for your time -
Implementing a django forum app without cstarting from scratch
I'm looking to add a forum to my site, I have a custom User model that helps me with my own apps (quizzess, uploads etc). I really don't want to create a forum from scratch and there are many wonderful packages for django forums. Does anyone know a good package or implementation where I can get the best of both worlds (not start fresh with the user model from the forum and get the functionalities from the forum package). If not whats the best recourse? -
ERRORS: blog.Post: (models.E015) 'ordering' refers to the nonexistent field, related field, or lookup 'publish'. How do i fix this?
Anytime I try migrating my models. I keep getting this error: ERRORS: blog.Post: (models.E015) 'ordering' refers to the nonexistent field, related field, or lookup 'publish'. Here's my models file. from django.db import models from django.utils import timezone from django.contrib.auth.models import User # Create your models here. class Post(models.Model): STATUS_CHOICES = ( ('draft', 'Draft'), ('published', 'Published') ) title = models.CharField(max_length=250) slug = models.SlugField(max_length=250, unique_for_date='publish') author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts', ) body = models.TextField() published = models.DateTimeField(default=timezone.now) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft') class Meta: ordering = ('-publish',) def __str__(self): return self.title The lines causing the error. class Meta: ordering = ('-publish',) i Would like a quick solution to this. Thanks in advance -
django upload multilple files fields not save
I am trying to upload multiple files but somehow other fields are saved, only the files that were uploaded were saved. I don't know what I did wrong. def company_form(request): if request.POST: form = CompanyFrom(request.POST, request.FILES) files = request.FILES.getlist('Supporting_Documents') if form.is_valid(): for f in files: file_instance = InternationalCompany(Supporting_Documents=f) file_instance.save() messages.info(request, 'Record was successfully added to the database!') return HttpResponseRedirect('/company_form') else: form = CompanyFrom() return render(request, 'company_form.html', locals()) class InternationalCompany(models.Model): International_company_Name = models.CharField(max_length=50) International_company_Id = models.CharField(max_length=50) options = ( ('Yes', 'Yes'), ('No', 'No'), ) Does_it_have_a_Financial_Dealers_License = models.CharField(max_length=20, choices=options, null=True) Register_Office = models.TextField(max_length=500, null=True) Beneficial_owner = models.CharField(max_length=100, null=True) Beneficial_owner_id = models.FileField(upload_to='passport/pdf/',null=True) Supporting_Documents = models.FileField(upload_to='support_doc/pdf/', null=True) expire_date = models.DateField(null=True) BO_Phone_number = models.IntegerField(null=True) BO_Email_Address = models.EmailField(null=True) BO_Residential_Address = models.TextField(max_length=200, null=True) def __str__(self): return self.International_company_Name -
how i can limit choices to django ManyToManyField
how i can limit number of choices to django ManyToManyField ? in my situation this is needed to choose one from many pick-up points pickup = models.ManyToManyField(PickUpPoint,related_name='orders') or how i can do another choice system -
Django Celery shared_task singleton pattern
I have a Django based site that has several background processes that are executed in Celery workers. I have one particular task that can run for a few seconds with several read/writes to the database that are subject to a race condition if a second task tries to access the same rows. I'm trying to prevent this by ensuring the task is only ever running on a single worker at a time but I'm running into issues getting this to work correctly. I've used this Celery Task Cookbook Recipe as inspiration, trying to make my own version that works for my scenario of ensuring that this specific task is only running on one worker at a time, but it still seems to be possible to encounter situations where it's executed across more than one worker. So far, in tasks.py I have: class LockedTaskInProgress(Exception): """The locked task is already in progress""" silent_variable_failure = True @shared_task(autoretry_for=LockedTaskInProgress], default_retry_delay=30) def create_or_update_payments(things=None): """ This takes a list of `things` that we want to process payments on. It will read the thing's status, then apply calculations to make one or more payments for various users that are owed money for the thing. `things` - The list … -
Django how to filter for producer
I have some issues in filtering the producer of the products. I want to display all producers in current category. So far I managed to display all producers when I put in my views 'myForm = Produkty.objects.all()' but it repeats producer name couple times as there is more products in that category from this producer. If I put in my views 'myForm = Producent.objects.all()' it doesn't display multiple times the name of producer but still I don't know how to filter for producer in current category so I can receive only producers in current category. *models: class Producent(models.Model): def __str__(self): return self.name name = models.CharField(max_length=60) description = models.TextField(blank=True) class Meta: verbose_name_plural = "Producent" class Produkty(models.Model): def str(self): return name + ' ' name = models.CharField(max_length=35) description = models.TextField(blank=True) producer = models.ForeignKey(Producent, on_delete=models.CASCADE, null=True) category = models.ForeignKey(Kategoria, on_delete=models.CASCADE, null=True, blank=True) price = models.DecimalField(max_digits=12,decimal_places=2) image = models.ImageField(upload_to="images", blank=True) class Meta: verbose_name_plural = "Produkty" *views: def kategoria(request, id): kategoria = Kategoria.objects.get(pk=id) kategoria_produkt = Produkty.objects.filter(kategoria=kategoria) kategorie = Kategoria.objects.all() paginator = Paginator(kategoria_produkt,3) page = request.GET.get('page') kategoria_produkt = paginator.get_page(page) # myForm = Produkty.objects.filter(kategoria=kategoria) # myForm = Producent.objects.all() produkt = Produkty.objects.get(pk=kategoria) myForm = Producent.objects.filter(id=produkt) dane = {'kategoria':kategoria, 'kategoria_produkt':kategoria_produkt, 'kategorie':kategorie, 'myForm':myForm, } return render(request, 'kategoria_produkt.html', dane) *html: <select … -
Heroku Django migration - ModuleNotFoundError: No module named 'settings'
I am trying to deploy this app to heroku, but i'm getting the following error ModuleNotFoundError: No module named 'oxm_crm.settings' when i run heroku run python manage.py migrate wsgi.py import os from dj_static import Cling from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'oxm_crm.settings') application = Cling(get_wsgi_application()) manage.py import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'oxm_crm.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == '__main__': main() Error: Traceback (most recent call last): File "/app/manage.py", line 20, in <module> main() File "/app/manage.py", line 16, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 343, in run_from_argv connections.close_all() File "/app/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 232, in close_all for alias in self: File "/app/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 226, in __iter__ return iter(self.databases) File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 153, in databases self._databases = settings.DATABASES File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 83, in __getattr__ self._setup(name) File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 70, in _setup self._wrapped = Settings(settings_module) File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 177, … -
Django serializer share models and pk with models fields
When sending the data in json format, send the following: [{"model": "callserviceapp.item", "pk": 1, "fields":{.....}} As you can see, the model fields are sent but before "model" is sent: "callserviceapp.item", "pk": 1 Why that? def home (request , data=None): data = serializers.serialize("json", item.objects.filter(radius__lte=data)) if len(data)>0: return HttpResponse(data) else: return HttpResponse(401) -
LoadBalancer - how to intercept queries so that I can send them to all databases? [Python][Django]
I'm creating LoadBalancer package for Django. I wonder how can I intercept quiries so that I can send them to all my databases? I mean CREATE, UPDATE, DELETE queries. -
Django HTML: iteratively generate a new checkbox for each row in a table
I have a view in my Django app that displays a table of all of the factor model objects which are associated with a particular reference model object (indicated by ref_id in views.py below) through a foreign key relationship. This is the HTML for the table (key snippet from the full version of view_factors.html). The third column (Select) is where I would like to render a checkbox for each row. All examples I've found have hinged on knowing the number of checkboxes needed beforehand, but in my case, this number depends on how many factors are related to the reference at hand--the checkboxes must be generated iteratively. Using the code as is below, the Select column renders as blank--no checkboxes appear. <table id="factorTable" class="table table-bordered table-sm" cellspacing="0" width="100%"> <thead> <tr> <th>Title</th> <th>Description</th> <th>Select</th> </tr> </thead> <tbody> {% for factor in ref_factors %} <tr> <td>{{ factor.factor_title }}</td> <td>{{ factor.factor_description }}</td> <td> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input"> </div> </td> </tr> {% endfor %} </tbody> </table> So, I assumed I needed to assign the checkbox an id that can change iteratively, but something like <input type="checkbox" class="custom-control-input" id={{ factor.id }}> does not work as I'm not sure how to parse that factor.id … -
Trying to fix an issue returned by my program
i have an add to cart and place order website everything is smooth i place the order with false shipping address and credit card information and the order is placed but when i log into the admin pannel and try to pick that order up it returns this. TypeError at /admin/core/order/11/change/ str returned non-string (type NoneType) str returned non-string (type NoneType) 9 {% for field in line %} 10 <div{% if not line.fields|length_is:'1' %} class="fieldBox{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif field.is_checkbox %} class="checkbox-row"{% endif %}> 11 {% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %} 12 {% if field.is_checkbox %} 13 {{ field.field }}{{ field.label_tag }} 14 {% else %} 15 {{ field.label_tag }} 16 {% if field.is_readonly %} 17 <div class="readonly">{{ field.contents }}</div> 18 {% else %} 19 {{ field.field }} 20 {% endif %} 21 {% endif %} 22 {% if field.field.help_text %} 23 <div class="help">{{ field.field.help_text|safe }}</div> 24 {% endif %} 25 </div> 26 {% endfor %} 27 </div> 28 {% endfor %} 29 </fieldset> my models from django.conf import settings from django.db import models … -
Python/Django: Where in the cloud to store my log files for analysis/visualization?
I have a Django web app nearing deployment. I've been logging to .log files. Rather than CTRL+F, I want some way to export these logs to a cloud service for analysis and visualization. I already have sentry configured for errors but need more granular logging. How can I achieve what I want to do? -
What is wrong with my logic in for loops - django templates
This is my home.html, problem is with the if block: {% for menu in menus %} <div class="dropdown show"> <a class="btn dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> {{ menu.main_menu_item }} </a> <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> {% for item in menu.items.all %} {% for second_item in item.items_second_level.all %} {% if item.items_second_level.all != None %} <li class="dropdown-submenu"><a class="dropdown-item dropdown-toggle" href="#">{{ item.sub_menu_item }}</a> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">{{second_item.sub_menu_item}}</a></li> </ul> </li> {% else %} <li><a class="dropdown-item" href="#">{{ item.sub_menu_item }}</a></li> {% endif %} {% endfor %} {% endfor %} </ul> </div> {% endfor %} Namely, {% else %} part always "blanks". When I change condition to {% if item.items_second_level.all == None %} again, only items which satisfies the if condition get showed (obviously this time the ones that were not shown before). it behaves like there is no else. Does anyone know what could be the issue here?