Goodbye to Flake8 and PyLint: faster linting with Ruff
https://pythonspeed.com/articles/pylint-flake8-ruff/
/r/Python
https://redd.it/134zkvd
https://pythonspeed.com/articles/pylint-flake8-ruff/
/r/Python
https://redd.it/134zkvd
Python⇒Speed
Goodbye to Flake8 and PyLint: faster linting with Ruff
Ruff is a new linter that is vastly faster than PyLint and flake8—with many of the same checks.
Is there a way to integrate djdt results with tests?
The problem is djdt is not suitable to be active during tests because it significantly slows down the tests and is unnecessary. But this means that before committing, manual work has to be done to check for query efficiency which is a waste of time and is the whole purpose of tests. I'm thinking it would be nice if there's a way to set a maximum number of duplicate queries/any other metrics, for each view and have it checked by a test. It still would be inconvenient to enable djdt over the entire suite just to enable running just a few tests. How do you usually approach this? I'm using
/r/django
https://redd.it/135eqku
The problem is djdt is not suitable to be active during tests because it significantly slows down the tests and is unnecessary. But this means that before committing, manual work has to be done to check for query efficiency which is a waste of time and is the whole purpose of tests. I'm thinking it would be nice if there's a way to set a maximum number of duplicate queries/any other metrics, for each view and have it checked by a test. It still would be inconvenient to enable djdt over the entire suite just to enable running just a few tests. How do you usually approach this? I'm using
pytest + django test client + selenium fyi./r/django
https://redd.it/135eqku
Reddit
r/django on Reddit: Is there a way to integrate djdt results with tests?
Posted by u/shindigin - 3 votes and 2 comments
Introducing Grasshopper - An Open Source Python Library for Load Testing
https://innovation.alteryx.com/introducing-grasshopper-an-open-source-python-library-for-load-testing/
/r/Python
https://redd.it/135dcvs
https://innovation.alteryx.com/introducing-grasshopper-an-open-source-python-library-for-load-testing/
/r/Python
https://redd.it/135dcvs
Learning more about forward and reverse relationships.
Hello there, I am relatively new to django and came to know about forward and reverse relationships and wanted to craft a real world problem. Let's say I have the following classes
class User(AbstractBaseUser):
phone_number=models.CharField()
class ClientPackage(models.Model):
user = models.OnetoOneField(User,,related_name='user_client_package')
package = models.ForeignKey(Package,null=True, blank=True)
expiry_date = models.DateField()
class NotificationSettings(models.Model):
user = models.OneToOneField(User, related_name="user_notification_settings")
master = models.BooleanField(default=True, help_text='set false turn off notifications.')
Now to get all the user\_id and phone\_number of currently active users who have set the master control for notifications to be true I can do it in three ways
1. User.objects.filter(
user_client_package__pacakge__isnull=False,
user_client_package__expiry_date=date.today(),
user_notification_settings__master=True
).values_list('id', 'phone_number')
2. ClientPackage.objects.filter(
/r/django
https://redd.it/135k9s2
Hello there, I am relatively new to django and came to know about forward and reverse relationships and wanted to craft a real world problem. Let's say I have the following classes
class User(AbstractBaseUser):
phone_number=models.CharField()
class ClientPackage(models.Model):
user = models.OnetoOneField(User,,related_name='user_client_package')
package = models.ForeignKey(Package,null=True, blank=True)
expiry_date = models.DateField()
class NotificationSettings(models.Model):
user = models.OneToOneField(User, related_name="user_notification_settings")
master = models.BooleanField(default=True, help_text='set false turn off notifications.')
Now to get all the user\_id and phone\_number of currently active users who have set the master control for notifications to be true I can do it in three ways
1. User.objects.filter(
user_client_package__pacakge__isnull=False,
user_client_package__expiry_date=date.today(),
user_notification_settings__master=True
).values_list('id', 'phone_number')
2. ClientPackage.objects.filter(
/r/django
https://redd.it/135k9s2
Reddit
r/django on Reddit: Learning more about forward and reverse relationships.
Posted by u/RS2-CN3 - 4 votes and 1 comment
HTMX and Wagtail
Hi, has anyone used HTMX with wagtail, I’m very new to using both but I’ve dabbled with HTMX and would love to use it in a wagtail project.
How do HTMX requests work with wagtail page models? As the views are all handled for you.
How does the wagtail admin deal with editing the partial temples?
/r/djangolearning
https://redd.it/135o2m6
Hi, has anyone used HTMX with wagtail, I’m very new to using both but I’ve dabbled with HTMX and would love to use it in a wagtail project.
How do HTMX requests work with wagtail page models? As the views are all handled for you.
How does the wagtail admin deal with editing the partial temples?
/r/djangolearning
https://redd.it/135o2m6
Reddit
r/djangolearning on Reddit: HTMX and Wagtail
Posted by u/rob8624 - No votes and 1 comment
Streamsync: UI editor + Python
Hello everyone, I've just released Streamsync, an open-source, pip-installable data apps framework.
You build the UI using a visual editor, you write the backend code in Python. No HTML, JS or CSS required. It's an alternative to Streamlit and Dash.
https://i.redd.it/u4nazv8ohexa1.gif
https://github.com/ramedina86/streamsync
I'd really appreciate your feedback, thanks.
/r/Python
https://redd.it/135i584
Hello everyone, I've just released Streamsync, an open-source, pip-installable data apps framework.
You build the UI using a visual editor, you write the backend code in Python. No HTML, JS or CSS required. It's an alternative to Streamlit and Dash.
https://i.redd.it/u4nazv8ohexa1.gif
https://github.com/ramedina86/streamsync
I'd really appreciate your feedback, thanks.
/r/Python
https://redd.it/135i584
Convolutional Neural Network for Reverse Engineering
Hey everyone,
I created a project that uses machine learning for reverse engineering compiled binaries and identifing function boundaries: https://github.com/alonstern/function-identification.
The GitHub repo also includes a link to a TDS article with an explanation about the model.
Let me know what you think. Thanks!
/r/Python
https://redd.it/135jrz1
Hey everyone,
I created a project that uses machine learning for reverse engineering compiled binaries and identifing function boundaries: https://github.com/alonstern/function-identification.
The GitHub repo also includes a link to a TDS article with an explanation about the model.
Let me know what you think. Thanks!
/r/Python
https://redd.it/135jrz1
GitHub
GitHub - alonstern/function-identification: This project demonstrates how a convolutional neural network can be used to detect…
This project demonstrates how a convolutional neural network can be used to detect the boundaries of a function in compiled code - alonstern/function-identification
Automating the creation of Forms, Views, and Templates
I'm trying to use a couple loops to automatically build from the models each form, view, and url, and have a single template file render each list. I'm newer to python but I do know generating classes and functions like this is not best practice to say the least, however its something I wanted to try for my own project. What I'm interested in is playing with on the front end with my primary fact table and not the two dozen or so dimension tables, which may require frequent field additions or abstractions.
base/app/models.py
from django.db import models
from django.contrib.auth.models import User
#Create your models here.
class UserTypeModel(models.Model):
code = models.CharField(maxlength = 10, primarykey = True)
name = models.CharField(maxlength = 100, blank = False, unique = True)
def str(self):
return self.name
/r/djangolearning
https://redd.it/135v43t
I'm trying to use a couple loops to automatically build from the models each form, view, and url, and have a single template file render each list. I'm newer to python but I do know generating classes and functions like this is not best practice to say the least, however its something I wanted to try for my own project. What I'm interested in is playing with on the front end with my primary fact table and not the two dozen or so dimension tables, which may require frequent field additions or abstractions.
base/app/models.py
from django.db import models
from django.contrib.auth.models import User
#Create your models here.
class UserTypeModel(models.Model):
code = models.CharField(maxlength = 10, primarykey = True)
name = models.CharField(maxlength = 100, blank = False, unique = True)
def str(self):
return self.name
/r/djangolearning
https://redd.it/135v43t
Reddit
r/djangolearning on Reddit: Automating the creation of Forms, Views, and Templates
Posted by u/burmeisterN - 1 vote and 1 comment
Review My Python Chat Room Project with Flask and SocketIO
Hey everyone, I just completed a Python chat room project using the Flask web framework and SocketIO library for real-time communication. The front-end was implemented with JavaScript. I would love to get some feedback on my code and project, so I'm sharing it here!
Project Overview: The goal of this project is to create a chat room web application where users can chat with each other in real-time. Users can join different chat rooms and send messages to other users in the same room. The chat room interface is implemented with HTML, CSS, and JavaScript using the SocketIO library for real-time communication with the server.
https://github.com/Hajiub/flask\_chat\_room.git
/r/flask
https://redd.it/1365afd
Hey everyone, I just completed a Python chat room project using the Flask web framework and SocketIO library for real-time communication. The front-end was implemented with JavaScript. I would love to get some feedback on my code and project, so I'm sharing it here!
Project Overview: The goal of this project is to create a chat room web application where users can chat with each other in real-time. Users can join different chat rooms and send messages to other users in the same room. The chat room interface is implemented with HTML, CSS, and JavaScript using the SocketIO library for real-time communication with the server.
https://github.com/Hajiub/flask\_chat\_room.git
/r/flask
https://redd.it/1365afd
GitHub
GitHub - Hajiub/flask_chat_room: Welcome to our virtual hangout where code and conversation merge seamlessly. Explore our GitHub…
Welcome to our virtual hangout where code and conversation merge seamlessly. Explore our GitHub repo to join the fun and contribute to the community - GitHub - Hajiub/flask_chat_room: Welcome to ou...
Wednesday Daily Thread: Beginner questions
New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!
This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.
/r/Python
https://redd.it/1364mx7
New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!
This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.
/r/Python
https://redd.it/1364mx7
Discord
Join the Python Discord Server!
We're a large community focused around the Python programming language. We believe that anyone can learn to code. | 412982 members
url_for() generated dynamics link for routes and assets in js, css file?
so I want to request a route from js code which i am serving from static... is there no way to insert dynamically generated link in js code??
/r/flask
https://redd.it/13638ub
so I want to request a route from js code which i am serving from static... is there no way to insert dynamically generated link in js code??
/r/flask
https://redd.it/13638ub
Reddit
r/flask on Reddit: url_for() generated dynamics link for routes and assets in js, css file?
Posted by u/asking_for_a_friend0 - 1 vote and 1 comment
How should I send requests to another API using DRF?
Should I use requests built-in python library or there is a special instruments to send requests to another API in APIView class?
/r/djangolearning
https://redd.it/136d4kg
Should I use requests built-in python library or there is a special instruments to send requests to another API in APIView class?
/r/djangolearning
https://redd.it/136d4kg
Reddit
r/djangolearning on Reddit: How should I send requests to another API using DRF?
Posted by u/Tea-Stock - 2 votes and 6 comments
Wagtail CMS v5.0 released with Django 4.2 support, dark mode, SVG image support, customisable icons, always-on minimap and more
https://docs.wagtail.org/en/stable/releases/5.0.html
/r/django
https://redd.it/136h75q
https://docs.wagtail.org/en/stable/releases/5.0.html
/r/django
https://redd.it/136h75q
Reddit
r/django on Reddit: Wagtail CMS v5.0 released with Django 4.2 support, dark mode, SVG image support, customisable icons, always…
Posted by u/Dauros - 16 votes and no comments
Should I build Backend or Frontend first?
I'm using Django Rest Framework for the backend and React for the front-end.
Which should I build first for a Full-Stack project.
/r/django
https://redd.it/136lg76
I'm using Django Rest Framework for the backend and React for the front-end.
Which should I build first for a Full-Stack project.
/r/django
https://redd.it/136lg76
Reddit
r/django on Reddit: Should I build Backend or Frontend first?
Posted by u/Icy_Key19 - 3 votes and 12 comments
Best practice for model id/pk?
So I'm starting a new Django project, and I want to get this right.
What's the best practice for model IDs?
1.
2.
3. Just use the default auto-increment pk (i.e. not define any specific primary key field)
I'm leaning strongly towards 2, as I heard that it's impossible to get a collision, since UUID1 generates a UUID from timestamp.
Problem with 3 is that I might need to use it publicly, so sequential IDs are no bueno.
What is the best practice for this?
/r/django
https://redd.it/136c4qb
So I'm starting a new Django project, and I want to get this right.
What's the best practice for model IDs?
1.
id = models.UUIDField(default = uuid.uuid4, unique = True, primary_key = True)2.
id = models.UUIDField(default = uuid.uuid1, unique = True, primary_key = True)3. Just use the default auto-increment pk (i.e. not define any specific primary key field)
I'm leaning strongly towards 2, as I heard that it's impossible to get a collision, since UUID1 generates a UUID from timestamp.
Problem with 3 is that I might need to use it publicly, so sequential IDs are no bueno.
What is the best practice for this?
/r/django
https://redd.it/136c4qb
Reddit
r/django on Reddit: Best practice for model id/pk?
Posted by u/3kvn394 - 12 votes and 3 comments
[N] OpenLLaMA: An Open Reproduction of LLaMA
https://github.com/openlm-research/open_llama
> We train our models on the RedPajama dataset released by Together, which is a reproduction of the LLaMA training dataset containing over 1.2 trillion tokens. We follow the exactly same preprocessing steps and training hyperparameters as the original LLaMA paper, including model architecture, context length, training steps, learning rate schedule, and optimizer. The only difference between our setting and the original one is the dataset used: OpenLLaMA employs the RedPajama dataset rather than the one utilized by the original LLaMA.
/r/MachineLearning
https://redd.it/136exj2
https://github.com/openlm-research/open_llama
> We train our models on the RedPajama dataset released by Together, which is a reproduction of the LLaMA training dataset containing over 1.2 trillion tokens. We follow the exactly same preprocessing steps and training hyperparameters as the original LLaMA paper, including model architecture, context length, training steps, learning rate schedule, and optimizer. The only difference between our setting and the original one is the dataset used: OpenLLaMA employs the RedPajama dataset rather than the one utilized by the original LLaMA.
/r/MachineLearning
https://redd.it/136exj2
GitHub
GitHub - openlm-research/open_llama: OpenLLaMA, a permissively licensed open source reproduction of Meta AI’s LLaMA 7B trained…
OpenLLaMA, a permissively licensed open source reproduction of Meta AI’s LLaMA 7B trained on the RedPajama dataset - openlm-research/open_llama
Django security releases issued: 4.2.1, 4.1.9, and 3.2.19
https://www.djangoproject.com/weblog/2023/may/03/security-releases/
/r/django
https://redd.it/136k1gh
https://www.djangoproject.com/weblog/2023/may/03/security-releases/
/r/django
https://redd.it/136k1gh
Django Project
Django security releases issued: 4.2.1, 4.1.9, and 3.2.19
Posted by Mariusz Felisiak on May 3, 2023
Recommendations are not shown
**result.html**
`<!DOCTYPE html>`
`<html lang="en">`
`<head>`
`<meta charset="UTF-8">`
`<meta http-equiv="X-UA-Compatible" content="IE=edge">`
`<meta name="viewport" content="width=device-width, initial-scale=1.0">`
`<title>Result</title>`
`</head>`
`<body>`
`<h1>Result</h1>`
`<p id ="emotion">Emotion: {{ emotion }}</p>`
`<p id ="gender">Gender: {{ gender }}</p>`
`<button onclick="recommendation('{{ gender }}', '{{ emotion }}')">Recommendation</button>`
`<div id="suggested"></div>`
`<script>`
`window.onload = function() {`
`var gender = "{{ gender }}";`
`var emotion = "{{ emotion }}";`
`recommendation(gender, emotion);`
`document.getElementById("recommendBtn").addEventListener("click", function() {`
`recommendation(gender, emotion);`
`});`
`}`
`</script>`
`</body>`
`</html>`
[**app.py**](https://app.py)
`@app.route('/resultpage')`
`def resultpage():`
`gender = request.args.get('gender')`
`emotion = request.args.get('emotion')`
`return render_template('result.html', gender=gender, emotion=emotion)`
**app.js**
`function recommendation(gender, emotion){`
`var animePlaylist = '';`
`if(emotion == 'Angry'){`
`if(gender == 'Male'){`
`animePlaylist = 'https://myanimelist.net/anime/genre/36/Slice_of_Life';`
`}`
`else if(gender == 'Female'){`
`animePlaylist = 'https://myanimelist.net/anime/genre/1/Action';`
`}`
`}`
`else if(emotion
/r/flask
https://redd.it/136wsxg
**result.html**
`<!DOCTYPE html>`
`<html lang="en">`
`<head>`
`<meta charset="UTF-8">`
`<meta http-equiv="X-UA-Compatible" content="IE=edge">`
`<meta name="viewport" content="width=device-width, initial-scale=1.0">`
`<title>Result</title>`
`</head>`
`<body>`
`<h1>Result</h1>`
`<p id ="emotion">Emotion: {{ emotion }}</p>`
`<p id ="gender">Gender: {{ gender }}</p>`
`<button onclick="recommendation('{{ gender }}', '{{ emotion }}')">Recommendation</button>`
`<div id="suggested"></div>`
`<script>`
`window.onload = function() {`
`var gender = "{{ gender }}";`
`var emotion = "{{ emotion }}";`
`recommendation(gender, emotion);`
`document.getElementById("recommendBtn").addEventListener("click", function() {`
`recommendation(gender, emotion);`
`});`
`}`
`</script>`
`</body>`
`</html>`
[**app.py**](https://app.py)
`@app.route('/resultpage')`
`def resultpage():`
`gender = request.args.get('gender')`
`emotion = request.args.get('emotion')`
`return render_template('result.html', gender=gender, emotion=emotion)`
**app.js**
`function recommendation(gender, emotion){`
`var animePlaylist = '';`
`if(emotion == 'Angry'){`
`if(gender == 'Male'){`
`animePlaylist = 'https://myanimelist.net/anime/genre/36/Slice_of_Life';`
`}`
`else if(gender == 'Female'){`
`animePlaylist = 'https://myanimelist.net/anime/genre/1/Action';`
`}`
`}`
`else if(emotion
/r/flask
https://redd.it/136wsxg
MyAnimeList.net
Slice of Life - Anime - MyAnimeList.net
Trying to find Slice of Life anime? Discover more Slice of Life anime on MyAnimeList, the largest online anime and manga database in the world!
Textual 0.23.0 improves message handling
https://textual.textualize.io/blog/2023/05/03/textual-0230-improves-message-handling/
/r/Python
https://redd.it/136jf50
https://textual.textualize.io/blog/2023/05/03/textual-0230-improves-message-handling/
/r/Python
https://redd.it/136jf50
Textual Documentation
Textual - Textual 0.23.0 improves message handling
Textual is a TUI framework for Python, inspired by modern web development.
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!
This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.
/r/Python
https://redd.it/1373x63
Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!
This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.
/r/Python
https://redd.it/1373x63
Reddit
r/Python on Reddit: Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
Posted by u/Im__Joseph - No votes and no comments