Hi, 

Thanks for the help.

The header for each model is # out, so is not read when the code parsed, it is 
just to help me identify the models.
I only have 3 models Project, Category and Expense.

Best wishes,

Kean

On 6 Sep 2019, at 20:04, Bhoopesh sisoudiya <[email protected]> wrote:

> Hi kean,
>     Please check Expenses Class is not Manager
>     Please make Manager Class.
> 
> 
> Thanks
> Bhoopesh sisoudiya
> 
> On Sat, Sep 7, 2019, 12:20 AM Kean <[email protected]> wrote:
> Hi, 
> 
> New to Django. when navigating to the reqired view, I get the error above.
> 
> urls.py
> 
> path('businesslogin/businessadmin/busproject', views.projectdetail, 
> name='projectdetail'),
> 
> views.py
> 
> def projectdetail(request):
>     project = Project.objects.all()
>     return render(request, 'busprojectdetail.html', {'project': project, 
> 'expense_list': project.expenses.all()})
> 
> models.py
> 
> # Project model
> 
> class Project(models.Model):
>     name = models.CharField(max_length=100)
>     budget = IntegerField()
> 
>     def save(self, *args, **kwargs):
>         self.name
>         super(Project, self).save(*args, **kwargs)
> 
> # Category manager model
> 
> 
> class Category(models.Model):
>     project = models.ForeignKey(
>         Project, on_delete=models.CASCADE)
>     name = models.CharField(max_length=150)
> 
> 
> # Expenses manager model
> 
> class Expense(models.Model):
>     project = models.ForeignKey(
>         Project, on_delete=models.CASCADE, related_name='expenses')
>     title = models.CharField(max_length=100)
>     amount = models.DecimalField(max_digits=8, decimal_places=2)
>     category = models.ForeignKey(Category, on_delete=models.CASCADE)
> 
> the error is as follows:
> 
> 
> Exception Type:       AttributeError
> Exception Value:      
> 'QuerySet' object has no attribute 'expenses'
> Exception Location:   
> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
> line 238
> 
> Please can anyone help?
> 
> Best 
> 
> K
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAAk3c1PoGuLeAsnJoEUuB1LdZw8SwpJDFy51%3Di89%2BAv_Zd1sOA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/72107009-5D9C-4EC6-8D4D-233A244E8563%40gmail.com.

Reply via email to