Saturday, July 27, 2024

Re: Help deciding ORM VS raw SQL trade-off in Complex scenario

Talking about Ninja.

I am actually trying to figure out how I can distribute my crud APIs in seperate python modules (one per model ) and make a package in my app.

Then How all the routs can be imported in the project urls.py at once.

Any suggestions?

Regards.

On 7/14/24 21:35, Sam Brown wrote:
Im sure there are performance metrics out there to prove the ORM will not be the bottleneck. But I've never seen it slow things down when I've employed a timer on operation

Also, ive recently ran into some of the limitations of drf and am looking into moving to an api that can be less coupled with orm. Django-ninja looks promising. 

On Sat, Jul 13, 2024 at 9:15 PM Krishnakant Mane <kkproghub@gmail.com> wrote:
Hello.

I am seasoned SQLAlchemy user and quite good in node's sequelise ORM.

But I am new to the one with Django.So here's my situation.

I am developing an accounting (book keeping ) automation software service.

So there are accounting rules (Debit = Dr and credit = Cr) for double
entry book keeping.

Every transaction will have 2 or more amounts, at least 1 each for dr or
Cr.

These entries are called vouchers.

We also store retail bills, receipts and payments again all in different
tables.

But the bills and receipt&payment tables are connected to the voucher
table.

The software generates reports such as cash flow, meaning day's opening
balance, total Drs, total crs, and final closing balance (DRs - Crs).

then there are Profit and Loss as well as balance sheet reports.

All this needs a lot of aggregations (sum and counts ) and also joining
of invoice + voucher and recept&payment + voucher tables.

so here are my questions.

1: given the fact that I have created materialised views in Postgresql,
should I even care to model them and use the ORM syntax instead of raw
query?  What would perform better?

2: datasets are going to be huge some times in terms of shear rows (all
transactions aka vouchers ) or some times sum and count will be used in
complex queries on a huge dataset.

Again, should I rely on raw queries or will ORM plan the queries for me
better?  Should I instead create stored procedures and call them from my
REST API?

talking of which,

3: I am using Django REST Framework and serialising records is an option
to get json output.

Should I use it or just go with raw queries and convert output to JSON
as required?

Again performance is a question.

Tip, My team is very proficient in SQL and yours truely can modestly
call himself an expert in the same, so maintenance is not an issue here.

Regards.

Krishnakant.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/097a6e55-c30e-491e-bf43-86e4c672faa4%40gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALmEK1sEN%2BLjwcrT-7eYbQkrdkU2bynGehBo4BjvkW1NEBVUjQ%40mail.gmail.com.

Friday, July 26, 2024

how to keep django ninja APIs distributed in modules in an apis package?

Hello.

I have decided to use django ninja for its simplicity and performance.

However I have one specific confusion.

Suppose I have an app with a models.py, schemas.py and all my APIs in
one package called apis.

    Suppose in the apis package along with __init__.py I have
api_accounts.py, api_parties.py and api_bills.py with crud functions
decorated with respective get, post ... etc.

Now How all these APIs can be bound together in such a way that they can
be imported in my project's urls.py?

or will there be a differnt way of doing this?

Regards.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b5f215f2-3a5a-4daf-93c7-ca1f44058fe3%40gmail.com.

Wednesday, July 24, 2024

Django 5.1 release candidate 1 released

Details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2024/jul/24/django-51-rc1/

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BfOnFYZqVJPJVT0_M1O%3D9mt%3D%3Dwfpv3M-RRMzh%2Bb3uOD4xQE8g%40mail.gmail.com.

Monday, July 15, 2024

Re: ComboBox

Hey! Did you ever find a solution to this problem? I found this   https://github.com/trevoreyre/autocomplete/tree/master/packages/autocomplete-js   and it works well : I fill it with > 26,000 choices and it handles it better that anything else I have found.


On Sunday, June 5, 2022 at 4:58:07 AM UTC-5 Phil Parkin wrote:
Thanks for the responses. 
rgam - I appreciate what you are saying. I think it is roughly what I am doing now, but it is a bit clumsy in that  the user (of a financial application) will typically have a list of regular  customers to select from, and also may have other customers that are one-off, or infrequent which they will not want to clutter their options list with but still need to record against a transaction.
Ryan - thanks, the datalist looks like it might be right option. I will look at custom widgets.

All the best - Phil
On Wednesday, 1 June 2022 at 09:13:11 UTC+1 rgam...@gammascience.co.uk wrote:
Hi

If any arbitrary text is allowable, then at the model level I'd just use a CharField. I wouldn't add a choices= argument to the field unless is the value is strictly constrained to those choice as other test would then fail validation.

At the Form level, I'm not sure. I'd probably work just mirror what the frontend needed.

Does that help ?

On Tue, 2022-05-31 at 09:52 -0700, Phil Parkin wrote:
Hi all

I am converting a desktop application to Django web application. The desktop app uses comboboxes (editable dropdown/select). Is their any elegant way of applying the same functionality in Django? Stack Overflow etc. all seem to be about dropdown select lists only.

I can see ways of doing this with a Choicefield plus a separate Charfield, but is there a better way?

Thanks -Phil 

--
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/1b7836ae-e52e-4e35-aefc-739ce6f586d0n%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/268ca0a4-8d95-4560-9e93-eba6a77ce66an%40googlegroups.com.

Sunday, July 14, 2024

Re: Help deciding ORM VS raw SQL trade-off in Complex scenario

Hello,

On Sunday 14 July 2024 at 09:03:38 UTC+2 eric paul wrote:

In whatever way possible use the Django ORM for security purposes and also efficiency .

Offtopic: There are certain issues worth keeping in mind, even if you are using an ORM: https://www.elttam.com/blog/plormbing-your-django-orm/

Cheers,
ReynardSec
https://reynardsec.com/ 

On Sunday 14 July 2024 at 09:03:38 UTC+2 eric paul wrote:

In whatever way possible use the Django ORM for security purposes and also efficiency . I won't recommend to use Raw queries if you don't know what you are doing


On Sun, Jul 14, 2024, 7:34 AM Enock Deghost <enockd...@gmail.com> wrote:

🙄


On Sun, 14 Jul 2024, 6:15 am Krishnakant Mane, <kkpr...@gmail.com> wrote:
Hello.

I am seasoned SQLAlchemy user and quite good in node's sequelise ORM.

But I am new to the one with Django.So here's my situation.

I am developing an accounting (book keeping ) automation software service.

So there are accounting rules (Debit = Dr and credit = Cr) for double
entry book keeping.

Every transaction will have 2 or more amounts, at least 1 each for dr or
Cr.

These entries are called vouchers.

We also store retail bills, receipts and payments again all in different
tables.

But the bills and receipt&payment tables are connected to the voucher
table.

The software generates reports such as cash flow, meaning day's opening
balance, total Drs, total crs, and final closing balance (DRs - Crs).

then there are Profit and Loss as well as balance sheet reports.

All this needs a lot of aggregations (sum and counts ) and also joining
of invoice + voucher and recept&payment + voucher tables.

so here are my questions.

1: given the fact that I have created materialised views in Postgresql,
should I even care to model them and use the ORM syntax instead of raw
query?  What would perform better?

2: datasets are going to be huge some times in terms of shear rows (all
transactions aka vouchers ) or some times sum and count will be used in
complex queries on a huge dataset.

Again, should I rely on raw queries or will ORM plan the queries for me
better?  Should I instead create stored procedures and call them from my
REST API?

talking of which,

3: I am using Django REST Framework and serialising records is an option
to get json output.

Should I use it or just go with raw queries and convert output to JSON
as required?

Again performance is a question.

Tip, My team is very proficient in SQL and yours truely can modestly
call himself an expert in the same, so maintenance is not an issue here.

Regards.

Krishnakant.

--
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/097a6e55-c30e-491e-bf43-86e4c672faa4%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/019f7cda-12b8-4766-b8cb-6a6ed795b70cn%40googlegroups.com.

Re: Help deciding ORM VS raw SQL trade-off in Complex scenario

According to your scenario an accounting system is a more complex system that requires high performance. It can be written in any language but as the system grows some programming languages will experience performance issues python being one of them take a case like Dropbox which was originally written in python but because of python speeds and data handling limitations it led the team to introduce other languages (Go, Rust) . Since you've decided to go with Django then it's best you use raw queries and concurrency etc inorder to achieve high performance.It also comes down to your hardware and code practices . Take a look at the Django ledger repo an accounting system. About the API you can explore Graphql.


On Sun, Jul 14, 2024, 8:48 PM Krishnakant Mane <kkproghub@gmail.com> wrote:

Hi Eric.

Can you explain a bit more on the "performance " aspect you refered to?

I have already mentioned my scenario and given the case study which I am working on.

In that reference, how using the ORM will benefit more than raw queries working with materialised views?

Regarding security, I (and the team working on this ) are totally aware of the pitfalls and the way around them so that's out of the way.

Regards.

    

On 7/14/24 12:32, eric paul wrote:

In whatever way possible use the Django ORM for security purposes and also efficiency . I won't recommend to use Raw queries if you don't know what you are doing


On Sun, Jul 14, 2024, 7:34 AM Enock Deghost <enockdeghost@gmail.com> wrote:

🙄


On Sun, 14 Jul 2024, 6:15 am Krishnakant Mane, <kkproghub@gmail.com> wrote:
Hello.

I am seasoned SQLAlchemy user and quite good in node's sequelise ORM.

But I am new to the one with Django.So here's my situation.

I am developing an accounting (book keeping ) automation software service.

So there are accounting rules (Debit = Dr and credit = Cr) for double
entry book keeping.

Every transaction will have 2 or more amounts, at least 1 each for dr or
Cr.

These entries are called vouchers.

We also store retail bills, receipts and payments again all in different
tables.

But the bills and receipt&payment tables are connected to the voucher
table.

The software generates reports such as cash flow, meaning day's opening
balance, total Drs, total crs, and final closing balance (DRs - Crs).

then there are Profit and Loss as well as balance sheet reports.

All this needs a lot of aggregations (sum and counts ) and also joining
of invoice + voucher and recept&payment + voucher tables.

so here are my questions.

1: given the fact that I have created materialised views in Postgresql,
should I even care to model them and use the ORM syntax instead of raw
query?  What would perform better?

2: datasets are going to be huge some times in terms of shear rows (all
transactions aka vouchers ) or some times sum and count will be used in
complex queries on a huge dataset.

Again, should I rely on raw queries or will ORM plan the queries for me
better?  Should I instead create stored procedures and call them from my
REST API?

talking of which,

3: I am using Django REST Framework and serialising records is an option
to get json output.

Should I use it or just go with raw queries and convert output to JSON
as required?

Again performance is a question.

Tip, My team is very proficient in SQL and yours truely can modestly
call himself an expert in the same, so maintenance is not an issue here.

Regards.

Krishnakant.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/097a6e55-c30e-491e-bf43-86e4c672faa4%40gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA2jrmJ0TtbxmfXeSCq5S9p8XsrPjJBf6_gKMRY_MSuTagFt4Q%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALv%3Dr_nWJjrSk%3DLbFh-pfL5Ni%2B%2ByZu0qH%3DRU7o7mnpD-eJHcqw%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALv%3Dr_mgDtMtaoC-4mav0c79JgH1m-dRC_PL_GU9tVCV8rjypg%40mail.gmail.com.

Re: Help deciding ORM VS raw SQL trade-off in Complex scenario

Bro ,
Just go for it !

On Sun, 14 Jul, 2024, 22:58 Krishnakant Mane, <kkproghub@gmail.com> wrote:

I am looking into ninja too.

I guess I may be able to use SQLAlchemy seamlessly with it.

Regards.

On 7/14/24 21:35, Sam Brown wrote:
Im sure there are performance metrics out there to prove the ORM will not be the bottleneck. But I've never seen it slow things down when I've employed a timer on operation

Also, ive recently ran into some of the limitations of drf and am looking into moving to an api that can be less coupled with orm. Django-ninja looks promising. 

On Sat, Jul 13, 2024 at 9:15 PM Krishnakant Mane <kkproghub@gmail.com> wrote:
Hello.

I am seasoned SQLAlchemy user and quite good in node's sequelise ORM.

But I am new to the one with Django.So here's my situation.

I am developing an accounting (book keeping ) automation software service.

So there are accounting rules (Debit = Dr and credit = Cr) for double
entry book keeping.

Every transaction will have 2 or more amounts, at least 1 each for dr or
Cr.

These entries are called vouchers.

We also store retail bills, receipts and payments again all in different
tables.

But the bills and receipt&payment tables are connected to the voucher
table.

The software generates reports such as cash flow, meaning day's opening
balance, total Drs, total crs, and final closing balance (DRs - Crs).

then there are Profit and Loss as well as balance sheet reports.

All this needs a lot of aggregations (sum and counts ) and also joining
of invoice + voucher and recept&payment + voucher tables.

so here are my questions.

1: given the fact that I have created materialised views in Postgresql,
should I even care to model them and use the ORM syntax instead of raw
query?  What would perform better?

2: datasets are going to be huge some times in terms of shear rows (all
transactions aka vouchers ) or some times sum and count will be used in
complex queries on a huge dataset.

Again, should I rely on raw queries or will ORM plan the queries for me
better?  Should I instead create stored procedures and call them from my
REST API?

talking of which,

3: I am using Django REST Framework and serialising records is an option
to get json output.

Should I use it or just go with raw queries and convert output to JSON
as required?

Again performance is a question.

Tip, My team is very proficient in SQL and yours truely can modestly
call himself an expert in the same, so maintenance is not an issue here.

Regards.

Krishnakant.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/097a6e55-c30e-491e-bf43-86e4c672faa4%40gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALmEK1sEN%2BLjwcrT-7eYbQkrdkU2bynGehBo4BjvkW1NEBVUjQ%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f1a8a082-61c9-449c-9361-d1c8d77c0b07%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADg%2BKQth%3DNd593qVO09L%2Bh6GPobPswYO-%3DZDkeXkfZAuWxbR5A%40mail.gmail.com.