Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-07 Thread Kean
Hi,

removing did, not work, still getting same error.
Welcome any other help from the wider community in reference to this issue.
best,

Kean

On 6 Sep 2019, at 22:26, Bhoopesh sisoudiya  wrote:

> Try after removing related_name='expenses' from Expenses model.
> 
> On Sat, Sep 7, 2019, 2:28 AM Kean  wrote:
> Hi Bhoopesh,
> 
> If this is a simple issue to resolve, please provide code which works.
> Reading an abstract reference, is welcome, but is not really helping to solve 
> as one can always reference a source. 
> 
> Please advise solution that works, and then reference a learning resource, so 
> user knows where to go for learning, but with solution in hand.
> 
> Best,
> 
> Kean
> 
> On 6 Sep 2019, at 21:54, Bhoopesh sisoudiya  wrote:
> 
>> https://stackoverflow.com/questions/31237042/whats-the-difference-between-select-related-and-prefetch-related-in-django-orm
>> 
>> 
>> On Sat, Sep 7, 2019, 2:20 AM Kean  wrote:
>> Don’t understand?
>> 
>> On 6 Sep 2019, at 21:41, Bhoopesh sisoudiya  wrote:
>> 
>>> 'project' inside select_related() is foreign key in Expenses modal of 
>>> Project modal.
>>> 
>>> On Sat, Sep 7, 2019, 2:07 AM Kean  wrote:
>>> Ok,
>>> 
>>> Updated to below, and am still getting the same error:
>>> 
>>> def projectdetail(request):
>>> projectList = Project.objects.all()
>>> projectExpenseDetails = Expense.objects.select_related('project').all()
>>> return render(request, 'busprojectdetail.html', {'project': project, 
>>> 'expense_list': projectExpenseDetails})
>>> 
>>> Exception Type: NameError
>>> Exception Value:
>>> name 'project' is not defined
>>> Exception Location: 
>>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
>>> line 239
>>> Best,
>>> Kean
>>> 
>>> 
>>> On 6 Sep 2019, at 21:32, Bhoopesh sisoudiya  wrote:
>>> 
 Sorry my mistake
 
 
 def projectdetail(request):
 projectList = Project.objects.all()
 projectExpenseDetails = Expense.objects.select_related('project').all()
 return render(request, 'busprojectdetail.html', {'project': 
 projectList, 'expense_list': projectExpenseDetails})
 
 
 On Sat, Sep 7, 2019, 1:55 AM Kean  wrote:
 Hi Ok,
 
 I updated as advised.
 
 views.py
 
 def projectdetail(request):
 projectExpenseDetails = Expense.objects.select_related('project').all()
 return render(request, 'busprojectdetail.html', {'project': project, 
 'expense_list': projectExpenseDetails})
 
 I get new error
 Exception Type:NameError
 Exception Value:   
 name 'project' is not defined
 Exception Location:
 /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in 
 projectdetail, line 238
 
 
 Please advise?
 
 Best,
 
 Kean
 On 6 Sep 2019, at 21:19, Bhoopesh sisoudiya  wrote:
 
> projectExpnseDetails
 
>>> 
>> 
> 

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/43C89EFD-1D4C-4B03-962E-898124A8D96D%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Ok,

Updated to below, and am still getting the same error:

def projectdetail(request):
projectList = Project.objects.all()
projectExpenseDetails = Expense.objects.select_related('project').all()
return render(request, 'busprojectdetail.html', {'project': project, 
'expense_list': projectExpenseDetails})

Exception Type: NameError
Exception Value:
name 'project' is not defined
Exception Location: 
/Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
line 239
Best,
Kean


On 6 Sep 2019, at 21:32, Bhoopesh sisoudiya  wrote:

> Sorry my mistake
> 
> 
> def projectdetail(request):
> projectList = Project.objects.all()
> projectExpenseDetails = Expense.objects.select_related('project').all()
> return render(request, 'busprojectdetail.html', {'project': projectList, 
> 'expense_list': projectExpenseDetails})
> 
> 
> On Sat, Sep 7, 2019, 1:55 AM Kean  wrote:
> Hi Ok,
> 
> I updated as advised.
> 
> views.py
> 
> def projectdetail(request):
> projectExpenseDetails = Expense.objects.select_related('project').all()
> return render(request, 'busprojectdetail.html', {'project': project, 
> 'expense_list': projectExpenseDetails})
> 
> I get new error
> Exception Type:   NameError
> Exception Value:  
> name 'project' is not defined
> Exception Location:   
> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
> line 238
> 
> 
> Please advise?
> 
> Best,
> 
> Kean
> On 6 Sep 2019, at 21:19, Bhoopesh sisoudiya  wrote:
> 
>> projectExpnseDetails
> 

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20716649-508A-4E8C-8134-8DD8EECADF7C%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Hi Ok,

I updated as advised.

views.py

def projectdetail(request):
projectExpenseDetails = Expense.objects.select_related('project').all()
return render(request, 'busprojectdetail.html', {'project': project, 
'expense_list': projectExpenseDetails})

I get new error
Exception Type: NameError
Exception Value:
name 'project' is not defined
Exception Location: 
/Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
line 238


Please advise?

Best,

Kean
On 6 Sep 2019, at 21:19, Bhoopesh sisoudiya  wrote:

> projectExpnseDetails

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/86E3CF35-2148-4C36-A503-5413BE568F95%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
def projectdetail(request):
projectExpnseDetails = Expense.objects.select_related('project').all()
return render(request, 'busprojectdetail.html', {'project': project,
'expense_list':projectExpnseDetails })


On Sat, Sep 7, 2019, 1:43 AM Bhoopesh sisoudiya 
wrote:

> Write this
>
> Expense.objects.select_related('project').all()
>
>
>
> On Sat, Sep 7, 2019, 1:37 AM Kean  wrote:
>
>> Thanks,
>>
>> I updated the view, and now I am getting syntax error.
>> Please see below.
>>
>> views.py
>>
>> def projectdetail(request):
>> project = Project.objects.all()
>> return render(request, 'busprojectdetail.html', {'project': project,
>> 'expense_list': project.expenses.all()})
>>
>> projectDetails =
>> Project.objects.select_related(Project).values(select column).all()
>>
>> please advise how to correct?
>>
>> Best,
>>
>> Kean
>>
>> On 6 Sep 2019, at 21:01, Bhoopesh sisoudiya  wrote:
>>
>> def projectdetail(request):
>> project = Project.objects.all()
>> return render(request, 'busprojectdetail.html', {'project': project,
>> 'expense_list': project.expenses.all()})
>>
>> According to me by this archive you want expense details of each project
>>
>> Then you write
>>
>> projectDetails = Project.objects.select_related(your foreign key).values
>> (select column).all()
>>
>> Thanks
>> Bhoopesh sisoudiya
>>
>>
>> On Sat, Sep 7, 2019, 1:22 AM Kean  wrote:
>>
>>> Hi,
>>>
>>> please ignore the manager it is just a naming convention ignore, it if
>>> for me to identify tables, if i have 50 table, I want to be able to know
>>> which model is holding which object information and for what I need it.
>>>
>>> Please use below, I have removed the # information to reduce confusion.
>>>
>>> models.py
>>>
>>> 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)
>>>
>>> class Category(models.Model):
>>> project = models.ForeignKey(
>>> Project, on_delete=models.CASCADE)
>>> name = models.CharField(max_length=150)
>>>
>>> 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)
>>> On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya 
>>> wrote:
>>>
>>> Best wishes,
>>> Kean
>>>
>>> Ok No problem but
>>> why you want Manager?
>>>
>>> Please send me answer
>>>
>>> Thanks
>>> Bhoopesh sisoudiya
>>>
>>> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>>>
 Hi Bhoopesh
 Thanks for this, please can you put it into the context of my specific
 model setup, so I get it right and understand.
 This will be easier for me as this approach is causing me some other
 errors, when i try to apply it.

 Best wishes,

 Kean
 On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya 
 wrote:

 Hi Kean,

  Write manager like this ,I give you reference

 from django.db import models
  # First, define the Manager subclass.
 class BhoopeshBookManager(models.Manager):
def get_queryset(self):
 return super(BhoopeshBookManager,
 self).get_queryset().filter(author='Bhoopesh')

 # Then hook it into the Book model explicitly. class
 Book(models.Model):
 title = models.CharField(max_length=100)
 author = models.CharField(max_length=50)
  # ...
 objects = models.Manager()
  # The default manager.

 bhoopesh_objects = BhoopeshBookManager()
  # The Bhoopesh-specific manager.


 Book.bhoopesh_objects.all() # use manager


 Thanks
 Bhoopesh Kumar


 On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
 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  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 manag

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
This is still not working,
please can you provide full code, this way it is complete and accurate, and not 
me guessing?

Best,
Kean

On 6 Sep 2019, at 21:13, Bhoopesh sisoudiya  wrote:

> Write this
> 
> Expense.objects.select_related('project').all()
> 
> 
> 
> On Sat, Sep 7, 2019, 1:37 AM Kean  wrote:
> Thanks,
> 
> I updated the view, and now I am getting syntax error.
> Please see below.
> 
> views.py
> 
> def projectdetail(request):
> project = Project.objects.all()
> return render(request, 'busprojectdetail.html', {'project': project, 
> 'expense_list': project.expenses.all()})
> 
> projectDetails = Project.objects.select_related(Project).values(select 
> column).all()
> 
> please advise how to correct?
> 
> Best,
> 
> Kean
> 
> On 6 Sep 2019, at 21:01, Bhoopesh sisoudiya  wrote:
> 
>> def projectdetail(request):
>> project = Project.objects.all()
>> return render(request, 'busprojectdetail.html', {'project': project, 
>> 'expense_list': project.expenses.all()})
>> 
>> According to me by this archive you want expense details of each project
>> 
>> Then you write
>> 
>> projectDetails = Project.objects.select_related(your foreign key).values 
>> (select column).all()
>> 
>> Thanks
>> Bhoopesh sisoudiya
>> 
>> 
>> On Sat, Sep 7, 2019, 1:22 AM Kean  wrote:
>> Hi,
>> 
>> please ignore the manager it is just a naming convention ignore, it if for 
>> me to identify tables, if i have 50 table, I want to be able to know which 
>> model is holding which object information and for what I need it.
>> 
>> Please use below, I have removed the # information to reduce confusion.
>> 
>> models.py
>> 
>> 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)
>> 
>> class Category(models.Model):
>> project = models.ForeignKey(
>> Project, on_delete=models.CASCADE)
>> name = models.CharField(max_length=150)
>> 
>> 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)
>> On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya  wrote:
>> 
>> Best wishes,
>> Kean
>> 
>>> Ok No problem but 
>>> why you want Manager?
>>> 
>>> Please send me answer
>>> 
>>> Thanks
>>> Bhoopesh sisoudiya
>>> 
>>> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>>> Hi Bhoopesh
>>> Thanks for this, please can you put it into the context of my specific 
>>> model setup, so I get it right and understand.
>>> This will be easier for me as this approach is causing me some other 
>>> errors, when i try to apply it.
>>> 
>>> Best wishes, 
>>> 
>>> Kean 
>>> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>>> 
 Hi Kean,
 
  Write manager like this ,I give you reference
 
 from django.db import models
  # First, define the Manager subclass. 
 class BhoopeshBookManager(models.Manager):
def get_queryset(self): 
 return super(BhoopeshBookManager, 
 self).get_queryset().filter(author='Bhoopesh') 
 
 # Then hook it into the Book model explicitly. class Book(models.Model): 
 title = models.CharField(max_length=100) 
 author = models.CharField(max_length=50)
  # ... 
 objects = models.Manager()
  # The default manager. 
 
 bhoopesh_objects = BhoopeshBookManager()
  # The Bhoopesh-specific manager.
 
 
 Book.bhoopesh_objects.all() # use manager
 
 
 Thanks 
 Bhoopesh Kumar
 
 
 On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya  
 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  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_len

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Write this

Expense.objects.select_related('project').all()



On Sat, Sep 7, 2019, 1:37 AM Kean  wrote:

> Thanks,
>
> I updated the view, and now I am getting syntax error.
> Please see below.
>
> views.py
>
> def projectdetail(request):
> project = Project.objects.all()
> return render(request, 'busprojectdetail.html', {'project': project,
> 'expense_list': project.expenses.all()})
>
> projectDetails = Project.objects.select_related(Project).values(select
> column).all()
>
> please advise how to correct?
>
> Best,
>
> Kean
>
> On 6 Sep 2019, at 21:01, Bhoopesh sisoudiya  wrote:
>
> def projectdetail(request):
> project = Project.objects.all()
> return render(request, 'busprojectdetail.html', {'project': project,
> 'expense_list': project.expenses.all()})
>
> According to me by this archive you want expense details of each project
>
> Then you write
>
> projectDetails = Project.objects.select_related(your foreign key).values
> (select column).all()
>
> Thanks
> Bhoopesh sisoudiya
>
>
> On Sat, Sep 7, 2019, 1:22 AM Kean  wrote:
>
>> Hi,
>>
>> please ignore the manager it is just a naming convention ignore, it if
>> for me to identify tables, if i have 50 table, I want to be able to know
>> which model is holding which object information and for what I need it.
>>
>> Please use below, I have removed the # information to reduce confusion.
>>
>> models.py
>>
>> 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)
>>
>> class Category(models.Model):
>> project = models.ForeignKey(
>> Project, on_delete=models.CASCADE)
>> name = models.CharField(max_length=150)
>>
>> 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)
>> On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya  wrote:
>>
>> Best wishes,
>> Kean
>>
>> Ok No problem but
>> why you want Manager?
>>
>> Please send me answer
>>
>> Thanks
>> Bhoopesh sisoudiya
>>
>> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>>
>>> Hi Bhoopesh
>>> Thanks for this, please can you put it into the context of my specific
>>> model setup, so I get it right and understand.
>>> This will be easier for me as this approach is causing me some other
>>> errors, when i try to apply it.
>>>
>>> Best wishes,
>>>
>>> Kean
>>> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya 
>>> wrote:
>>>
>>> Hi Kean,
>>>
>>>  Write manager like this ,I give you reference
>>>
>>> from django.db import models
>>>  # First, define the Manager subclass.
>>> class BhoopeshBookManager(models.Manager):
>>>def get_queryset(self):
>>> return super(BhoopeshBookManager,
>>> self).get_queryset().filter(author='Bhoopesh')
>>>
>>> # Then hook it into the Book model explicitly. class Book(models.Model):
>>> title = models.CharField(max_length=100)
>>> author = models.CharField(max_length=50)
>>>  # ...
>>> objects = models.Manager()
>>>  # The default manager.
>>>
>>> bhoopesh_objects = BhoopeshBookManager()
>>>  # The Bhoopesh-specific manager.
>>>
>>>
>>> Book.bhoopesh_objects.all() # use manager
>>>
>>>
>>> Thanks
>>> Bhoopesh Kumar
>>>
>>>
>>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
>>> 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  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 = m

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Thanks,

I updated the view, and now I am getting syntax error.
Please see below.

views.py

def projectdetail(request):
project = Project.objects.all()
return render(request, 'busprojectdetail.html', {'project': project, 
'expense_list': project.expenses.all()})

projectDetails = Project.objects.select_related(Project).values(select 
column).all()

please advise how to correct?

Best,

Kean

On 6 Sep 2019, at 21:01, Bhoopesh sisoudiya  wrote:

> def projectdetail(request):
> project = Project.objects.all()
> return render(request, 'busprojectdetail.html', {'project': project, 
> 'expense_list': project.expenses.all()})
> 
> According to me by this archive you want expense details of each project
> 
> Then you write
> 
> projectDetails = Project.objects.select_related(your foreign key).values 
> (select column).all()
> 
> Thanks
> Bhoopesh sisoudiya
> 
> 
> On Sat, Sep 7, 2019, 1:22 AM Kean  wrote:
> Hi,
> 
> please ignore the manager it is just a naming convention ignore, it if for me 
> to identify tables, if i have 50 table, I want to be able to know which model 
> is holding which object information and for what I need it.
> 
> Please use below, I have removed the # information to reduce confusion.
> 
> models.py
> 
> 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)
> 
> class Category(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
> 
> 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)
> On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya  wrote:
> 
> Best wishes,
> Kean
> 
>> Ok No problem but 
>> why you want Manager?
>> 
>> Please send me answer
>> 
>> Thanks
>> Bhoopesh sisoudiya
>> 
>> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>> Hi Bhoopesh
>> Thanks for this, please can you put it into the context of my specific model 
>> setup, so I get it right and understand.
>> This will be easier for me as this approach is causing me some other errors, 
>> when i try to apply it.
>> 
>> Best wishes, 
>> 
>> Kean 
>> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>> 
>>> Hi Kean,
>>> 
>>>  Write manager like this ,I give you reference
>>> 
>>> from django.db import models
>>>  # First, define the Manager subclass. 
>>> class BhoopeshBookManager(models.Manager):
>>>def get_queryset(self): 
>>> return super(BhoopeshBookManager, 
>>> self).get_queryset().filter(author='Bhoopesh') 
>>> 
>>> # Then hook it into the Book model explicitly. class Book(models.Model): 
>>> title = models.CharField(max_length=100) 
>>> author = models.CharField(max_length=50)
>>>  # ... 
>>> objects = models.Manager()
>>>  # The default manager. 
>>> 
>>> bhoopesh_objects = BhoopeshBookManager()
>>>  # The Bhoopesh-specific manager.
>>> 
>>> 
>>> Book.bhoopesh_objects.all() # use manager
>>> 
>>> 
>>> Thanks 
>>> Bhoopesh Kumar
>>> 
>>> 
>>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya  
>>> 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  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:
>>> 

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
def projectdetail(request):
project = Project.objects.all()
return render(request, 'busprojectdetail.html', {'project': project,
'expense_list': project.expenses.all()})

According to me by this archive you want expense details of each project

Then you write

projectDetails = Project.objects.select_related(your foreign key).values
(select column).all()

Thanks
Bhoopesh sisoudiya


On Sat, Sep 7, 2019, 1:22 AM Kean  wrote:

> Hi,
>
> please ignore the manager it is just a naming convention ignore, it if for
> me to identify tables, if i have 50 table, I want to be able to know which
> model is holding which object information and for what I need it.
>
> Please use below, I have removed the # information to reduce confusion.
>
> models.py
>
> 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)
>
> class Category(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
>
> 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)
> On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya  wrote:
>
> Best wishes,
> Kean
>
> Ok No problem but
> why you want Manager?
>
> Please send me answer
>
> Thanks
> Bhoopesh sisoudiya
>
> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>
>> Hi Bhoopesh
>> Thanks for this, please can you put it into the context of my specific
>> model setup, so I get it right and understand.
>> This will be easier for me as this approach is causing me some other
>> errors, when i try to apply it.
>>
>> Best wishes,
>>
>> Kean
>> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>>
>> Hi Kean,
>>
>>  Write manager like this ,I give you reference
>>
>> from django.db import models
>>  # First, define the Manager subclass.
>> class BhoopeshBookManager(models.Manager):
>>def get_queryset(self):
>> return super(BhoopeshBookManager,
>> self).get_queryset().filter(author='Bhoopesh')
>>
>> # Then hook it into the Book model explicitly. class Book(models.Model):
>> title = models.CharField(max_length=100)
>> author = models.CharField(max_length=50)
>>  # ...
>> objects = models.Manager()
>>  # The default manager.
>>
>> bhoopesh_objects = BhoopeshBookManager()
>>  # The Bhoopesh-specific manager.
>>
>>
>> Book.bhoopesh_objects.all() # use manager
>>
>>
>> Thanks
>> Bhoopesh Kumar
>>
>>
>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
>> 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  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 django-users+unsubscr...@googlegroups.com.
 To view this discussion on the web visit

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Hi,

please ignore the manager it is just a naming convention ignore, it if for me 
to identify tables, if i have 50 table, I want to be able to know which model 
is holding which object information and for what I need it.

Please use below, I have removed the # information to reduce confusion.

models.py

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)

class Category(models.Model):
project = models.ForeignKey(
Project, on_delete=models.CASCADE)
name = models.CharField(max_length=150)

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)
On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya  wrote:

Best wishes,
Kean

> Ok No problem but 
> why you want Manager?
> 
> Please send me answer
> 
> Thanks
> Bhoopesh sisoudiya
> 
> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
> Hi Bhoopesh
> Thanks for this, please can you put it into the context of my specific model 
> setup, so I get it right and understand.
> This will be easier for me as this approach is causing me some other errors, 
> when i try to apply it.
> 
> Best wishes, 
> 
> Kean 
> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
> 
>> Hi Kean,
>> 
>>  Write manager like this ,I give you reference
>> 
>> from django.db import models
>>  # First, define the Manager subclass. 
>> class BhoopeshBookManager(models.Manager):
>>def get_queryset(self): 
>> return super(BhoopeshBookManager, 
>> self).get_queryset().filter(author='Bhoopesh') 
>> 
>> # Then hook it into the Book model explicitly. class Book(models.Model): 
>> title = models.CharField(max_length=100) 
>> author = models.CharField(max_length=50)
>>  # ... 
>> objects = models.Manager()
>>  # The default manager. 
>> 
>> bhoopesh_objects = BhoopeshBookManager()
>>  # The Bhoopesh-specific manager.
>> 
>> 
>> Book.bhoopesh_objects.all() # use manager
>> 
>> 
>> Thanks 
>> Bhoopesh Kumar
>> 
>> 
>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya  
>> 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  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 django-users+unsubscr...@googlegroups.com.
>> 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 django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.com.
> 
> 
> -- 
> You received this message because you are subscribed to the Goo

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Hi kean,

Category and Expense is not Manager model this is only model class.

Thanks
Bhoopesh Kumar



On Sat, Sep 7, 2019, 1:15 AM Bhoopesh sisoudiya 
wrote:

> Ok No problem but
> why you want Manager?
>
> Please send me answer
>
> Thanks
> Bhoopesh sisoudiya
>
> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>
>> Hi Bhoopesh
>> Thanks for this, please can you put it into the context of my specific
>> model setup, so I get it right and understand.
>> This will be easier for me as this approach is causing me some other
>> errors, when i try to apply it.
>>
>> Best wishes,
>>
>> Kean
>> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>>
>> Hi Kean,
>>
>>  Write manager like this ,I give you reference
>>
>> from django.db import models
>>  # First, define the Manager subclass.
>> class BhoopeshBookManager(models.Manager):
>>def get_queryset(self):
>> return super(BhoopeshBookManager,
>> self).get_queryset().filter(author='Bhoopesh')
>>
>> # Then hook it into the Book model explicitly. class Book(models.Model):
>> title = models.CharField(max_length=100)
>> author = models.CharField(max_length=50)
>>  # ...
>> objects = models.Manager()
>>  # The default manager.
>>
>> bhoopesh_objects = BhoopeshBookManager()
>>  # The Bhoopesh-specific manager.
>>
>>
>> Book.bhoopesh_objects.all() # use manager
>>
>>
>> Thanks
>> Bhoopesh Kumar
>>
>>
>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
>> 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  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 django-users+unsubscr...@googlegroups.com.
 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 django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%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 django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/52D49AAA-5E17-4F6C-92DE-E1576F305927%40gmail.com
>> 
>> .
>>
>

-- 
You 

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Ok No problem but
why you want Manager?

Please send me answer

Thanks
Bhoopesh sisoudiya

On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:

> Hi Bhoopesh
> Thanks for this, please can you put it into the context of my specific
> model setup, so I get it right and understand.
> This will be easier for me as this approach is causing me some other
> errors, when i try to apply it.
>
> Best wishes,
>
> Kean
> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>
> Hi Kean,
>
>  Write manager like this ,I give you reference
>
> from django.db import models
>  # First, define the Manager subclass.
> class BhoopeshBookManager(models.Manager):
>def get_queryset(self):
> return super(BhoopeshBookManager,
> self).get_queryset().filter(author='Bhoopesh')
>
> # Then hook it into the Book model explicitly. class Book(models.Model):
> title = models.CharField(max_length=100)
> author = models.CharField(max_length=50)
>  # ...
> objects = models.Manager()
>  # The default manager.
>
> bhoopesh_objects = BhoopeshBookManager()
>  # The Bhoopesh-specific manager.
>
>
> Book.bhoopesh_objects.all() # use manager
>
>
> Thanks
> Bhoopesh Kumar
>
>
> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
> 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  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 django-users+unsubscr...@googlegroups.com.
>>> 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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/52D49AAA-5E17-4F6C-92DE-E1576F305927%40gmail.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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAk3c1PtFX7oNie8qZKF

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Hi Bhoopesh
Thanks for this, please can you put it into the context of my specific model 
setup, so I get it right and understand.
This will be easier for me as this approach is causing me some other errors, 
when i try to apply it.

Best wishes, 

Kean 
On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:

> Hi Kean,
> 
>  Write manager like this ,I give you reference
> 
> from django.db import models
>  # First, define the Manager subclass. 
> class BhoopeshBookManager(models.Manager):
>def get_queryset(self): 
> return super(BhoopeshBookManager, 
> self).get_queryset().filter(author='Bhoopesh') 
> 
> # Then hook it into the Book model explicitly. class Book(models.Model): 
> title = models.CharField(max_length=100) 
> author = models.CharField(max_length=50)
>  # ... 
> objects = models.Manager()
>  # The default manager. 
> 
> bhoopesh_objects = BhoopeshBookManager()
>  # The Bhoopesh-specific manager.
> 
> 
> Book.bhoopesh_objects.all() # use manager
> 
> 
> Thanks 
> Bhoopesh Kumar
> 
> 
> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya  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  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 django-users+unsubscr...@googlegroups.com.
> 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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52D49AAA-5E17-4F6C-92DE-E1576F305927%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Hi Kean,

 Write manager like this ,I give you reference

from django.db import models
 # First, define the Manager subclass.
class BhoopeshBookManager(models.Manager):
   def get_queryset(self):
return super(BhoopeshBookManager,
self).get_queryset().filter(author='Bhoopesh')

# Then hook it into the Book model explicitly. class Book(models.Model):
title = models.CharField(max_length=100)
author = models.CharField(max_length=50)
 # ...
objects = models.Manager()
 # The default manager.

bhoopesh_objects = BhoopeshBookManager()
 # The Bhoopesh-specific manager.


Book.bhoopesh_objects.all() # use manager


Thanks
Bhoopesh Kumar


On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
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  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 django-users+unsubscr...@googlegroups.com.
>> 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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
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  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  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 django-users+unsubscr...@googlegroups.com.
> 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 django-users+unsubscr...@googlegroups.com.
> 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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/72107009-5D9C-4EC6-8D4D-233A244E8563%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
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  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 django-users+unsubscr...@googlegroups.com.
> 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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAk3c1PoGuLeAsnJoEUuB1LdZw8SwpJDFy51%3Di89%2BAv_Zd1sOA%40mail.gmail.com.


AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com.