0
def show_scoring_average(self):
from .Rating import Rating # Gostaria de entender esta linha
try:
ratings = Rating.objects.filter(user_rated = self.user).aggregate(Sum('value'), Count('user'))
if ratings['user__count'] > 0 :
scoring_average = ratings['value__sum'] / ratings ['user__count']
scoring_average = round(scoring_average,2)
return scoring_average
return 'Sem avaliações'
except:
return 'Sem Avaliações'
**from .Rating import Rating**
is written anyway or Voce added the*
?– Cmte Cardeal
I added the **
– Felipe Lamarao
You are importing a module called Rating and inside delete taking the Rating. So in the same folder of this script you probably have a file
Rating.py
and inside it seems to have a class (model Django think) with the nameRating
(something likeclass Rating
).– wallacesilva09
within this function called show_scoring_average(self): there is an import that could be outside it... this import is from a model... a model matching the database assignments... and a filter that selects a particular item
– stack.cardoso