Reset to default
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
For future readers, this can also happen if you name a python file the same name as a dependency your project uses.
I cannot have a file named retrying.py that is using the retrying package.
Assuming I had the retrying package in my project, I could not have a file called retrying.py with the below contents:
from retrying import retry print("HI")
A similar error with the message “most likely due to a circular import” would occur.
The same contents would work fine if I renamed the file to “retrying_example1.py”
You have a circular import.
corporate/models, which imports
You can’t do that.
When importing code from other files, it helps if you spell out the entire subpackage where the thing you want to import comes from. Let’s say you have the following file structure:
mypackage/ subpackage/ __init__.py helper.py main/ work.py
__init__.pyimports things from
helper.py(for the end-user to conveniently access)
- and you’re working inside
- and you need something from
Then rather than doing:
from ..subpackage import thing_i_need
You should instead do:
from ..subpackage.helper import thing_i_need
For reasonable code, this should help you avoid some of the circular dependency problems, as now you’re no longer relying on
__init__.py to fully finish.
In my case the problem was that I defined the function in the x.py file and in the x.py file I import models from the modals.py file and in the modals.py file I tried to import this function I was trying to set the default value after querying the tables with this function
I received this error when I tried to do a relative import. I had two models files:
class BaseModel(models.Model): ...
from .models import BaseModel ...
The problem was fixed when, in
main.models, I changed it to:
from utils.models import BaseModel