Re: Help me with the view please

2020-09-23 Thread coolguy
ohh i missed that...
in your urls.py

You may be using like this with 
path('student/fee//new/', views.AddFeeView.as_view(), name='add_fee'),

Since i have overridden PK configuration in view using 
pk_url_kwarg = 'student_id', I don't have to supply pk rather i have 
replaced it with student_id...
path('fee//new/', views.AddFeeView.as_view(), name='add_fee'),

On Wednesday, September 23, 2020 at 4:00:29 PM UTC-4 dex9...@gmail.com 
wrote:

> I cant seem to put together this template for adding fee, for roll#, 
> tuition fee and remaining fee, I have managed only to create the form, can 
> you help me with that
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 22, 2020 6:10 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> how about following outputs... 
>
> On Tuesday, September 22, 2020 at 4:44:45 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your previous tips, and I have already created the 
> get_absolute_url for my DetailView and It is working just fine
>
> *def* get_absolute_url(*self*):
>
> return reverse("student_detail", *kwargs*={"pk": self.pk})
>
> I think now I can learn from you how use views to generate my output
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 22, 2020 4:32 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> I have made some changes to the model.py and now methods/functions are 
> properties(*@property*). It's of personal preference and you will find 
> programmers prefer properties and functions for their own understanding.
> google it you will see...
>
>  
>
> Since these functions are not doing big calculations with no 
> parameter/argument and are very basic so we can use property instead. 
>
>  
>
> What you need to do is.. wherever you called the method with () 
> brackets... remove them like example below...
>
>  
>
> fee = self.student.get_remaining_fee()
>
> to
>
> fee = self.student.get_remaining_fee
>
>  
>
> There is one get_absolute_url method that you can use to reverse to 
> student_detail view (if you have create one). We can later talk about how 
> you are using views to generate your output...
>
> On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:
>
> Hi @coolguy, thanks for your attachments,  have created all the views and 
> templates, and I have been working on them for my new web app, for this new 
> models will it be easy for more implement or auto check paid all checkbox 
> all payments have been completed, please, how?
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Thursday, September 17, 2020 6:26 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If you are using sqllite3 then make a copy of it and delete the existing 
> sqllite3 file from your project. Keep the old file as you may need it.
>
>  
>
> Here are project files... i quickly make them but these are working..
>
>  
>
>  
>
>  
>
>  
>
> On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> Since model design is where I very much struggle, and I think  my fee 
> management system models are not well design, so I need your help in 
> redesigning my models please
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Wednesday, September 16, 2020 5:31 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> There are a lot of courses but those are very basic and keep on talking 
> about same thing that you might have learned before... even after taking 
> courses you will have to think yourself how to structure your tables
>
>  
>
> I would suggest don't start any big project rather start with a simple 
> Student, Payment and Class models. Keep master information in your Student 
> and class models and all transaction in Payment model.
>
>  
>
> I can help you in designing the models.
>
>  
>
> Let me know...
>
>  
>
> On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your valuable information, it seems my models are not well 
> constructed, I will first work on them.
>
> Don’t you have a YouTube chan

Re: Help me with the view please

2020-09-23 Thread coolguy
Now that you have structure ready... you can explore new options to pull 
the report with your requirement. I just created while watching NBA 
playoffs... so design may be silly...

Did you create view for adding fee?
Here is what i have done...

from django.views.generic.edit import CreateView
from . import forms

class AddFeeView(CreateView):
model = StudentFee
pk_url_kwarg = 'student_id'  # in createview pk would be parent table pk
template_name = 'students/fee_create_form.html'
form_class = forms.StudentFeeForm

def get_context_data(self, **kwargs):
student = Student.objects.get(id=self.kwargs['student_id'])

# adds the custom 'student' key to make it available to the
# class-based view template i.e. ('students/fee_create_form.html')
kwargs['student'] = student

# a call is made to the parent class’s get_context_data() method (i.e., 
CreateView)
# to run its context set up logic, which consists of setting up the 
form reference
# which is also used in the template. Finally, the context reference 
with all the
# template context values is returned by the get_context_data() method 
for use inside
# the template
context = super().get_context_data(**kwargs)

return context

def form_valid(self, form):
# form has only 
date, type and payment but student_id is empty at this time
obj = form.save(commit=False)
obj.student_id = self.kwargs.get('student_id')
obj.save()
# submit to super to save and redirect.
return super().form_valid(form)

Now you will have access to student and studentfee variables

you do can something like this on template

Roll# {{ student.id }} - {{ student.full_name }}
Tution fees: {{ student.tution_fee }}
Remaining Tution fees: {{ student.get_remaining_fee }}

On Wednesday, September 23, 2020 at 4:00:29 PM UTC-4 dex9...@gmail.com 
wrote:

> I cant seem to put together this template for adding fee, for roll#, 
> tuition fee and remaining fee, I have managed only to create the form, can 
> you help me with that
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 22, 2020 6:10 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> how about following outputs... 
>
> On Tuesday, September 22, 2020 at 4:44:45 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your previous tips, and I have already created the 
> get_absolute_url for my DetailView and It is working just fine
>
> *def* get_absolute_url(*self*):
>
> return reverse("student_detail", *kwargs*={"pk": self.pk})
>
> I think now I can learn from you how use views to generate my output
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 22, 2020 4:32 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> I have made some changes to the model.py and now methods/functions are 
> properties(*@property*). It's of personal preference and you will find 
> programmers prefer properties and functions for their own understanding.
> google it you will see...
>
>  
>
> Since these functions are not doing big calculations with no 
> parameter/argument and are very basic so we can use property instead. 
>
>  
>
> What you need to do is.. wherever you called the method with () 
> brackets... remove them like example below...
>
>  
>
> fee = self.student.get_remaining_fee()
>
> to
>
> fee = self.student.get_remaining_fee
>
>  
>
> There is one get_absolute_url method that you can use to reverse to 
> student_detail view (if you have create one). We can later talk about how 
> you are using views to generate your output...
>
> On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:
>
> Hi @coolguy, thanks for your attachments,  have created all the views and 
> templates, and I have been working on them for my new web app, for this new 
> models will it be easy for more implement or auto check paid all checkbox 
> all payments have been completed, please, how?
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Thursday, September 17, 2020 6:26 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If you are using sqllite3 then make a copy of it and delete the existing 
> sqllite3 file from your project. Keep the old file as you may need it.
>
>  
>
> Here are project files... i quickly ma

Re: Help me with the view please

2020-09-23 Thread coolguy
Now that you have structure ready... you can explore new options to pull 
the report with your requirement. I just created while watch NBA 
playoffs... so design may be silly...

Did you create view for adding fee?
Here is what i have done...

from django.views.generic.edit import CreateView
from . import forms

class AddFeeView(CreateView):
model = StudentFee
pk_url_kwarg = 'student_id'  # in createview pk would be parent table pk
template_name = 'students/fee_create_form.html'
form_class = forms.StudentFeeForm

def get_context_data(self, **kwargs):
student = Student.objects.get(id=self.kwargs['student_id'])

# adds the custom 'student' key to make it available to the
# class-based view template i.e. ('students/fee_create_form.html')
kwargs['student'] = student

# a call is made to the parent class’s get_context_data() method (i.e., 
CreateView)
# to run its context set up logic, which consists of setting up the 
form reference
# which is also used in the template. Finally, the context reference 
with all the
# template context values is returned by the get_context_data() method 
for use inside
# the template
context = super().get_context_data(**kwargs)

return context

def form_valid(self, form):
# form has only 
date, type and payment but student_id is empty at this time
obj = form.save(commit=False)
obj.student_id = self.kwargs.get('student_id')
obj.save()
# submit to super to save and redirect.
return super().form_valid(form)

Now you will have access to student and studentfee variables

you can something like this on template

Roll# {{ student.id }} - {{ student.full_name }}
Tution fees: {{ student.tution_fee }}
Remaining Tution fees: {{ student.get_remaining_fee }}

On Wednesday, September 23, 2020 at 4:00:29 PM UTC-4 dex9...@gmail.com 
wrote:

> I cant seem to put together this template for adding fee, for roll#, 
> tuition fee and remaining fee, I have managed only to create the form, can 
> you help me with that
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 22, 2020 6:10 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> how about following outputs... 
>
> On Tuesday, September 22, 2020 at 4:44:45 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your previous tips, and I have already created the 
> get_absolute_url for my DetailView and It is working just fine
>
> *def* get_absolute_url(*self*):
>
> return reverse("student_detail", *kwargs*={"pk": self.pk})
>
> I think now I can learn from you how use views to generate my output
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 22, 2020 4:32 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> I have made some changes to the model.py and now methods/functions are 
> properties(*@property*). It's of personal preference and you will find 
> programmers prefer properties and functions for their own understanding.
> google it you will see...
>
>  
>
> Since these functions are not doing big calculations with no 
> parameter/argument and are very basic so we can use property instead. 
>
>  
>
> What you need to do is.. wherever you called the method with () 
> brackets... remove them like example below...
>
>  
>
> fee = self.student.get_remaining_fee()
>
> to
>
> fee = self.student.get_remaining_fee
>
>  
>
> There is one get_absolute_url method that you can use to reverse to 
> student_detail view (if you have create one). We can later talk about how 
> you are using views to generate your output...
>
> On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:
>
> Hi @coolguy, thanks for your attachments,  have created all the views and 
> templates, and I have been working on them for my new web app, for this new 
> models will it be easy for more implement or auto check paid all checkbox 
> all payments have been completed, please, how?
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Thursday, September 17, 2020 6:26 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If you are using sqllite3 then make a copy of it and delete the existing 
> sqllite3 file from your project. Keep the old file as you may need it.
>
>  
>
> Here are project files... i quickly make th

RE: Help me with the view please

2020-09-23 Thread fadhil alex
I cant seem to put together this template for adding fee, for roll#, tuition fee and remaining fee, I have managed only to create the form, can you help me with thatSent from Mail for Windows 10 From: coolguySent: Tuesday, September 22, 2020 6:10 PMTo: Django usersSubject: Re: Help me with the view please how about following outputs... On Tuesday, September 22, 2020 at 4:44:45 AM UTC-4 dex9...@gmail.com wrote:Thanks for your previous tips, and I have already created the get_absolute_url for my DetailView and It is working just finedef get_absolute_url(self):return reverse("student_detail", kwargs={"pk": self.pk})I think now I can learn from you how use views to generate my output Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 22, 2020 4:32 AMTo: Django usersSubject: Re: Help me with the view please I have made some changes to the model.py and now methods/functions are properties(@property). It's of personal preference and you will find programmers prefer properties and functions for their own understanding.    google it you will see... Since these functions are not doing big calculations with no parameter/argument and are very basic so we can use property instead.  What you need to do is.. wherever you called the method with () brackets... remove them like example below... fee = self.student.get_remaining_fee()tofee = self.student.get_remaining_fee There is one get_absolute_url method that you can use to reverse to student_detail view (if you have create one). We can later talk about how you are using views to generate your output...On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:Hi @coolguy, thanks for your attachments,  have created all the views and templates, and I have been working on them for my new web app, for this new models will it be easy for more implement or auto check paid all checkbox all payments have been completed, please, how? Sent from Mail for Windows 10 From: coolguySent: Thursday, September 17, 2020 6:26 AMTo: Django usersSubject: Re: Help me with the view please If you are using sqllite3 then make a copy of it and delete the existing sqllite3 file from your project. Keep the old file as you may need it. Here are project files... i quickly make them but these are working..On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com wrote:Since model design is where I very much struggle, and I think  my fee management system models are not well design, so I need your help in redesigning my models please Sent from Mail for Windows 10 From: coolguySent: Wednesday, September 16, 2020 5:31 PMTo: Django usersSubject: Re: Help me with the view please There are a lot of courses but those are very basic and keep on talking about same thing that you might have learned before... even after taking courses you will have to think yourself how to structure your tables I would suggest don't start any big project rather start with a simple Student, Payment and Class models. Keep master information in your Student and class models and all transaction in Payment model. I can help you in designing the models. Let me know... On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com wrote:Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Stude

Re: Help me with the view please

2020-09-22 Thread Let's Get Going
Hey everyone I am working on a miniChatProject. I have an error in that.
Can anyone help me with that? Let me know if you can help me via email. I
will share my AnyDesk unique id with you.


On Tue, 22 Sep 2020 at 07:02, coolguy 
wrote:

> I have made some changes to the model.py and now methods/functions are
> properties(*@property*). It's of personal preference and you will find
> programmers prefer properties and functions for their own understanding.
> google it you will see
>
> Since these functions are not doing big calculations with no
> parameter/argument and are very basic so we can use property instead.
>
> What you need to do is... wherever you called the method with ()
> brackets... remove them like example below...
>
> fee = self.student.get_remaining_fee()
> to
> fee = self.student.get_remaining_fee
>
> There is one get_absolute_url method that you can use to reverse to
> student_detail view (if you have create one). We can later talk about how
> you are using views to generate your output...
> On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:
>
>> Hi @coolguy, thanks for your attachments,  have created all the views
>> and templates, and I have been working on them for my new web app, for this
>> new models will it be easy for more implement or auto check paid all
>> checkbox all payments have been completed, please, how?
>>
>>
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
>> Windows 10
>>
>>
>>
>> *From: *coolguy
>> *Sent: *Thursday, September 17, 2020 6:26 AM
>> *To: *Django users
>> *Subject: *Re: Help me with the view please
>>
>>
>>
>> If you are using sqllite3 then make a copy of it and delete the existing
>> sqllite3 file from your project. Keep the old file as you may need it.
>>
>>
>>
>> Here are project files... i quickly make them but these are working..
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com
>> wrote:
>>
>> Since model design is where I very much struggle, and I think  my fee
>> management system models are not well design, so I need your help in
>> redesigning my models please
>>
>>
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
>> Windows 10
>>
>>
>>
>> *From: *coolguy
>> *Sent: *Wednesday, September 16, 2020 5:31 PM
>> *To: *Django users
>> *Subject: *Re: Help me with the view please
>>
>>
>>
>> There are a lot of courses but those are very basic and keep on talking
>> about same thing that you might have learned before... even after taking
>> courses you will have to think yourself how to structure your tables
>>
>>
>>
>> I would suggest don't start any big project rather start with a simple
>> Student, Payment and Class models. Keep master information in your Student
>> and class models and all transaction in Payment model.
>>
>>
>>
>> I can help you in designing the models.
>>
>>
>>
>> Let me know...
>>
>>
>>
>> On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com
>> wrote:
>>
>> Thanks for your valuable information, it seems my models are not well
>> constructed, I will first work on them.
>>
>> Don’t you have a YouTube channel or website or paid course somewhere like
>> Udemy where I can learn more
>>
>>
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
>> Windows 10
>>
>>
>>
>> *From: *coolguy
>> *Sent: *Tuesday, September 15, 2020 10:57 PM
>> *To: *Django users
>> *Subject: *Re: Help me with the view please
>>
>>
>>
>> Isn't this 'paid_fee' used to record the quarterly/monthly payments from
>> students? and this field will have multiple records?
>>
>>
>>
>> It seems you are looking to save an accumulated paid_fee
>> (total_paid_fees) somewhere in table.
>>
>> If i am corrected then... this type of structure is okay when you are
>> working on spreadsheet solution e.g. microsoft excel, and save/calculate
>> the result in a separate column for the user info but when we deal with the
>> database and UI solution we don't use this approach... rather we show such
>> calculation on template. We persist initial setup values like student name,
>> school_fees etc and the recurring transactions in database.
>>
>>
>>
>

RE: Help me with the view please

2020-09-22 Thread fadhil alex
Thanks for your previous tips, and I have already created the get_absolute_url for my DetailView and It is working just finedef get_absolute_url(self):return reverse("student_detail", kwargs={"pk": self.pk})I think now I can learn from you how use views to generate my output Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 22, 2020 4:32 AMTo: Django usersSubject: Re: Help me with the view please I have made some changes to the model.py and now methods/functions are properties(@property). It's of personal preference and you will find programmers prefer properties and functions for their own understanding.    google it you will see... Since these functions are not doing big calculations with no parameter/argument and are very basic so we can use property instead.  What you need to do is... wherever you called the method with () brackets... remove them like example below... fee = self.student.get_remaining_fee()tofee = self.student.get_remaining_fee There is one get_absolute_url method that you can use to reverse to student_detail view (if you have create one). We can later talk about how you are using views to generate your output...On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:Hi @coolguy, thanks for your attachments,  have created all the views and templates, and I have been working on them for my new web app, for this new models will it be easy for more implement or auto check paid all checkbox all payments have been completed, please, how? Sent from Mail for Windows 10 From: coolguySent: Thursday, September 17, 2020 6:26 AMTo: Django usersSubject: Re: Help me with the view please If you are using sqllite3 then make a copy of it and delete the existing sqllite3 file from your project. Keep the old file as you may need it. Here are project files... i quickly make them but these are working..On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com wrote:Since model design is where I very much struggle, and I think  my fee management system models are not well design, so I need your help in redesigning my models please Sent from Mail for Windows 10 From: coolguySent: Wednesday, September 16, 2020 5:31 PMTo: Django usersSubject: Re: Help me with the view please There are a lot of courses but those are very basic and keep on talking about same thing that you might have learned before... even after taking courses you will have to think yourself how to structure your tables I would suggest don't start any big project rather start with a simple Student, Payment and Class models. Keep master information in your Student and class models and all transaction in Payment model. I can help you in designing the models. Let me know... On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com wrote:Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to save then which record in the table would you update... so logically its wrong. On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fe

Re: Help me with the view please

2020-09-21 Thread coolguy
I have made some changes to the model.py and now methods/functions are 
properties(*@property*). It's of personal preference and you will find 
programmers prefer properties and functions for their own understanding.
google it you will see

Since these functions are not doing big calculations with no 
parameter/argument and are very basic so we can use property instead. 

What you need to do is... wherever you called the method with () 
brackets... remove them like example below...

fee = self.student.get_remaining_fee()
to
fee = self.student.get_remaining_fee

There is one get_absolute_url method that you can use to reverse to 
student_detail view (if you have create one). We can later talk about how 
you are using views to generate your output...
On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:

> Hi @coolguy, thanks for your attachments,  have created all the views and 
> templates, and I have been working on them for my new web app, for this new 
> models will it be easy for more implement or auto check paid all checkbox 
> all payments have been completed, please, how?
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Thursday, September 17, 2020 6:26 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If you are using sqllite3 then make a copy of it and delete the existing 
> sqllite3 file from your project. Keep the old file as you may need it.
>
>  
>
> Here are project files... i quickly make them but these are working..
>
>  
>
>  
>
>  
>
>  
>
> On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> Since model design is where I very much struggle, and I think  my fee 
> management system models are not well design, so I need your help in 
> redesigning my models please
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Wednesday, September 16, 2020 5:31 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> There are a lot of courses but those are very basic and keep on talking 
> about same thing that you might have learned before... even after taking 
> courses you will have to think yourself how to structure your tables
>
>  
>
> I would suggest don't start any big project rather start with a simple 
> Student, Payment and Class models. Keep master information in your Student 
> and class models and all transaction in Payment model.
>
>  
>
> I can help you in designing the models.
>
>  
>
> Let me know...
>
>  
>
> On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your valuable information, it seems my models are not well 
> constructed, I will first work on them.
>
> Don’t you have a YouTube channel or website or paid course somewhere like 
> Udemy where I can learn more
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 15, 2020 10:57 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Isn't this 'paid_fee' used to record the quarterly/monthly payments from 
> students? and this field will have multiple records? 
>
>  
>
> It seems you are looking to save an accumulated paid_fee (total_paid_fees) 
> somewhere in table. 
>
> If i am corrected then... this type of structure is okay when you are 
> working on spreadsheet solution e.g. microsoft excel, and save/calculate 
> the result in a separate column for the user info but when we deal with the 
> database and UI solution we don't use this approach... rather we show such 
> calculation on template. We persist initial setup values like student name, 
> school_fees etc and the recurring transactions in database.
>
>  
>
> If you really want to save this type of information in your database you 
> get to change your database structure and create a parent and child 
> relationship between Fee (being parent) and Student_Payments (being child). 
> 'Fee' would have all setup information as well as calculated fields like 
> total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would 
> only carry number of payments over the periods. When you have this 
> structure ready then you can think of maintaining totals in parent table 
> per student.
>
>  
>
> anyways, to your question following line would not work in save() method
>
> >>> self.paid_fees = *student*.fee_set.aggregate(*total_paid

Re: Help me with the view please

2020-09-21 Thread coolguy
write me directly so i can respond fast... naseem.pyt...@gmail.com

On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:

> Hi @coolguy, thanks for your attachments,  have created all the views and 
> templates, and I have been working on them for my new web app, for this new 
> models will it be easy for more implement or auto check paid all checkbox 
> all payments have been completed, please, how?
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Thursday, September 17, 2020 6:26 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If you are using sqllite3 then make a copy of it and delete the existing 
> sqllite3 file from your project. Keep the old file as you may need it.
>
>  
>
> Here are project files... i quickly make them but these are working..
>
>  
>
>  
>
>  
>
>  
>
> On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> Since model design is where I very much struggle, and I think  my fee 
> management system models are not well design, so I need your help in 
> redesigning my models please
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Wednesday, September 16, 2020 5:31 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> There are a lot of courses but those are very basic and keep on talking 
> about same thing that you might have learned before... even after taking 
> courses you will have to think yourself how to structure your tables
>
>  
>
> I would suggest don't start any big project rather start with a simple 
> Student, Payment and Class models. Keep master information in your Student 
> and class models and all transaction in Payment model.
>
>  
>
> I can help you in designing the models.
>
>  
>
> Let me know...
>
>  
>
> On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your valuable information, it seems my models are not well 
> constructed, I will first work on them.
>
> Don’t you have a YouTube channel or website or paid course somewhere like 
> Udemy where I can learn more
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 15, 2020 10:57 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Isn't this 'paid_fee' used to record the quarterly/monthly payments from 
> students? and this field will have multiple records? 
>
>  
>
> It seems you are looking to save an accumulated paid_fee (total_paid_fees) 
> somewhere in table. 
>
> If i am corrected then... this type of structure is okay when you are 
> working on spreadsheet solution e.g. microsoft excel, and save/calculate 
> the result in a separate column for the user info but when we deal with the 
> database and UI solution we don't use this approach... rather we show such 
> calculation on template. We persist initial setup values like student name, 
> school_fees etc and the recurring transactions in database.
>
>  
>
> If you really want to save this type of information in your database you 
> get to change your database structure and create a parent and child 
> relationship between Fee (being parent) and Student_Payments (being child). 
> 'Fee' would have all setup information as well as calculated fields like 
> total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would 
> only carry number of payments over the periods. When you have this 
> structure ready then you can think of maintaining totals in parent table 
> per student.
>
>  
>
> anyways, to your question following line would not work in save() method
>
> >>> self.paid_fees = *student*.fee_set.aggregate(*total_paid_fees*
> =sum('paid_fees'))  
>
>  
>
> since you don't have 
>
> >>> *student* = Student.objects.get(id=pk)
>
>  
>
> even if you want to save then which record in the table would you 
> update... so logically its wrong.
>
>  
>
> On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> *def* save(*self*, **args*, ***kwargs*):
>
> self.paid_fees = student.fee_set.aggregate(*total_paid_fees*=sum(
> 'paid_fees'))
>
> self.school_fees = first_record.school_fees
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if self.rema

Re: Help me with the view please

2020-09-21 Thread coolguy
checkout my work for you on https://github.com/naseemfico/students

On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:

> Hi @coolguy, thanks for your attachments,  have created all the views and 
> templates, and I have been working on them for my new web app, for this new 
> models will it be easy for more implement or auto check paid all checkbox 
> all payments have been completed, please, how?
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Thursday, September 17, 2020 6:26 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If you are using sqllite3 then make a copy of it and delete the existing 
> sqllite3 file from your project. Keep the old file as you may need it.
>
>  
>
> Here are project files... i quickly make them but these are working..
>
>  
>
>  
>
>  
>
>  
>
> On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> Since model design is where I very much struggle, and I think  my fee 
> management system models are not well design, so I need your help in 
> redesigning my models please
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Wednesday, September 16, 2020 5:31 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> There are a lot of courses but those are very basic and keep on talking 
> about same thing that you might have learned before... even after taking 
> courses you will have to think yourself how to structure your tables
>
>  
>
> I would suggest don't start any big project rather start with a simple 
> Student, Payment and Class models. Keep master information in your Student 
> and class models and all transaction in Payment model.
>
>  
>
> I can help you in designing the models.
>
>  
>
> Let me know...
>
>  
>
> On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your valuable information, it seems my models are not well 
> constructed, I will first work on them.
>
> Don’t you have a YouTube channel or website or paid course somewhere like 
> Udemy where I can learn more
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 15, 2020 10:57 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Isn't this 'paid_fee' used to record the quarterly/monthly payments from 
> students? and this field will have multiple records? 
>
>  
>
> It seems you are looking to save an accumulated paid_fee (total_paid_fees) 
> somewhere in table. 
>
> If i am corrected then... this type of structure is okay when you are 
> working on spreadsheet solution e.g. microsoft excel, and save/calculate 
> the result in a separate column for the user info but when we deal with the 
> database and UI solution we don't use this approach... rather we show such 
> calculation on template. We persist initial setup values like student name, 
> school_fees etc and the recurring transactions in database.
>
>  
>
> If you really want to save this type of information in your database you 
> get to change your database structure and create a parent and child 
> relationship between Fee (being parent) and Student_Payments (being child). 
> 'Fee' would have all setup information as well as calculated fields like 
> total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would 
> only carry number of payments over the periods. When you have this 
> structure ready then you can think of maintaining totals in parent table 
> per student.
>
>  
>
> anyways, to your question following line would not work in save() method
>
> >>> self.paid_fees = *student*.fee_set.aggregate(*total_paid_fees*
> =sum('paid_fees'))  
>
>  
>
> since you don't have 
>
> >>> *student* = Student.objects.get(id=pk)
>
>  
>
> even if you want to save then which record in the table would you 
> update... so logically its wrong.
>
>  
>
> On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> *def* save(*self*, **args*, ***kwargs*):
>
> self.paid_fees = student.fee_set.aggregate(*total_paid_fees*=sum(
> 'paid_fees'))
>
> self.school_fees = first_record.school_fees
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if self.rema

Re: Help me with the view please

2020-09-21 Thread coolguy
yes you will... I left these for you... but definitely you can write me. 

On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:

> Hi @coolguy, thanks for your attachments,  have created all the views and 
> templates, and I have been working on them for my new web app, for this new 
> models will it be easy for more implement or auto check paid all checkbox 
> all payments have been completed, please, how?
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Thursday, September 17, 2020 6:26 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If you are using sqllite3 then make a copy of it and delete the existing 
> sqllite3 file from your project. Keep the old file as you may need it.
>
>  
>
> Here are project files... i quickly make them but these are working..
>
>  
>
>  
>
>  
>
>  
>
> On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> Since model design is where I very much struggle, and I think  my fee 
> management system models are not well design, so I need your help in 
> redesigning my models please
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Wednesday, September 16, 2020 5:31 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> There are a lot of courses but those are very basic and keep on talking 
> about same thing that you might have learned before... even after taking 
> courses you will have to think yourself how to structure your tables
>
>  
>
> I would suggest don't start any big project rather start with a simple 
> Student, Payment and Class models. Keep master information in your Student 
> and class models and all transaction in Payment model.
>
>  
>
> I can help you in designing the models.
>
>  
>
> Let me know...
>
>  
>
> On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your valuable information, it seems my models are not well 
> constructed, I will first work on them.
>
> Don’t you have a YouTube channel or website or paid course somewhere like 
> Udemy where I can learn more
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 15, 2020 10:57 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Isn't this 'paid_fee' used to record the quarterly/monthly payments from 
> students? and this field will have multiple records? 
>
>  
>
> It seems you are looking to save an accumulated paid_fee (total_paid_fees) 
> somewhere in table. 
>
> If i am corrected then... this type of structure is okay when you are 
> working on spreadsheet solution e.g. microsoft excel, and save/calculate 
> the result in a separate column for the user info but when we deal with the 
> database and UI solution we don't use this approach... rather we show such 
> calculation on template. We persist initial setup values like student name, 
> school_fees etc and the recurring transactions in database.
>
>  
>
> If you really want to save this type of information in your database you 
> get to change your database structure and create a parent and child 
> relationship between Fee (being parent) and Student_Payments (being child). 
> 'Fee' would have all setup information as well as calculated fields like 
> total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would 
> only carry number of payments over the periods. When you have this 
> structure ready then you can think of maintaining totals in parent table 
> per student.
>
>  
>
> anyways, to your question following line would not work in save() method
>
> >>> self.paid_fees = *student*.fee_set.aggregate(*total_paid_fees*
> =sum('paid_fees'))  
>
>  
>
> since you don't have 
>
> >>> *student* = Student.objects.get(id=pk)
>
>  
>
> even if you want to save then which record in the table would you 
> update... so logically its wrong.
>
>  
>
> On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> *def* save(*self*, **args*, ***kwargs*):
>
> self.paid_fees = student.fee_set.aggregate(*total_paid_fees*=sum(
> 'paid_fees'))
>
> self.school_fees = first_record.school_fees
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if s

Re: Help me with the view please

2020-09-21 Thread coolguy
yes you will... I left these for you... but definitely you can write me 
directly @ naseem.pyt...@gmail.com


On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:

> Hi @coolguy, thanks for your attachments,  have created all the views and 
> templates, and I have been working on them for my new web app, for this new 
> models will it be easy for more implement or auto check paid all checkbox 
> all payments have been completed, please, how?
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Thursday, September 17, 2020 6:26 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If you are using sqllite3 then make a copy of it and delete the existing 
> sqllite3 file from your project. Keep the old file as you may need it.
>
>  
>
> Here are project files... i quickly make them but these are working..
>
>  
>
>  
>
>  
>
>  
>
> On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> Since model design is where I very much struggle, and I think  my fee 
> management system models are not well design, so I need your help in 
> redesigning my models please
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Wednesday, September 16, 2020 5:31 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> There are a lot of courses but those are very basic and keep on talking 
> about same thing that you might have learned before... even after taking 
> courses you will have to think yourself how to structure your tables
>
>  
>
> I would suggest don't start any big project rather start with a simple 
> Student, Payment and Class models. Keep master information in your Student 
> and class models and all transaction in Payment model.
>
>  
>
> I can help you in designing the models.
>
>  
>
> Let me know...
>
>  
>
> On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your valuable information, it seems my models are not well 
> constructed, I will first work on them.
>
> Don’t you have a YouTube channel or website or paid course somewhere like 
> Udemy where I can learn more
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 15, 2020 10:57 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Isn't this 'paid_fee' used to record the quarterly/monthly payments from 
> students? and this field will have multiple records? 
>
>  
>
> It seems you are looking to save an accumulated paid_fee (total_paid_fees) 
> somewhere in table. 
>
> If i am corrected then... this type of structure is okay when you are 
> working on spreadsheet solution e.g. microsoft excel, and save/calculate 
> the result in a separate column for the user info but when we deal with the 
> database and UI solution we don't use this approach... rather we show such 
> calculation on template. We persist initial setup values like student name, 
> school_fees etc and the recurring transactions in database.
>
>  
>
> If you really want to save this type of information in your database you 
> get to change your database structure and create a parent and child 
> relationship between Fee (being parent) and Student_Payments (being child). 
> 'Fee' would have all setup information as well as calculated fields like 
> total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would 
> only carry number of payments over the periods. When you have this 
> structure ready then you can think of maintaining totals in parent table 
> per student.
>
>  
>
> anyways, to your question following line would not work in save() method
>
> >>> self.paid_fees = *student*.fee_set.aggregate(*total_paid_fees*
> =sum('paid_fees'))  
>
>  
>
> since you don't have 
>
> >>> *student* = Student.objects.get(id=pk)
>
>  
>
> even if you want to save then which record in the table would you 
> update... so logically its wrong.
>
>  
>
> On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> *def* save(*self*, **args*, ***kwargs*):
>
> self.paid_fees = student.fee_set.aggregate(*total_paid_fees*=sum(
> 'paid_fees'))
>
> self.school_fees = first_record.school_fees
>
> self.remaining_fees = self.school_fees - self.

RE: Help me with the view please

2020-09-21 Thread fadhil alex
Hi @coolguy, thanks for your attachments,  have created all the views and templates, and I have been working on them for my new web app, for this new models will it be easy for more implement or auto check paid all checkbox all payments have been completed, please, how? Sent from Mail for Windows 10 From: coolguySent: Thursday, September 17, 2020 6:26 AMTo: Django usersSubject: Re: Help me with the view please If you are using sqllite3 then make a copy of it and delete the existing sqllite3 file from your project. Keep the old file as you may need it. Here are project files... i quickly make them but these are working..On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com wrote:Since model design is where I very much struggle, and I think  my fee management system models are not well design, so I need your help in redesigning my models please Sent from Mail for Windows 10 From: coolguySent: Wednesday, September 16, 2020 5:31 PMTo: Django usersSubject: Re: Help me with the view please There are a lot of courses but those are very basic and keep on talking about same thing that you might have learned before... even after taking courses you will have to think yourself how to structure your tables I would suggest don't start any big project rather start with a simple Student, Payment and Class models. Keep master information in your Student and class models and all transaction in Payment model. I can help you in designing the models. Let me know... On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com wrote:Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to save then which record in the table would you update... so logically its wrong. On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs)I have tried doing it like this, perhaps maybe you can see what I’m trying to doSent from Mail From: coolguySent: Monday, September 14, 2020 11:53 PMTo: Django usersSubject: Re: Help me with the view please not sure what are you looking for.. but based on your model setup... school fees is setup once so we picked it up from first object/record from table, while paid fees are collected quarterly or whatever means there will be more than one transaction in fee table. We have already calculated the "paid_fees" from fee table like this>>>    paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees')) I definitely want to help as long as i know what you are looking for :)  On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = stud

Re: Help me with the view please

2020-09-16 Thread coolguy
If you are using sqllite3 then make a copy of it and delete the existing 
sqllite3 file from your project. Keep the old file as you may need it.

Here are project files... i quickly make them but these are working...





On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com 
wrote:

> Since model design is where I very much struggle, and I think  my fee 
> management system models are not well design, so I need your help in 
> redesigning my models please
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Wednesday, September 16, 2020 5:31 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> There are a lot of courses but those are very basic and keep on talking 
> about same thing that you might have learned before... even after taking 
> courses you will have to think yourself how to structure your tables
>
>  
>
> I would suggest don't start any big project rather start with a simple 
> Student, Payment and Class models. Keep master information in your Student 
> and class models and all transaction in Payment model.
>
>  
>
> I can help you in designing the models.
>
>  
>
> Let me know...
>
>  
>
> On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for your valuable information, it seems my models are not well 
> constructed, I will first work on them.
>
> Don’t you have a YouTube channel or website or paid course somewhere like 
> Udemy where I can learn more
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 15, 2020 10:57 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Isn't this 'paid_fee' used to record the quarterly/monthly payments from 
> students? and this field will have multiple records? 
>
>  
>
> It seems you are looking to save an accumulated paid_fee (total_paid_fees) 
> somewhere in table. 
>
> If i am corrected then... this type of structure is okay when you are 
> working on spreadsheet solution e.g. microsoft excel, and save/calculate 
> the result in a separate column for the user info but when we deal with the 
> database and UI solution we don't use this approach... rather we show such 
> calculation on template. We persist initial setup values like student name, 
> school_fees etc and the recurring transactions in database.
>
>  
>
> If you really want to save this type of information in your database you 
> get to change your database structure and create a parent and child 
> relationship between Fee (being parent) and Student_Payments (being child). 
> 'Fee' would have all setup information as well as calculated fields like 
> total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would 
> only carry number of payments over the periods. When you have this 
> structure ready then you can think of maintaining totals in parent table 
> per student.
>
>  
>
> anyways, to your question following line would not work in save() method
>
> >>> self.paid_fees = *student*.fee_set.aggregate(*total_paid_fees*
> =sum('paid_fees'))  
>
>  
>
> since you don't have 
>
> >>> *student* = Student.objects.get(id=pk)
>
>  
>
> even if you want to save then which record in the table would you 
> update... so logically its wrong.
>
>  
>
> On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> *def* save(*self*, **args*, ***kwargs*):
>
> self.paid_fees = student.fee_set.aggregate(*total_paid_fees*=sum(
> 'paid_fees'))
>
> self.school_fees = first_record.school_fees
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if self.remaining_fees == 0:
>
> self.completed = True
>
>     else:
>
> self.completed = False
>
> 
>
> *super*().save(*args, **kwargs)
>
> I have tried doing it like this, perhaps maybe you can see what I’m trying 
> to do
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>
>  
>
> *From: *coolguy
> *Sent: *Monday, September 14, 2020 11:53 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> not sure what are you looking for.. but based on your model setup... 
> school fees is setup once so we picked it up from first object/record from 
> table, while paid fees are collected quarterly or whatever means there will 
> be more than on

RE: Help me with the view please

2020-09-16 Thread fadhil alex
Since model design is where I very much struggle, and I think  my fee management system models are not well design, so I need your help in redesigning my models please Sent from Mail for Windows 10 From: coolguySent: Wednesday, September 16, 2020 5:31 PMTo: Django usersSubject: Re: Help me with the view please There are a lot of courses but those are very basic and keep on talking about same thing that you might have learned before... even after taking courses you will have to think yourself how to structure your tables I would suggest don't start any big project rather start with a simple Student, Payment and Class models. Keep master information in your Student and class models and all transaction in Payment model. I can help you in designing the models. Let me know... On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com wrote:Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to save then which record in the table would you update... so logically its wrong. On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs)I have tried doing it like this, perhaps maybe you can see what I’m trying to doSent from Mail From: coolguySent: Monday, September 14, 2020 11:53 PMTo: Django usersSubject: Re: Help me with the view please not sure what are you looking for.. but based on your model setup... school fees is setup once so we picked it up from first object/record from table, while paid fees are collected quarterly or whatever means there will be more than one transaction in fee table. We have already calculated the "paid_fees" from fee table like this>>>    paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees')) I definitely want to help as long as i know what you are looking for :)  On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.complete

Re: Help me with the view please

2020-09-16 Thread coolguy
There are a lot of courses but those are very basic and keep on talking 
about same thing that you might have learned before... even after taking 
courses you will have to think yourself how to structure your tables

I would suggest don't start any big project rather start with a simple 
Student, Payment and Class models. Keep master information in your Student 
and class models and all transaction in Payment model.

I can help you in designing the models.

Let me know...

On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com 
wrote:

> Thanks for your valuable information, it seems my models are not well 
> constructed, I will first work on them.
>
> Don’t you have a YouTube channel or website or paid course somewhere like 
> Udemy where I can learn more
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 15, 2020 10:57 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Isn't this 'paid_fee' used to record the quarterly/monthly payments from 
> students? and this field will have multiple records? 
>
>  
>
> It seems you are looking to save an accumulated paid_fee (total_paid_fees) 
> somewhere in table. 
>
> If i am corrected then... this type of structure is okay when you are 
> working on spreadsheet solution e.g. microsoft excel, and save/calculate 
> the result in a separate column for the user info but when we deal with the 
> database and UI solution we don't use this approach... rather we show such 
> calculation on template. We persist initial setup values like student name, 
> school_fees etc and the recurring transactions in database.
>
>  
>
> If you really want to save this type of information in your database you 
> get to change your database structure and create a parent and child 
> relationship between Fee (being parent) and Student_Payments (being child). 
> 'Fee' would have all setup information as well as calculated fields like 
> total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would 
> only carry number of payments over the periods. When you have this 
> structure ready then you can think of maintaining totals in parent table 
> per student.
>
>  
>
> anyways, to your question following line would not work in save() method
>
> >>> self.paid_fees = *student*.fee_set.aggregate(*total_paid_fees*
> =sum('paid_fees'))  
>
>  
>
> since you don't have 
>
> >>> *student* = Student.objects.get(id=pk)
>
>  
>
> even if you want to save then which record in the table would you 
> update... so logically its wrong.
>
>  
>
> On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com 
> wrote:
>
> *def* save(*self*, **args*, ***kwargs*):
>
> self.paid_fees = student.fee_set.aggregate(*total_paid_fees*=sum(
> 'paid_fees'))
>
> self.school_fees = first_record.school_fees
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if self.remaining_fees == 0:
>
> self.completed = True
>
> else:
>
> self.completed = False
>
> 
>
> *super*().save(*args, **kwargs)
>
> I have tried doing it like this, perhaps maybe you can see what I’m trying 
> to do
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>
>  
>
> *From: *coolguy
> *Sent: *Monday, September 14, 2020 11:53 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> not sure what are you looking for... but based on your model setup... 
> school fees is setup once so we picked it up from first object/record from 
> table, while paid fees are collected quarterly or whatever means there will 
> be more than one transaction in fee table. We have already calculated the 
> "paid_fees" from fee table like this
>
> >>>  
>   paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
>  
>
> I definitely want to help as long as i know what you are looking for :)
>
>  
>
>  
>
> On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:
>
> Thanks it has worked, but it doesn’t work with my total_paid_fees, I want 
> to be automatically checked when school_fees substracts summation of all 
> paid_fees, just like this solution you provided me with the last time
>
> first_record = student.fee_set.first()
>
>  school_fees = first_record.school_fees
>
>   paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
>balance_fees =  school_fees - paid_fees["tota

RE: Help me with the view please

2020-09-15 Thread fadhil alex
Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to save then which record in the table would you update... so logically its wrong. On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs)I have tried doing it like this, perhaps maybe you can see what I’m trying to doSent from Mail From: coolguySent: Monday, September 14, 2020 11:53 PMTo: Django usersSubject: Re: Help me with the view please not sure what are you looking for... but based on your model setup... school fees is setup once so we picked it up from first object/record from table, while paid fees are collected quarterly or whatever means there will be more than one transaction in fee table. We have already calculated the "paid_fees" from fee table like this>>>    paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees')) I definitely want to help as long as i know what you are looking for :)  On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs) On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:Thank you brother @coolguy, I have put to work your latest solution and it has worked like a charm.I have been learning a lot from you lately, as you know i am still a beginner, i would love to learn one more thing from you..i have a boolean field "completed", and i want django to automatically check it when balance_fees or remaining_fees is equal to zero, Here is  my model my template  Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 8:51 PMTo: Django usersSubject: Re: Help me with the view please Technically your Fee model is designed incorrectly. You should have separate models for 'fees' and 'fees_paid' where fee would have been the foreign key in 'fees_paid. Fee should have a

Re: Help me with the view please

2020-09-15 Thread coolguy
Isn't this 'paid_fee' used to record the quarterly/monthly payments from 
students? and this field will have multiple records? 

It seems you are looking to save an accumulated paid_fee (total_paid_fees) 
somewhere in table. 
If i am corrected then... this type of structure is okay when you are 
working on spreadsheet solution e.g. microsoft excel, and save/calculate 
the result in a separate column for the user info but when we deal with the 
database and UI solution we don't use this approach... rather we show such 
calculation on template. We persist initial setup values like student name, 
school_fees etc and the recurring transactions in database.

If you really want to save this type of information in your database you 
get to change your database structure and create a parent and child 
relationship between Fee (being parent) and Student_Payments (being child). 
'Fee' would have all setup information as well as calculated fields like 
total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would 
only carry number of payments over the periods. When you have this 
structure ready then you can think of maintaining totals in parent table 
per student.

anyways, to your question following line would not work in save() method
>>> self.paid_fees = *student*.fee_set.aggregate(*total_paid_fees*
=sum('paid_fees'))  

since you don't have 
>>> *student* = Student.objects.get(id=pk)

even if you want to save then which record in the table would you update... 
so logically its wrong.


On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:

> *def* save(*self*, **args*, ***kwargs*):
>
> self.paid_fees = student.fee_set.aggregate(*total_paid_fees*=sum(
> 'paid_fees'))
>
> self.school_fees = first_record.school_fees
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if self.remaining_fees == 0:
>
> self.completed = True
>
> else:
>
> self.completed = False
>
> 
>
> *super*().save(*args, **kwargs)
>
> I have tried doing it like this, perhaps maybe you can see what I’m trying 
> to do
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>
>  
>
> *From: *coolguy
> *Sent: *Monday, September 14, 2020 11:53 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> not sure what are you looking for... but based on your model setup... 
> school fees is setup once so we picked it up from first object/record from 
> table, while paid fees are collected quarterly or whatever means there will 
> be more than one transaction in fee table. We have already calculated the 
> "paid_fees" from fee table like this
>
> >>>  
>   paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
>  
>
> I definitely want to help as long as i know what you are looking for :)
>
>  
>
>  
>
> On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:
>
> Thanks it has worked, but it doesn’t work with my total_paid_fees, I want 
> to be automatically checked when school_fees substracts summation of all 
> paid_fees, just like this solution you provided me with the last time
>
> first_record = student.fee_set.first()
>
>  school_fees = first_record.school_fees
>
>   paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
>balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Monday, September 14, 2020 9:09 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Its simple... in your fee models' save method check that 
> self.remaining_fees is zero then make self.completed field to true... I 
> added else clause in case if admin make changes to paid fees and after 
> changes student still has some dues.
>
>  
>
> def save(self, *args, **kwargs):
>
>  
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if self.remaining_fees == 0:
>
> self.completed = True
>
> else:
>
> self.completed = False
>
> 
>
> super().save(*args, **kwargs)
>
>  
>
> On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:
>
> Thank you brother @coolguy, I have put to work your latest solution and it 
> has worked like a charm.I have been learning a lot from you lately, as you 
> know i am still a beginner, i would love to learn one more thing from 
> you..i have a boolean field "completed",

RE: Help me with the view please

2020-09-15 Thread fadhil alex
def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs)I have tried doing it like this, perhaps maybe you can see what I’m trying to doSent from Mail From: coolguySent: Monday, September 14, 2020 11:53 PMTo: Django usersSubject: Re: Help me with the view please not sure what are you looking for... but based on your model setup... school fees is setup once so we picked it up from first object/record from table, while paid fees are collected quarterly or whatever means there will be more than one transaction in fee table. We have already calculated the "paid_fees" from fee table like this>>>    paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees')) I definitely want to help as long as i know what you are looking for :)  On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs) On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:Thank you brother @coolguy, I have put to work your latest solution and it has worked like a charm.I have been learning a lot from you lately, as you know i am still a beginner, i would love to learn one more thing from you..i have a boolean field "completed", and i want django to automatically check it when balance_fees or remaining_fees is equal to zero, Here is  my model my template  Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 8:51 PMTo: Django usersSubject: Re: Help me with the view please Technically your Fee model is designed incorrectly. You should have separate models for 'fees' and 'fees_paid' where fee would have been the foreign key in 'fees_paid. Fee should have a property like annual fee etc for each student as fee may be different based on student discounts etc. Then when student pays the fees, fees should go in a separate transactional table i.e. 'fees paid'. In your scenario, does each row in fee table carries the annual/school fee? if so then yes summing them up will definitely cause incorrect figure. Here is what i would do if i don't change my models structure. views.py===def student_detail(request, pk):student = Student.objects.get(id=pk)# in your case pick the first record from fee_setfirst_record = student.fee_set.first()school_fees = first_record.school_feespaid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))balance_fees =  school_fees - paid_fees["total_paid_fees"]  context = {"student": student,   "paid_fees": paid_fees,   "school_fees": school_fees,   "balance_fees": balance_fees, } return render(request, "student_details.html", context) template===Student DetailStudent name: {{ student.name }}School fees: {{ school_fees }}Paid fees: {{ paid_fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Output:Student name: student1School fees: 10.0Paid fees: 35000.0Remaining fees: 65000.0 On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:Sorry for bothering you @coolguy, you’re the only person who seems to be nice to a Django beginner developer like me, and I would like to bother you one more timeYour solution for using methods in models is perfectly fineYou see I want school_fees to be a fixed amount, example $300So when a student pays more than once(student.fee_set), lets say this month student 1 pays $50 And another month pays $100 dollars, I want payments to added and subtracted from fixed schools_fees($300)Remainingfees to 

Re: Help me with the view please

2020-09-14 Thread coolguy
not sure what are you looking for... but based on your model setup... 
school fees is setup once so we picked it up from first object/record from 
table, while paid fees are collected quarterly or whatever means there will 
be more than one transaction in fee table. We have already calculated the 
"paid_fees" from fee table like this
>>>  
  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))

I definitely want to help as long as i know what you are looking for :)


On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:

> Thanks it has worked, but it doesn’t work with my total_paid_fees, I want 
> to be automatically checked when school_fees substracts summation of all 
> paid_fees, just like this solution you provided me with the last time
>
> first_record = student.fee_set.first()
>
>  school_fees = first_record.school_fees
>
>   paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
>balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Monday, September 14, 2020 9:09 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Its simple... in your fee models' save method check that 
> self.remaining_fees is zero then make self.completed field to true... I 
> added else clause in case if admin make changes to paid fees and after 
> changes student still has some dues.
>
>  
>
> def save(self, *args, **kwargs):
>
>  
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if self.remaining_fees == 0:
>
> self.completed = True
>
> else:
>
> self.completed = False
>
> 
>
> super().save(*args, **kwargs)
>
>  
>
> On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:
>
> Thank you brother @coolguy, I have put to work your latest solution and it 
> has worked like a charm.I have been learning a lot from you lately, as you 
> know i am still a beginner, i would love to learn one more thing from 
> you..i have a boolean field "completed", and i want django to automatically 
> check it when balance_fees or remaining_fees is equal to zero, 
>
> Here is  my model
>
>  my template
>
>  
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 8:51 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Technically your Fee model is designed incorrectly. You should have 
> separate models for 'fees' and 'fees_paid' where fee would have been the 
> foreign key in 'fees_paid. Fee should have a property like annual fee etc 
> for each student as fee may be different based on student discounts etc. 
> Then when student pays the fees, fees should go in a separate transactional 
> table i.e. 'fees paid'. In your scenario, does each row in fee table 
> carries the annual/school fee? if so then yes summing them up will 
> definitely cause incorrect figure.
>
>  
>
> Here is what i would do if i don't change my models structure.
>
>  
>
> views.py
>
> ===
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
> 
>
> *# in your case pick the first record from fee_set*
>
> first_record = student.fee_set.first()
>
> school_fees = first_record.school_fees
>
> 
>
> paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
> 
>
> balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
> context = {"student": student,
>
>"paid_fees": paid_fees,
>
>"school_fees": school_fees,
>
>"balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> template
>
> ===
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ school_fees }}
>
> Paid fees: {{ paid_fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Output:
>
> 
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 35000.0
>
> Remaining fees: 65000.0
>
>  
>
> On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com

RE: Help me with the view please

2020-09-14 Thread fadhil alex
Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs) On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:Thank you brother @coolguy, I have put to work your latest solution and it has worked like a charm.I have been learning a lot from you lately, as you know i am still a beginner, i would love to learn one more thing from you..i have a boolean field "completed", and i want django to automatically check it when balance_fees or remaining_fees is equal to zero, Here is  my model my template  Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 8:51 PMTo: Django usersSubject: Re: Help me with the view please Technically your Fee model is designed incorrectly. You should have separate models for 'fees' and 'fees_paid' where fee would have been the foreign key in 'fees_paid. Fee should have a property like annual fee etc for each student as fee may be different based on student discounts etc. Then when student pays the fees, fees should go in a separate transactional table i.e. 'fees paid'. In your scenario, does each row in fee table carries the annual/school fee? if so then yes summing them up will definitely cause incorrect figure. Here is what i would do if i don't change my models structure. views.py===def student_detail(request, pk):student = Student.objects.get(id=pk)# in your case pick the first record from fee_setfirst_record = student.fee_set.first()school_fees = first_record.school_feespaid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))balance_fees =  school_fees - paid_fees["total_paid_fees"]  context = {"student": student,   "paid_fees": paid_fees,   "school_fees": school_fees,   "balance_fees": balance_fees, } return render(request, "student_details.html", context) template===Student DetailStudent name: {{ student.name }}School fees: {{ school_fees }}Paid fees: {{ paid_fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Output:Student name: student1School fees: 10.0Paid fees: 35000.0Remaining fees: 65000.0 On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:Sorry for bothering you @coolguy, you’re the only person who seems to be nice to a Django beginner developer like me, and I would like to bother you one more timeYour solution for using methods in models is perfectly fineYou see I want school_fees to be a fixed amount, example $300So when a student pays more than once(student.fee_set), lets say this month student 1 pays $50 And another month pays $100 dollars, I want payments to added and subtracted from fixed schools_fees($300)Remainingfees to be $300 – (($50)+($100)) BUT what “ fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees'))” does is that it sums both paid fees school fees every time a student pays, I want only paid fees to added every time a student pays but not school fees   Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 4:27 AMTo: Django usersSubject: Re: Help me with the view please If i choose to go with your way of calculation, i would do this... def student_detail(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees')) balance_fees = fees["total_school_fees"] - fees["total_paid_fees"] context = {"student": student, "fees": fees, "balance_fees": balance_fees, } return render(request, "student_details.html", context) Template e.g.Student DetailStudent name: {{ student.name }}School fees: {{ fees.total_school_fees }}Paid fees: {{ fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Result:Student DetailStudent name:

Re: Help me with the view please

2020-09-14 Thread coolguy
Its simple... in your fee models' save method check that 
self.remaining_fees is zero then make self.completed field to true... I 
added else clause in case if admin make changes to paid fees and after 
changes student still has some dues.

def save(self, *args, **kwargs):
self.remaining_fees = self.school_fees - self.paid_fees
if self.remaining_fees == 0:
self.completed = True
else:
self.completed = False

super().save(*args, **kwargs)

On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:

> Thank you brother @coolguy, I have put to work your latest solution and 
> it has worked like a charm.I have been learning a lot from you lately, as 
> you know i am still a beginner, i would love to learn one more thing from 
> you..i have a boolean field "completed", and i want django to automatically 
> check it when balance_fees or remaining_fees is equal to zero, 
>
> Here is  my model
> [image: image.png]
>
>  my template
> [image: image.png]
>
>  
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 8:51 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Technically your Fee model is designed incorrectly. You should have 
> separate models for 'fees' and 'fees_paid' where fee would have been the 
> foreign key in 'fees_paid. Fee should have a property like annual fee etc 
> for each student as fee may be different based on student discounts etc. 
> Then when student pays the fees, fees should go in a separate transactional 
> table i.e. 'fees paid'. In your scenario, does each row in fee table 
> carries the annual/school fee? if so then yes summing them up will 
> definitely cause incorrect figure.
>
>  
>
> Here is what i would do if i don't change my models structure.
>
>  
>
> views.py
>
> ===
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
> 
>
> *# in your case pick the first record from fee_set*
>
> first_record = student.fee_set.first()
>
> school_fees = first_record.school_fees
>
> 
>
> paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
> 
>
> balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
> context = {"student": student,
>
>"paid_fees": paid_fees,
>
>"school_fees": school_fees,
>
>"balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> template
>
> ===
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ school_fees }}
>
> Paid fees: {{ paid_fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Output:
>
> 
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 35000.0
>
> Remaining fees: 65000.0
>
>  
>
> On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:
>
> Sorry for bothering you @coolguy, you’re the only person who seems to be 
> nice to a Django beginner developer like me, and I would like to bother you 
> one more time
>
> Your solution for using methods in models is perfectly fine
>
> You see I want school_fees to be a fixed amount, example $300
>
> So when a student pays more than once(student.fee_set), lets say this 
> month student 1 pays $50 
>
> And another month pays $100 dollars, I want payments to added and 
> subtracted from fixed schools_fees($300)
>
> Remainingfees to be $300 – (($50)+($100))
>
>  
>
> BUT what “ 
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))” 
> does is that it sums both paid fees school fees every time a student pays, 
> I want only paid fees to added every time a student pays but not school fees
>
>  
>
>  
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 4:27 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If i choose to go with your way of calculation, i would do this...
>
>  
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
>
> fees = student.fee_set.aggregate(total_paid

Re: Help me with the view please

2020-09-14 Thread coolguy
Its simple... in your fee models' save method check that 
self.remaining_fees is zero then make self.completed field to true..

def save(self, *args, **kwargs):
self.remaining_fees = self.school_fees - self.paid_fees
if self.remaining_fees == 0:
self.completed = True
super().save(*args, **kwargs)

On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:

> Thank you brother @coolguy, I have put to work your latest solution and 
> it has worked like a charm.I have been learning a lot from you lately, as 
> you know i am still a beginner, i would love to learn one more thing from 
> you..i have a boolean field "completed", and i want django to automatically 
> check it when balance_fees or remaining_fees is equal to zero, 
>
> Here is  my model
> [image: image.png]
>
>  my template
> [image: image.png]
>
>  
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 8:51 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Technically your Fee model is designed incorrectly. You should have 
> separate models for 'fees' and 'fees_paid' where fee would have been the 
> foreign key in 'fees_paid. Fee should have a property like annual fee etc 
> for each student as fee may be different based on student discounts etc. 
> Then when student pays the fees, fees should go in a separate transactional 
> table i.e. 'fees paid'. In your scenario, does each row in fee table 
> carries the annual/school fee? if so then yes summing them up will 
> definitely cause incorrect figure.
>
>  
>
> Here is what i would do if i don't change my models structure.
>
>  
>
> views.py
>
> ===
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
> 
>
> *# in your case pick the first record from fee_set*
>
> first_record = student.fee_set.first()
>
> school_fees = first_record.school_fees
>
> 
>
> paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
> 
>
> balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
> context = {"student": student,
>
>"paid_fees": paid_fees,
>
>"school_fees": school_fees,
>
>"balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> template
>
> ===
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ school_fees }}
>
> Paid fees: {{ paid_fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Output:
>
> 
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 35000.0
>
> Remaining fees: 65000.0
>
>  
>
> On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:
>
> Sorry for bothering you @coolguy, you’re the only person who seems to be 
> nice to a Django beginner developer like me, and I would like to bother you 
> one more time
>
> Your solution for using methods in models is perfectly fine
>
> You see I want school_fees to be a fixed amount, example $300
>
> So when a student pays more than once(student.fee_set), lets say this 
> month student 1 pays $50 
>
> And another month pays $100 dollars, I want payments to added and 
> subtracted from fixed schools_fees($300)
>
> Remainingfees to be $300 – (($50)+($100))
>
>  
>
> BUT what “ 
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))” 
> does is that it sums both paid fees school fees every time a student pays, 
> I want only paid fees to added every time a student pays but not school fees
>
>  
>
>  
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 4:27 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If i choose to go with your way of calculation, i would do this...
>
>  
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
>
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))
>
>  
>
> balance_fees = fees["total_school_fees"] - fees["total_paid_fees&qu

Re: Help me with the view please

2020-09-11 Thread coolguy
Technically your Fee model is designed incorrectly. You should have 
separate models for 'fees' and 'fees_paid' where fee would have been the 
foreign key in 'fees_paid. Fee should have a property like annual fee etc 
for each student as fee may be different based on student discounts etc. 
Then when student pays the fees, fees should go in a separate transactional 
table i.e. 'fees paid'. In your scenario, does each row in fee table 
carries the annual/school fee? if so then yes summing them up will 
definitely cause incorrect figure.

Here is what i would do if i don't change my models structure.

views.py
===
def student_detail(request, pk):
student = Student.objects.get(id=pk)

# in your case pick the first record from fee_set
first_record = student.fee_set.first()
school_fees = first_record.school_fees

paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))

balance_fees =  school_fees - paid_fees["total_paid_fees"] 

context = {"student": student,
   "paid_fees": paid_fees,
   "school_fees": school_fees,
   "balance_fees": balance_fees, }

return render(request, "student_details.html", context)

template
===

Student Detail
Student name: {{ student.name }}
School fees: {{ school_fees }}
Paid fees: {{ paid_fees.total_paid_fees }}
Remaining fees: {{ balance_fees }}


Output:


Student name: student1

School fees: 10.0

Paid fees: 35000.0

Remaining fees: 65000.0

On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:

> Sorry for bothering you @coolguy, you’re the only person who seems to be 
> nice to a Django beginner developer like me, and I would like to bother you 
> one more time
>
> Your solution for using methods in models is perfectly fine
>
> You see I want school_fees to be a fixed amount, example $300
>
> So when a student pays more than once(student.fee_set), lets say this 
> month student 1 pays $50 
>
> And another month pays $100 dollars, I want payments to added and 
> subtracted from fixed schools_fees($300)
>
> Remainingfees to be $300 – (($50)+($100))
>
>  
>
> BUT what “ 
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))” 
> does is that it sums both paid fees school fees every time a student pays, 
> I want only paid fees to added every time a student pays but not school fees
>
>  
>
>  
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 4:27 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If i choose to go with your way of calculation, i would do this...
>
>  
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
>
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))
>
>  
>
> balance_fees = fees["total_school_fees"] - fees["total_paid_fees"]
>
>  
>
> context = {"student": student, 
> "fees": fees, "balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> Template e.g.
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ fees.total_school_fees }}
>
> Paid fees: {{ fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Result:
>
> Student Detail
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 25000.0
>
> Remaining fees: 75000.0
>
> I hope this helps!
>
> On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for helping me @coolguy,but it seems I ran into another problem, 
> the school fees and remaining fees somehow sums together, I want students 
> to pay school fees in phases, i.e, first quarter, second etc, and I want 
> remaining fee to be the difference between the initial school fees which is 
> 100 and total fee paid.
>
> Thanks in advance
>
>  
>
> My views.py for student
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 11:58 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> I see now what you are asking...
>
>  
>
> I never do such calculations in views rather I create methods i

RE: Help me with the view please

2020-09-11 Thread fadhil alex
Sorry for bothering you @coolguy, you’re the only person who seems to be nice to a Django beginner developer like me, and I would like to bother you one more timeYour solution for using methods in models is perfectly fineYou see I want school_fees to be a fixed amount, example $300So when a student pays more than once(student.fee_set), lets say this month student 1 pays $50 And another month pays $100 dollars, I want payments to added and subtracted from fixed schools_fees($300)Remainingfees to be $300 – (($50)+($100)) BUT what “ fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees'))” does is that it sums both paid fees school fees every time a student pays, I want only paid fees to added every time a student pays but not school fees   Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 4:27 AMTo: Django usersSubject: Re: Help me with the view please If i choose to go with your way of calculation, i would do this... def student_detail(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees')) balance_fees = fees["total_school_fees"] - fees["total_paid_fees"] context = {"student": student, "fees": fees, "balance_fees": balance_fees, } return render(request, "student_details.html", context) Template e.g.Student DetailStudent name: {{ student.name }}School fees: {{ fees.total_school_fees }}Paid fees: {{ fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Result:Student DetailStudent name: student1School fees: 10.0Paid fees: 25000.0Remaining fees: 75000.0I hope this helps!On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 dex9...@gmail.com wrote:Thanks for helping me @coolguy,but it seems I ran into another problem, the school fees and remaining fees somehow sums together, I want students to pay school fees in phases, i.e, first quarter, second etc, and I want remaining fee to be the difference between the initial school fees which is 100 and total fee paid.Thanks in advance My views.py for studentSent from Mail for Windows 10 From: coolguySent: Tuesday, September 8, 2020 11:58 PMTo: Django usersSubject: Re: Help me with the view please I see now what you are asking... I never do such calculations in views rather I create methods in models.py to do so and call them in the template... Like what you could do is.. class Student(models.Model):name = models.CharField(max_length=200, null=True, blank=True)classroom = models.ForeignKey(Classroom,  _on_delete_=models.DO_NOTHING, blank=True, null=True) def __str__(self):return self.name     def get_total_fee(self):return sum(student.school_fees for student in self.fee_set.all()) def get_total_paid_fee(self):return sum(student.paid_fees for student in self.fee_set.all()) def get_remaining_fee(self):total_fee = self.get_total_fee()total_paid = self.get_total_paid_fee()return float(total_fee - total_paid) and in template you can call...{{ student.get_remaining_fee }}On Tuesday, September 8, 2020 at 1:35:56 PM UTC-4 dex9...@gmail.com wrote:Thank you for your help @coolguy..but my real problem lies in writing the code for “fee_remaining”, can you help me with that also..thanks Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 8, 2020 7:45 PMTo: Django usersSubject: Re: Help me with the view please In your return line of code, you are referring to context variable but I don't see you assigned any value to this context variable in your code.Or if you want to send three variables i.e. "fees", "total_fees" and "fee_remaining"... you need to send them separately like return render(request, 'website/students.html', {"fees": fees, "total_fees": total_fees, "fee_remaining": fee_remaining }) then use these variables on your students.html template.   On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com wrote:My Modelsclass Student(models.Model):name = models.CharField(max_length=200, null=True, blank=True)classroom = models.ForeignKey(‘Classroom’,_on_delete_=models.DO_NOTHING,blank=True, null=True)class Classroom(models.Model):name = models.CharField(max_length=40,blank=True, null=True)class Fee(models.Model):student = models.ForeignKey(Student, _on_delete_=models.CASCADE, null=True,)classroom = models.ForeignKey(Classroom, _on_delete_=models.CASCADE, null=True)school_fees = models.FloatField(default=100)paid_fees = models.FloatField(null=False)remaining_fees = models.FloatField(blank=True)completed = models.BooleanField(null=False, default=False)views.pydef student(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.all().order_by('-publish_date') total_fees = student.fee_set.all().filt

Re: Help me with the view please

2020-09-10 Thread coolguy
If i choose to go with your way of calculation, i would do this...

def student_detail(request, pk):
student = Student.objects.get(id=pk)
fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
total_school_fees=Sum('school_fees'))

balance_fees = fees["total_school_fees"] - fees["total_paid_fees"]

context = {"student": student, 
"fees": fees, "balance_fees": balance_fees, }

return render(request, "student_details.html", context)

Template e.g.

Student Detail
Student name: {{ student.name }}
School fees: {{ fees.total_school_fees }}
Paid fees: {{ fees.total_paid_fees }}
Remaining fees: {{ balance_fees }}


Result:
Student Detail

Student name: student1

School fees: 10.0

Paid fees: 25000.0

Remaining fees: 75000.0
I hope this helps!
On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 dex9...@gmail.com wrote:

> Thanks for helping me @coolguy,but it seems I ran into another problem, 
> the school fees and remaining fees somehow sums together, I want students 
> to pay school fees in phases, i.e, first quarter, second etc, and I want 
> remaining fee to be the difference between the initial school fees which is 
> 100 and total fee paid.
>
> Thanks in advance
>
>  
>
> My views.py for student
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 11:58 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> I see now what you are asking...
>
>  
>
> I never do such calculations in views rather I create methods in models.py 
> to do so and call them in the template...
>
>  
>
> Like what you could do is..
>
>  
>
> class Student(models.Model):
>
> name = models.CharField(max_length=200, null=True, blank=True)
>
> classroom = models.ForeignKey(Classroom,
>
>
>   on_delete=models.DO_NOTHING, blank=True, 
> null=True)
>
>  
>
> def __str__(self):
>
> return *self*.name
>
>  
>
> def get_total_fee(self):
>
> return sum(student.school_fees for student in *self*
> .fee_set.all())
>
>  
>
> def get_total_paid_fee(self):
>
> return sum(student.paid_fees for student in *self*.fee_set.all())
>
>  
>
> def get_remaining_fee(self):
>
> total_fee = *self*.get_total_fee()
>
> total_paid = *self*.get_total_paid_fee()
>
> return float(total_fee - total_paid)
>
>  
>
> and in template you can call...
>
> {{ student.get_remaining_fee }}
>
> On Tuesday, September 8, 2020 at 1:35:56 PM UTC-4 dex9...@gmail.com wrote:
>
> Thank you for your help @coolguy..but my real problem lies in writing the 
> code for “fee_remaining”, can you help me with that also..thanks
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 7:45 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> In your return line of code, you are referring to context variable but I 
> don't see you assigned any value to this context variable in your code.
>
> Or if you want to send three variables i.e. "fees", "total_fees" and 
> "fee_remaining"... you need to send them separately like
>
>  
>
> return render(request, 'website/students.html', {"fees": fees, 
> "total_fees": total_fees, "fee_remaining": fee_remaining })
>
>  
>
> then use these variables on your students.html template.  
>
>  
>
> On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> My Models
> class Student(models.Model):
> name = models.CharField(max_length=200, null=True, blank=True)
> classroom = models.ForeignKey(‘Classroom’,
> on_delete=models.DO_NOTHING,blank=True, null=True)
> class Classroom(models.Model):
> name = models.CharField(max_length=40,blank=True, null=True)
>
> class Fee(models.Model):
> student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True,)
> classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE, 
> null=True)
> school_fees = models.FloatField(default=100)
> paid_fees = models.FloatField(null=False)
> remaining_fees = models.FloatField(blank=True)
> completed = models.BooleanField(null=False, default=False)
>
> views.py
> def student(request, pk):
> student = Student.objects.get(id=pk)
>
> fees = student.fee_set.all().order_by('-publish_date') tot

Re: Help me with the view please

2020-09-10 Thread coolguy
Can you please share the template you are using.
You can send another context variable for remaining fee.

On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 dex9...@gmail.com wrote:

> Thanks for helping me @coolguy,but it seems I ran into another problem, 
> the school fees and remaining fees somehow sums together, I want students 
> to pay school fees in phases, i.e, first quarter, second etc, and I want 
> remaining fee to be the difference between the initial school fees which is 
> 100 and total fee paid.
>
> Thanks in advance
>
>  
>
> My views.py for student
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 11:58 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> I see now what you are asking...
>
>  
>
> I never do such calculations in views rather I create methods in models.py 
> to do so and call them in the template...
>
>  
>
> Like what you could do is..
>
>  
>
> class Student(models.Model):
>
> name = models.CharField(max_length=200, null=True, blank=True)
>
> classroom = models.ForeignKey(Classroom,
>
>
>   on_delete=models.DO_NOTHING, blank=True, 
> null=True)
>
>  
>
> def __str__(self):
>
> return *self*.name
>
>  
>
> def get_total_fee(self):
>
> return sum(student.school_fees for student in *self*
> .fee_set.all())
>
>  
>
> def get_total_paid_fee(self):
>
> return sum(student.paid_fees for student in *self*.fee_set.all())
>
>  
>
> def get_remaining_fee(self):
>
> total_fee = *self*.get_total_fee()
>
> total_paid = *self*.get_total_paid_fee()
>
> return float(total_fee - total_paid)
>
>  
>
> and in template you can call...
>
> {{ student.get_remaining_fee }}
>
> On Tuesday, September 8, 2020 at 1:35:56 PM UTC-4 dex9...@gmail.com wrote:
>
> Thank you for your help @coolguy..but my real problem lies in writing the 
> code for “fee_remaining”, can you help me with that also..thanks
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 7:45 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> In your return line of code, you are referring to context variable but I 
> don't see you assigned any value to this context variable in your code.
>
> Or if you want to send three variables i.e. "fees", "total_fees" and 
> "fee_remaining"... you need to send them separately like
>
>  
>
> return render(request, 'website/students.html', {"fees": fees, 
> "total_fees": total_fees, "fee_remaining": fee_remaining })
>
>  
>
> then use these variables on your students.html template.  
>
>  
>
> On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> My Models
> class Student(models.Model):
> name = models.CharField(max_length=200, null=True, blank=True)
> classroom = models.ForeignKey(‘Classroom’,
> on_delete=models.DO_NOTHING,blank=True, null=True)
> class Classroom(models.Model):
> name = models.CharField(max_length=40,blank=True, null=True)
>
> class Fee(models.Model):
> student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True,)
> classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE, 
> null=True)
> school_fees = models.FloatField(default=100)
> paid_fees = models.FloatField(null=False)
> remaining_fees = models.FloatField(blank=True)
> completed = models.BooleanField(null=False, default=False)
>
> views.py
> def student(request, pk):
> student = Student.objects.get(id=pk)
>
> fees = student.fee_set.all().order_by('-publish_date') total_fees = 
> student.fee_set.all().filter(student__id=pk) 
> .aggregate(sum=Sum('paid_fees', flat=True)['sum'] 
>
> fees_remaining = () 
>
> return render(request, 'website/students.html', context)  
>
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%40googlegroups.com?utm_

Re: Help me with the view please

2020-09-10 Thread coolguy
Since you didn't share the template screen shot i can't say what you are 
using there for remaining fee. Anyways, you are sending two context 
variables 'fees' and 'total_fees'... you can either calculate it on 
template {{ fees - total_fees }} or you can send another context variable 
from your view.

  

On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 dex9...@gmail.com wrote:

> Thanks for helping me @coolguy,but it seems I ran into another problem, 
> the school fees and remaining fees somehow sums together, I want students 
> to pay school fees in phases, i.e, first quarter, second etc, and I want 
> remaining fee to be the difference between the initial school fees which is 
> 100 and total fee paid.
>
> Thanks in advance
>
>  
>
> My views.py for student
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 11:58 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> I see now what you are asking...
>
>  
>
> I never do such calculations in views rather I create methods in models.py 
> to do so and call them in the template...
>
>  
>
> Like what you could do is..
>
>  
>
> class Student(models.Model):
>
> name = models.CharField(max_length=200, null=True, blank=True)
>
> classroom = models.ForeignKey(Classroom,
>
>
>   on_delete=models.DO_NOTHING, blank=True, 
> null=True)
>
>  
>
> def __str__(self):
>
> return *self*.name
>
>  
>
> def get_total_fee(self):
>
> return sum(student.school_fees for student in *self*
> .fee_set.all())
>
>  
>
> def get_total_paid_fee(self):
>
> return sum(student.paid_fees for student in *self*.fee_set.all())
>
>  
>
> def get_remaining_fee(self):
>
> total_fee = *self*.get_total_fee()
>
> total_paid = *self*.get_total_paid_fee()
>
> return float(total_fee - total_paid)
>
>  
>
> and in template you can call...
>
> {{ student.get_remaining_fee }}
>
> On Tuesday, September 8, 2020 at 1:35:56 PM UTC-4 dex9...@gmail.com wrote:
>
> Thank you for your help @coolguy..but my real problem lies in writing the 
> code for “fee_remaining”, can you help me with that also..thanks
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 7:45 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> In your return line of code, you are referring to context variable but I 
> don't see you assigned any value to this context variable in your code.
>
> Or if you want to send three variables i.e. "fees", "total_fees" and 
> "fee_remaining"... you need to send them separately like
>
>  
>
> return render(request, 'website/students.html', {"fees": fees, 
> "total_fees": total_fees, "fee_remaining": fee_remaining })
>
>  
>
> then use these variables on your students.html template.  
>
>  
>
> On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> My Models
> class Student(models.Model):
> name = models.CharField(max_length=200, null=True, blank=True)
> classroom = models.ForeignKey(‘Classroom’,
> on_delete=models.DO_NOTHING,blank=True, null=True)
> class Classroom(models.Model):
> name = models.CharField(max_length=40,blank=True, null=True)
>
> class Fee(models.Model):
> student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True,)
> classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE, 
> null=True)
> school_fees = models.FloatField(default=100)
> paid_fees = models.FloatField(null=False)
> remaining_fees = models.FloatField(blank=True)
> completed = models.BooleanField(null=False, default=False)
>
> views.py
> def student(request, pk):
> student = Student.objects.get(id=pk)
>
> fees = student.fee_set.all().order_by('-publish_date') total_fees = 
> student.fee_set.all().filter(student__id=pk) 
> .aggregate(sum=Sum('paid_fees', flat=True)['sum'] 
>
> fees_remaining = () 
>
> return render(request, 'website/students.html', context)  
>
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/djan

Re: Help me with the view please

2020-09-08 Thread coolguy
I see now what you are asking...

I never do such calculations in views rather I create methods in models.py 
to do so and call them in the template...

Like what you could do is...

class Student(models.Model):
name = models.CharField(max_length=200, null=True, blank=True)
classroom = models.ForeignKey(Classroom,
  on_delete=models.DO_NOTHING, blank=True, 
null=True)

def __str__(self):
return self.name

def get_total_fee(self):
return sum(student.school_fees for student in self.fee_set.all())

def get_total_paid_fee(self):
return sum(student.paid_fees for student in self.fee_set.all())

def get_remaining_fee(self):
total_fee = self.get_total_fee()
total_paid = self.get_total_paid_fee()
return float(total_fee - total_paid)

and in template you can call e.g
{% for student in students %}
{{ student.name }}: {{ student.get_remaining_fee }}

{% endfor %}


On Tuesday, September 8, 2020 at 1:35:56 PM UTC-4 dex9...@gmail.com wrote:

> Thank you for your help @coolguy..but my real problem lies in writing the 
> code for “fee_remaining”, can you help me with that also..thanks
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 7:45 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> In your return line of code, you are referring to context variable but I 
> don't see you assigned any value to this context variable in your code.
>
> Or if you want to send three variables i.e. "fees", "total_fees" and 
> "fee_remaining"... you need to send them separately like
>
>  
>
> return render(request, 'website/students.html', {"fees": fees, 
> "total_fees": total_fees, "fee_remaining": fee_remaining })
>
>  
>
> then use these variables on your students.html template.  
>
>  
>
> On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> My Models
> class Student(models.Model):
> name = models.CharField(max_length=200, null=True, blank=True)
> classroom = models.ForeignKey(‘Classroom’,
> on_delete=models.DO_NOTHING,blank=True, null=True)
> class Classroom(models.Model):
> name = models.CharField(max_length=40,blank=True, null=True)
>
> class Fee(models.Model):
> student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True,)
> classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE, 
> null=True)
> school_fees = models.FloatField(default=100)
> paid_fees = models.FloatField(null=False)
> remaining_fees = models.FloatField(blank=True)
> completed = models.BooleanField(null=False, default=False)
>
> views.py
> def student(request, pk):
> student = Student.objects.get(id=pk)
>
> fees = student.fee_set.all().order_by('-publish_date') total_fees = 
> student.fee_set.all().filter(student__id=pk) 
> .aggregate(sum=Sum('paid_fees', flat=True)['sum'] 
>
> fees_remaining = () 
>
> return render(request, 'website/students.html', context)  
>
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%40googlegroups.com?utm_medium=email_source=footer>
> .
>
>  
>

-- 
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/fa0084c8-5c21-4f46-82f1-23cbb8abe1can%40googlegroups.com.


Re: Help me with the view please

2020-09-08 Thread coolguy
I see now what you are asking...

I never do such calculations in views rather I create methods in models.py 
to do so and call them in the template...

Like what you could do is...

class Student(models.Model):
name = models.CharField(max_length=200, null=True, blank=True)
classroom = models.ForeignKey(Classroom,
  on_delete=models.DO_NOTHING, blank=True, 
null=True)

def __str__(self):
return self.name

def get_total_fee(self):
return sum(student.school_fees for student in self.fee_set.all())

def get_total_paid_fee(self):
return sum(student.paid_fees for student in self.fee_set.all())

def get_remaining_fee(self):
total_fee = self.get_total_fee()
total_paid = self.get_total_paid_fee()
return float(total_fee - total_paid)

and in template you can call...
{{ student.get_remaining_fee }}
On Tuesday, September 8, 2020 at 1:35:56 PM UTC-4 dex9...@gmail.com wrote:

> Thank you for your help @coolguy..but my real problem lies in writing the 
> code for “fee_remaining”, can you help me with that also..thanks
>
>  
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 7:45 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> In your return line of code, you are referring to context variable but I 
> don't see you assigned any value to this context variable in your code.
>
> Or if you want to send three variables i.e. "fees", "total_fees" and 
> "fee_remaining"... you need to send them separately like
>
>  
>
> return render(request, 'website/students.html', {"fees": fees, 
> "total_fees": total_fees, "fee_remaining": fee_remaining })
>
>  
>
> then use these variables on your students.html template.  
>
>  
>
> On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> My Models
> class Student(models.Model):
> name = models.CharField(max_length=200, null=True, blank=True)
> classroom = models.ForeignKey(‘Classroom’,
> on_delete=models.DO_NOTHING,blank=True, null=True)
> class Classroom(models.Model):
> name = models.CharField(max_length=40,blank=True, null=True)
>
> class Fee(models.Model):
> student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True,)
> classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE, 
> null=True)
> school_fees = models.FloatField(default=100)
> paid_fees = models.FloatField(null=False)
> remaining_fees = models.FloatField(blank=True)
> completed = models.BooleanField(null=False, default=False)
>
> views.py
> def student(request, pk):
> student = Student.objects.get(id=pk)
>
> fees = student.fee_set.all().order_by('-publish_date') total_fees = 
> student.fee_set.all().filter(student__id=pk) 
> .aggregate(sum=Sum('paid_fees', flat=True)['sum'] 
>
> fees_remaining = () 
>
> return render(request, 'website/students.html', context)  
>
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%40googlegroups.com?utm_medium=email_source=footer>
> .
>
>  
>

-- 
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/bc5f52f8-4b46-40c5-8ff1-9d05e3095346n%40googlegroups.com.


RE: Help me with the view please

2020-09-08 Thread fadhil alex
Thank you for your help @coolguy..but my real problem lies in writing the code for “fee_remaining”, can you help me with that also..thanks Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 8, 2020 7:45 PMTo: Django usersSubject: Re: Help me with the view please In your return line of code, you are referring to context variable but I don't see you assigned any value to this context variable in your code.Or if you want to send three variables i.e. "fees", "total_fees" and "fee_remaining"... you need to send them separately like return render(request, 'website/students.html', {"fees": fees, "total_fees": total_fees, "fee_remaining": fee_remaining }) then use these variables on your students.html template.   On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com wrote:My Modelsclass Student(models.Model):name = models.CharField(max_length=200, null=True, blank=True)classroom = models.ForeignKey(‘Classroom’,_on_delete_=models.DO_NOTHING,blank=True, null=True)class Classroom(models.Model):name = models.CharField(max_length=40,blank=True, null=True)class Fee(models.Model):student = models.ForeignKey(Student, _on_delete_=models.CASCADE, null=True,)classroom = models.ForeignKey(Classroom, _on_delete_=models.CASCADE, null=True)school_fees = models.FloatField(default=100)paid_fees = models.FloatField(null=False)remaining_fees = models.FloatField(blank=True)completed = models.BooleanField(null=False, default=False)views.pydef student(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.all().order_by('-publish_date') total_fees = student.fee_set.all().filter(student__id=pk) .aggregate(sum=Sum('paid_fees', flat=True)['sum'] fees_remaining = () return render(request, 'website/students.html', context)  -- 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/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%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/22CCCFA9-83C9-45FF-A2E7-413F1221FE49%40hxcore.ol.


Re: Help me with the view please

2020-09-08 Thread coolguy
In your return line of code, you are referring to context variable but I 
don't see you assigned any value to this context variable in your code.
Or if you want to send three variables i.e. "fees", "total_fees" and 
"fee_remaining"... you need to send them separately like

return render(request, 'website/students.html', {"fees": fees, 
"total_fees": total_fees, "fee_remaining": fee_remaining })

then use these variables on your students.html template.  


On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com wrote:

> My Models
> class Student(models.Model):
> name = models.CharField(max_length=200, null=True, blank=True)
> classroom = models.ForeignKey(‘Classroom’,
> on_delete=models.DO_NOTHING,blank=True, null=True)
> class Classroom(models.Model):
> name = models.CharField(max_length=40,blank=True, null=True)
>
> class Fee(models.Model):
> student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True,)
> classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE, 
> null=True)
> school_fees = models.FloatField(default=100)
> paid_fees = models.FloatField(null=False)
> remaining_fees = models.FloatField(blank=True)
> completed = models.BooleanField(null=False, default=False)
>
> views.py
> def student(request, pk):
> student = Student.objects.get(id=pk)
> fees = student.fee_set.all().order_by('-publish_date') total_fees = 
> student.fee_set.all().filter(student__id=pk) 
> .aggregate(sum=Sum('paid_fees', flat=True)['sum'] 
> fees_remaining = () 
> return render(request, 'website/students.html', context)  
>

-- 
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/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%40googlegroups.com.