Django agGrid
Hello r/django,
I'm new to Django and would like to get some advise on a project I'm working on.
My table returns a list of hotels with CRUD functionality via modal forms utilizing django forms. The problem is that scrolling is quite slow (overflow-auto was used to make the table scrollable). I intend to use agGrid to output the list, but it only accepts JSON response. Is it a bad idea to have a separate view for handling JSON response? Is it possible to just create an app using drf and have separate app for html views that output the forms and send the post to the view created from drf?
Here's the html table.
<tbody>
{% for hotel in hotels %}
<tr class="border-b dark:border-gray-700">
<th scope="row" class="px-4 py-2 font-medium text-gray-900 whitespace-nowrap dark:text-white">{{ hotel.name }}</th>
<td class="px-4 py-2 whitespace-nowrap">{{ hotel.rating }}</td>
/r/djangolearning
https://redd.it/13mytbu
Hello r/django,
I'm new to Django and would like to get some advise on a project I'm working on.
My table returns a list of hotels with CRUD functionality via modal forms utilizing django forms. The problem is that scrolling is quite slow (overflow-auto was used to make the table scrollable). I intend to use agGrid to output the list, but it only accepts JSON response. Is it a bad idea to have a separate view for handling JSON response? Is it possible to just create an app using drf and have separate app for html views that output the forms and send the post to the view created from drf?
Here's the html table.
<tbody>
{% for hotel in hotels %}
<tr class="border-b dark:border-gray-700">
<th scope="row" class="px-4 py-2 font-medium text-gray-900 whitespace-nowrap dark:text-white">{{ hotel.name }}</th>
<td class="px-4 py-2 whitespace-nowrap">{{ hotel.rating }}</td>
/r/djangolearning
https://redd.it/13mytbu
I want to build a chatbot with Openai API
Hello guys! Does someone have a tutorial or an example?
/r/flask
https://redd.it/13n0hly
Hello guys! Does someone have a tutorial or an example?
/r/flask
https://redd.it/13n0hly
Reddit
r/flask on Reddit: I want to build a chatbot with Openai API
Posted by u/Danteurd - No votes and 4 comments
This media is not supported in your browser
VIEW IN TELEGRAM
[R] Video Demo of “Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold”
https://redd.it/13mpxbw
@pythondaily
https://redd.it/13mpxbw
@pythondaily
Sunday Daily Thread: What's everyone working on this week?
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/13nd675
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/13nd675
Reddit
r/Python on Reddit: Sunday Daily Thread: What's everyone working on this week?
Posted by u/Im__Joseph - 1 vote and 2 comments
Python Infrastructure Status - PyPI new user and new project registrations temporarily suspended.
https://status.python.org/incidents/qy2t9mjjcc7g
/r/Python
https://redd.it/13n5o2d
https://status.python.org/incidents/qy2t9mjjcc7g
/r/Python
https://redd.it/13n5o2d
status.python.org
PyPI new user and new project registrations temporarily suspended.
Python Infrastructure's Status Page - PyPI new user and new project registrations temporarily suspended..
JIRA <3 Django ?
Is there a way to use JIRA as a bug-reporting system for the users of my Django app ? How can I do this integration ? If not - how is everyone handling bug reporting from user side for SaaS apps ?
/r/django
https://redd.it/13nk7mj
Is there a way to use JIRA as a bug-reporting system for the users of my Django app ? How can I do this integration ? If not - how is everyone handling bug reporting from user side for SaaS apps ?
/r/django
https://redd.it/13nk7mj
Reddit
r/django on Reddit: JIRA <3 Django ?
Posted by u/inner2021planet - 4 votes and 5 comments
Mastering Python Function Arguments: A Comprehensive Guide
https://neuronize.dev/mastering-python-function-arguments-a-comprehensive-guide
/r/Python
https://redd.it/13nhpss
https://neuronize.dev/mastering-python-function-arguments-a-comprehensive-guide
/r/Python
https://redd.it/13nhpss
Neuronize
Mastering Python Function Arguments: A Comprehensive Guide
Master Python function arguments: comprehensive guide on parameters, positional/keyword arguments, unpacking iterables, and using *args/**kwargs
Discover Awesome Python projects
www.awesomepython.org is an app with useful, hand-picked packages and libraries
Each project links to its GitHub repo and makes it easy to discover new trending projects, quality established projects and other statistics (e.g. that auto-gpt is growing by \~13k stars per week!)
screenshot
I posted this last year and have added a lot of new functionality since then: category filtering, similar libraries, pypi & arxiv links, an "importance" score (based on the OpenSSF criticality score), and many more useful libraries
It has many recently created libraries too, for example, it's got a comprehensive list of repos in the large language model/chatgpt category: www.awesomepython.org/?c=llm
The full list, code and json data is available on GitHub: https://github.com/dylanhogg/awesome-python
Package/library suggestions welcome, I hope you find it useful
/r/Python
https://redd.it/13nrf87
www.awesomepython.org is an app with useful, hand-picked packages and libraries
Each project links to its GitHub repo and makes it easy to discover new trending projects, quality established projects and other statistics (e.g. that auto-gpt is growing by \~13k stars per week!)
screenshot
I posted this last year and have added a lot of new functionality since then: category filtering, similar libraries, pypi & arxiv links, an "importance" score (based on the OpenSSF criticality score), and many more useful libraries
It has many recently created libraries too, for example, it's got a comprehensive list of repos in the large language model/chatgpt category: www.awesomepython.org/?c=llm
The full list, code and json data is available on GitHub: https://github.com/dylanhogg/awesome-python
Package/library suggestions welcome, I hope you find it useful
/r/Python
https://redd.it/13nrf87
Awesome Python
Awesome Python: find the best Python libraries
Hand-picked awesome Python libraries, organised by category
Simple flask get and post messenger
Hi there am new in flask and I want to create a Flask server that handles GET and POST requests. In this case, the server will wait for a specific GET request and won't respond until it receives a corresponding POST request. Once the POST request is received, the server will use the data from the POST request to respond to the pending GET request.
Simply put, the server waits for a POST request to arrive before answering a specific GET request with the data from the POST request
Look i make the script i ask if there more professional way to do it look
''from flask import Flask, request, jsonify
import threading
app = Flask(__name__)
pending_request = None
event = threading.Event()
@app.route('/data', methods=['GET', 'POST'])
def handle_data():
global pending_request
if request.method == 'GET':
event.wait() # Wait until the event is set (POST request received)
data = pending_request
pending_request = None
event.clear() # Reset the event for the next round
return jsonify({'status': 'Data received', 'data': data})
/r/flask
https://redd.it/13nle2r
Hi there am new in flask and I want to create a Flask server that handles GET and POST requests. In this case, the server will wait for a specific GET request and won't respond until it receives a corresponding POST request. Once the POST request is received, the server will use the data from the POST request to respond to the pending GET request.
Simply put, the server waits for a POST request to arrive before answering a specific GET request with the data from the POST request
Look i make the script i ask if there more professional way to do it look
''from flask import Flask, request, jsonify
import threading
app = Flask(__name__)
pending_request = None
event = threading.Event()
@app.route('/data', methods=['GET', 'POST'])
def handle_data():
global pending_request
if request.method == 'GET':
event.wait() # Wait until the event is set (POST request received)
data = pending_request
pending_request = None
event.clear() # Reset the event for the next round
return jsonify({'status': 'Data received', 'data': data})
/r/flask
https://redd.it/13nle2r
Reddit
r/flask on Reddit: Simple flask get and post messenger
Posted by u/Responsible_Snow_303 - 1 vote and 3 comments
Turn your Click CLI into a TUI with a two-line change
https://github.com/Textualize/trogon
/r/Python
https://redd.it/13nv4a7
https://github.com/Textualize/trogon
/r/Python
https://redd.it/13nv4a7
GitHub
GitHub - Textualize/trogon: Easily turn your Click CLI into a powerful terminal application
Easily turn your Click CLI into a powerful terminal application - Textualize/trogon
Serve static files with compression/decompression?
I have a flask app that will serve static swf and mp3 files. Some of them are ~25 each. They are served as a batch. What options do I have to speed up the transfer via compression on flask side and definition at the endpoint?
/r/flask
https://redd.it/13nzge5
I have a flask app that will serve static swf and mp3 files. Some of them are ~25 each. They are served as a batch. What options do I have to speed up the transfer via compression on flask side and definition at the endpoint?
/r/flask
https://redd.it/13nzge5
Reddit
r/flask on Reddit: Serve static files with compression/decompression?
Posted by u/Gunplexityyy - 2 votes and 6 comments
Most efficient way of using cursor connections
I have a database and have multiple endpoints where each endpoint makes a specific DB query of its own. Now if we open and close connections on each endpoint, that would be too resource heavy.
Is there a way where we can open a connection for each user once and let him visit all the endpoints without re-opening/closing cursors? Like so:
conn = connection.open()
@app.route('/')
def home():
# some db execution
@app.route('/new', methods='POST')
def new():
# some other db execution
# and then close the cursor once a user is not there any longer
or we need to open and close cursors on every endpoint?
If there is a library to do so, then too I would like to know how it is handling cursors
# Edit:
I just learned about connection pooling. That answers everything
/r/flask
https://redd.it/13mnpro
I have a database and have multiple endpoints where each endpoint makes a specific DB query of its own. Now if we open and close connections on each endpoint, that would be too resource heavy.
Is there a way where we can open a connection for each user once and let him visit all the endpoints without re-opening/closing cursors? Like so:
conn = connection.open()
@app.route('/')
def home():
# some db execution
@app.route('/new', methods='POST')
def new():
# some other db execution
# and then close the cursor once a user is not there any longer
or we need to open and close cursors on every endpoint?
If there is a library to do so, then too I would like to know how it is handling cursors
# Edit:
I just learned about connection pooling. That answers everything
/r/flask
https://redd.it/13mnpro
Reddit
r/flask on Reddit: Most efficient way of using cursor connections
Posted by u/lofi_thoughts - 2 votes and 2 comments
How do I avoid MySQL/SQLAlchemy connection timeouts on a production server?
I have a Flask application server running on A2Hosting. An SQLAlchemy engine is created upon application launch:
As a consequence, every day I'll be greeted with this error in my logs when I access the Website:
I deduce that this error is probably due to a connection timeout, although I cannot confirm this.
It's only mildly annoying because when I try my backend call again, everything proceeds as normal.
Obviously, it'd be nice if this didn't happen when the app is released to the public.
What should I do instead?
/r/flask
https://redd.it/13l8fw7
I have a Flask application server running on A2Hosting. An SQLAlchemy engine is created upon application launch:
engine = create_engine("mysql+pymysql://{}:{}@{}:{}/{}".format( db_uname, db_pswd, db_host, "3306", db_name))As a consequence, every day I'll be greeted with this error in my logs when I access the Website:
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")I deduce that this error is probably due to a connection timeout, although I cannot confirm this.
It's only mildly annoying because when I try my backend call again, everything proceeds as normal.
Obviously, it'd be nice if this didn't happen when the app is released to the public.
What should I do instead?
/r/flask
https://redd.it/13l8fw7
Reddit
r/flask on Reddit: How do I avoid MySQL/SQLAlchemy connection timeouts on a production server?
Posted by u/Comprehensive-Ad3963 - 2 votes and 7 comments
How to add another kernel to jupyter lite online notebook?
I am not a coder. I am just taking data science classes. I want to use Jupyter on my own. I have a problem. I want the python 3 kernel, but jupyter only has 2 other kernels. Im trying to import a module but the other 2 kernels don't have it. thanks.
/r/JupyterNotebooks
https://redd.it/13ocaxe
I am not a coder. I am just taking data science classes. I want to use Jupyter on my own. I have a problem. I want the python 3 kernel, but jupyter only has 2 other kernels. Im trying to import a module but the other 2 kernels don't have it. thanks.
/r/JupyterNotebooks
https://redd.it/13ocaxe
Reddit
r/JupyterNotebooks on Reddit: How to add another kernel to jupyter lite online notebook?
Posted by u/Disastrous-Field-906 - No votes and 1 comment
How can I have two 'static' folders for 2 containers (each running a flask app) behind the same reverse proxy?
I have a docker, with 3 containers. One running nginx and two python containers serving with uwsgi and each having a flask app.
Before only one of the python containers needed to access the /static/ folder but now they both need to but /static/ is mapped to one of them in nginx.conf. How can I make it so each python container can access their own static folder with :
{{ urlfor('static', filename='script.js') }}
this is the nginx.conf:
http {
server {
include uwsgiparams;
include mime.types;
servertokens off;
proxyhideheader X-Powered-By;
addheader Content-Security-Policy "default-src 'self' cdn.jsdelivr.net code.jquery.com; frame-ancestors 'self'; form-action 'self';";
addheader X-Frame-Options SAMEORIGIN;
addheader X-Content-Type-Options nosniff;
addheader Referrer-Policy "no-referrer";
addheader Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()";
/r/flask
https://redd.it/13od98c
I have a docker, with 3 containers. One running nginx and two python containers serving with uwsgi and each having a flask app.
Before only one of the python containers needed to access the /static/ folder but now they both need to but /static/ is mapped to one of them in nginx.conf. How can I make it so each python container can access their own static folder with :
{{ urlfor('static', filename='script.js') }}
this is the nginx.conf:
http {
server {
include uwsgiparams;
include mime.types;
servertokens off;
proxyhideheader X-Powered-By;
addheader Content-Security-Policy "default-src 'self' cdn.jsdelivr.net code.jquery.com; frame-ancestors 'self'; form-action 'self';";
addheader X-Frame-Options SAMEORIGIN;
addheader X-Content-Type-Options nosniff;
addheader Referrer-Policy "no-referrer";
addheader Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()";
/r/flask
https://redd.it/13od98c
Reddit
r/flask on Reddit: How can I have two 'static' folders for 2 containers (each running a flask app) behind the same reverse proxy?
Posted by u/Pickinanameainteasy - 1 vote and no comments
Monday Daily Thread: Project ideas!
Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, "The Big Book of Small Python Projects" which provides a list of projects and the code to make them work.
/r/Python
https://redd.it/13oakho
Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, "The Big Book of Small Python Projects" which provides a list of projects and the code to make them work.
/r/Python
https://redd.it/13oakho
Reddit
r/Python on Reddit: Monday Daily Thread: Project ideas!
Posted by u/Im__Joseph - 2 votes and no comments
Raspberry Pi Debuts a Code Editor for Young People: "Python is the preferred coding language for beginners (particularly young people), as it’s the most intuitive language utilized by professionals. For this reason, Raspberry Pi’s Code Editor uses Python (specifically the standard library and P5)."
https://www.reviewgeek.com/150725/raspberry-pi-debuts-a-code-editor-for-young-people/
/r/Python
https://redd.it/13o040f
https://www.reviewgeek.com/150725/raspberry-pi-debuts-a-code-editor-for-young-people/
/r/Python
https://redd.it/13o040f
Reviewgeek
Raspberry Pi Debuts a Code Editor for Young People
Teaching a child or a teenager to code can give them a sense of pride, or even put them on track for a career in technology. That’s why the Raspberry Pi Foundation is now launching its online Code Editor in beta. It’s a free and simple tool that lets you…
Cuid2 - Secure, collision-resistant ids optimized for horizontal scaling and performance. Next generation UUIDs.
I've just released v2.0.0 of my cuid2 python port. The original cuid2 package comes from JS world by ParallelDrive. They have a lot of the reasons to use Cuid2 posted in their repo, including
Secure: It's not feasible to guess the next id, existing valid ids, or learn anything about the referenced data from the id. Cuid2 uses multiple, independent entropy sources and hashes them with a security-audited, NIST-standard cryptographically secure hashing algorithm (Sha3).
Collision resistant: It's extremely unlikely to generate the same id twice (by default, you'd need to generate roughly 4,000,000,000,000,000,000 ids (sqrt(36^(24-1) 26) = 4.0268498e+18) to reach 50% chance of collision.
Horizontally scalable: Generate ids on multiple machines without coordination.
Offline-compatible: Generate ids without a network connection.
URL and name-friendly: No special characters.
Fast and convenient: No async operations. Won't introduce user-noticeable delays. Less than 5k, gzipped.
But not too fast: If you can hash too quickly you can launch parallel attacks to find duplicates or break entropy-hiding. For unique ids, the fastest runner loses the security race.
You can find the source code of my package here: https://github.com/gordon-code/cuid2
And install it with
When doing my own research on UUID replacements, I came across another of
/r/django
https://redd.it/13nyey6
I've just released v2.0.0 of my cuid2 python port. The original cuid2 package comes from JS world by ParallelDrive. They have a lot of the reasons to use Cuid2 posted in their repo, including
Secure: It's not feasible to guess the next id, existing valid ids, or learn anything about the referenced data from the id. Cuid2 uses multiple, independent entropy sources and hashes them with a security-audited, NIST-standard cryptographically secure hashing algorithm (Sha3).
Collision resistant: It's extremely unlikely to generate the same id twice (by default, you'd need to generate roughly 4,000,000,000,000,000,000 ids (sqrt(36^(24-1) 26) = 4.0268498e+18) to reach 50% chance of collision.
Horizontally scalable: Generate ids on multiple machines without coordination.
Offline-compatible: Generate ids without a network connection.
URL and name-friendly: No special characters.
Fast and convenient: No async operations. Won't introduce user-noticeable delays. Less than 5k, gzipped.
But not too fast: If you can hash too quickly you can launch parallel attacks to find duplicates or break entropy-hiding. For unique ids, the fastest runner loses the security race.
You can find the source code of my package here: https://github.com/gordon-code/cuid2
And install it with
$ pipx install cuid2
When doing my own research on UUID replacements, I came across another of
/r/django
https://redd.it/13nyey6
GitHub
GitHub - paralleldrive/cuid2: The most secure, collision-resistant ids optimized for horizontal scaling and performance.
The most secure, collision-resistant ids optimized for horizontal scaling and performance. - paralleldrive/cuid2
DRF views across multiple tables
I've written an API using DRF to help with tracking multiple deployments of an app with different configurations, so I have about half-a-dozen models with many-to-many relationships between each. Here's an example of one of my models:
class Package(models.Model):
engine = models.ForeignKey(Engine, on_delete=models.CASCADE)
ruleset = models.ForeignKey(Ruleset, on_delete=models.CASCADE)
configuration = models.ForeignKey(Configuration, on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
Each of the Engine, Ruleset and Configuration models has a name field. I was able to get the API running very quickly, the problem is that DRF expects that if I create a new package entry that I should supply the ID numbers for each of engine, ruleset and configuration. Is there a way I can allow the user / client to supply the name for each instead?
Similarly, when accessing in the browser, the view for Package just shows the ids of the other pieces and the form wants me to pick from a list of ids instead of names. Do I need to write a custom view and form myself to be able to see
/r/django
https://redd.it/13om7y0
I've written an API using DRF to help with tracking multiple deployments of an app with different configurations, so I have about half-a-dozen models with many-to-many relationships between each. Here's an example of one of my models:
class Package(models.Model):
engine = models.ForeignKey(Engine, on_delete=models.CASCADE)
ruleset = models.ForeignKey(Ruleset, on_delete=models.CASCADE)
configuration = models.ForeignKey(Configuration, on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
Each of the Engine, Ruleset and Configuration models has a name field. I was able to get the API running very quickly, the problem is that DRF expects that if I create a new package entry that I should supply the ID numbers for each of engine, ruleset and configuration. Is there a way I can allow the user / client to supply the name for each instead?
Similarly, when accessing in the browser, the view for Package just shows the ids of the other pieces and the form wants me to pick from a list of ids instead of names. Do I need to write a custom view and form myself to be able to see
/r/django
https://redd.it/13om7y0
Reddit
r/django on Reddit: DRF views across multiple tables
Posted by u/wolfson109 - No votes and 1 comment