Re: Volunteer wanted: convert Mathics Django from 1.x to 2.x or 3.x

2020-09-15 Thread Ogunsanya Opeyemi
Hi i would like to .

On Tuesday, September 15, 2020, rocky.bernst...@gmail.com <
rocky.bernst...@gmail.com> wrote:

> Mathics is a general-purpose computer algebra system (CAS). It is an
> open-source alternative to Mathematica. It is free both as in "free beer"
> and as in "freedom".
>
> With installation, it comes with a very simple Django web interface to
> enter expressions and show them. (There is also a Jupyter interface in the
> works as well as plain-old command line.)
>
> Mathics has had a long hiatus of inactivity, but we'd ike to bring it to
> life again. It was written in the Django 1.x era and it shoud be upgraded
> to Django 2.x or even better 3.x. Since the Django part isn't that involved
> I imagine it is a simple thing to do.
>
> Any volunteers?
>
> The git repository is at https://github.com/mathics/Mathics/
>
> Thanks.
>
> --
> 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/c2d319d6-44ef-4926-bb91-d63c3b8f2a37n%
> 40googlegroups.com
> 
> .
>


-- 
OGUNSANYA OPEYEMI

-- 
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/CABJxPrGJrKETGrQ5ZWnMQmzy_Yi1bV3UbAgGaod25PEwJ%3Ddu4A%40mail.gmail.com.


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 property like annual fee etc for each student as fee may be 

Re: HTML5 drag and drop: How does it really work?

2020-09-15 Thread Elliot
 

As part of the Javascript drop logic I am changing the status field of the 
form of the sending item to indicate where the player is going, A for slot 
A, B for slot B, or D for drop.  It won't help to change anything on the 
receiving side, because the item will not exist in the form submitted data.  
When the user hits the submit button following all the completed transfers, 
I will go thru each entry on the form and isolate the players with a letter 
in the status code.  I will then delete them from the initial slot and add 
them to either the A slot, B,   slot, or no slot if they are being dropped. 
 This allows for all dnd updates to be done on 1 trip to the server and 
allows the user to change their mind before submitting.

-- 
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/ca777cd6-30e4-4f07-b6c2-d8dedbb01531n%40googlegroups.com.


Re: HTML5 drag and drop: How does it really work?

2020-09-15 Thread coolguy
Are you saving these players in database with their present slot ids etc. 
they are in? It seems easy solution if we can update their present slot 
info after dnd in the database table and filter the templates based on the 
slot ids.


On Tuesday, September 15, 2020 at 2:23:17 PM UTC-4 Elliot wrote:

> Thanks Coolguy.  Your answer is the first one getting close to what I am 
> looking for.  I have a similar situation to the one you described.  I 
> have 2 timeslots slot A and Slot B.  Slot A might represent 10:00am on 
> 09/15 and slot B  11:00AM on 9/16.  These slots have been chosen from a 
> list of all time slots for the week.  The user goes down the list of all 
> time slots and selects a time for slot A and another for slot B.  This in 
> turn populates a list of all players in each slot.  The user may then 
> drag a player name from slot A to slot B or vice versa.  This works great 
> visually, but doesn't do anything else.
>
>  In the html each player in a slot is represented by a row in a table.  The 
> slot A table and the slot B table are each within their own div and part of 
> the same form.
>
>  So the form is something like this:
>
>  
>
>
>
>  ="id_Aplayerstable" name ="Aplayerstable" > 
>
>="Aid_tbody"  ondragover="allowdrop(event)" ondrop="drop(event)" 
> contenteditable ="true">
>
>   
>
> {% for player in Aplayers %}   
>
>  tabindex="0" id="{{forloop.counter0}}Aid_tr" style="width:100%;" 
> contenteditable ="true" draggable="true"  
>  
>   ondragstart="dragstart(event)"  >
>
> 
>
>   
> 
>  contenteditable ="true" > 
>
>   
>   
>  readonly value="{{player.status}}"
>   
>
> style="display:none; " 
>
>   
> 
>id="{{forloop.counter0}}Aid_playerid "name ="Aplayerid" 
> value="{{player.Player_id}}" 
>
>   
>   
>   style ="display: none;" contenteditable ="true"
>
>   
> 
>id="{{forloop.counter0}}Aid_username" name ="Ausername"   
>
>   
> 
>   readonly value="{{player.username}}" style="width: 
> 90%;text-align : center;  
>
>   
> 
> background-color:cornflowerblue;  color:white; border-style:groove; 
> border-color:yellow; border:medium;   
>   
> 
> bordercollapse:separate;" 
> draggable ="false" ondrop="drop(event)"  ondragover="allowdrop(event)"
>   
>  
>   contenteditable="true"  
>
>   
> 
> 
>
> 
> 
>
> {% endfor %}   
>
>   
>
> 
>
>
>
>  
>
>   
>
> same as Aplayers except for the "*B*" 
> replacing "*A*" ids and names
>
> .
>
> .
>
> .
>
>   
>
> 
>
> The method I am trying to use now is to use javascript to update the 
> status field as follows: 
>
>   status value '0': no change has been made
>
>   status value 'A':  row has been moved from "B" to "A"
>
>   status value 'B ': row has been moved from "B" to "A"
>
>   status value 'D': row has been deleted from list.  I 
> have an additional area to drop players who will be removed from their list 
> (will 

Filtering Display

2020-09-15 Thread dopej...@gmail.com
Please I want to add a filter to my django template that displays media 
files such that users can select what sort of file is displayed by 
selecting by file extension. Please whats the best way to achieve this?

-- 
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/88ba8617-173b-420e-b437-13ab47be9872n%40googlegroups.com.


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 
>
>  
>
> *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  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  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 

How Upload Image Html File To save DataBase

2020-09-15 Thread kkwaq...@gmail.com
*Problem :- I have Create table and add ImageField , i wanna upload_image 
Front-end  and save database.*.


html file: But Image Not save 
*I am upload using database*


[image: u.JPG]
*models.py*

[image: i.JPG]

Html Coding file
[image: j.JPG]

*urls.py*

[image: g.JPG]




-- 
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/7bcbd386-354a-40fd-87dc-2e9d83b11fa6n%40googlegroups.com.


Volunteer wanted: convert Mathics Django from 1.x to 2.x or 3.x

2020-09-15 Thread rocky.bernst...@gmail.com
Mathics is a general-purpose computer algebra system (CAS). It is an 
open-source alternative to Mathematica. It is free both as in "free beer" 
and as in "freedom". 

With installation, it comes with a very simple Django web interface to 
enter expressions and show them. (There is also a Jupyter interface in the 
works as well as plain-old command line.)

Mathics has had a long hiatus of inactivity, but we'd ike to bring it to 
life again. It was written in the Django 1.x era and it shoud be upgraded 
to Django 2.x or even better 3.x. Since the Django part isn't that involved 
I imagine it is a simple thing to do.

Any volunteers? 

The git repository is at https://github.com/mathics/Mathics/

Thanks.

-- 
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/c2d319d6-44ef-4926-bb91-d63c3b8f2a37n%40googlegroups.com.


Re: HTML5 drag and drop: How does it really work?

2020-09-15 Thread Elliot
 

Thanks Coolguy.  Your answer is the first one getting close to what I am 
looking for.  I have a similar situation to the one you described.  I have 
2 timeslots slot A and Slot B.  Slot A might represent 10:00am on 09/15 and 
slot B  11:00AM on 9/16.  These slots have been chosen from a list of all 
time slots for the week.  The user goes down the list of all time slots and 
selects a time for slot A and another for slot B.  This in turn populates a 
list of all players in each slot.  The user may then drag a player name 
from slot A to slot B or vice versa.  This works great visually, but 
doesn't do anything else.

 In the html each player in a slot is represented by a row in a table.  The 
slot A table and the slot B table are each within their own div and part of 
the same form.

 So the form is something like this:

 

   

 

  

  

{% for player in Aplayers %}   






  
 






  
  


  
  


  





{% endfor %}   

  



   

 

  

same as Aplayers except for the "*B*" 
replacing "*A*" ids and names

.

.

.

  



The method I am trying to use now is to use javascript to update the status 
field as follows: 

  status value '0': no change has been made

  status value 'A':  row has been moved from "B" to "A"

  status value 'B ': row has been moved from "B" to "A"

  status value 'D': row has been deleted from list.  I have 
an additional area to drop players who will be removed from their list 
(will not be playing in either time slot).

When the post is returned to python each unique field name appears in its 
own dictionary.  The form class I defined simply consists of 1 field which 
serves as a catchall for everything. The post data looks like this: 
AllPlayersData  The changes are done through script which you are doing at this time... 
> the changes would only be visual for user and would not impact the source 
> code.
>
> following may be irrelevant for you but i would add this here...
> Lets take an example of an online-course where instructor of the course 
> can make changes to the order number of the course-contents.. suppose dnd 
> functionality has been provided to him. When he shuffles the 
> course-contents, a new order number is assigned to each content accordingly 
> and persisted in database through a field setup for it in the model. In 
> this case also, there will be no changes in the source-code rather changes 
> will be saved in database and loaded when page is refreshed.
>
> On Monday, September 14, 2020 at 12:36:01 PM UTC-4 Elliot wrote:
>
>> I am familiar with the various events in building a dnd.  I am trying to 
>> find out what is supposed to happen to the HTML source when a drag and drop 
>> works. Can anyone explain this to me.? After an apparently successful drag 
>> and drop I see no changes to the underlying HTML. I have been using Django 
>> 3.0.10 and Python 3.8.1 and javascript. 
>>
>> If I do a "view source" after a dnd should the source code now reflect 
>> the changes made by the dnd?  Exactly what is supposed to happen?  I am not 
>> submitting any code because I just want to find out how it is supposed to 
>> work.
>>
>

-- 
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/e313d667-f19a-4c45-a557-69818e6ebd85n%40googlegroups.com.


XYZModel matching query does not exist

2020-09-15 Thread Jatin Agrawal
I am facing some issues while fixtures loading while running testcases. The 
error is 

app_name.models.company.CompanyModel.DoesNotExist: Problem installing 
fixture '/Users/xyz/Documents/temp/testdir/random/fixtures/product.json': 
XYZModel matching query does not exist.

1. Earlier, there was no issue while loading fixtures.
2. Testcases were running fine.
3. Not all testcases are breaking.
4. Only some testcases are throwing this error.
5. Fixture of XYZModel is valid and tried and tested by using the loaddata 
command.
6. FK of XYZModel instance in product.json is also valid.


Stuck with this problem last few hours.


Any help or suggestions would be appreciated.


Thanks
Jatin Agrawal

-- 
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/73b44bd5-91b1-4105-ba2a-fe65110f06f2n%40googlegroups.com.


Re: Change Date Formate

2020-09-15 Thread waqar khan
Thanks guys you code 100% work

On Tue, Sep 15, 2020 at 6:52 PM Niraj Panchasara 
wrote:

> Y for 
> m for mm
> d for dd
>
> as per you needed, try this out in html with django template code
>
> {{you_date_field|date:'d/m/Y'}}
>
>
> On Tuesday, September 15, 2020 at 4:29:41 PM UTC+5:30 mailto...@gmail.com
> wrote:
>
>> {{you_date_field|date:'Y-m-d'}}
>>
>>
>> On Tue, Sep 15, 2020 at 3:52 PM kkwaq...@gmail.com 
>> wrote:
>>
>>> How to change date format in django (mmdd to ddmm)
>>>
>>> [image: p.jpg]
>>> [image: p1.jpg]
>>> how to change like this dd/mm/
>>>
>>> --
>>> 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/fd9f1b17-cc30-43f9-9855-c7c5f68e7800n%40googlegroups.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Thanks & Regards
>>
>> Regards,
>> Danish
>>
> --
> 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/858d0719-4268-472e-b7c7-735c9bdc5f91n%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/CA%2B08CAOaumqqw6NRy2-gto5%3D01DT7RFaD_kTN0_Avc97Cc%2BT5g%40mail.gmail.com.


Re: Django as a back end for data as a service web service.

2020-09-15 Thread Ogunsanya Opeyemi
Django is suitable

On Tuesday, September 15, 2020, Hukum Gosain <
np03a180...@heraldcollege.edu.np> wrote:

> Hello everyone,
> I am planning to develop a system that can handle more than 1000 of
> request concurrently and also can be used for real time activities like
> video calls , texting and more at the same time. what might be the
> efficient way to develop this system, is django suitable for me or will be
> there any problem if i developed this system on django or is there any
> other python3 framework for me to work on in this scenario.
>
> --
> 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/2ddd2c78-be3b-4af7-b92f-266b09d541afn%
> 40googlegroups.com
> 
> .
>


-- 
OGUNSANYA OPEYEMI

-- 
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/CABJxPrHyGva1RmvjRbcCnHx4_eMdzdaNR_o8CFOn_3GCfkZpXw%40mail.gmail.com.


Re: DatabaseRouter, add on runtime add new items to db.connections

2020-09-15 Thread Anton Melser
There appear to be relatively few references to this sort of thing peppered 
about the net, like this ancient stackoverflow 
post 
https://stackoverflow.com/questions/6585373/django-multiple-and-dynamic-databases,
 
the below email, or the now long abandoned db router mentioned below. 

Is there a "why this is completely unsupported and we won't answer any 
questions about it" post from one of the Django Masters somewhere? I also 
really want to do this... (actually am doing it but the dynamic dbs aren't 
managed by django, and I would really like them to be...). If it is a 
reasonable thing to do, is there some place with good advice on how to go 
about it? Thanks!

Le jeudi 23 février 2017 à 19:58:53 UTC+8, Matthieu Guffroy a écrit :

> Hello,
>
> We are using in our system for more than 2 years now, a specific 
> DatabaseRouter allowing us to use multiple databases depending on which 
> clients is connecting.
> It appears now, that the databases lists start to be really big, and that 
> it becomes bad to be forced to re-deploy our backend to add a new database 
> in the settings.
>
> So we add the configurations in a specific database, and add to our 
> middleware that was previously just setting the database to use in function 
> of the request, the ability to load dynamically new database configurations.
> With a function like this :
>
> from django.db import connections
> def add_db_connection(system_id, name, user, password, host, protocol):
> connections.databases[system_id] = {
> 'ENGINE': 'django.db.backends.' + protocol,
> 'NAME': name,
> 'USER': user,
> 'PASSWORD': password,
> 'HOST': host,
> 'CONN_MAX_AGE': 0
> }
>
> It appears we don't seams to be firsts to edit dynamically this, as it is 
> also the way works this extension : 
> https://github.com/ambitioninc/django-dynamic-db-router
>
> But before we put our new code in production, as we doesn't have found 
> some clear indication about if we can or if we cannot edit 
> django.db.connections in the documentation. We will be more confident, if 
> someone involved in django development can give us it's feedback about this 
> way of making things and if it's the recommended way ? or if their is a 
> better way ?
>
> Thanks a lot, for all you feedback,
>
> Matthieu
>

-- 
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/b9f60727-30ae-4844-88e1-e4e030060c5bn%40googlegroups.com.


Queries vs Serializers

2020-09-15 Thread Gs_1001

Hey,

I previously worked with an organization which had it's back-end 
implemented using Django. The developers there with did not use the 
serializers most of the time, I think i must mention that the code base had 
evolved for the past 4-5 years and the data requested in the APIs was quite 
complex (not just from one Model)

Most of the data that was required was queried from the database, stored in 
a dictionary and sent back as json. Though in most of the tutorials and 
documentation the data that is sent back through the APIs is using 
serializers to get it serialized.

Documentation:
1. Query(id=pk)
2. User Serializer
3. Send back

What I did:
1. Query(id=pk) [even for a queryset]
2. Insert into a dictionary
3. Send back
What is the difference and which one is better ?

Also not using serializers helped us quite well with "separation of 
concern" in terms of:
1. End user views
2. Business Logic
3. Database Accesses

How does it work out using serializers ?
Any kind of help is appreciated 

-- 
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/68f74fcd-6c94-43ec-b57c-bfc18878c9e8n%40googlegroups.com.


Using Getstream with Django

2020-09-15 Thread 'alan_mo...@yahoo.com.au' via Django users
Hi All! I'm very keen to use the feeds and chat 'Getstream' python-django 
packages, but I'm finding the tutorials on the company website assume a bit 
too much knowledge for me - my 'first' career was as an economist, and I'm 
currently retooling with python in my fifties! Does anybody know of 
additional third-party tutorials/youtube videos etc that I could take a 
look at?  Any advice at all would be very much appreciated.

-- 
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/b390eb22-d9a1-45bc-956c-ed1d1c928f16n%40googlegroups.com.


Django as a back end for data as a service web service.

2020-09-15 Thread Hukum Gosain
Hello everyone,
I am planning to develop a system that can handle more than 1000 of request 
concurrently and also can be used for real time activities like  video 
calls , texting and more at the same time. what might be the efficient way 
to develop this system, is django suitable for me or will be there any 
problem if i developed this system on django or is there any other python3 
framework for me to work on in this scenario. 

-- 
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/2ddd2c78-be3b-4af7-b92f-266b09d541afn%40googlegroups.com.


Re: Change Date Formate

2020-09-15 Thread Niraj Panchasara
Hi 
in your html file try to set like below
{your_date_reference | date: "Y-m-d" } 

Thanks
On Tuesday, September 15, 2020 at 3:51:42 PM UTC+5:30 kkwaq...@gmail.com 
wrote:

> How to change date format in django (mmdd to ddmm)  
>
> [image: p.jpg]
> [image: p1.jpg]
> how to change like this dd/mm/
>

-- 
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/0097df42-cbfd-4989-9cd3-004180ffa8a3n%40googlegroups.com.


Re: Change Date Formate

2020-09-15 Thread Niraj Panchasara
 Y for 
m for mm
d for dd

as per you needed, try this out in html with django template code

{{you_date_field|date:'d/m/Y'}}


On Tuesday, September 15, 2020 at 4:29:41 PM UTC+5:30 mailto...@gmail.com 
wrote:

> {{you_date_field|date:'Y-m-d'}}
>
>
> On Tue, Sep 15, 2020 at 3:52 PM kkwaq...@gmail.com  
> wrote:
>
>> How to change date format in django (mmdd to ddmm)  
>>
>> [image: p.jpg]
>> [image: p1.jpg]
>> how to change like this dd/mm/
>>
>> -- 
>> 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/fd9f1b17-cc30-43f9-9855-c7c5f68e7800n%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Thanks & Regards 
>   
> Regards, 
> Danish
>

-- 
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/858d0719-4268-472e-b7c7-735c9bdc5f91n%40googlegroups.com.


Re: Change Date Formate

2020-09-15 Thread Mohammad Ahshan Danish
{{you_date_field|date:'Y-m-d'}}


On Tue, Sep 15, 2020 at 3:52 PM kkwaq...@gmail.com 
wrote:

> How to change date format in django (mmdd to ddmm)
>
> [image: p.jpg]
> [image: p1.jpg]
> how to change like this dd/mm/
>
> --
> 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/fd9f1b17-cc30-43f9-9855-c7c5f68e7800n%40googlegroups.com
> 
> .
>


-- 
Thanks & Regards

Regards,
Danish

-- 
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/CAPQdaF0sjiB3Bbyc5TW32%2BSVUfAv%2Bt36XbGJcVcorDVmXmuoUg%40mail.gmail.com.


Change Date Formate

2020-09-15 Thread kkwaq...@gmail.com
How to change date format in django (mmdd to ddmm)  

[image: p.jpg]
[image: p1.jpg]
how to change like this dd/mm/

-- 
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/fd9f1b17-cc30-43f9-9855-c7c5f68e7800n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-15 Thread Mislav Jurić
Thank you for your suggestion. I will use the username, as it is unique as 
well.

Best,
Mislav

Dana ponedjeljak, 14. rujna 2020. u 19:45:36 UTC+2 korisnik coolguy napisao 
je:

> If i had to stick to your code then i would save the file with 
> instance.username. username is available and folder would be readable as 
> well.
>
> However, as i mentioned in my last reply and seems you agreed, 
> save/register the employee and then have employee upload the picture.
>
> On Monday, September 14, 2020 at 8:20:21 AM UTC-4 mislav@gmail.com 
> wrote:
>
>> What I can do is first register the employee via a register form, then 
>> once he logs in ask him/her for the profile picture. *Can I do that this 
>> way? *
>>
>> If I do it this way, I don't have to change my model in any way.
>>
>> Dana nedjelja, 13. rujna 2020. u 18:11:18 UTC+2 korisnik coolguy napisao 
>> je:
>>
>>> not sure about the purpose of showing that example in Django 
>>> documentation while its comments are clear that "object will not have been 
>>> saved to the database yet, so if it uses the default AutoField, *it 
>>> might not yet have a value for its primary key field*."
>>>
>>> so that's the reason for having None with file path.
>>>
>>> In this approach what i can see is to save the employee first without 
>>> file and then edit and select the file.
>>>
>>> I would not use this approach and rather keep it simple as followed:
>>>
>>> photo = models.ImageField(upload_to='employee/%Y/%m/%d/', blank=True)
>>>
>>> On Sunday, September 13, 2020 at 5:41:18 AM UTC-4 mislav@gmail.com 
>>> wrote:
>>>
 Hey coolguy,

 thanks for responding. After I changed that line as you suggested that 
 error is solved, *but when I add the user through the admin interface, 
 I get None as the ID* (the folder that gets created in the 
 */media/users* is titled *None*). I'm not sure if this is expected 
 behavior.

 I haven't added the registration or the login yet, so maybe the ID gets 
 a value when someone is actually registering.

 Let me know.

 Best,
 Mislav

 Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao 
 je:

> I wanted to see your model to understand but i realized after my last 
> post that you are using "instance.user.id" while your employee 
> instance does not have user field. (had to go somewhere urgently) >>> 
> return "employees/media/users/{0}/profile_picture.{1}".format(
> instance.user.id, extension)  
>
> change it as follow and remove user from it.
> return "employees/media/users/{0}/profile_picture.{1}".format(
> instance.id , extension)  
>
> It should work...
>
> On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 
> mislav@gmail.com wrote:
>
>> coolguy here is the complete Employee model:
>>
>> class Employee(models.Model): #TODO: Double-check this
>> username = models.CharField(max_length=50, unique=True)
>> email = models.EmailField()
>> password = models.CharField(max_length=50)
>> first_name = models.CharField(max_length=150)
>> last_name = models.CharField(max_length=100)
>> website = models.URLField(max_length=200, blank=True)
>>
>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>> blank=True, null=True)
>> 
>> def __str__(self):
>> return str(self.first_name) + str(self.last_name)
>>
>> *Why do I need the foreign key to User in the first place?* I don't 
>> recall seing the foreign key to User in any one of the tutorials.
>> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy 
>> napisao je:
>>
>>> Please share the complete employee model. It seems you are missing 
>>> User foreign key in it.
>>>
>>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 
>>> mislav@gmail.com wrote:
>>>
 Hey guys,

 I have the following code in models.py file in one of my apps:

 def get_upload_path(instance, filename):
 extension = filename.split('.')[-1]
 return "employees/media/users/{0}/profile_picture.{1}".format(
 instance.user.id, extension)

 class Employee(models.Model):
 # some attributes here
 profile_picture = models.ImageField(upload_to=get_upload_path, 
 blank=True, null=True)

 I am getting the following error when I try to add an Employee via 
 the admin interface:

 AttributeError at /admin/employees/employee/add/

 'Employee' object has no attribute 'user'

 *I don't know where this error is stemming from.* I took the 
 get_upload_path function from the official Django FIleField 
 documentation 
 

Re: I've got two apps in my project and each one should have different authentication model. How do achieve this?

2020-09-15 Thread Mislav Jurić
Hey there,

could you elaborate on

*Just connect with User model the fields that are needed*

If I do it like I did in my first app (via *OneToOneField* to *User* from 
*django.contrib.auth.models*), then I will have the fields *first_name* and 
*last_name*, which I won't use.

Could you elaborate?

Best,
Mislav

Dana ponedjeljak, 14. rujna 2020. u 18:47:14 UTC+2 korisnik 
hanz...@gmail.com napisao je:

> You can actually just extend it like the First app.
> 1. Create new Model for Second App authentication.
> 2. Just connect with User model the fields that are needed, the rest you 
> can add it on the new Model
>
> It could be the one of the easy ways.
> Thanks
>
> On Mon, Sep 14, 2020 at 11:00 PM Mislav Jurić  
> wrote:
>
>> Hey guys,
>>
>> as the title says, I've got two apps in my project and each one should 
>> have different authentication model.
>>
>> My first app just extends the User class, which I have done following the 
>> instructions here 
>> .
>>  
>> However, my second app should have a custom User class (with just the 
>> username, email and password) and I have read the instructions here 
>> ,
>>  
>> but those instructions imply that I would have to change the configuration 
>> of my project, which I don't want, because my first app uses the default 
>> User class and just extends it.
>>
>> I deleted my database and am starting fresh.
>>
>> *How do I do this?* Do I change the project-wide setting as described 
>> here 
>> ,
>>  
>> add the class *User(AbstractUser)* to both of my apps's *models.py* 
>> files and then in my second app create a new user class based on my needs 
>> (i.e. *MyUser(User)*)?
>>
>> Best,
>> Mislav
>>
>> -- 
>> 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/CABTqP_F%3DV1spho7D78QqqfaCVKdUhuPGL1s3wdxdc9okubHKjg%40mail.gmail.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9c6a21aa-3716-44e2-b24a-3966173d32e9n%40googlegroups.com.


Re: Environment Variables for Django Secret Key etc On Windows 10 and Heroku

2020-09-15 Thread dum dum
without any quotes.

[image: image.png]



On Tue, Sep 15, 2020 at 5:10 AM coolguy 
wrote:

> Did you input the variable value under single quote or without it?
>
> e.g. ''
>
> On Saturday, September 12, 2020 at 12:35:29 PM UTC-4 hanz...@gmail.com
> wrote:
>
>> Yes, I've seen so many tutorials. I did the same thing, and didn't work.
>> I believe there is something wrong with my Django Project. I don't know
>> what it is.
>> Still tinkering.
>>
>>
>> On Sat, Sep 12, 2020 at 9:38 PM Mbah Victor 
>> wrote:
>>
>>> Have you try googling your problem
>>>
>>> Victor
>>>
>>> On Sat, Sep 12, 2020, 9:34 AM dum dum  wrote:
>>>
 I tried to put my Django Secret Key in Environment Variables.

 SECRET_KEY = os.environ.get('SECRET_KEY')

 I did save the SECRET_KEY on env var windows 10 like this
 [image: image.png]


 When I tried to py manage.py runserver, I got this error

 django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must 
 not be empty.

 I followed this

 https://stackoverflow.com/questions/19681102/my-django-secret-key-is-in-an-environment-variable-but-i-cant-do-syncdb

 But no idea with the solution..

 At this point, strange thing even occurred, I tried to py manage.py
 without any SECRET_KEY on my Env Var on windows 10, and just leaving
   SECRET_KEY = os.environ.get('SECRET_KEY')
 in my settings.py.

 I got no error.

 Strange.. But when I deployed it on heroku, it says the same error like
 this
 django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting
 must not be empty.

 Is anyone here experienced the same stuck like me? Please kindly
 advise. Thanks

 --
 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/CANV3w%3DYdb3SuiC7KYrkN4bfieQx-fQxhm%2BPeMLpxJDWubVbwyA%40mail.gmail.com
 
 .

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CANTsAyc%3D%3DBLN7a0_c8rYd%3DsLHyWq78CHxAQr6Sa_PMcqtP7Cwg%40mail.gmail.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/11d60767-06d3-4d4c-8435-10151e5726cdn%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/CANV3w%3DYfmW4HTKVNdbkXKn5iNAd5%3DMt1OtLY60i%3DBni3yHSANw%40mail.gmail.com.


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 be $300 – (($50)+($100)) BUT what “ fees =