We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am using in django the following models.py:
class Expense(models.Model): name = models.CharField(max_length=50) date = models.DateField(unique=False, blank=False) slug = models.SlugField(unique=True, null=True, default='') price = models.DecimalField(default=0.0, blank=True, max_digits = 20, decimal_places = 2) category = models.ForeignKey( 'Category', related_name="Expense", on_delete=models.CASCADE ) account = models.ForeignKey(Account, on_delete=models.CASCADE, verbose_name=u"Account", help_text=u"account") def __str__(self): return '{},{},{}'.format(self.name, self.date, self.price) def save(self, *args, **kwargs): self.slug = slugify(self.name) super(Expense,self).save(*args, **kwargs) def get_absolute_url(self): return self.slug class Category(MPTTModel): name = models.CharField(max_length=200) slug = models.SlugField(unique=True, null=True, default='') parent = TreeForeignKey( 'self', blank=True, null=True, related_name='child', on_delete=models.CASCADE ) class Meta: unique_together = ('slug', 'parent',) verbose_name_plural = "categories" def __str__(self): full_path = [self.name] k = self.parent while k is not None: full_path.append(k.name) k = k.parent return ' -> '.join(full_path[::-1])
The TreeForeignKey allows me to define nested categories, such as Home -> Electricity and so on. I am using the following Slick Report view.py:
class TotalExpenses(SlickReportView): report_model = Expense date_field = 'date' group_by = 'category' columns = ['name', SlickReportField.create(method=Sum, field='price', name='price__sum', verbose_name=('Total category $'))] charts_settings = [ { 'type': 'bar', 'data_source': 'price__sum', 'title_source': 'name', }, ]
It works but I would like to sum only level 1 categories. Do you know how this might be possible?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am using in django the following models.py:
The TreeForeignKey allows me to define nested categories, such as Home -> Electricity and so on.
I am using the following Slick Report view.py:
It works but I would like to sum only level 1 categories. Do you know how this might be possible?
The text was updated successfully, but these errors were encountered: