Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to hash the password using bcrypt in django?
I am converting php website to django. I have to match the password of a user during login. For hashing the password in cakephp Security::setHash('blowfish'); Security::setCost(7); Now I have to find same hashing function in django. I went through the this and found out that they use bcrypt to hash the password in CakePhp. I am beginner in Django and Can not figure out how to encrypt the password using bcrypt in Django specially setCost() function so that hashed password is same as in CakePhp. -
The first loading for a site was refused but freshing shows the website Django/Nginx/Gunicon/AWS Linux
The first loading for a site shows a connection refuse error. This site can’t be reached Xyz.com refused to connect. Try: • Checking the connection • Checking the proxy and the firewall ERR_CONNECTION_REFUSED Then, when I refreshed the site, the site is up and running. The tech stack for the site is on Django NginX Gunicorn AWS Ubuntu v18. This is a bit unusal, where can I start off to check the connection? -
Django reports that" NoReverseMatch at /"
When I learing Django, I wrote these code: In urls.py: In Views.py: In base.html: In Models.py: In topics.html: The Django report that NoRecerseMath at /, I have tried to use regx, replacing the re_path() with url() or path(), and rename the topics function. However, it does not work till now. Here is the full screenshop of the report. I'm really confusing with that, realllllly thanks for your help! -
Could not find the GDAL library in django. What can I do to resolve this problem?
I am working in django project and need to use PointField imported from django.contrib.gis.db.models. To use it, I installed GDAL by brew install gdal. When I enter gdal-config --version in terminal after installing it, I got the message 3.3.1. I believe this tells GDAL has been successfully installed. I also updated the database setting in settings.py like this. DATABASES = { 'default': { "ENGINE": "django.contrib.gis.db.backends.mysql", 'NAME': config("DB_PROD_NAME"), 'USER': config("DB_USER"), "PASSWORD": config("DB_PASSWORD"), "HOST": config("DB_HOST"), "PORT": config("DB_PORT") }, } And this is the models.py where PointField is used. from django.contrib.gis.db import models class Address(models.Model): address_name = models.CharField(max_length=100) address_name_detail = models.CharField(max_length=100) address_type = models.CharField(max_length=11) address_coord = models.PointField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'address' The problem is when I try python3 manage.py runserver or import the model Address in views.py, I get an error django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings. By adding GDAL_LIBRARY_PATH = config('GDAL_LIBRARY_PATH') GEOS_LIBRARY_PATH = config('GEOS_LIBRARY_PATH') in settings.py, there is no longer error when I enter python3 manage.py runserver, but it is not the case in importing Address model. What … -
How is django's default root homepage rendered?
This is a kind of want-to-know itch. Many questions here ask how to replace the default Django homepage (e.g. ). I understand that issue. What I'm curious to know is how the default page is rendered when a new project is created (i.e., in debug mode). Even though my question is not as directly practical as knowing how to replace the default homepage, I have the feeling that if I figure it out, I may understand how Django works a bit better. I would expect it to be in the default urls.py file, but the only entry by default in urlpatterns of urls.py is path('admin/', admin.site.urls). My first naive expectation would be an entry in urlpatterns that you could remove or comment out. Since there's nothing there besides admin/, I'm guessing there's some other built-in app or middleware that specifies the default homepage, but I don't know where to look. Here's my progress in understanding this so far: Commenting out DEBUG=True in settings.py causes the default homepage to no longer appear. I've seen this documentation about how Django processes requests, which mentions middleware that can set the urlconf attribute on a request that changes the default, ROOT_URLCONF. So far Django … -
Passing Dropdown Choice to Modal Using Django For Loop
I have a dropdown with choices. The dropdown should be linked to a modal where I'd like to say "You selected Choice A" (or B or C), depending on what was clicked. I tried data-target="#myModal{{choice}}" and id="myModal{{choice}}", hoping that they would be linked, but with this, the modal won't show up at all. The modal appears when I remove {{choice}} though, but that's not what I want. Thanks for reading. Your help would be much appreciated. views.py: def modal_home(request): choices = [ "A", "B", "C" ] return render(request, 'modal/test-modal.html', { 'choices': choices, }) test-modal.html: <!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"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> </head> <body> <div class="dropdown"> <button class="btn dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown"> Create </button> <div class="dropdown-menu"> {% for choice in choices %} <a class="dropdown-item" href="#" data-toggle="modal" data-target="#myModal{{choice}}">{{ choice }}</a> {% endfor %} </div> </div> <div class="modal fade" id="myModal{{choice}}" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">MODAL</h5> <button type="button" class="close" data-dismiss="modal"> </button> </div> <p>Here I want to say "You selected Choice A"</p> </div> </div> </div> </body> </html> -
Fetching data from other website in django website and saved into our database
How I fetch data from one website to other website in django and stored into our database. -
Different queryset, same result
I'm currently learning Model Manager and Custom Queryset. While trying to understand the implementation of it, I somehow just don't get how the difference between these two calls. I like to include the all() because its more understandable. However I would like to know if there's any difference. 1. Post.objects.all().filter(status=1).order_by('-updated') 2. Post.objects.filter(status=1).order_by('-updated') >>> from django.contrib.auth.models import User >>> from blog.models import Post >>> user= User.objects.filter(username='chair').first() >>> Post.objects.filter(author= user) <PostQuerySet [<Post: 111 updateeee>, <Post: 22222>, <Post: draftdraft>]> >>> Post.objects.all().filter(author= user) <PostQuerySet [<Post: 111 updateeee>, <Post: 22222>, <Post: draftdraft>]> -
How to replicate "Available Groups" to "Chosen Group" functionality in Django Admin
I am moving from Rails to Django and trying to convert a Hamper Business website I run. Love Django!! I have hampers with a number of products. Each hamper has different products. I'd love to be able to use the following structure to move products into a hamper. An example: Django uses the following to have a list of groups which then moves to Chosen Groups: All I seem to be able to get with a ManyToManyField is a list box which I have to select by control and clicking to add multiple fields. This becomes impractical and not easy to read. To take it one step further, I'd love to be able to include a product more than once. For example, a hamper which has three bottles of the same beer. I would like to not have to set up three seperate products for the same hamper. Thanks so much in advance for pointing me in the right direction. -
Celery tasks get blocked by SSE client
I am running a SSE consumer in order to update a few tables like this @app.task(ignore_result=True) @worker_ready.connect def xx_sse_nodes_uptime_info_consumer(sender, **kwargs): update_tables... By some reason, other tasks are not triggered when we have a .delay calling other tasks. If I remove the task above, other tasks will work normally. Also, when CELERY_TASK_ALWAYS_EAGER=True and CELERY_TASK_EAGER_PROPAGATES=True everything runs fine. Since the SSE consumer uses stream=True the xx_sse_nodes_uptime_info_consumer never ends. I am not sure why this blocks others tasks tho as there are enough threads. -
How can I fix, "Failed lookup for key [name] in <URLResolver", on a django site that is hosted by a2hosting.com?
I am hoping to find someone that has django experience and also experience running a django site on a2hosting.com as that is the hosting i have. I originally set this up on my personal hosting there and the site is running just fine (just to make sure i could get it functioning before having the person im making it for buy their own hosting there.) I tried setting it up multiple times on the new hosting and i have been getting the 'Failed lookup for key [name] in <URLResolver' error. Most of the support i have found online suggests making sure all the names match across the url files and anywhere the app name is mentioned. Since i essentially copied and pasted this from a working copy on the same hosting service everything checks out. I am hoping someone with experience with a2hosting and django can offer any additional support or ideas as to how to fix this. it is currently throwing a 404 error saying: Using the URLconf defined in rextech.urls, Django tried these URL patterns, in this order: admin/ home/ The empty path didn’t match any of these. the error mentioned above appears in the django logs i … -
django model foreign key: reference to composite key
I have a table named as Detail with several columns: columns: 'header_id' 'code_key' 'code_desc' 'header_id' and 'code_key' are composite key. So I set constraints = [ models.UniqueConstraint( fields = ['code_key', 'header_id'], name = 'XXXX' ) ] in the table's Meta. I have another table named Report which also contains column 'code_key'. I want this column to refer to the 'code_key' column in table Detail . However, error comes out saying: 'Detail.code_key' must be unique because it is referenced by a foreign key. HINT: Add unique=True to this field or add a UniqueConstraint (without condition) in the model Meta.constraints. Since I already set UniqueConstraint in table Detail, what else should I do now? Thanks for any help T___T -
Changing Boolean value after specific time
I am building a BlogApp and I am trying to set a Boolean Field to False after 10 minutes , so created a function in models.py to change the Boolean Value which are older than 10 minutes. But the function in models.py is not working, It is not changing the Boolean value after 10 minutes. import datetime from django.utils import timezone from datetime import timedelta class Question(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=30,default='') body = models.CharField(max_length=30,default='') date_added = models.DateTimeField(auto_now_add=True) is_old = models.BooleanField(default=False) #Function to change Boolean Value to False after 10 minutes def active(self): now = timezone.now() if date_added < timezone.now() - timedelta(minutes=10): is_bountied = False self.save() I am not using in views What have i tried ? I followed THIS question's Answers and created a celery task but it was not working, didn't show any errors. Than i tried :- @property def active(self): return self.date_added >timezone.now() - timedelta(minutes=10) def __init__(self): super().__init__() self.active = self.end_date > datetime.datetime.utcnow() BUT it also didn't update the field. It is still not changing or saving the field. Any help would be much Appreciated. Thank You in Advance. -
Django serve image authorization with JWT
I am trying to serve images from my Django server. I need these images to be secured with my user's JWT token. ie. If user GETs profile 1, and profile 1 has image ABC. Unless the user has access to Profile 1, they should not be able to navigate to BASE_URL/static/images/ABC.jpg and get an image. -
login error when I try to login the user. Django
Good evening community, I am building my first website and I am facing the following two problems when I try to logging the user: I can see the password as I write it. When I click submit I get a 404 because it sends me to the wrong URL: Request URL: http://127.0.0.1:8000/login_user/simple_investing/create_company.htm/ Here is my code: Forms.py: class UserForm(UserCreationForm): class Meta: model = User fields = ('username', 'email', 'password1', 'password2') class UserLogin(ModelForm): class Meta: model = User fields= ('username', 'password') Views.py: def login_page(request): messages.success(request, 'Account created successfully') form = UserLogin if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') user = authenticate(request, username=username, password=password) if user is not None: login(request, user) return HttpResponseRedirect('simple_investing/create_company.htm/') context = {'form' : form} return render(request, 'simple_investing/login.htm', context) HTHML: {% for message in messages %} <p>{{ message }}</p> {% endfor %} <p>Log in and start using our tools!</p> <form action= "" method='post'> {% csrf_token %} {% for field in form %} <p>{{field.label}}{{field}}</p> {% endfor %} <button type="submit" class="btn btn-success">Login User</button> </form> Any hints? -
Environment variables works on Django's server but not on Apache server
When I use the environment variable in Django's server, it works. SMTP_PASSWORD = os.environ["SMTP_PASSWORD"] However, when I run the same code on Apache, it doesn't. The code os.environ["..."] just doesn't work. I am using Windows 10, Python 3.9.5 and Django 3.2.4. Any idea what is happening? -
Create postgresql view in django
I want to use postgresql view to store intermediate result of queryset in django. Is there a good way to create a view in django? Below is the code of the flow I want! elements = Element.objects.filter(is_active=True, eventcardad__isnull=False) # save elements to database view # reuse the query results by using view -
How to create individual product page using Django?
I'm trying to create an individual page for each of my products. I found a solution online so I did this: models.py: #IMPORTS from django.db import models from django.utils import timezone from django.contrib.auth.models import User from django.urls import reverse from multiselectfield import MultiSelectField import uuid class Product(models.Model): product_id=models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) product_title=models.CharField(max_length=100) product_price=models.FloatField(default=1.00) image_one = models.ImageField(upload_to='media', default='def.jpg') image_two = models.ImageField(upload_to='media', default='def.jpg') image_three = models.ImageField(upload_to='media', default='def.jpg') product_description = models.TextField() #Toys class Toy(Product): CATS = ( ("BT", "Boy Toys"), ("GT", "Girl toys"), ("BbyT", "Baby toys") ) Category=models.CharField(max_length=10, choices=CATS) views.py: class ProductList(ListView): model = Product def Productdetail(request,pk): product= Product.objects.get(id=id) context = {'product': product} return render(request, 'ecomm/product.html', context) . . . my urls.py: from django.urls import path from . import views from .views import ProductList, Productdetail urlpatterns = [ path('', views.home, name='ecomm-home'), path('products/', ProductList.as_view()), path('products/<int:pk>/', Productdetail, name='product_detail'), .... product_detail.html: {% extends "base.html" %} {% block content %} <h2>Product</h2> {{product.product_title}} {% endblock %} girls_toys.html: {% extends "ecomm/base.html" %} {% block content %} <style> .prod{ text-align:center; padding-left:50px; width:500px; display:block; float:left; padding-top:50px; } .header{ font-size:40px; font-family:serif; } </style> <center><h class="header"> Shop girl toys </h></center> <br> {% for t in toys %} {% if t.Category == 'GT' %} <div class="prod"> <a href="{% url 'product_detail' t.id %}"><img src="{{t.image_one.url}}" height="200px" width="250px"></a> … -
Is this the correct way to update existing data using formset?
I have the following code to update my database using formset for one part of the form. I am able to get a queryset and display it currently. But when i submit back, dd_form has the following error in my powershell []. Can anyone guide me on how to correct this? Thank you. def device_edit(request, pk): device = Device.objects.get(pk=pk) deviceDetail = DeviceDetail.objects.get(DD2DKEY=pk) deviceInterface = DeviceInterface.objects.filter(I2DKEY = pk) if request.method == 'POST': # Device_frm contains only hostname and ip address device_frm = DeviceForm2(request.POST) dd_form = DeviceDetailForm2(request.POST) di_formset = modelformset_factory(DeviceInterface, fields=('moduletype', 'firstportid', 'lastportid'), extra=1,max_num=3) di_form=di_formset(request.POST) device_frm.hostname = device.hostname device_frm.ipaddr = device.ipaddr if device_frm.is_valid(): Device.objects.filter(pk=pk).update(ipaddr=device_frm.cleaned_data['ipaddr']) if dd_form.is_valid(): DeviceDetail.objects.filter(DD2DKEY=pk).update(mgt_interface=dd_form.cleaned_data['mgt_interface'],subnetmask = dd_form.cleaned_data['subnetmask'],ssh_id = dd_form.cleaned_data['ssh_id'],ssh_pwd = dd_form.cleaned_data['ssh_pwd'],enable_secret = dd_form.cleaned_data['enable_secret'], dev_mod = dd_form.cleaned_data['dev_mod']) if di_form.is_valid(): for instances in deviceInterface: DeviceInterface.objects.filter(I2DKEY = pk).update(moduletype = di_form.cleaned_data['moduletype'], firstportid = di_form.cleaned_data['firstportid'], lastportid = di_form.cleaned_data['lastportid']) return redirect('/device/', {'device':Device.objects.all, 'devices':device}) else: print(di_form.errors) else: device_frm = DeviceForm2() dd_form = DeviceDetailForm2() di_form = DeviceInterfaceForm() return render(request, 'interface/device_edit.html',{'form': device_frm, 'dd_form': dd_form, 'di_form': di_form, 'devices':device, 'deviceDetail':deviceDetail, 'deviceInterface':deviceInterface }) -
How to hide SMTP Host name and password to Heroku hosted site Django
I made forgot password reset for my Django hosted Heroku app. I have been finding it difficult to hide my Gmail account, especially the password for production and security reasons but it couldn't be found. I hid it in the Heroku config var EMAIL_HOST_USER 'email address' EMAIL_HOST_PASSWORD 'email address password' but it was not still working. I also tried using config, but the .env file is not pushed to GitHub because it is hidden in .gitignore and Heroku can't access it. Is there any other way I can set this?? -
Django + Gunicorn + Nginx wont reload old static file
I have a site running with django > gunicorn > nginx combination. Here are my config files gunicorn.config #!/bin/bash # Name of the application NAME="mediadbin" DJANGODIR=/home/mediaroot/mediadbin/mediadbin NUM_WORKERS= $(( $(nproc) * 2 + 1 )) DJANGO_SETTINGS_MODULE=mediadbin.settings DJANGO_WSGI_MODULE=mediadbin.wsgi echo "Starting $NAME as `whoami`" cd $DJANGODIR ENV=new_django source /root/.virtualenvs/new_django/bin/activate exec gunicorn ${DJANGO_WSGI_MODULE}:application \ --timeout 600 --name $NAME \ --workers &NUM_WORKERS \ --bind=127.0.0.1 \ --log-level=debug \ --log-file=- My site-enabled in nginx congif server { listen 80; server_name mediadbin.n-media.co.jp; client_max_body_size 500M; access_log /home/mediaroot/mediadbin/logs/nginx-access.log; error_log /home/mediaroot/mediadbin/logs/nginx-error.log; server_tokens off; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Real-IP $remote_addr; } location /static { alias /home/mediaroot/mediadbin/mediadbin/static; } location /media { alias /home/mediaroot/mediadbin/mediadbin/media; } include global404; } I have my static files in /home/mediaroot/mediadbin/mediadbin/main_app/static/main_app (as for development) and also collected in /home/mediaroot/mediadbin/mediadbin/static for deployment. Both folders contains the newest static files. Here is the problem: When I try to update existing static files: for example x.js or x.jpg which name already existed on the site before, the static files are not updated to the newest file. But when I change a name to something new <- something that doesn't existed on the page before, like y.jpg this files are … -
DRF Browserable API triggering other self.actions - which in turn is triggering irrelevant permissions resulting in KeyError
I have a DRF ViewSet that seems is triggering the "create" permission_class (IsListOwner below) when I simply want to retrieve a list view. urls.py router = DefaultRouter() router.register(r"list-items", ListItemViewSet, basename="list_item") views.py class ListItemViewSet(viewsets.ModelViewSet): queryset = ListItem.objects.all() def get_serializer_class(self): if self.action == "retrieve": return ListItemDetailSerializer if self.action == "create": return ListItemCreateSerializer return ListItemListSerializer def get_permissions(self): print("self.action", self.action) permission_classes = [AllowAny] if self.action == "list" or self.action == "retrieve": permission_classes = [AllowAny] elif ( self.action == "create" or self.action == "update" or self.action == "partial_update" or self.action == "destroy" ): permission_classes = [IsListItemOwner] return [permission() for permission in permission_classes] So that when I go to http://localhost:8000/api/v1/list-items/, I get the following error: web_1 | Internal Server Error: /api/v1/list-items/ web_1 | view.check_permissions(request) web_1 | File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 332, in check_permissions web_1 | if not permission.has_permission(request, self): web_1 | File "/project/app/permissions.py", line 60, in has_permission web_1 | return List.objects.get(pk=request.data["list_id"]).user == request.user web_1 | KeyError: 'list_id' web_1 | [27/Aug/2021 01:22:14] "GET /api/v1/list-items/ HTTP/1.1" 500 126003 Which points to the "IsListOwner" permission in my permissions.py file. (Even though my only explicit self.action is "list") I understand that this happens because DRF's browserable API initializes serializers for HTML forms. If I log the self.actions when I visit http://localhost:8000/api/v1/list-items/, … -
Django DRF: read_only_fields not working properly
I have the following models class Breed(models.Model):: name = models.CharField(max_length=200) class Pet(models.Model): owner = models.ForeignKey( "User", on_delete=models.CASCADE, ) name = models.CharField(max_length=200) breed = models.ForeignKey( "Breed", on_delete=models.CASCADE, ) I am trying to add few fileds for representation purpose. I dont want them to be included while create or update class PetSerializer(serializers.ModelSerializer): owner_email = serializers.CharField(source='owner.email') breed_name = serializers.CharField(source='breed.str') class Meta: model = Pet fields = "__all__" read_only_fields = ["breed_name","owner_email"] This is not working. I see the owner_email and breed_name in the HTMLform (the DRF api page) Where as class PetSerializer(serializers.ModelSerializer): owner_email = serializers.CharField(source='owner.email',read_only=True) breed_name = serializers.CharField(source='breed.str',read_only=True) class Meta: model = Pet fields = "__all__" This is working. I dont see them in the HTMLform Also i observed, if i use a model field directly in read_only_fields then it works. class PetSerializer(serializers.ModelSerializer): class Meta: model = Pet fields = "__all__" read_only_fields = ["name"] This will make all name not shown in update or create Why read_only_fields is not working properly -
TypeError: Object of type 'Product' is not JSON serializable
I am creating a store which can handle shopping without any registration, but i have some problems. I am storing data about products that user added to basket in django sessions and i am trying to create the similar system which would store a orders which user has done. This is the view which is executed after all payments are done: #I am not pasting the imports, all fine with them basket = Basket(request) orders = Orders(request) ### We are looping through the all items we are storing in basket to create for each one, single order for basketitem in basket: #This order is automatically created for admin, just ignore it, it's working fine order = Order.objects.create(user_id=user_id, product=basketitem['product'], size=basketitem['size'], quantity=basketitem['quantity'], full_name=full_name, address1=address1, address2=address2, postcode=postcode, town=town, country=country, total_paid=baskettotal, order_key=order_key, authenticated=False) #This is the main problem, this is trying to get a product from database "Product" comparing id from database to id that we store in basket in django sessions product = get_object_or_404( Product, id=int(basketitem['productid'])) orders.add(product=product, quantity=basketitem['quantity'], size=basketitem['size'], full_name=full_name, address1=address1, address2=address2, postcode=postcode, town=town, country=country, created=now.strftime("%d/%m/%Y %H:%M:%S")) And after this occurs error "Object of type 'Product' is not JSON serializable" Basket.py class Basket(): def __init__(self, request): self.session = request.session basket = self.session.get('bt') if … -
How do I pass a search query to a Django backend without storing the search results in a database?
My goal is to post a search query to a scraper function in a Django Rest Framework backend and return the results to the frontend without storing the results in a database. Currently, I can pass a search a search from the frontend to the backend, but the search results are stored in the database. Here are my Django Model and Views file that show how it is structured: models.py from django.db import models from django.contrib.auth import get_user_model User = get_user_model() class Data(models.Model): created_at = models.DateTimeField(auto_now_add=True) created_by = models.ForeignKey(User, on_delete=models.CASCADE) data_1 = models.TextField(blank=True) data_2 = models.TextField(blank=True) search = models.CharField(max_length=255, default='') views.py from rest_framework import viewsets from apps.data.models import Data from apps.data.serializers import DataSerializer from apps.search.util import scraper class DataViewSet(viewsets.ModelViewSet): serializer_class = DataSerializer queryset = Data.objects.all() def perform_create(self, serializer): print(scraper(self.request.data['search'])) data_1 = scraper(self.request.data['search']) data_2 = scraper(self.request.data['search']) serializer.save(created_by=self.request.user, data_1 = data_1, data_2 = data_2) def get_queryset(self): return self.queryset.filter(created_by=self.request.user) How would I structure this Django backend application to pass a search query through my scraper without storing the result in the database?