I’ve a field in my model called, test_data = models.TextField(…), and the model is called MyOrm and this test_data contains data which is actually string, some holds JSON data, and some reference to blob-url. Now I’m trying to streamline my data. So I want to filter all the MyOrm object whos…
Tag: django-models
Django dev server no longer reloads on save
I’m developing a simple Django app and things were going great until suddenly the dev server stopped reloading automatically on file change. Now I have to manually restart the server every time I change some Python file, which is pretty annoying. I’ve tried removing my virtual environment and rein…
Django – store.models.Customer.MultipleObjectsReturned: get() returned more than one Customer — it returned 2″
I am trying to make an e-commerce website where “AnonymousUser” or Guest user can order and check out products by providing their name, email, and address. But after clicking the “Make Payment” button, my terminal was having an error that says “store.models.Customer.MultipleObjec…
Django Model method that uses data from the model
I want to generate unique codes (e.g. “DXGH”) and save it as a field in one of my models. The problem I have is that I do not know how to check against previously generated codes whenever a new object is created. Currently my models.py looks something like this: Ideally I would set the default val…
‘QuerySet’ object has no attribute ‘x’
I want to go to a users page and see the their photos, so I was trying to get the objects assigned to a foreign key, but I keep getting the error above AttributeError at /user/30/ ‘QuerySet’ object has no attribute ‘file’. I feel like the problem is in my syntax, but I really have no c…
Extracting data from Django Queryset and inserting into a Python list
I am trying to get one column of data from a Django model into a python list for further processing the in Django view. I have successfully created a simple Django model and populated the data. The fields are: “id”, “x_coord”, “y_coord”. I have run a few commands to extract…
Associating user id to courses that the user create
My django project basically allows users to create its own courses. So, I am trying to associate a user id to the courses that the user created so that it will display only the courses that the user has created when the user wanted to view all the courses that he/she has created. However, it returns an error …
Django: Initialize a container model with child models when a new container is created – e.g. Todo list with default tasks
I’m trying to create a todo list as part of an application that is used to prompt a user what they must complete before the application is assessed. To achieve this I have created a TaskList model and a Task model belonging to a TaskList. When I create a new TaskList instance (on a new application) I wa…
I have updated my code– I want to pass an object in “for loop” with employee_id and his specific donation amount, How can I do this?
I am working on a donation app. In this app, There was a feature that sends an equal amount of donation money to every employee of the organization now they want to change this feature by sending a customized amount of donation to all or some of the employees. I have worked on it: Now I am using a for
add a single data to serializer in django
I’m writing an API where the user’s followers are listed.I also want to send the total number of followers in this API.But the totalFollower field keeps repeating.I only want it sent once. Like that: MY serializer Answer You have a couple of options: Use a DRF paginator on your view, which will gi…