J
J
Jack4442020-04-28 16:45:42
Django
Jack444, 2020-04-28 16:45:42

How to make django queryset global?

In general, I have such a problem:

5ea82bd6bcdc2616531150.png
If I go to the console, then Bb.objects works without any complaints. If I declare the .objects class outside the console, in the controller, for example, then the python does not understand what I require from it, it thinks that I refer to a specific objects field and gives an error like there is no such field. The Pycharm IDE also suggests creating an object field in the Bb class. I think you need to add django or somehow highlight the queryset in the PATH variable for Windows, so that you can call it from anywhere.
I tried through conda and through the virtual environment all the same.

Please advise how to solve

Python 3.7
Django 3
Window 10 problem

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2020-04-28
@sergey-gornostaev

5e1ff0ac066b9696317852.jpeg

S
Sanya Hihi Haha, 2020-04-28
@ValarMayar

And what is it for? output in a template? - context_processors
Call in other views? - I would use cbv's and write a mixin, and call it where necessary at the right time (not the fact that I'm doing it right, but it works). It is possible to describe this logic in the model, so it’s probably much more correct

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question