Extracting a list from database

Hi, I’m new on django and I’m using it for a school project.
I need help , i started to create a site with django and i’m actually working on the database .
I’ve created models with my database table and now i have a problem . I want to extract a list with a specific data from the database to create a fonction using them but i don’t know how ,is there a shell request to do or something ?

I think we’re going to need to see a bit more detail about what you’re trying to do. It would be helpful if you posted your model along with the details of the function you’re trying to create.

When you post code, please insert it between lines containing only 3 backticks - ```. (Make sure you use the backtick - ` and not the apostrophe - '.) That means you would have one line with the 3 backticks, your code, and then one more line with just the 3 backticks. That allows this forum software to format your code nicely:

# The line above this is just ```
def function(parm):
    return parm
# The line after this is just ```

Hi Ken this is my program but my problem is that i need to extract 2 list from database table created in model i let you a screenshot : in Stock i need to extract a list from “Nom_Aliment” and from “Present” to use them after in my fonction and where do i have to write my fonction in pycharm on model.py folder or in views ? The fact is that the first list is for eatable products name and the second one to see if they are present or no in a fridge then my fonction create a new list with products we have to buy but i don’t have the data it’s in database. Thanks for your help

List i need to extract from database to use them in my fonction


def lister(L1,L2):
    for i in range(n):
        if L2[i]==0:
    return Liste


I’m going to recommend that you take a step back from what you’re doing right now, and work through either the official Django Tutorial or the Django Girls Tutorial , or both. Both are really good. and if you work through at least one of them, you’ll have a better understanding of how the different pieces of Django all fit together. These questions indicate to me that you would be best served by gaining more knowledge of the fundamentals and the structure of a Django application.

i forget to give the screenshot i wanna extract data from those models

i have never seen a tuto talking about extracting a list from my database in model to use it in a fonction it’s use an orm to do database so i don’t know how to do

So the issue here is more fundamental. What you’re asking and the way you’re phrasing your questions is an indication to me that you’re not really familiar yet with how Django works with the database and the nature of the data within your tables. That is the knowledge that the tutorials would provide. You’re going to save yourself a lot of frustration by working through one of them before trying to proceed with this task.

Hi ken im actually doing a tuto but i have a problem i can’t access to the the admin page when i start the server and i go to i need to see a login page but i have an error . I show you the error i get thanks for help

I want to acknowledge your reply. I have read it, but my advice doesn’t change.