Django and SOLID principles
I'm studying traditional software development best practices and also trying to tie up with what I do at work (building APIs).
If I take a look at Django's Model class, it doesn't seem to me to follow S of SOLID (it has validate() and save() methods, which means it has too many responsibilites apart from just defining model). Do you agree with me here? It seems that the framework is not written to follow SOLID. Does it follow some kind of other philosophy? It's hard for me to understand what's best practice when even the giant in the industry (e.g. Django) doesn't follow it...
/r/django
https://redd.it/1hdidm0
I'm studying traditional software development best practices and also trying to tie up with what I do at work (building APIs).
If I take a look at Django's Model class, it doesn't seem to me to follow S of SOLID (it has validate() and save() methods, which means it has too many responsibilites apart from just defining model). Do you agree with me here? It seems that the framework is not written to follow SOLID. Does it follow some kind of other philosophy? It's hard for me to understand what's best practice when even the giant in the industry (e.g. Django) doesn't follow it...
/r/django
https://redd.it/1hdidm0
Reddit
From the django community on Reddit
Explore this post and more from the django community
I am sharing Python & Data Science courses on YouTube
Hello, I wanted to share that I am sharing free courses and projects on my YouTube Channel. I have more than 200 videos and I created playlists for Python and Data Science. I am leaving the playlist link below, have a great day!
Python Data Science Full Courses & Projects -> https://youtube.com/playlist?list=PLTsu3dft3CWiow7L7WrCd27ohlra\_5PGH&si=6WUpVwXeAKEs4tB6
Python Tutorials -> https://youtube.com/playlist?list=PLTsu3dft3CWgJrlcs\_IO1eif7myukPPKJ&si=fYIz2RLJV1dC6nT5
/r/Python
https://redd.it/1hdygzz
Hello, I wanted to share that I am sharing free courses and projects on my YouTube Channel. I have more than 200 videos and I created playlists for Python and Data Science. I am leaving the playlist link below, have a great day!
Python Data Science Full Courses & Projects -> https://youtube.com/playlist?list=PLTsu3dft3CWiow7L7WrCd27ohlra\_5PGH&si=6WUpVwXeAKEs4tB6
Python Tutorials -> https://youtube.com/playlist?list=PLTsu3dft3CWgJrlcs\_IO1eif7myukPPKJ&si=fYIz2RLJV1dC6nT5
/r/Python
https://redd.it/1hdygzz
YouTube
Data Science Full Courses & Projects
Check out the "Data Science Full Courses & Projects" playlist, your go-to spot for diving deep into Data Analysis, Data Visualization, and Machine Learning. ...
How to navigate through file tree using Jinja's `url_for`?
I apologize if I'm asking at a slightly unrelated subreddit. I'll delete the post of if suggested.
Hi all, I'm having trouble making my web app to read static `.css` using jinja's `url_for()`. My backend is Flask but I think Jinja is commonly used too in Django so I'm hoping to find more suggestions here.
The HTML fails to read this stylesheet. I'm going describe how the project files are structured followed by the content of each files.
**Project structure**
Below is the file structure tree:
coolest_app/
├── __init__.py
└── pages/
├── __init__.py
├── templates/
│ ├── base.html
└── static/
└── styles/
└── base.cssmain.py
**File contents**
There are in total 5 files in total within this project. But, I'm only giving the content of 4 files only since the `.css` file content is irrelevant.
a. [`main.py`](http://main.py) file
/r/django
https://redd.it/1he3ne1
I apologize if I'm asking at a slightly unrelated subreddit. I'll delete the post of if suggested.
Hi all, I'm having trouble making my web app to read static `.css` using jinja's `url_for()`. My backend is Flask but I think Jinja is commonly used too in Django so I'm hoping to find more suggestions here.
The HTML fails to read this stylesheet. I'm going describe how the project files are structured followed by the content of each files.
**Project structure**
Below is the file structure tree:
coolest_app/
├── __init__.py
└── pages/
├── __init__.py
├── templates/
│ ├── base.html
└── static/
└── styles/
└── base.cssmain.py
**File contents**
There are in total 5 files in total within this project. But, I'm only giving the content of 4 files only since the `.css` file content is irrelevant.
a. [`main.py`](http://main.py) file
/r/django
https://redd.it/1he3ne1
Reddit
From the django community on Reddit
Explore this post and more from the django community
Imposter Syndrome
hello everyone!
i hope you're all doing well. as a final year computer science student and aspiring backend engineer, i've been working with django and drf for a while now. however, i've reached a point where i feel stuck and unsure about my next steps.
if anyone has advice, project ideas, or knows of open-source projects i can contribute to, i'd really appreciate it. any guidance on improving my skills would be incredibly helpful.
thank you all in advance!
/r/django
https://redd.it/1he50zz
hello everyone!
i hope you're all doing well. as a final year computer science student and aspiring backend engineer, i've been working with django and drf for a while now. however, i've reached a point where i feel stuck and unsure about my next steps.
if anyone has advice, project ideas, or knows of open-source projects i can contribute to, i'd really appreciate it. any guidance on improving my skills would be incredibly helpful.
thank you all in advance!
/r/django
https://redd.it/1he50zz
Reddit
From the django community on Reddit
Explore this post and more from the django community
Feedback - Cyberbro - Analyze observable (IP, hash, domain) with ease - (CTI Cybersecurity project)
Hello there,
I am a junior cybersecurity engineer and I am developing an open source project in Python Flask and HTML.
Any feedback would be appreciated on the code structure, even if it actually works I think there are many improvements to be made (OOP, classes, I/O, MultiThread, MultiProcessing?).
I would be really glad to have a real Python programmer giving me even small pieces of advice to improve the project.
This project is a simple application that extracts your IoCs from garbage input (using regex) and checks their reputation using multiple services.
It is mainly Inspired by existing projects Cybergordon and IntelOwl.
I am convinced that this project is useful for SOC analysts or CTI professionnals (I use it daily for my job, and my company took interest for it).
**Features**
* **Effortless Input Handling**: Paste raw logs, IoCs, or fanged IoCs, and let our regex parser do the rest.
* **Multi-Service Reputation Checks**: Verify observables (IP, hash, domain, URL) across multiple services like VirusTotal, AbuseIPDB, IPInfo, Spur\[.\]us, IP Quality Score, MDE, Google Safe Browsing, Shodan, Abusix, Phishtank, ThreatFox, Github, Google...
* **Detailed Reports**: Generate comprehensive reports with advanced search and filter options.
* **High Performance**: Leverage multithreading for faster processing.
* **Automated Observable Pivoting**: Automatically pivot on domains, URL and
/r/Python
https://redd.it/1he1r6i
Hello there,
I am a junior cybersecurity engineer and I am developing an open source project in Python Flask and HTML.
Any feedback would be appreciated on the code structure, even if it actually works I think there are many improvements to be made (OOP, classes, I/O, MultiThread, MultiProcessing?).
I would be really glad to have a real Python programmer giving me even small pieces of advice to improve the project.
This project is a simple application that extracts your IoCs from garbage input (using regex) and checks their reputation using multiple services.
It is mainly Inspired by existing projects Cybergordon and IntelOwl.
I am convinced that this project is useful for SOC analysts or CTI professionnals (I use it daily for my job, and my company took interest for it).
**Features**
* **Effortless Input Handling**: Paste raw logs, IoCs, or fanged IoCs, and let our regex parser do the rest.
* **Multi-Service Reputation Checks**: Verify observables (IP, hash, domain, URL) across multiple services like VirusTotal, AbuseIPDB, IPInfo, Spur\[.\]us, IP Quality Score, MDE, Google Safe Browsing, Shodan, Abusix, Phishtank, ThreatFox, Github, Google...
* **Detailed Reports**: Generate comprehensive reports with advanced search and filter options.
* **High Performance**: Leverage multithreading for faster processing.
* **Automated Observable Pivoting**: Automatically pivot on domains, URL and
/r/Python
https://redd.it/1he1r6i
Reddit
From the Python community on Reddit: Feedback - Cyberbro - Analyze observable (IP, hash, domain) with ease - (CTI Cybersecurity…
Explore this post and more from the Python community
Backend development
Which one study for backend development python Django can be useful??
/r/djangolearning
https://redd.it/1hdwjhl
Which one study for backend development python Django can be useful??
/r/djangolearning
https://redd.it/1hdwjhl
Reddit
From the djangolearning community on Reddit
Explore this post and more from the djangolearning community
Speeds up the query of a database with a lot of data
Hello everyone
I am working on an Oauth2 project App 1, one has a model company with 20 fields, when the user creates for example 20,000 company, when I created App 2 which can introspect App 1 and the model company , it takes 5 minutes for my request to return the companies to me and create or update them if they exist, I however used blinkcreate and blinkupdate when it is a new company, the others I update company by company is where the query takes a lot of time...
I also tried to overwrite the data received on the existing one, but my database or the Django ORM refuses because the foreight key already exists
Do you have any solutions when I update a list to do one by one and come update all at once?
Thanks to you
/r/django
https://redd.it/1he5055
Hello everyone
I am working on an Oauth2 project App 1, one has a model company with 20 fields, when the user creates for example 20,000 company, when I created App 2 which can introspect App 1 and the model company , it takes 5 minutes for my request to return the companies to me and create or update them if they exist, I however used blinkcreate and blinkupdate when it is a new company, the others I update company by company is where the query takes a lot of time...
I also tried to overwrite the data received on the existing one, but my database or the Django ORM refuses because the foreight key already exists
Do you have any solutions when I update a list to do one by one and come update all at once?
Thanks to you
/r/django
https://redd.it/1he5055
Reddit
From the django community on Reddit
Explore this post and more from the django community
Deploy Flask App
Hi everyone, I'm new to web app development and have created a Flask-based application that requests data from a PostgreSQL database, which is then updated on a Vanilla JS-based frontend.
Currently, the application is running on my local Windows environment, and want to publish it so it can be accessed by everyone on the internet. I'm finding it challenging to choose the right path and tools.
My company has a Windows server on Azure. Should deploy the app on an server, or is there a simpler, better approach? Any documentation or tutorials on the recommended deployment path would be very helpful.
/r/flask
https://redd.it/1hed4l9
Hi everyone, I'm new to web app development and have created a Flask-based application that requests data from a PostgreSQL database, which is then updated on a Vanilla JS-based frontend.
Currently, the application is running on my local Windows environment, and want to publish it so it can be accessed by everyone on the internet. I'm finding it challenging to choose the right path and tools.
My company has a Windows server on Azure. Should deploy the app on an server, or is there a simpler, better approach? Any documentation or tutorials on the recommended deployment path would be very helpful.
/r/flask
https://redd.it/1hed4l9
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Django DRF serializers best practices
👋Hi everyone, I'm new to Django Rest Framework, I've been wondering about whether I should use two different ModelSerializers, one for read and the other for write, I hope it's clear, if not then just enlighten me with the best practices of drf serializers for a scalable, and to add on top of that, I have a post model which requires different fields for read and write.
Thanks in advance🙏
/r/django
https://redd.it/1heewq6
👋Hi everyone, I'm new to Django Rest Framework, I've been wondering about whether I should use two different ModelSerializers, one for read and the other for write, I hope it's clear, if not then just enlighten me with the best practices of drf serializers for a scalable, and to add on top of that, I have a post model which requires different fields for read and write.
Thanks in advance🙏
/r/django
https://redd.it/1heewq6
Reddit
From the django community on Reddit
Explore this post and more from the django community
Sunday Daily Thread: What's everyone working on this week?
# Weekly Thread: What's Everyone Working On This Week? 🛠️
Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
## How it Works:
1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.
## Guidelines:
Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.
## Example Shares:
1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a noscript to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
/r/Python
https://redd.it/1heg422
# Weekly Thread: What's Everyone Working On This Week? 🛠️
Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
## How it Works:
1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.
## Guidelines:
Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.
## Example Shares:
1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a noscript to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
/r/Python
https://redd.it/1heg422
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
Flask-JWT-Extended and "Invalid crypto padding"
Hi,
This is my first message on this subreddit.
I've been learning to write backend in Flask for some time now and now I'm trying to familiarize myself with using JWT in it. I have encountered a problem related to the use of the Flask-JWT-Extended library, and more precisely, when I try to send the generated token back, I get the error: "Invalid crypto padding".
It seems to me that token generation is done correctly but I could be wrong, below are some code snippets related to this.
@app.route('/login', methods='POST')
def login():
if request.method == 'POST': return logincontroller()
else:
return 'Method is Not Allowed'
def logincontroller():
requestform = request.json
print(requestform)
password = requestform['password']
try:
login = requestform'username'
/r/flask
https://redd.it/1hedkxa
Hi,
This is my first message on this subreddit.
I've been learning to write backend in Flask for some time now and now I'm trying to familiarize myself with using JWT in it. I have encountered a problem related to the use of the Flask-JWT-Extended library, and more precisely, when I try to send the generated token back, I get the error: "Invalid crypto padding".
It seems to me that token generation is done correctly but I could be wrong, below are some code snippets related to this.
@app.route('/login', methods='POST')
def login():
if request.method == 'POST': return logincontroller()
else:
return 'Method is Not Allowed'
def logincontroller():
requestform = request.json
print(requestform)
password = requestform['password']
try:
login = requestform'username'
/r/flask
https://redd.it/1hedkxa
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
[P] Curated list of LLM papers 2024
https://magazine.sebastianraschka.com/p/llm-research-papers-the-2024-list
/r/MachineLearning
https://redd.it/1he4htl
https://magazine.sebastianraschka.com/p/llm-research-papers-the-2024-list
/r/MachineLearning
https://redd.it/1he4htl
Sebastianraschka
LLM Research Papers: The 2024 List
A curated list of interesting LLM-related research papers from 2024, shared for those looking for something to read over the holidays.
Streaming HTTP Response Factory
In django I have a few API integrations that take a few seconds in a single HTTP request to finish. Rather than just letting the page spin, I decided it would be way better UX to send back "status updates" for each step.
Im using the StreamingHttpResponse and a custom factory I built. I'm trying to implement a few more solid design patterns in the app. So this is kind of practice, but also being used in prod. The way it functions is very similar to how ChatGPT's typed text is streamed back to the client.
Here's the code below:
# task_factory.py
class MyTaskFactory:
def __init__(self):
self.tasks = []
def _build(self):
return [task.build() for task in self.tasks]
def add_task(self, name):
task = MyTask(name, self)
/r/django
https://redd.it/1hek6g5
In django I have a few API integrations that take a few seconds in a single HTTP request to finish. Rather than just letting the page spin, I decided it would be way better UX to send back "status updates" for each step.
Im using the StreamingHttpResponse and a custom factory I built. I'm trying to implement a few more solid design patterns in the app. So this is kind of practice, but also being used in prod. The way it functions is very similar to how ChatGPT's typed text is streamed back to the client.
Here's the code below:
# task_factory.py
class MyTaskFactory:
def __init__(self):
self.tasks = []
def _build(self):
return [task.build() for task in self.tasks]
def add_task(self, name):
task = MyTask(name, self)
/r/django
https://redd.it/1hek6g5
Reddit
From the django community on Reddit
Explore this post and more from the django community
Looking to Switch from MERN to Django – Seeking Resources and Guidance for a Smooth Transition!
Hi,
I just wanna switch my tech stack from MERN to django I just need suggestions to find resources nd for the sake of references I have made projects like c++ code editor which is basically a serverless website user just visits write,run and compiles the code nd they gets the output as simple as that. And also a vitagaurd a micro nutrition tracker which tracks users micronutrients such as vitamins, minerals stuff it also have a profile which shows a piechart of all nutritions consumed in a day. couple other projects those were like very common such as social media platform,course selling, chat application etc...
The reason why I wanna switch is cuz wanna explore django nd how it works yeah
Any suggestions might help hehe
/r/django
https://redd.it/1heb2ls
Hi,
I just wanna switch my tech stack from MERN to django I just need suggestions to find resources nd for the sake of references I have made projects like c++ code editor which is basically a serverless website user just visits write,run and compiles the code nd they gets the output as simple as that. And also a vitagaurd a micro nutrition tracker which tracks users micronutrients such as vitamins, minerals stuff it also have a profile which shows a piechart of all nutritions consumed in a day. couple other projects those were like very common such as social media platform,course selling, chat application etc...
The reason why I wanna switch is cuz wanna explore django nd how it works yeah
Any suggestions might help hehe
/r/django
https://redd.it/1heb2ls
Reddit
From the django community on Reddit
Explore this post and more from the django community
NGL Like project updates.
A small update from my NGL like project built with flask and react with following feature.
\- Reset password
\- New profile & settings design
\- Added an email
You can try:
https://stealthmessage.vercel.app/
Send me a message:
https://stealthmessage.vercel.app/secret/c3aec79d0c
Code:
https://github.com/nordszamora/Stealth-Message.git
Send me your feedback:)
/r/flask
https://redd.it/1he3hg9
A small update from my NGL like project built with flask and react with following feature.
\- Reset password
\- New profile & settings design
\- Added an email
You can try:
https://stealthmessage.vercel.app/
Send me a message:
https://stealthmessage.vercel.app/secret/c3aec79d0c
Code:
https://github.com/nordszamora/Stealth-Message.git
Send me your feedback:)
/r/flask
https://redd.it/1he3hg9
stealthmessage.vercel.app
StealthMessage | Message Anonymously
Anonymous user will send a message for you.
Practice Probs is awesome!
Who ever is the creator of this site, thank you very much! Your content is very useful for learning and practicing. I am using this for Pandas and Numpy!
Link
/r/Python
https://redd.it/1heasge
Who ever is the creator of this site, thank you very much! Your content is very useful for learning and practicing. I am using this for Pandas and Numpy!
Link
/r/Python
https://redd.it/1heasge
Practiceprobs
Home
Fun programming practice problems to help you learn including numpy, pandas, matplotlib, pytorch, pytest, regular expressions, sparse matrices, bigquery, selenium, git, and more! All problems include explained solutions. Tons of free content, including tutorials…
How to navigate through file tree using
I'm having trouble making my web app to read static style
# Project structure
Below is the file structure tree:
main.py
coolestapp/
├── init.py
└── pages/
├── init.py
├── templates/
│ ├── base.html
└── static/
└── styles/
└── base.css
There are in total 5 files within this project. But, I'm only giving the content of 4 files only since the `.css` file content is irrelevant.
a. [`main.py`](http://main.py) file
from coolestapp import createapp
app = createapp()
if name == "main":
app.run(debug=True, host="0.0.0.0", port="10000")
b.
/r/flask
https://redd.it/1he36l5
url_for with flask buleprint?I'm having trouble making my web app to read static style
.css file when using flask blueprint. The HTML fails to read this stylesheet. I'm going describe how the project files are structured followed by the content of each files.# Project structure
Below is the file structure tree:
main.py
coolestapp/
├── init.py
└── pages/
├── init.py
├── templates/
│ ├── base.html
└── static/
└── styles/
└── base.css
There are in total 5 files within this project. But, I'm only giving the content of 4 files only since the `.css` file content is irrelevant.
a. [`main.py`](http://main.py) file
from coolestapp import createapp
app = createapp()
if name == "main":
app.run(debug=True, host="0.0.0.0", port="10000")
b.
coolest_app/__init__.py/r/flask
https://redd.it/1he36l5
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Redirect from a called function
let's say I have a route, where the second function is in another file. The redirect is not working.
route
def fun1():
fun2()
def fun2():
redirect(url_for())
/r/flask
https://redd.it/1het5j4
let's say I have a route, where the second function is in another file. The redirect is not working.
route
def fun1():
fun2()
def fun2():
redirect(url_for())
/r/flask
https://redd.it/1het5j4
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
New to JWTs: How to Maintain User Login Beyond Token Expiration?
Hey everyone! I'm new to working with JWTs and have created a REST API that uses them for authentication, with a token validity of 15 minutes. As I integrate this API with a frontend framework, I'm facing a challenge: after the user logs in, the token expires after 15 minutes.
I want to ensure that users remain logged in indefinitely unless they explicitly log out. What are the best practices for handling JWT expiration? Should I implement a refresh token system, and if so, how should it be structured? Any guidance or examples would be greatly appreciated as I navigate this! Thanks in advance for your help!
/r/flask
https://redd.it/1hdbkcx
Hey everyone! I'm new to working with JWTs and have created a REST API that uses them for authentication, with a token validity of 15 minutes. As I integrate this API with a frontend framework, I'm facing a challenge: after the user logs in, the token expires after 15 minutes.
I want to ensure that users remain logged in indefinitely unless they explicitly log out. What are the best practices for handling JWT expiration? Should I implement a refresh token system, and if so, how should it be structured? Any guidance or examples would be greatly appreciated as I navigate this! Thanks in advance for your help!
/r/flask
https://redd.it/1hdbkcx
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
D Simple Questions Thread
Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here instead!
Thread will stay alive until next one so keep posting after the date in the noscript.
Thanks to everyone for answering questions in the previous thread!
/r/MachineLearning
https://redd.it/1hevk2a
Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here instead!
Thread will stay alive until next one so keep posting after the date in the noscript.
Thanks to everyone for answering questions in the previous thread!
/r/MachineLearning
https://redd.it/1hevk2a
Reddit
From the MachineLearning community on Reddit
Explore this post and more from the MachineLearning community