Django questions that I need answers to. I need to be a better coder. Thank you guys in advance.
re:
I see the new “Native connection pooling” feature released in Django 5.1
Question:
According to Django docs I only find this feature works with PostgreSQL. Is this true? Can this work with MariaDB(MySQL) products?
Based on my previous posts in this forum you can see that I’m trying to use several different queries thru a select input and I’m having issues with pagination losing it’s mind. I have tried the new
{% querystring %} template tag
and not working all the way. Really a total lack of a complete example(s) of usage. Even Django docs only shows partial coding (not all of us newbies are smart enough yet to work all this out without a great deal of time invested, exhausted). But I have also run into the need while fixing the pagination issue of needing to access the current query being used in other functions within views.py. It’s almost like Django / python is forcing you to create 1 big function or class that handles everything i.e.: displaying, editing, adding, deleting etc. I don’t feel this is right.
Question:
What is the best practice for this? 1 big function or class or many of them specific to each of the needs as outlined? Note: cannot readily find this in Django docs or python docs.
Question:
How do you use the current query=Model. Object… across other functions in views.py? I tried to create a global object type for this … crash and burn. Then I find myself creating spaghetti code. Must be a answer to this?
Question:
I read many many articles and everyone seems to have there own answer to “Using global vars”.
Others outright say “You a poor programmer if u use global vars” or local global vars…
“You get 16 times in your entire life when you can use global vars”. etc. etc…
So first off if that’s a no no then why is it available to use?
Case:
I use a .env file (as Django says to do) to store secret things i.e.: API keys, Django secret key, Database creds. So that blows away above listed statements .
I also use a local global var in my views.py to manage my ‘order by’ selections and ‘items per page’ for pagination. etc…
Please answer this conundrum.
I appreciate all the help I can get answering these questions.
Thank you.