Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
an application that measures me the distance between the locale and the position of the client
django.contrib.gis.geoip2.base.GeoIP2Exception: Could not load a database from … I can't find a solution for an application that measures me the distance between the locale and the position of the client setting.py ` INSTALLEDAPPS = [ 'django.contrib.gis.geoip2', ] GEOIPPATH = os.path.join(BASE_DIR, 'geoip') utils.py from django.contrib.gis.geoip2 import GeoIP2 def get_geo(ip): g=GeoIP2() country=g.country(ip) city=g.city(ip) lat,lon=g.lat_lon(ip) return country, city, lat, lon ` -
Python Django saving two models from an html form
I have two models: PersonelModel and ArizaModel. Both in one html form. Personel data was previously saved in the PersonelModel table. When the fetch data button is pressed, the data is fetched by querying according to the p_sicil field. It is displayed in the p_isim and p_bilgisayar_adi fields. I created the required relationship between PersonelModel and ArizaModel. I want to save the data I entered in the a_aciklama field into the database according to the relationship between PersonelModel and ArizaModel. How can i do that? models.py: class PersonelModel(models.Model): p_sicil = models.CharField(max_length=8, verbose_name='Personel Sicili') p_isim = models.CharField(max_length=50, verbose_name='Personel Adı') p_bilgisayar_adi = models.CharField(max_length=4, verbose_name='Bilgisayar Adı') p_durum = models.BooleanField(default=True, verbose_name='Personel Durumu') birim = models.ForeignKey(BirimModel, verbose_name=("BİRİM"), on_delete=models.DO_NOTHING, null=True) grup = models.ForeignKey(GrupModel, verbose_name=("GRUP"), on_delete=models.DO_NOTHING, null=True) unvan = models.ForeignKey(UnvanModel, verbose_name=("ÜNVAN"), on_delete=models.DO_NOTHING, null=True) class Meta: db_table = 'PersonelTablosu' verbose_name = "PERSONEL" verbose_name_plural = "PERSONELLER" def __str__(self): return self.p_sicil class ArizaModel(models.Model): a_aciklama = models.CharField(max_length=100, verbose_name='Arıza Açıklama') a_acilma_tarihi = models.DateTimeField(auto_now_add=True, verbose_name='Açılma Tarihi') a_durum = models.BooleanField(default=True, verbose_name='Arıza Durumu') a_kapanma_tarihi = models.DateTimeField(auto_now_add=True, verbose_name='Kapanma Tarihi') birim = models.ForeignKey(BirimModel, verbose_name=("BİRİM"), on_delete=models.DO_NOTHING, null=True) teknik_personel = models.ForeignKey(TeknikPersonelModel, verbose_name=("TEKNİK PERSONEL"), on_delete=models.DO_NOTHING, null=True) personel_ariza_acan = models.ForeignKey(PersonelModel, verbose_name=("AÇAN PERSONEL"), on_delete=models.DO_NOTHING, null=True) class Meta: db_table = 'ArizaTablosu' verbose_name = "ARIZA" verbose_name_plural = "ARIZALAR" def __str__(self): return self.a_aciklama forms.py: class … -
How to change Django MultipleChoiceField to display multiple data from multiple tables and use specific value
I have 3 relational Django database tables and I want to display 1st column values as label, and 1st table id as value in Django MultipleChoiceField | Example Table Structure | Table 1 (province): | id | name_en |name_ta | | -------- | ---------- |---------- | |1 | Western | - | |2 | Central | - | Table 2 (district): | id | ForeignKey | Name_en |Name_ta | | -------- | ----------- | ----------- |------- | |1 | 2 | Kandy | - | |2 | 1 | Colombo | - | Table 3 (city): | id | ForeignKey | Name_en |Name_ta | | -------- | ----------- | ---------- |---------- | |1 | 1 | Uduwela | - | |2 | 2 | Homagama |- | I want to display MultipleChoiceField in this format <select> <option value='1(city id)'>Western,Colombo,Homagama</option> </select> -
auto generate thumbnail for FileField in django
I uploaded different file types to my project(pdf,doc,mp4 ,jpg). now I want to auto-generate thumbnail for each file which is going to add or was added previously, and save it to my DB. here is what I think: here is my File model: class File(models.Model): slug = models.SlugField( max_length=255, unique=True, ) address = models.FileField( validators=[ file_size, FileExtensionValidator( allowed_extensions=[ "jpg", "mp4", "doc", "pdf", ] ), ], upload_to="files/", max_length=255, ) thumbnail = models.ImageField( upload_to="files/thum/", max_length=255, null=True, blank=True ) TYPES = [ (IMG, "Image"), (VID, "Video"), (DOC, "Document"), ] type = models.CharField(max_length=3, choices=TYPES, default=IMG) here I wrote a function : def make_thumbnail(file): if file.type == File.IMG: make_image_thumbnail(file) if file.type == File.VID: make_video_thumbnail(file) if file.type == File.DOC: make_document_thumbnail(file) def make_image_thumbnail(file): #does not work img = Image.open(file.address) img.thumbnail((128, 128), Image.ANTIALIAS) thumbnailString = StringIO.StringIO() img.save(thumbnailString, "JPEG") newFile = InMemoryUploadedFile( thumbnailString, None, "temp.jpg", "image/jpeg", thumbnailString.len, None ) return newFile def make_video_thumbnail(file): video_input_path = file.address file_name = file.slug + "thumbnail" img_output_path = os.path.join(settings.MEDIA_ROOT, file_name) subprocess.call( [ "ffmpeg", "-i", video_input_path, "-ss", "00:00:00.000", "-vframes", "1", img_output_path, ] ) def make_document_thumbnail(file): # cache_path = ? # pdf_or_odt_to_preview_path = file.address # manager = PreviewManager(cache_path, create_folder=True) # path_to_preview_image = manager.get_jpeg_preview(pdf_or_odt_to_preview_path) pass now I want to fill the functions and I don't know a) … -
How to call a function in a Django template?
I have a function on my views.py file that connects to a mail server and then appends to my Django model the email addresses of the recipients. The script works good. In Django, I'm displaying the model with a table, and I'd like to include a button that says Get Emails and runs this function and it then reloads the page with the new data in the model / table. This is my views.py: class SubscriberListView(LoginRequiredMixin, SingleTableView): model = EmailMarketing table_class = EmailMarketingTable template_name = 'marketing/subscribers.html' # Get emails from email server # Connection settings HOST = 'xXxxxxXxXx' USERNAME = 'xXxxxxXxXx' PASSWORD = "xXxxxxXxXx" m = imaplib.IMAP4_SSL(HOST, 993) m.login(USERNAME, PASSWORD) m.select('INBOX') def get_emails(): result, data = m.uid('search', None, "ALL") if result == 'OK': for num in data[0].split(): result, data = m.uid('fetch', num, '(RFC822)') if result == 'OK': email_message_raw = email.message_from_bytes(data[0][1]) email_from = str(make_header(decode_header(email_message_raw['From']))) email_addr = email_from.replace('<', '>').split('>') if len(email_addr) > 1: new_entry = EmailMarketing(email_address=email_addr[1]) new_entry.save() else: new_entry = EmailMarketing(email_address=email_addr[0]) new_entry.save() # Close server connection m.close() m.logout() And this is what I tried on the urls.py: from django.urls import path from django.contrib.auth import views as auth_views from . import views urlpatterns = [ path('', views.marketing, name='marketing'), path('/getemails', views.get_emails, name='getemails'), ] And … -
How to point to a celery beat periodic task inside the upper level folder?
I want to make a periodic task with Django and Celery. I have configured the celery in my project. The project structure looks like this: ├── apps │ ├── laws └──tasks └──periodic.py # the task is in this file ├── config │ ├── celery.py │ ├── settings └── base.py # CELERY_BEAT_SCHEDULE defined in this file content of base.py settings file: CELERY_BEAT_SCHEDULE = { "sample_task": { "task": "apps.laws.tasks.periodic.SampleTask", # the problem is in the line "schedule": crontab(minute="*/1"), }, } The task on periodic.py: class LawAmendmentTask(Task): def run(self, operation, *args, **kwargs): logger.info("The sample task in running...") How can I define the route of the task correctly? -
How to Change File Upload Size Limit Django Summernote
I'm using Django-summernote. I have installed it by pip install django-summernote command. How can I change the file size upload limit? I get the error: "File size exceeds the limit allowed and cannot be saved" when I try to add an image using the summernote widget's toolbar. Thanks! -
Creating and updating data from API answerI to Django REST project (MySQ)?
I have a Django REST project. I have a models User, Store and Warehouse. And I have a module with marketplace parser, that gets data from marketplace API. In this module there is a class Market and a method "get_warehouses_list". This method returns a JSON with a STORE's warehouse list. Examle answer: { "result": [ { "warehouse_id": 1, "name": "name1", "is_rfbs": false }, { "warehouse_id": 2, "name": "name2", "is_rfbs": true } ] } What I have to do is to make creating and updating methods to set and update this warehouse list into my MySQL DB (with creating an endpoint for setting and updating this data). I don't know what is incorrect in my code, but when I send POST request to my endpoint in urls.py router.register("", WarehouseApi, basename="warehouse") I get 400 error instead of setting warehouse list into my DB. My code: user/models.py class User(AbstractUser): username = models.CharField( max_length=150, unique=True, null=True) id = models.UUIDField( primary_key=True, default=uuid.uuid4, unique=True, editable=False) store/models.py ` class Store(models.Model): user = models.ForeignKey( User, on_delete=models.PROTECT) name = models.CharField(max_length=128, blank=True) type = models.PositiveSmallIntegerField( choices=MARKET, default=1, verbose_name="Type API") api_key = models.CharField(max_length=128) client_id = models.CharField(max_length=128) warehouses/models.py class Warehouse(models.Model): store = models.ForeignKey( Store, on_delete=models.СASCAD, null=True) warehouse_id = models.BigIntegerField( unique = True, … -
Add type hints on django initialization
I have user as foreign key user = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE) But when I access user through related object I can't see auto-completion for user attributes. F.e Unresolved attribute reference 'public_name' for class 'ForeignKey' How can I add type hint that it is actually User model? In django app initialization I am overriding serializers.ModelSerializer with my custom serializer. And overriding is taking place in app/init.py module. Problem is I can't see some attributes that exists in CustomModelSerializer. Pycharm is thinking it is ModelSerializer from drf. Is it possible to hint somewhere that it is CustomModelSerializer. (PS: I know I can import CustomModelSerializer everwhere, but it is a big project and I was looking for solutions with adding type hint or making Pycharm recognize overriding) -
Ignore options which already given in django
I created a django forms class StudentFamilyForm(forms.ModelForm): class Meta: model = StudentFamily fields = '__all__' exclude = ['created', 'is_deleted'] it is used to create family details for a student. in the StudentFamily model, there is a student one-to-one field. If i've created a family entry for a student, I don't want to see it in the select input. so how to do that? -
How to filter the dates from datetime field in django
views.py import datetime from django.shortcuts import render import pymysql from django.http import HttpResponseRedirect from facligoapp.models import Scrapper from django.utils import timezone import pytz roles = "" get_records_by_date = "" def index(request): if request.method == "POST": from_date = request.POST.get("from_date") f_date = datetime.datetime.strptime(from_date,'%Y-%m-%d') print(f_date) to_date = request.POST.get("to_date") t_date = datetime.datetime.strptime(to_date, '%Y-%m-%d') print(t_date) global get_records_by_date get_records_by_date = Scrapper.objects.all().filter(start_time=f_date,end_time=t_date) print(get_records_by_date) else: global roles roles = Scrapper.objects.all() return render(request, "home.html",{"scrappers": roles}) return render(request, "home.html", {"scrappers": get_records_by_date}) models.py from django.db import models from django.db import connections # Create your models here. from django.utils import timezone class Scrapper(models.Model): scrapper_id = models.IntegerField(primary_key=True) scrapper_jobs_log_id = models.IntegerField() external_job_source_id = models.IntegerField() start_time = models.DateField(default=True) end_time = models.DateField(default=True) scrapper_status = models.IntegerField() processed_records = models.IntegerField() new_records = models.IntegerField() skipped_records = models.IntegerField() error_records = models.IntegerField() class Meta: db_table = "scrapper_job_logs" Database structure I post f_date = 2022-11-24 00:00:00 , t_date = 2022-11-24 00:00:00 . I need to get the row start_time and end_time which has dates 2022-11-24. Is there any solution how to filter datas from datetime field. If I pass f_date and t_date my <QuerySet []> is empty. -
How to configure webmail tools in django?
I configured mail for my django project. It worked as usual perfectly for gmail. But when I used this configuration for webmail it won't work. Someone pleas help me how to setup webmail configuration for django proejct. I try for several time but it gives me error. I expect to send mail using my webmail. -
Is there a way to update a webpage after it is loaded in django without doing a periodic check?
I'm trying to do something similar to this question. Basically, I want to have the html page being updated once new information arrives at the server. The information won't come periodically, but rather in bursts. Is there a way for me to trigger the javascript/htmx function via django or is it that I have to do the per-X-seconds check on the browser side? All solutions that I've found are using the periodic check in a script which appears a bit surprising to me. -
DRF How to serialize model with media and foreign key field Django
I have django model containing filefield and imagefield class Audios(models.Model): name = models.CharField(max_length = 29,blank=True,null=True) duration = models.DecimalField(default=0.0,max_digits=5, decimal_places=2) language = models.ForeignKey(Language,on_delete=models.PROTECT,related_name='audios') zartist = models.ForeignKey(Artist,on_delete=models.CASCADE,related_name='myaudios') annotation = models.CharField(max_length=50) avatar = models.ImageField(upload_to=saveAudioImage, validators=[FileExtensionValidator(allowed_extensions=["jpg","png","jpeg"])], null=True, blank=True) audio = models.FileField(upload_to=saveAudioFile, validators=[FileExtensionValidator(allowed_extensions=["mp3","acc"])], null=True, blank=True) streamed = models.PositiveIntegerField(default=0) rating = models.DecimalField(default=0.0,max_digits=2, decimal_places=1) created = models.DateTimeField(auto_now_add=True) likes = models.PositiveIntegerField(default=0) modified = models.DateTimeField(auto_now=True) def __str__(self): return self.name and zartist field is a foreign key to another artist model and i wrote a serializer for it class AudiSerializer(serializers.ModelSerializer): class Meta: model = Audios fields = ('id','name','language','zartist','annotation','avatar','audio') and a view class AudioUpload(APIView): parser_classes = [MultiPartParser, FormParser] def post(self, request,format=None): print(request.data) print("\n\n") serializer = AudiSerializer(data=request.data) if serializer.is_valid(): serializer.save return Response(serializer.data) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) but when i test it with httpie it doesn't save it to the database and the filefield and imagefield are not properly handled. Any one help please ? -
Forbidden (403) CSRF verification failed. Request aborted. in django
I am new to Django and learning using templates. When I properly use csrf token in my sign up template form, submitting form stil makes the csrf token missing error. Following is my signup.html code. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Sign In</title> </head> <body> <form action="/" method="post"> {% csrf_token %} <label for="">Username</label> <input type="text" name="username"> <br> <label for="">First Name</label> <input type="text" name="fname"> <br> <label for="">Last Name</label> <input type="text" name="lname"> <br> <label for="">email</label> <input type="email" name="email"> <br> <label for="">Password</label> <input type="password" name="pass1"> <br> <label for="">Confirm Password</label> <input type="password" name="pass1"> <br> <br> <button>Submit</button> </form> </body> </html> I guess there is something missing in TEMPLATES section of settings.py. Here is the section os settings.py . TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] Here is the screenshot of error. And here is the screenshot of my directories format. Login is main project and authenticate is app -
If I have multilable admin register through API in django , How do I show the users of each admin?
I'm using DRF for make API , and I have API for register Admin. Admins have regitser users ( teacher , student). I won't to display users ( teacher , student) for each Admin when login in (Frontend , Django-Admin) -
Django shows Service Unavailable page
My Django app works fine in my local computer, then I deployed the code to an EC2 instance with Ubuntu and Apache. All was working fine, I was able to see the page, but when i setup the DB connection with the same DB info (postgres database) that I used locally the App started showing a Service Unavailable page, when I remove the DB connection info from the settings.py file work fine, when i put the DB connect fail. The connection with the DB is ok because I use the Django commands to create a super user and was created correctly. Setup DB connection to postgres from DJango app -
Is it possible to receive message from one web socket even though the web socket connection is closed?
I am learning Django Channels and trying to implement WhatsApp like feature. I want to update the contact box of a particular user with latest message even though that particular WebSocket connection is not open I am using Django channels and each window ( mowdin & jack ) represents a individual web socket connection with that user. When the connection is open with mowdin and mowdin sends a message, I'm able to update that message in the contact box of mowdin. ( As highlighted in image above). consumers.py class PersonalChatConsumer(AsyncWebsocketConsumer): async def connect(self): print('Line 8 Connect',self.scope['user']) self.my_id = self.scope['user'].id self.other_user_id = self.scope['url_route']['kwargs']['id'] if int(self.my_id) > int(self.other_user_id): self.room_name = f'{self.my_id}-{self.other_user_id}' else: self.room_name = f'{self.other_user_id}-{self.my_id}' self.room_group_name = 'chat_%s' %self.room_name await self.channel_layer.group_add( self.room_group_name, self.channel_name, ) await self.accept() async def disconnect(self, code): await self.channel_layer.group_discard( self.room_group_name, self.channel_name ) async def receive(self, text_data=None, bytes_data=None): data = json.loads(text_data) message = data['message'] sender_username = data['sender'] group = await database_sync_to_async(Group.objects.get)(name=self.room_group_name) receiving_user = await database_sync_to_async(User.objects.get)(id=self.other_user_id) group.last_message = message group.sent_by = self.scope['user'].username group.received_by = receiving_user.username await database_sync_to_async(group.save)() chat = Chat(message=message, group=group, user=self.scope['user']) await self.channel_layer.group_send( self.room_group_name, { 'type':'chat.message', 'message': message, 'sender':sender_username, 'group':self.room_group_name, } ) async def chat_message(self, event): print('Line 52 Sending Message',self.scope['user'], event) message = event['message'] username = event['sender'] group = event['group'] … -
Django Rest How to show all related foreignkey object?
I have an blog website and my visitors can also comment on my blog posts. Each blog post have multiple comment and I want to show those comment under my each single blog post. Assume Blog1 have 10 comment so all 10 comment will be show under Blog1 here is my code: models.py class Blog(models.Model): blog_title = models.CharField(max_length=200, unique=True) class Comment(models.Model): name = models.CharField(max_length=100) email = models.EmailField(max_length=100) comment = models.TextField() blog = models.ForeignKey(Blog, on_delete=models.CASCADE) Serializer.py class CommentSerializer(serializers.ModelSerializer): class Meta: model = Comment fields = '__all__' class BlogSerializer(serializers.ModelSerializer): class Meta: model = Blog exclude = ("author", "blog_is_published") lookup_field = 'blog_slug' extra_kwargs = { 'url': {'lookup_field': 'blog_slug'} } views.py: class BlogViewSet(viewsets.ModelViewSet): queryset = Blog.objects.all().order_by('-id') serializer_class = BlogSerializer pagination_class = BlogPagination lookup_field = 'blog_slug' -
DRF pagination issue in APIView
I want to implement LimitOffsetPagination in my APIView which was successful but the url is required to be appended with ?limit=<int>. Something like this: But I do not want to manually add that endpoint. So I tried creating a new pagination.py file: But now I am not getting the pagination prompt for navigation to next post like before. I think return needs to be altered? -
Display PDF in django
im new in django programming and i need to display a pdf file in a browser, but i cannot find the solution to take the PDF for the folder media, the PDF file was save in my database, but i cannot show. my urls.py: urlpatterns = [ path('uploadfile/', views.uploadFile, name="uploadFile"), path('verPDF/<idtermsCondition>', views.verPDF, name='verPDF'), ] my models.py: class termsCondition(models.Model): title = models.CharField(max_length=20, verbose_name="title") uploadPDF = models.FileField( upload_to="PDF/", null=True, blank=True) dateTimeUploaded = models.DateTimeField(auto_now_add=True) deleted_at = models.DateTimeField( auto_now=False, verbose_name="Fecha eliminacion", blank=True, null=True) class Meta: verbose_name = "termsCondition" verbose_name_plural = "termsConditions" my views.py: def uploadFile(request): user = request.user if user.is_authenticated: if user.is_admin: if request.method == "POST": # Fetching the form data fileTitle = request.POST["fileTitle"] loadPDF = request.FILES["uploadPDF"] # Saving the information in the database termscondition = termsCondition.objects.create( title=fileTitle, uploadPDF=loadPDF ) termscondition.save() else: listfiles = termsCondition.objects.all()[:1].get() return render(request, 'subirTerminos.html', context={ "files": listfiles }) else: messages.add_message(request=request, level=messages.SUCCESS, message="No tiene suficientes permisos para ingresar a esta página") return redirect('customer') else: return redirect('login2') def verPDF(request, idtermsCondition): user = request.user if user.is_authenticated(): if user.is_admin: getPDF = termsCondition.objects.get(pk=idtermsCondition) seePDF = {'PDF': getPDF.uploadPDF} print(seePDF) return render(request, 'subirTerminos.html', {'termsCondition': getPDF, 'uploadPDF': getPDF.uploadPDF}) else: messages.error(request, 'Do not have permission') else: return redirect('login2') my html: <div> <iframe id="verPDF" src="media/PDF/{{ uploadPDF.url }}" style="width:800px; height:800px;"></iframe> </div> … -
What is the application.properties alternative in Django?
I am beginner in web development. I have previously done a few small projects using Quarkus. I am trying to do a project in Django. I have some properties to set for my application. I had done that in the application.properties file in Quarkus. Is there any similar way to do so in Django? -
I want to create new model with name query but due to this issue I can't do that. this customer model had been created and working properly
from django.db import models class Customer(models.Model): fullname=models.CharField(blank=False,max_length=100) username=models.CharField(blank=False,max_length=100) email=models.CharField(blank=False,max_length=100) password=models.CharField(blank=False,max_length=100) cpassword=models.CharField(blank=False,max_length=100) phone=models.CharField(blank=False,max_length=100) address=models.CharField(blank=False,max_length=256) city=models.CharField(blank=False,max_length=256) def register(self): self.save() I want to create new model but due to this issue I can't do that. this customer model had been created for few days before. its properly working but new model can't create. I tried to create same model in new project, just by copy and paste so the new model had been created but the same model is not working in this project. this error occurred in terminal. python manage.py makemigrations It is impossible to change a nullable field 'email' on customer to non-nullable without providing a default. This is because the database needs something to populate existing rows. Please select a fix: 1) Provide a one-off default now (will be set on all existing rows with a null value for this column) 2) Ignore for now. Existing rows that contain NULL values will have to be handled manually, for example with a RunPython or RunSQL operation. 3) Quit and manually define a default value in models.py. -
django url specific to keyword without adding page number for first page
I have more list in specfic page https://www.hiicanhelpyou.com/india/best-top-doorstep-online-nearby/ro-water-purifier-service-repair-install-near-me-chennai in that i have added ten agent but i have more agent next page https://www.hiicanhelpyou.com/india/best-top-doorstep-online-nearby/ro-water-purifier-service-repair-install-near-me-chennai-1 . The first page always specific to keyword and next pageonwards it should append the page number . How to do SEO URL ? first page it should not add the page number so that keyword showup properly first page https://www.hiicanhelpyou.com/india/best-top-doorstep-online-nearby/ro-water-purifier-service-repair-install-near-me-chennai second page with appending page number https://www.hiicanhelpyou.com/india/best-top-doorstep-online-nearby/ro-water-purifier-service-repair-install-near-me-chennai-1 how to do this seo url in django -
how can i implement python script on html or display python script result on browser?
I am working on a project in python in which i am converting pdf file to text and then extracting keywords from that so i need to display keyword result on browser where i can take pdf as input and display keywords I tried using django but problem is that i am not able to take pdf as input but it is displaying output if taking text as input. code: from django.shortcuts import render import requests def button(request): return render(request,'home.html') def output(request): data="hjhjdhj" return render(request,'home.html',{'data':data})