Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
serializer.save() not saving in django rest
I am having a problem with my APIView for reading and writing names of places. Here is my view, class pList(APIView): def get(self,request): e = placename.objects.all() ser = placeSerializer(e,many=True) return Response(ser.data) def post(self,request): serializer = placeSerializer(data=request.data, many=True) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) and my serializer class placeSerializer(serializers.ModelSerializer): class Meta: model = placename fields = ('em_name') the get method works fine but when i try to POST, i get an empty set([]).What am i doing wrong here? PS: I am new to DRF. -
filter object which begin by string in a list
Here is my code : communeList = [ "78", "95", "77", "91", "92", "93", "94", "75", ] commune_list_1 = list(Commune.objects.all()) commune_list = [] for c in commune_list_1 : if c.codePostal[0:2] not in communeList : commune_list.append([c]) CodePostal is a charfield with 6 characters and i would like a query to return me all the codepostal which begins (the first 2 characters) by the element of the list communeList. Regards -
why im unable to authenticate other users except the super user in django?
I have used the default path('',include("django.contrib.auth.urls")) in django to perform login,password reset operations for my project,i have thoroughly checked my signup form and the database,everything goes well with the registration part,but i'm unable to authenticate all other users except the super user,what might be the reason for this issue? -
Django PasswordResetView - Gmail email is not sending
I setup a PasswordResetView with a template that has a submit button, I also setup the necessary configuration for sending using a Gmail account but then when I try to send a password reset to an email, the console returns a 302 response and no email is received. I already allowed less secure apps in my gmail account, but it still doesn't send any email. Below are the details of my setup. URL: path('password-reset/', auth_views.PasswordResetView.as_view(template_name='users/password_reset.html'), name='password_reset'), settings.py: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_HOST_USER = 'my@gmail.com' EMAIL_HOST_PASSWORD = 'mypass' Reset Password Template: {% extends "blog/base.html" %} {% load crispy_forms_tags %} {% block content %} <div class="content-section"> <form method="POST"> {% csrf_token %} <fieldset class="form-group"> <legend class="border-bottom mb-4 pb-2">Reset Password</legend> {{ form|crispy }} </fieldset> <div class="form-group"> <button class="btn btn-outline-info" type="submit">Request Password Reset</button> </div> </form> </div> {% endblock content %} Server Response: -
SES emails are getting timed out on AWS Lambda
I have deployed a Django app on AWS lambda using Zappa. But I cannot send emails using AWS SES. It is always getting timed out. My lambda function is inside a VPC. It can access the RDS instance without any problem. -
Djanglo Logger not writing INFO level logs on server. (Works fine on Localhost)
I am using Django Logger to auto-write logs to file. My application is based on Django Rest Framework, so I want status of every request to be logged in a file. This is my settings.py file: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s' }, }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'simple', }, 'file': { 'level': 'INFO', 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(BASE_DIR, '../logs', 'pt.log'), 'formatter': 'verbose', 'maxBytes': 1024*1024*5, # 5 MB 'backupCount': 5, }, 'mail_admins': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django': { 'handlers': ['file'], 'level': 'INFO', 'propagate': True, }, 'core': { 'handlers': ['console', 'file'], 'level': 'INFO', 'propagate': True }, 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, }, } DEBUG = True Wit this setting, my local pt.log files show exactly what I need. INFO 2019-01-25 13:58:22,04872 basehttp 26474674 139808464443811584 "GET /api/v1/test/157/ HTTP/1.1" 200 935 INFO 2019-01-25 13:58:22,042 basehttp 26474 139808443811584 "GET /api/v1/test/157/ HTTP/1.1" 200 935 INFO 2019-01-25 13:58:23,311 basehttp 26474 139808443811584 "GET /api/v1/dummy/data HTTP/1.1" 200 13764 INFO 2019-01-25 13:58:23,311 basehttp 26474 139808443811584 "GET /api/v1/dummy/data HTTP/1.1" 200 13764 But when same settings are deployed on server, … -
Django mysql strange id generation
I use django to connect to mysql database. My model is like this: class MyModal (models.Model): unit = models.CharField(blank=True, max_length=500) name = models.CharField(blank=True, max_length=500) I add object to my table using this script: myModal = MyModal() myModal.unit = unit myModal.name = name myModal.save() I notice that mysql generated strange ids like this: 1, 21, 31, 41,... 91, 101, 111. I expect the ids will be 1, 2, 3, 4, ... 9, 10, 11 Any idea what caused this strange behavior? -
How can I face Invalid filter: 'has_group' error in custom django templatetags
Despite the fact that I have created a templatetags folder and put in __init__.py the code below, from django import template from django.contrib.auth.models import Group register = template.Library() @register.filter(name='has_group') def has_group(user, group_name): group = Group.objects.get(name=group_name) return True if group in user.groups.all() else False I still facing the error "Invalid filter: 'has_group'". I want based on a specific group that I have created in admin to give access to certain functions. This is an example of my template. {% if request.user|has_group:"operationalusers" %} <div class="col-md-12"> <h1>Warehouse</h1> <div style="margin: 0 auto; text-align:center; padding:1em;"> <a href="{% url 'warehouse_stuffing_new' %}"> <button class="btn btn-success" type="">New Entry to warehouse</button></a> <a href="{% url 'upload_csv' %}"> <button class="btn btn-success" type="">Bulk Entry to warehouse</button></a> </div> {% endif %} The Traceback stack gives an error to the return line of code in my views.py def warehouse_stuffing_list(request, template_name='warehouse/warehouse_list.html'): products_with_serial_numbers = ProductSerialNumbers.objects.all() data = {} data['object_list'] = products_with_serial_numbers return render(request, template_name, data) What I miss? -
Changing the language on the page does not reflect the language in the menu
If I change the language on the page, the menu remains unchanged, while the language is translated in other places. This problem comes up if prefix_default_language=False in urls.py Has anyone had similar experiences? Thanks in advance. -
Get all Objects one by one but in a random way
Here is the code from an other post : from random import randint count = article.objects.all().count() random_index = randint(0, count - 1) all_articles_query = article.objects.all() article = all_articles_query[random_index] but now i would like to remove article from the list all_articles_query, and multiple time. I would like to sort a list of article then a random article and each time i sort a random article to move it from the list of article. I would like to get all article one by one but in a random way. Regards -
Docker, SELinux and MCS: allow container to access files created by another container in the same volume
I have two containers that share the same volume mount and the reason behind it is that I want Django uploads to be served by a reverse proxy (nginx). A user/admin will upload a file through Django (i.e. django handles the saving to MEDIA_ROOT). MEDIA_ROOT points to a volume that is mounted like so: ./assets:/assets:z According to Docker, the lowercase z flag "indicates that the bind mount content is shared among multiple containers". However, all my uploads have the following SELinux context: system_u:object_r:container_file_t:s0:c156,c725 Notice the compartments that are added to the user-uploaded file. This prevents my other container, that runs as a reverse proxy, from accessing the file (nginx returns a 403 error). May I know if there is a way to disable this container flag when a container process adds a file to a shared volume? -
How come the context of my form.py is not showing up?
I have had the same problem for quite some time and have been trying different solutions but nothing is working. I have seen different examples here on the website, but most of them are addressing older versions of Django. I have tried such solutions, but nothing is workin. The problem is as addressed by the title, " A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext. " I have tried to add RequestContext(request) to my code instead of writing {'form': 'form'} but it didn't work out. I have tried to use HttpResponse() instead of render_to_response in my urls' views, but didn't work out as well. This is the for my original views.py before I alter anything! def ask_page_view(request): if request.method == 'POST': form = Ask_Page_Form(request.POST) if form.is_valid(): pass # does nothing, just trigger the validation else: form = Ask_Page_Form() return render(request, "ask.html", {'form': form }) This is the views.py when I have added the RequestContext() def ask_page_view(request): if request.method == 'POST': form = Ask_Page_Form(request.POST) if form.is_valid(): pass else: form = Ask_Page_Form() return renderto('ask.html', context_instance = RequestContext(request)) This is the forms.py that I am using: … -
Setting up circle ci django environment variables in config.yml file
How do I set up django environment variables for in circle ci in the config.yml file?. For instance I have environment variables DJANGO_EXECUTION_ENVIRONMENT="PRODUCTION" and DJANGO_SECRET_KEY="YOUR_SECRET_KEY_GOES_HERE". This is a sample snippet set up of the config.yml file: # Python CircleCI 2.0 configuration file version: 2 jobs: build: docker: # specify the version you desire here # use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers` - image: circleci/python:3.6.1 environment: # environment variables for primary container PIPENV_VENV_IN_PROJECT: true DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable - image: circleci/postgres:9.6.2 environment: POSTGRES_USER: root POSTGRES_DB: circle_test working_directory: ~/accounting_api steps: - checkout - run: sudo chown -R circleci:circleci /usr/local/bin - run: sudo chown -R circleci:circleci .................. -
Django Websocket communication
I have a web application, in which i have implemented Django Channels 2 using the tutorial . The chat is working according to the tutorial. consumer.py class EchoConsumer(WebsocketConsumer): def connect(self): self.room_name = self.scope['url_route']['kwargs']['room_name'] self.room_group_name = 'power_%s' % self.room_name # Join room group async_to_sync(self.channel_layer.group_add)( self.room_group_name, self.channel_name ) self.accept() def disconnect(self, close_code): # Leave room group async_to_sync(self.channel_layer.group_discard)( self.room_group_name, self.channel_name ) # Receive message from WebSocket def receive(self, text_data): text_data_json = json.loads(text_data) message = text_data_json['message'] # Send message to room group async_to_sync(self.channel_layer.group_send)( self.room_group_name, { 'type': 'chat_message', 'message': message } ) # Receive message from room group def chat_message(self, event): message = event['message'] # Send message to WebSocket self.send(text_data=json.dumps({ 'message': message })) routing.py websocket_urlpatterns = [ re_path(r'^ws/power/(?P<room_name>[^/]+)/$', consumers.EchoConsumer), ] But now, i want to implement a simple python client which send messages to Django Channels application using web sockets. A simple python websocket but i am unable to connect. The error i receive is as under error ----------------------- --- response header --- [WinError 10054] An existing connection was forcibly closed by the remote host ### closed ### ----------------------- --- response header --- [WinError 10054] An existing connection was forcibly closed by the remote host ### closed ### --- request header --- GET /power/room/ HTTP/1.1 … -
how to make one models data choices for another models and how to assign id on forms.py
how to aasign id on forms.py and how to generates choices on the form of another models for individual id ,choices may be differenet for individual id class Doctor_Patient_Med(models.Model): medicines=models.CharField(max_length=1000,blank=False) comments=models.TextField(max_length=1000,blank=False) follow_up=models.DateField(null=True,blank=True) patient=models.ForeignKey(Patient) doctor=models.ForeignKey(Doctor) def __str__(self): return self.patient.name class Medical_Meds(models.Model): medicines=models.CharField(max_length=250) amount=models.IntegerField(default=0) # is_purchase=models.BooleanField(default=False) p_date=models.DateTimeField(default=datetime.now) patient=models.ForeignKey(Patient) medical=models.ForeignKey(Medical) class Medical_Meds_Forms(forms.ModelForm): patient=4, opt = [] # my = Doctor_Patient_Med.objects.all() my = Doctor_Patient_Med.objects.filter(patient=patient) for x in my: opt.append([x.medicines,x.medicines]) total=len(opt) print(total) medicines =forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=opt) amount=forms.IntegerField(label='Amount',initial="0") p_date=forms.widgets.DateTimeInput(attrs={'type':'date'}) # p_date = forms.DateTimeField(label='Purchase-Date', widget=forms.DateTimeInput(attrs={'type':'date'})) class Meta: model=Medical_Meds exclude=['patient','doctor','medical'] the problem is cannot assign id for individual user,that's why i defined patient id: patient=4 -
I need help for foreignkey queryset
I have this model class UserInfo(models.Model) : userNumber = models.CharField(max_length=15) userPin = models.CharField(max_length=7, unique=True) def __str__(self) : return str(self.userPin) class UserFollows(models.Model) : following = models.ForeignKey(UserInfo, on_delete=models.CASCADE, related_name='UserFollows.following+') followers = models.ForeignKey(UserInfo, on_delete=models.CASCADE, related_name='UserFollows.followers+') I need inner join for userPin. This command try error UserInfo.objects.filter(userPin__UserFollows__followers= '****') Unsupported lookup 'UserFollows' for CharField or join on the field not permitted. -
not getting updated fields using django signals
I am trying to fetch the updated fields using django signals.when i update the model using update view and call the post_save i get the update_fields as None in the kwargs. How to get the updated fields using django signals ?? signals.py from .models import Department from django.db.models.signals import post_save from django.dispatch import receiver @receiver(post_save, sender=Department) def department_history(sender, created, **kwargs): update = kwargs['update_fields'] views.py class DepartmentEditView(LoginRequiredMixin, SuccessMessageMixin,PermissionRequiredMixin, UpdateView): model = Department form_class = DepartmentForm success_url = reverse_lazy('departments:departments') success_message ="%(department_name)s was Updated Sucessfully " template_name_suffix = '_update' permission_required = ('departments.change_department',) -
Is there a function that can compare one user's a week ago database and today's database?
I'm now making a "Score checker" site, that can analyze the one user's increase and decrease of score. But the problem is, I think there's no function that I can use. Where do I need to compare before score and after score, and show result on the site? I'm now running Django on macOS 10.14.2, Safari browser, and SQLite (Django stock database). I've already tried registering custom templates, getting variables from HTML and calculate on views, but every methods gave me a syntax error. *Score is same with contribution point. **Models.py (shows line 5-10, line 31-34) class CharacterMain(models.Model): name = models.CharField(verbose_name = '닉네임', max_length = 10, default = ' ') characterPicture = models.URLField(max_length = 500) job = models.ForeignKey('Job', on_delete = models.CASCADE) guildHierarchy = models.ForeignKey('GuildHierarchy', on_delete = models.CASCADE) guildName = models.ForeignKey('GuildName', on_delete = models.CASCADE) class ContributionPoint(models.Model): name = models.ForeignKey('CharacterMain', on_delete = models.CASCADE) point = models.IntegerField(default = 0) createdTime = models.DateTimeField(blank=True, null=True) **views.py (shows line 12-16) def characterMain_detail(request, pk): characterMain = get_object_or_404(CharacterMain, pk=pk) characterSubs = CharacterSub.objects.filter(mainCharacter__exact=characterMain.id) contributions = ContributionPoint.objects.filter(createdTime__month=timezone.now().month, name__exact=characterMain.id) return render(request, 'contribution/characterMain_detail.html', {'characterMain':characterMain, 'characterSubs':characterSubs, 'contributions':contributions}) **characterMain_detail.html (shows line 31-52), using Bootstrap 4 <div class="col-md-6"> <h4>Changes of contribution point</h4> <table class="table"> <thead class="thead-dark"> <tr> <th scope="col">Date</th> <th scope="col">Point</th> <th scope="col">Inc/Dec</th> </tr> </thead> … -
Within a specific view function Regardless of the login status, request.user = AnonymousUser. Is there a way to fix it?
Feed view works normally so request.user = allieus (login user) class Feed(APIView): def get(self, request, format=None): user = request.user following_users = user.following.all() print("following_users , ", following_users) image_list = [] for following_user in following_users: user_images = following_user.images.all()[:2] for image in user_images: print("image : ", image) image_list.append(image) # 본인 이미지도 추가 my_images = user.images.all()[:2] for image in my_images: image_list.append(image) print("image_list : ", image_list) sorted_list = sorted(image_list, key=get_key, reverse=True) serializer = serializers.ImageSerializer(sorted_list, many=True) # return Response(status=200) return Response(serializer.data) def get_key(image): return image.created_at but request.user of ChangePassword is always printed for AnonymousUser so An error occurred when trying to change the password. If you know why and If you know how to fix it Thank you very much! github : https://github.com/hyunsokstar/hyun4/blob/master/nomadgram/nomadgram/users/views.py class ChangePassword(APIView): def put(self, request, username, format=None): print("함수 실행 확인(ChangePassword) ") user = request.user print('user : ', user) current_password = request.data.get('current_password',None) if current_password is not None: # request로 넘어온 비밀번호와 db의 비밀번호를 비교 passwords_match = user.check_password(current_password) # 비밀번호가 정확할 경우 새로운 비밀번호를 request로부터 가져와서 user 객체에 save if passwords_match: new_password = request.data.get('new_password',None) if new_password is not None: user.set_password(new_password) user.save() return Response(status=status.HTTP_200_OK) # None일 경우 400 응답 else: return Response(status=status.HTTP_400_BAD_REQUEST) # false일 경우 400 응답 else: return Response(status=status.HTTP_400_BAD_REQUEST) # None일 경우 400 응답 else: … -
Django use intranet server for uploaded huge media files
I have a Django project and I have a server on the internet (with Nginx and Gunicorn). I also have an intranet server (on the local network). I want to upload user uploaded files (media) in the intranet server. Is it possible? How? I know users can't upload files when they are not connected to the intranet network, there's no problem this way. -
Django 2.1 Create Profile on User creation
I'm working on a project using Python(3.7) and Django(2.1) in which I need to create user's profile on user creation. Here what I have tried: From models.py: class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) avatar = models.CharField(max_length=500, null=True) about = models.CharField(max_length=1000, null=True) slogan = models.CharField(max_length=500, null=True) profile_pic = models.FileField(upload_to='media/profile_pics', null=True) def __str__(self): return self.user.username From signals.py: @receiver(post_save, sender=User) def create_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=User) def save_profile(sender, instance, created, **kwargs): instance.profile.save() From urls.py: path('register/', views.RegisterUser.as_view(), name='register'), From views.py: def post(self, request, *args, **kwargs): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): username = form.cleaned_data.get('username') messages.success(request, f'Account has been created for {username}!') form.save() return HttpResponseRedirect(reverse_lazy('login')) else: form = UserRegisterForm() return render(request, 'users/register.html', {'form': form}) From forms.py: class UserRegisterForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ('username', 'email', 'first_name', 'last_name', 'password1', 'password2') When I create a new account via signup page, it creates the user but not the profile. Also, couldn't find any error on the console on user creation. What can be wrong here? Thanks in advance! -
Why doesn't saving queryset element at index work in django?
I am trying to save an object at a particular index of my queryset but it doesn't seem to work. I have a model called Customer and I wish to change a field called first_name from None to something, say 'aa' and I want to do this for index 0. code 1 customers = Customer.objects.filter(first_name=None) customers[0].first_name = 'aa' customers[0].save() code 2 customers = Customer.objects.filter(first_name=None) customer = customers[0] customer.first_name = 'aa' customer.save() Code 1 doesn't work but Code 2 works. Why doesn't the code 1 work? -
How to remove this error 'No application configured for scope type 'websocket''
I am trying to build a chat app with Django but when I am trying to run it I am getting this error 'No application configured for scope type 'websocket'' my routing.py file is from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter , URLRouter import chat.routing application = ProtocolTypeRouter({ # (http->django views is added by default) 'websocket':AuthMiddlewareStack( URLRouter( chat.routing.websocket_urlpatterns ) ), }) my settings.py is ASGI_APPLICATION = 'mychat.routing.application' CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { "hosts": [('127.0.0.1', 6379)], }, }, } when I open my URL in 2 tabs I should be able to see the messages that I posted in the first tab appeared in the 2nd tab but I am getting an error [Failure instance: Traceback: <class 'ValueError'>: No application configured for scope type 'websocket' /home/vaibhav/.local/lib/python3.6/site-packages/autobahn/websocket/protocol.py:2801:processHandshake /home/vaibhav/.local/lib/python3.6/site-packages/txaio/tx.py:429:as_future /home/vaibhav/.local/lib/python3.6/site-packages/twisted/internet/defer.py:151:maybeDeferred /home/vaibhav/.local/lib/python3.6/site-packages/daphne/ws_protocol.py:82:onConnect --- <exception caught here> --- /home/vaibhav/.local/lib/python3.6/site-packages/twisted/internet/defer.py:151:maybeDeferred /home/vaibhav/.local/lib/python3.6/site-packages/daphne/server.py:198:create_application /home/vaibhav/.local/lib/python3.6/site-packages/channels/staticfiles.py:41:__call__ /home/vaibhav/.local/lib/python3.6/site-packages/channels/routing.py:61:__call__ ] WebSocket DISCONNECT /ws/chat/lobby/ [127.0.0.1:34724] -
Django container - serving static files
I'm trying to put my API made with django-rest-framework into a docker container. Everything seems to works except that I can't access to my static files. Here is my settings.py: MEDIA_URL = '/uploads/' MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads') STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') My urls.py urlpatterns = [ url(r'^admin/', admin.site.urls), path('api/bookmakers/', include('bookmakers.urls')), path('api/pronostics/', include('pronostics.urls')), path('api/', include('authentication.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) My Dockerfile FROM python:3.6 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ && localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8 ENV LANG fr_FR.UTF-8 ENV LANGUAGE fr_FR ENV LC_ALL fr_FR.UTF-8 RUN python --version RUN pip install --upgrade pip RUN pip install -r requirements.txt ADD . /code/ COPY docker-entrypoint.sh /code/ ENTRYPOINT ["/code/docker-entrypoint.sh"] And finally my docker-compose.yml version: '3.1' services: db: image: postgres container_name: nyl2pronos-db restart: always environment: POSTGRES_PASSWORD: password POSTGRES_DB: nyl2pronos website: container_name: nyl2pronos-website image: nyl2pronos-website build: context: nyl2pronos_webapp dockerfile: Dockerfile ports: - 3000:80 api: container_name: nyl2pronos-api build: context: nyl2pronos_api dockerfile: Dockerfile image: nyl2pronos-api restart: always ports: - 8000:8000 depends_on: - db environment: - DJANGO_PRODUCTION=1 So once I go to the url: http://localhost:8000/admin/, I can login but there is … -
how can i get all records of filter id in django
the code i've done showing only one first save record in database whether the id data consists more than once. @login_required(login_url='/login/') def lab_check_pats_list(request): if request.user.is_lab: lab=UserProfile.objects.get(id=request.user.id) labs=Lab.objects.get(user=lab.id) labt=Lab_Test.objects.filter(lab_id=labs.id) print(labt) pt = [] for x in labt: pt.append(x.patient_id) pts= Patient.objects.filter(id__in=pt) context={ 'ab':zip(pts,labt) } print(pts) return render(request,'lab_check_pats_list.html',context) i want to grab all the record of the filter id but it is only showing once For.exe-: Name Contact Test-Name Status Test_Date ID mr.x 123 sugar pending 12/28/2019 1 mr.x 123 blood pending 10/28/2019 1 mr.x 123 thyroid done 8/28/2019 1