Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Error: Request failed with code 403 in axios post api
I am struggling with this problem for a while. I have a new django-vue project, just created it. When I press a button that makes a api request I get the 403 error and recieve "Forbidden (CSRF cookie not set.):" through console. I made some other little newbie projects and I never pass the CSRF token before in a api post. I think that must be another error but I don't know which one The code is the following: views.py from django.shortcuts import render from django.http import HttpRequest, HttpResponse, JsonResponse, HttpResponseRedirect from django.shortcuts import redirect from django.contrib.auth import authenticate, login from django.contrib.auth.decorators import login_required import requests def discord_login(request): print('Hola, cómo estas') return redirect(auth_url_discord) settings.py from pathlib import Path ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'corsheaders', 'djoser', 'key', 'discordlogin', ] CORS_ALLOWED_ORIGINS = [ 'http://localhost:8080', ] REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', ), } MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'leviathan_django.urls' 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', ], }, }, ] WSGI_APPLICATION = 'leviathan_django.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', … -
How to use regex in django query to get the shortest match?
I have some bunch of entries in a column of a Postgres database that looks like below Abcd/* Abcd/dir1/* Abcd/dir1/dir2/* Abcd/dir1/dir2/dir3/* I am using django ORM to access this information like below given_path = "/some/path" access_obj = Access.objects.get(dir_id=given_path) #dir_id is the column name Now given a path, I need to find the earliest match (any path after * is allowed, hence don't search further) and give the result back. What I mean is say a path is given Abcd/dir1/dir2, since my first entry itself is Abcd/* so I don't need to look any further and return the first row object itself. Currently I try to fetch using __icontains check like below access_obj = Access.objects.get(dir_id__icontains=given_path) But it would return all the matches and then I am unable to figure out how to target the first match (in this case) and query the object. I am aware django supports regex on queries but I am not sure what to apply here. Any help will be appreciated. -
How do delete an object using axios and Django?
I've got a react Frontend, and a Django backend. I am basically trying send some data to the backend in order to filter out the desired object to delete it. However, I am only able to delete an object when both the django method and the axios method are PUT, not DELETE. (authentication disabled) Here is the error I get when I use DELETE instead of PUT: Error (authentication enabled) Here is the error I get when I use DELETE instead of PUT: Error Codes to delete an object here is my backend code: class deleteTrack(APIView): permission_classes = [IsAuthenticated] def delete(self, request): #ONLY WORKS WHEN THIS METHOD IS PUT, AND WHEN THE AXIOS METHOD IS ALSO PUT user = request.user data = request.data track = Track.objects.get(user=user) trackitem = TrackItem.objects.get(track=track,_id=data['trackitem_id']) trackitem.delete() message = {'detail':'Tracked Item successfully deleted'} return Response(message,status=status.HTTP_200_OK) Here is my frontend code: export const deleteTracks = (track) => async(dispatch,getState) => { try{ dispatch({ type:TRACK_DELETE_REQUEST, }) const { userLogin: {userInfo}, } = getState() const config = { headers:{ 'Content-type':'application/json', Authorization:`Bearer ${userInfo.token}` } } const { data } = await axios.delete(`/api/deletetrackitem/`,track,config) dispatch({ type:TRACK_DELETE_SUCCESS, payload:data, }) } catch(error){ dispatch({type:TRACK_DELETE_FAIL, payload:error.response && error.response.data.detail ? error.response.data.detail : error.message, }) } } Example data that … -
django-multiupload | render() got an unexpected keyword argument 'renderer'
I have the error "render() got an unexpected keyword argument 'renderer'" after starting using the django-multiupload. Hope someone can help me, please. Some info about my project: Django Version: | 3.1.7 Python Version: | 3.7.11 My models.py: class Intervention(models.Model): tower = models.ForeignKey('Tower', on_delete=models.DO_NOTHING) .... //got many other attributes class InterventionData(models.Model): interv = models.ForeignKey(Intervention, on_delete=models.CASCADE) files = models.FileField(upload_to="attachments") My forms.py: class InterventionForm(ModelForm): files = MultiFileField(min_num=1, max_num=3, max_file_size=1024*1024*5) class Meta: model = Intervention fields = ('tower',...) //got many other attributes def __init__(self, *args, **kwargs): super(InterventionForm, self).__init__(*args, **kwargs) self.fields['tower'].label = "Tower" .... //got many other attributes def save(self, commit=True): instance = super(InterventionForm, self).save(commit) for each in self.cleaned_data['files']: InterventionData.objects.create(files=each, interv=instance) return instance My views.py: def view_intervention(request, interv_id): try: interv = Intervention.objects.get(pk=interv_id) except Intervention.DoesNotExist: return HttpResponseRedirect(reverse("list_interventions")) if request.method == 'GET': form = InterventionForm(instance=interv) .... elif request.method == 'POST': form = InterventionForm(request.POST, request.FILES, instance=interv) if form.is_valid(): interv = form.save(commit=False) ... form.save() return render(request, 'view_intervention.html', {'form': form, 'interv_id': interv_id, 'interv': interv}) My HTML: <form action="{% url "view_intervention" interv_id %}" method="POST" enctype="multipart/form-data"> {% csrf_token %} .... <div class="form-group"> {{ form.files.errors }} {{ form.files.label_tag }}{% if form.files.field.required %} *{% endif %} {{ form.files }} </div> <input type="submit" value="Send" /> </form> -
Django multi stage form saves all fields except for selection fields
I have a multistage form. All fields save successfully but not select fields. My code related to the select field: Forms.py YEAR = [(r, r) for r in range(datetime.now().year, 1940, -1)] = forms.ChoiceField( label="Year", choices=YEAR, ) view.py @require_http_methods(["POST"]) def step5(request): form = forms.StepFive(request.POST) if form.is_valid(): status = 200 else: status = 400 return render( request, "step5.html", context={ "form": form, }, status=status, ) The html product on the browser <select class="form-control " name="year" id="id_year" aria-describedby="id_year-help" cursorshover="true"> <option value="2021">2021</option> <option value="2020">2020</option> ... etc ... </select> All the fields from the same step get saved except for the select value. I can see the form in the from.cleaned data but it gets reset when I click next. -
Is it safe to add EC2 public IP to ALLOWED_HOSTS in Django + Elastic Beanstalk?
I have deployed a Django app as a single instance Elastic Beanstalk environment without Elastic Load Balancer. The setup is Nginx + Gunicorn + Django. SSL is enabled for Nginx server. I have added the host assigned by elastic beanstalk (....elasticbeanstalk.com) to ALLOWED_HOSTS in the settings file, and the app is accessible. But some operations are failing and there are a lot of Invalid HTTP_HOST_HEADER errors in the log file. The header in majority of these errors are the Public IP of the EC2 instance. Is it safe to add the EC2 Public IP to the allowed hosts ? -
DJANGO | Redirect/Disable URLs based on environment variables
Usecase: I have some features that I don't want to release as of yet so I want to disable certain URLs or redirect them to 404/505s in production environment. Is there a way to accomplish that using just the environment settings instead of popping out routes in urls. -
Changing dropdown selection in django admin
I have a model as: class ProductSubcategory(models.Model): category = models.ForeignKey(ProductCategory, null=True, blank=True, on_delete=models.SET_NULL) sub_category = models.CharField(max_length=50, blank=True, null=True) def __str__(self): return self.sub_category class ProductCategorization(models.Model): product = models.ForeignKey(Product, null=True, blank=True, on_delete=models.SET_NULL) category = models.ForeignKey(ProductCategory, null=True, blank=True, on_delete=models.SET_NULL) subcategory = models.ForeignKey(ProductSubcategory, null=True, blank=True, on_delete=models.SET_NULL) Whenever one selects a category like Bath & Body in the subcategory section one should only see the subcategories of Bath & Body.But now all the subcategories are listed. my admin.py class CategorizationInline(admin.TabularInline): model = ProductCategorization fields = ('category', 'subcategory', 'id') readonly_fields = ('id',) extra = 1 class ProductAdmin(admin.ModelAdmin): inlines = [ CategorizationInline, ] #..some code -
how to copy one table colums to another tables column in Django?
Please tell me ? how to copy data from one table to another table in django? '''f request.method =="POST": agent_ids = request.POST.getlist('id[]') for id in agent_ids: user_del = User.objects.get(id=id) agent_del= AgentDetail.objects.get(u_id=id) # user_del.delete() # agent_del.delete() print("deleted agent Detail") messages.success(request,"Agent Deleted SuccesFully ")''' i want to know to copy these models(User and AgentDetail) data to new model please help me as soon as possible? -
Can I (safely) override Django settings in a server side wsgi.py?
I want to deploy two Django web-apps (individual domains) that share the same source code/repository and, hence, the same settings file. (Hosted on pythonanywhere by the way). The only difference between the two is that they should access different data bases (which I would usually define in settings.py or .env). As I see it, the only file that is unique to each web-app is their individual ...wsgi.py file (the one on the server not the one in the Django project folder). Thus, my idea is to use that file to specify each app's data base settings. Is it possible to (safely) override settings in a wsgi file? How would I do it? The current wsgi.py file looks like this: # +++++++++++ DJANGO +++++++++++ # To use your own django app use code like this: import os import sys # ## assuming your django settings file is at '/home/.../mysite/mysite/settings.py' ## and your manage.py is is at '/home/.../mysite/manage.py' path = '/home/.../...' if path not in sys.path: sys.path.append(path) # os.environ['DJANGO_SETTINGS_MODULE'] = 'core.settings' # ## then: from django.core.wsgi import get_wsgi_application application = get_wsgi_application() Many thanks for your help! -
Django getting value from database using ajax in tab system
I have a tab pane system Monday to Sunday.And the user select any day,then activate_day attribute of User updated.Then I want to get updated request.user.activate_day value from database without refreshing page.I guess ı have to use ajax but I don't know how to handled that.Can anyone help me ? <li class="nav-item" value="Pazartesi"> <a class="nav-link active" onclick="saveDay('Pazartesi');" data-toggle="tab" href="#slot_monday">Pazartesi</a> </li> <li class="nav-item" value="Salı"> <a class="nav-link" onclick="saveDay('Salı');" data-toggle="tab" href="#slot_tuesday">Salı</a> </li> <li class="nav-item" value="Çarşamba"> <a class="nav-link" data-toggle="tab" onclick="saveDay('Çarşamba');" href="#slot_wednesday">Çarşamba</a> </li> <li class="nav-item" value="Perşembe"> <a class="nav-link" onclick="saveDay('Perşembe');" data-toggle="tab" href="#slot_thursday">Perşembe</a> </li> <li class="nav-item" value="Cuma"> <a class="nav-link" onclick="saveDay('Cuma');" data-toggle="tab" href="#slot_friday">Cuma</a> </li> <li class="nav-item" value="Cumartesi"> <a class="nav-link" onclick="saveDay('Cumartesi');" data-toggle="tab" href="#slot_saturday">Cumartesi</a> </li> <li class="nav-item" value="Pazar"> <a class="nav-link" onclick="saveDay('Pazar');" data-toggle="tab" href="#slot_sunday">Pazar</a> </li> </ul> </div> <!-- /Schedule Nav --> saveDay() function(it is working but I don't know how to use returning day) <script> function saveDay(day) { $.get("change_active_day/" + day); } </script> my views.py def change_active_day(request,day): user=get_object_or_404(CustomUserModel,email=request.user.email) user.active_day=day user.save() load_active_day_of(request) data = json.loads(day) return JsonResponse(data=data,safe=False) urls.py path('change_active_day/<str:day>',change_active_day,name="change_active_day"), -
Getting error related to django model arrayfield
When trying to access serialized.data, throws error for type models.ArrayField, but is successfully stored in mongodb. models.py class testStep(models.Model): number = models.PositiveSmallIntegerField(max_length=100) payload = models.JSONField(blank=True) header = models.JSONField(blank=False) assertors = models.EmbeddedField(model_container=assertStep, blank=True) class Meta: abstract = True class test(models.Model): _id = models.ObjectIdField(primary_key=True) appId = models.ForeignKey(application, on_delete=models.PROTECT) name = models.TextField(blank=False, unique=True) step = models.ArrayField(model_container=step, blank=True, default=list) serializers.py class testStepSerializer(serializers.ModelSerializer): class Meta: model = models.testCase fields = '__all__' read_only_fields = ['dateCreated', 'dateUpdated', ] def update(self, instance, validated_data): instance.testStep = validated_data.get('testStep', instance.testStep) instance.save() return instance views.py def put(self, request, testCaseId, format=None): tcDetails = self.getTcDetails(testCaseId) reqData = request.data.copy() if serialized.is_valid(): serialized.save() return Response(json.loads(json_util.dumps(serialized.data)), status=status.HTTP_200_OK) -
Generate shareable link feature in Django?
I have a Django Rest Framework application that is fed in data from a csv. I then use React to create dashboards and Widgets from that data. I want to be able to generate a link to share a read-only version of any dashboard, much like in Google docs etc. I'm not sure how to go about doing that. Any help / pointers would be appreciated. Thank you! -
Why does the Django FileInput widget never render a value? Is it a security risk?
In the source code (link) for Django Widgets it's clear that FileInput does not render a value: # django.forms.fields class FileInput(Input): input_type = 'file' needs_multipart_form = True template_name = 'django/forms/widgets/file.html' def format_value(self, value): """File input never renders a value.""" return This is different to other fields such as CharField which returns an initial string: # django.forms.fields def format_value(self, value): """ Return a value as it should appear when rendered in a template. """ if value == '' or value is None: return None if self.is_localized: return formats.localize_input(value) return str(value) Why is this? It means that if you set a default value in a FileField it is not rendered, which can be confusing for the user. Is it a security concern? The value is stil rendered if the user has previously uploaded a file (I assume via the ModelField not the FormField?), so I don't see the difference? -
Django Form.Errors message is not showing and not printing in console
I am learning django forms right now. I can not see the output of the error in the website as a text message, it only shows as a pop-up message with the default error message even though I set my own error message. Also, my console is not printing anything after if form.is_valid(): This is my views.py file: def forms(request): if request.method == 'POST': form = Forms(request.POST) if form.is_valid(): print("hello") form.save() print(form.cleaned_data) return HttpResponseRedirect('/thank_you') else: form = Forms() return render(request, "form/index.html", { 'form': form }) def thank_you(request): return render(request, 'form/thankyou.html') And here's the html file <html lang='en'> <head> <meta charset="UTF-8"> </head> <body> <form action="/thank-you" method="POST"> {% csrf_token %} {{ form.name.label_tag}} <br> {{form.name}} <br> {{form.name.errors}} <button type="submit">Send</button> </form> -
How to update data in html view in Django?
I am building a photo editor in Django. I have attached the main page code that I have so far: https://jsfiddle.net/xfnLc5to/ I want at updating the brightness scale, the effect to be visible on the photo on the left, even before pressing the submit button. How can I achieve this? So far, I managed to get the brightness value after pressing the submit button, in the views script: brightness_value = request.POST.get('brightness') original_photo = request.POST.get('originalPic') The original_photo variable is still None. How to update the brightness on the photo with the selected brightness value from the slider, before pressing the submit button? -
How to Fix error if I run mange.py run server Django version 1.11
if i want to run my manage.py runserver it generate error File "c:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\admin\widgets.py", line 151 ('%s=%s') % (k, v) for k, v in params.items(), ^ Syntax Error: Generator expression must be parenthesized -
Can't call .delete() on a user account instance in Django
I am trying to set up a simple view to delete user accounts. However, for whatever reason it returns Field 'id' expected a number but got 'deleted_user'. I don't understand what this means and how to solve this. # View def delete_account(request, username): """ Deletes the user account """ user = Account.objects.get(username=username).delete() return redirect('pollboard') # Model class Account(AbstractBaseUser): email = models.EmailField(verbose_name='email', max_length=60, unique=True) username = models.CharField(max_length=40, unique=True) date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=True) email_confirmed = models.BooleanField(default=False) last_login = models.DateTimeField(verbose_name='last login', auto_now=True) is_admin = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) profile_image = models.ImageField(max_length=255, upload_to=get_profile_image_filepath, null=True, blank=True, default=get_default_profile_image()) hide_email = models.BooleanField(default=True) # Model Manager class MyAccountManager(BaseUserManager): def create_user(self, email, username, password=None): if not email: raise ValueError("Users must have an email address") if not username: raise ValueError("Users must have a username") user = self.model( email=self.normalize_email(email), username=username, ) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, username, password): user = self.create_user( email=self.normalize_email(email), username=username, password=password, ) user.is_admin = True user.is_staff = True user.is_superuser = True user.save(using=self._db) return user -
django admin renders links on readonly foreign key to which I don't have permission
I am using the latest django version (3.2.8) and I have the following problem: My user can see model "inspection" via permisson "view_inspection" My user cannot (!) see any foreign keys due to missing permissions The readonly-foreign key is still rendered as a link which leads to a 403 page What I need: Showing just the name of the object and not linking to it. Any ideas how I can fix this? Looks like a bug somehow... Googleing and browsing stack overflow didn't return any solutions. Thx in advance! -
Why I have many numbers after the decimal point with Sum?
I have a problem to recover a sum of float number. I have a Sale object with a total field that is a float. If I do the sum by hand : >>> sales = Sale.objects.all() >>> total = 0 >>> for sale in sales: ... total += sale.total ... >>> print(total) 134479.15 If I use the ORM Sum: >>> Sale.objects.all().aggregate(ca_total=Sum('total'))['ca_total'] 134479.15000000029 -
CSRF verification failed with 403 error when deployed to AWS elastic beanstalk
After creating a Django project in local, where we tested that all the functionality was working as expected, we finally deployed it in Amazon Web Services Beanstalk. But to our dismay, the production app was showing CSRF error which was never seen during the development phase. Here is a sample of the code: models.py class CustomerAccount(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) phone_number = models.CharField(max_length=50,blank=True) first_name = models.CharField(max_length=200, null=True,blank=True) last_name = models.CharField(max_length=200, null=True,blank=True) urls.py urlpatterns = [ path('', views.index, name='customer-index'), ] views.py @login_required(login_url="/login/") def index(request): if request.method == 'POST': form = CustomerForm(request.POST) if form.is_valid(): form.save() return redirect('customers:customer-index') else: form = CustomerForm() context= { 'form': form, } return render(request, 'customers/index.html', context) index.html <div class="col-md-4"> <div class="card p-3 mb-4 mx-2"> <h3 class="text-center">New Customer</h3> <hr> <form method="POST" action="{% url 'customers:customer-index' %}"> {% csrf_token %} {{ form|crispy }} <input class="btn btn-success btn-block" type="submit" value="Add Customer"> </form> </div> </div> Additional details about our configuration: Inside the settings.py, the middleware for CSRF has been added MIDDLEWARE = [ ... 'django.middleware.csrf.CsrfViewMiddleware', ... ] While we did go through some of the solutions that we could find such as adding @csrf_exempt before the views function setting the csrf token age to None added action attribute in the form tag … -
AttributeError when adding an item to a basket
I've been stuck for a while trying to figure why Django throws this AttributeError when attempting to add an item to a basket. The error looks like this: AttributeError: 'Basket' object has no attribute 'save' I've scoured over my code but can't seem to find the issue. I've posted the necessary code below. basket/basket.py: class Basket(): def __init__(self, request): self.session = request.session basket = self.session.get('skey') if 'skey' not in request.session: basket = self.session['skey'] = {} self.basket = basket def add(self, product, qty): """ Adding and updating the users basket session data """ product_id = str(product.id) if product_id in self.basket: self.basket[product_id]['qty'] = qty else: self.basket[product_id] = {'price': str(product.price), 'qty': qty} self.save() def __iter__(self): """ Collect the product_id in the session data to query the database and return products """ product_ids = self.basket.keys() products = Product.products.filter(id__in=product_ids) basket = self.basket.copy() for product in products: basket[str(product.id)]['product'] = product for item in basket.values(): item['price'] = Decimal(item['price']) item['total_price'] = item['price'] * item['qty'] yield item def __len__(self): """ Get the basket data and count the qty of items """ return sum(item['qty'] for item in self.basket.values()) basket/views.py: def basket_summary(request): basket = Basket(request) return render(request, 'main_store/basket/summary.html', {'basket': basket}) def basket_add(request): basket = Basket(request) if request.POST.get('action') == 'post': product_id = … -
Django ManyToMany (m2m) relationship in result table
Hej! I'm having trouble showing the M2M relationships in my rendered result table in Django. I know that I have to follow through the models to get there but something is not working. Does anyone have an idea what I'm doing wrong? # plants/models.py class Plant(models.Model): name = models.CharField( max_length=200 ) plant_type = models.ForeignKey( PlantType, on_delete=models.SET_NULL, blank=True, null=True, related_name="plant_type", ) used_xducts = models.ManyToManyField( Xduct, through="UsedXduct", blank=True, related_name="used_in_plant" ) class PlantType(models.Model): name_english = models.CharField( max_length=200, blank=True ) class UsedXduct(models.Model): class InputOrOutputChoices(models.TextChoices): IN = "in", _("input") OUT = "out", _("output") OWN = "own", _("own technical need") plant = models.ForeignKey( Plant, on_delete=models.PROTECT ) xduct = models.ForeignKey( Xduct, on_delete=models.PROTECT ) def xduct_str(self): return self.xduct def __str__(self): return f"Used xduct of {self.plant} of {self.xduct}" xducts/models.py class Xduct(models.Model): """(temporary) List of all xducts""" code = models.CharField( max_length=20, unique=True ) name_english = models.CharField( max_length=200, unique=True ) def __str__(self): return f"{self.code}" # plants/template.html {% block content %} <div class="row"> <div class="col-md"> <div class="card card-body"> <h5>Plants</h5> </div> <div class="card card-body"> <table class="table table-sm"> <tr> <th>Name</th> <th>Plant type</th> <th>Used Xducts</th> </tr> {% for i in plants %} <tr> <td>{{i.name}}</td> <td>{{i.plant_type}}</td> <td>{{i.used_in_plant.xduct}}</td> </tr> {% endfor %} </table> </div> </div> {% endblock %} 'name' and 'plant_type' are no problem in this example. … -
How to port a Django web app in mobile (iOS & Android)
We have a working WebApp developed with Django, Python and Vue.Js. The application is working ok when it is opened in Mobile devices but we need to do lot of tweaking UI to make it compatible to mobile devices everytime. So we are looking for a way to create a mobile app and also need to update the data irrespective of device that users use. Please let us know whether this can be achievable? Best regards, ~Alam -
Map Flask API and Django app to same database but different tables
I have a database model which is written in Django ORM and the same database is used by Flask using SQLAlchemy for another microservice (where I need only 2/3 new and 1 exiting table) to store and query some data. So when from my Flask API, I run this command- $ flask db migrate $ flask db upgrade I can see that from migrations/versions, it is trying to delete existing tables of my Django app which I don't want to do. So my question is how to run/use Flask SQLAlchemy ORM without touching existing tables of Django app? Also From my Flask app, I want to refer to some of the existing tables of the Django app but am not sure how to do those without creating models on the Flask app because those models are already created by Django APP. N.B For a particular reason I don't want to separate the Flask API to another database