Currently learning flask and need a bit of help. Please see below
Hi all, I am currently using flask to create a budget api application below are two tables:
from flasksqlalchemy import SQLAlchemy
from flasklogin import UserMixin
from datetime import datetime
db = SQLAlchemy()
```
from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin
from datetime import datetime
db = SQLAlchemy()
class User(db.Model, UserMixin):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
password = db.Column(db.String(255), nullable=False)
expenses = db.relationship('Expense', backref='user', lazy=True)
class Expense(db.Model):
__tablename__ = 'expenses'
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100), nullable=False)
amount = db.Column(db.Float, nullable=False)
date_created = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
/r/flask
https://redd.it/13d2uw7
Hi all, I am currently using flask to create a budget api application below are two tables:
from flasksqlalchemy import SQLAlchemy
from flasklogin import UserMixin
from datetime import datetime
db = SQLAlchemy()
```
from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin
from datetime import datetime
db = SQLAlchemy()
class User(db.Model, UserMixin):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
password = db.Column(db.String(255), nullable=False)
expenses = db.relationship('Expense', backref='user', lazy=True)
class Expense(db.Model):
__tablename__ = 'expenses'
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100), nullable=False)
amount = db.Column(db.Float, nullable=False)
date_created = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
/r/flask
https://redd.it/13d2uw7
Reddit
r/flask on Reddit: Currently learning flask and need a bit of help. Please see below
Posted by u/Consistent_Essay1139 - 5 votes and 4 comments
Do you really need microservices?
I was recently asked by a friend if they needed to use microservices in their project.
My answer is: it depends.
In general, microservices are a great way to structure your code so that it is modular, easy to maintain, and easy to scale.
However, there are some tradeoffs that you need to be aware of before deciding to use microservices.
Mainly because microservices add complexity to your system. This can make debugging and troubleshooting more difficult. It can also lead to increased latency due to the overhead of communication between services.
However, microservice (in my experience) is great for large-scale projects, where you need the flexibility to add or remove components as needed. It also allows greater control over how individual services are deployed and managed.
Goa and Kong are some of the best frameworks to develop and deploy microservices. They provide features such as out-of-the-box support for service discovery, routing and authentication that make it easier to build more complex applications. There are also newer architectural frameworks with less steep learning curves like GPTDeploy that lets you build and deploy microservices with a single command.
But If you did decide to go with microservices, make sure you have a good reason for doing
/r/Python
https://redd.it/13d227c
I was recently asked by a friend if they needed to use microservices in their project.
My answer is: it depends.
In general, microservices are a great way to structure your code so that it is modular, easy to maintain, and easy to scale.
However, there are some tradeoffs that you need to be aware of before deciding to use microservices.
Mainly because microservices add complexity to your system. This can make debugging and troubleshooting more difficult. It can also lead to increased latency due to the overhead of communication between services.
However, microservice (in my experience) is great for large-scale projects, where you need the flexibility to add or remove components as needed. It also allows greater control over how individual services are deployed and managed.
Goa and Kong are some of the best frameworks to develop and deploy microservices. They provide features such as out-of-the-box support for service discovery, routing and authentication that make it easier to build more complex applications. There are also newer architectural frameworks with less steep learning curves like GPTDeploy that lets you build and deploy microservices with a single command.
But If you did decide to go with microservices, make sure you have a good reason for doing
/r/Python
https://redd.it/13d227c
Goa – Design. Generate. Scale.
Transform the way you build APIs in Go. Goa bridges the gap between design and implementation, generating clean, scalable, and production-ready microservices.
GitHub - griptape-ai/griptape: Python framework for AI workflows and pipelines with chain of thought reasoning, external tools, and memory.
https://github.com/griptape-ai/griptape
/r/Python
https://redd.it/13djuec
https://github.com/griptape-ai/griptape
/r/Python
https://redd.it/13djuec
GitHub
GitHub - griptape-ai/griptape: Modular Python framework for AI agents and workflows with chain-of-thought reasoning, tools, and…
Modular Python framework for AI agents and workflows with chain-of-thought reasoning, tools, and memory. - GitHub - griptape-ai/griptape: Modular Python framework for AI agents and workflows with ...
HarvardX CS50's Introduction to Programming with Python
i highly recommend the online course created by harvard on the fundamentals of Python.
Very good teaching and very easy to understand.
ohh and its free
/r/Python
https://redd.it/13dls6c
i highly recommend the online course created by harvard on the fundamentals of Python.
Very good teaching and very easy to understand.
ohh and its free
/r/Python
https://redd.it/13dls6c
Reddit
r/Python on Reddit: HarvardX CS50's Introduction to Programming with Python
Posted by u/Andymanden33 - No votes and 2 comments
Cleanest way to install python
Hi, I'm on linux I was asking to myself what is the best and cleanest way to install python (with docker, using virtual environment, classic way ecc...)
/r/Python
https://redd.it/13dioxr
Hi, I'm on linux I was asking to myself what is the best and cleanest way to install python (with docker, using virtual environment, classic way ecc...)
/r/Python
https://redd.it/13dioxr
Reddit
r/Python on Reddit: Cleanest way to install python
Posted by u/VeterinarianHuman505 - 3 votes and 18 comments
End-to-End Tutorial on Combining AWS Lambda, Docker, and Python
https://www.youtube.com/watch?v=gvfoZq258gA&list=PLbn3jWIXv_ibGQml3zlXi1TfmdcIl6Afy&index=1
/r/flask
https://redd.it/13cqx6g
https://www.youtube.com/watch?v=gvfoZq258gA&list=PLbn3jWIXv_ibGQml3zlXi1TfmdcIl6Afy&index=1
/r/flask
https://redd.it/13cqx6g
YouTube
Python + AWS Lambda - Part 1: Introduction
Please consider supporting me on Patreon: https://www.patreon.com/programmingwithalex
GitHub link: https://github.com/programmingwithalex/aws_lambda_demo
The video series will cover:
1. Writing a Python script that pulls the current day's weather from an…
GitHub link: https://github.com/programmingwithalex/aws_lambda_demo
The video series will cover:
1. Writing a Python script that pulls the current day's weather from an…
"Should" i normalize everything ? Data modeling question
Hey guys,
I have a model called Problem that contains many fields : difficulty, status, category.
Each of these fields have 3 entries. For example, difficulty field has these values : "Easy", "Normal", "Hard".
Should i create a whole model with its own table just for the difficulty field and make it a foreign key of the Problem model ? As below :
from django.db import models
class Difficulty(models.Model):
name = models.CharField(max_length=50)
def __str__(self):
return self.name
class Problem(models.Model):
name = models.CharField(max_length=50)
difficulty = models.ForeignKey(Difficulty, on_delete=models.CASCADE)
def __str__(self):
return self.name
Or should i just create a multiple choice field and keep the logic in my code :
from django.db import models
/r/djangolearning
https://redd.it/13dixxh
Hey guys,
I have a model called Problem that contains many fields : difficulty, status, category.
Each of these fields have 3 entries. For example, difficulty field has these values : "Easy", "Normal", "Hard".
Should i create a whole model with its own table just for the difficulty field and make it a foreign key of the Problem model ? As below :
from django.db import models
class Difficulty(models.Model):
name = models.CharField(max_length=50)
def __str__(self):
return self.name
class Problem(models.Model):
name = models.CharField(max_length=50)
difficulty = models.ForeignKey(Difficulty, on_delete=models.CASCADE)
def __str__(self):
return self.name
Or should i just create a multiple choice field and keep the logic in my code :
from django.db import models
/r/djangolearning
https://redd.it/13dixxh
Reddit
r/djangolearning on Reddit: "Should" i normalize everything ? Data modeling question
Posted by u/doing20thingsatatime - 4 votes and 3 comments
Bevy v2.0
I've created a dependency injection framework that works similarly to Fast API using type annotations. You only need to use the
Installation
pip install bevy
Simple Example
from bevy import dependency, inject
class Demo:
def init(self):
self.message = "Hello World"
@inject
def example(thing: Demo = dependency()):
print(thing.message)
example()
That'll handle creating an instance of
Useful Links
Blog post explaining in more detail
Documentation
GitHub
/r/Python
https://redd.it/13dvdk8
I've created a dependency injection framework that works similarly to Fast API using type annotations. You only need to use the
inject decorator and the dependency function to indicate what should be injected.Installation
pip install bevy
Simple Example
from bevy import dependency, inject
class Demo:
def init(self):
self.message = "Hello World"
@inject
def example(thing: Demo = dependency()):
print(thing.message)
example()
That'll handle creating an instance of
Demo and injecting it into the example function.Useful Links
Blog post explaining in more detail
Documentation
GitHub
/r/Python
https://redd.it/13dvdk8
Zech Zimmerman
Bevy v2.0 - The Simple Python Dependency Injection Framework
Bevy v2.0 - The Python Dependency Injection Framework That Empowers You to Build Better Applications
Your Django-Docker Starter Kit: Streamlined Development & Production Ready
Hey there,
I've crafted a Django-Docker starter kit titled "**Django-Docker Quickstart**" to kickstart your Django projects in no time.
This kit includes Django, PostgreSQL, Redis, Celery, Nginx, and Traefik, all pre-configured for your ease. Nginx and Traefik are set up for your production environment to handle static files, proxy requests, route requests, and provide SSL termination.
You'll also find tools such as Pytest, Pytest plugins, Coverage, Ruff, and Black, making your development and testing process smoother.
Check it out here: **Django-Docker Quickstart**
Enjoy coding and please star the repo if you find it helpful!
P.S: Feedback and suggestions are always welcome! 🚀
/r/django
https://redd.it/13e1t5v
Hey there,
I've crafted a Django-Docker starter kit titled "**Django-Docker Quickstart**" to kickstart your Django projects in no time.
This kit includes Django, PostgreSQL, Redis, Celery, Nginx, and Traefik, all pre-configured for your ease. Nginx and Traefik are set up for your production environment to handle static files, proxy requests, route requests, and provide SSL termination.
You'll also find tools such as Pytest, Pytest plugins, Coverage, Ruff, and Black, making your development and testing process smoother.
Check it out here: **Django-Docker Quickstart**
Enjoy coding and please star the repo if you find it helpful!
P.S: Feedback and suggestions are always welcome! 🚀
/r/django
https://redd.it/13e1t5v
GitHub
GitHub - godd0t/django-docker-quickstart: Your all-in-one Django-Docker starter kit. Pre-configured services including PostgreSQL…
Your all-in-one Django-Docker starter kit. Pre-configured services including PostgreSQL, Redis, Celery, with Nginx and Traefik for production. Streamlined development with included tools for testin...
Took a web development job without much experience, am I doomed?
Okay so please don't ask how or why, but for the next year or so 50% of my 40 hour work week will be dedicated to developing a web application for a public authority.
The goal is to develop an application that offers users to fill out an extensive evaluation about sustainability.
Afterwards, they should receive information and visualizations/diagrams building on their answers. They should also receive a score for their sustainability in different categories and suggestions to improve on.
Both the answers and the suggestions should be stored in a connected database.
That’s about it.
I have a little bit of programming experience.
I know the basic principles like classes, objects, control structures like if/for/etc.
I don’t really have experience in web development though apart from fooling around a bit in Django. Honestly that’s why I want to choose Django as a framework for it.
Do y’all think it is possible if I spent around 20hrs/week on this project?
Obviously the first step would be to learn Django and web development in general the next couple weeks.
I would appreciate any input and also tips for any resources to start off.
/r/django
https://redd.it/13e1b5o
Okay so please don't ask how or why, but for the next year or so 50% of my 40 hour work week will be dedicated to developing a web application for a public authority.
The goal is to develop an application that offers users to fill out an extensive evaluation about sustainability.
Afterwards, they should receive information and visualizations/diagrams building on their answers. They should also receive a score for their sustainability in different categories and suggestions to improve on.
Both the answers and the suggestions should be stored in a connected database.
That’s about it.
I have a little bit of programming experience.
I know the basic principles like classes, objects, control structures like if/for/etc.
I don’t really have experience in web development though apart from fooling around a bit in Django. Honestly that’s why I want to choose Django as a framework for it.
Do y’all think it is possible if I spent around 20hrs/week on this project?
Obviously the first step would be to learn Django and web development in general the next couple weeks.
I would appreciate any input and also tips for any resources to start off.
/r/django
https://redd.it/13e1b5o
Reddit
r/django on Reddit: Took a web development job without much experience, am I doomed?
Posted by u/Dreamville2801 - No votes and 11 comments
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/13e7jfp
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/13e7jfp
Reddit
r/Python on Reddit: Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
Posted by u/Im__Joseph - No votes and no comments
15 tips and tricks for writing better Python
https://gist.github.com/Julynx/dd500d8ae7e335c3c84684ede2293e1f
/r/Python
https://redd.it/13e5oxw
https://gist.github.com/Julynx/dd500d8ae7e335c3c84684ede2293e1f
/r/Python
https://redd.it/13e5oxw
Gist
15 Python Tips To Take Your Code To The Next Level!
15 Python Tips To Take Your Code To The Next Level! - 15_python_tips.md
Running Multiple Gunicorn Instances for Low-Traffic Websites
I've been exploring the use of Gunicorn and Nginx to serve Django websites, and it's generally recommended for its performance benefits. However, I have a question regarding running multiple websites on the same server with Gunicorn.
If I want to run multiple websites, it seems that I need to run separate instances of Gunicorn for each site. My concern is whether this approach will unnecessarily consume CPU and RAM resources, especially if the websites have low traffic.
In the past, I've used a LAMP stack to run multiple websites without requiring dedicated processes for each site. This makes me wonder if the modern approach with Gunicorn and Nginx is better in terms of resource usage and efficiency.
Could anyone shed some light on this? Am I missing something in understanding the benefits of running multiple Gunicorn instances for multiple websites, even if they have low traffic?
I appreciate any insights or experiences you can share.
Thanks in advance!
/r/django
https://redd.it/13eed6n
I've been exploring the use of Gunicorn and Nginx to serve Django websites, and it's generally recommended for its performance benefits. However, I have a question regarding running multiple websites on the same server with Gunicorn.
If I want to run multiple websites, it seems that I need to run separate instances of Gunicorn for each site. My concern is whether this approach will unnecessarily consume CPU and RAM resources, especially if the websites have low traffic.
In the past, I've used a LAMP stack to run multiple websites without requiring dedicated processes for each site. This makes me wonder if the modern approach with Gunicorn and Nginx is better in terms of resource usage and efficiency.
Could anyone shed some light on this? Am I missing something in understanding the benefits of running multiple Gunicorn instances for multiple websites, even if they have low traffic?
I appreciate any insights or experiences you can share.
Thanks in advance!
/r/django
https://redd.it/13eed6n
Reddit
r/django on Reddit: Running Multiple Gunicorn Instances for Low-Traffic Websites
Posted by u/ResponsibleDot - No votes and no comments
word2num: Convert complex "word numbers" to numerical values
Hey all, I just published my first Python package called word2num. It converts written numbers like "one hundred and twenty-five" or "nine and three quarters" to their numerical values. There are a handful of other packages out there that do this already, but they're mostly no longer maintained and do not support fractional values (the key feature I need for my project).
It supports a variety of types of numbers and uses configurable fuzzy string matching to account for typos. It only supports English at the moment, but contributions for other languages would be more than welcome.
If you want to give it a try, you can
from word2num import word2num
word2num("twenty nine and a half") # 29.5
Check out the GitHub repo for more usage info and examples. My experience in Python is quite limited, so if anything comes across as non-Pythonic, I'd appreciate a heads-up! 🙌
/r/Python
https://redd.it/13e8tzc
Hey all, I just published my first Python package called word2num. It converts written numbers like "one hundred and twenty-five" or "nine and three quarters" to their numerical values. There are a handful of other packages out there that do this already, but they're mostly no longer maintained and do not support fractional values (the key feature I need for my project).
It supports a variety of types of numbers and uses configurable fuzzy string matching to account for typos. It only supports English at the moment, but contributions for other languages would be more than welcome.
If you want to give it a try, you can
pip install word2num.from word2num import word2num
word2num("twenty nine and a half") # 29.5
Check out the GitHub repo for more usage info and examples. My experience in Python is quite limited, so if anything comes across as non-Pythonic, I'd appreciate a heads-up! 🙌
/r/Python
https://redd.it/13e8tzc
GitHub
GitHub - doppio/word2num: A Python package for converting numbers expressed in natural language to numerical values.
A Python package for converting numbers expressed in natural language to numerical values. - GitHub - doppio/word2num: A Python package for converting numbers expressed in natural language to numer...
The Ultimate Django Guide for Beginners and Beyond
Hello, fellow Redditors! I remember the days when I first started learning Django. It was both exciting and challenging, and at times, I wished I had a comprehensive guide to help me navigate this new territory. That's why I decided to write this in-depth article on Django – to make the journey easier for you.
This guide explores everything from Django's history and core features to its project structure, comparison with other Python frameworks, and the future scope of Django development. It's a resource I wish I had when I started, and I hope it can be beneficial for those who are just beginning or looking to deepen their Django knowledge. Dive in, explore, and let's enter the fascinating world of Django together!
https://danielbuilescu.com/blogs/learn-python/understanding-django-an-introduction-to-pythons-web-framework
/r/django
https://redd.it/13ei9m2
Hello, fellow Redditors! I remember the days when I first started learning Django. It was both exciting and challenging, and at times, I wished I had a comprehensive guide to help me navigate this new territory. That's why I decided to write this in-depth article on Django – to make the journey easier for you.
This guide explores everything from Django's history and core features to its project structure, comparison with other Python frameworks, and the future scope of Django development. It's a resource I wish I had when I started, and I hope it can be beneficial for those who are just beginning or looking to deepen their Django knowledge. Dive in, explore, and let's enter the fascinating world of Django together!
https://danielbuilescu.com/blogs/learn-python/understanding-django-an-introduction-to-pythons-web-framework
/r/django
https://redd.it/13ei9m2
Danielbuilescu
Builescu Daniel - Python & Shopify Developer
Welcome to my blog, dedicated to exploring the world of Python and Shopify. Join me on this informative journey as I share valuable insights, tutorials, and tips on leveraging Python programming and Shopify development.
Any good course on Python microservices?
Trying to make the simplest one possible. Looking for a real quick and basic example with a message broker.
/r/Python
https://redd.it/13eqxic
Trying to make the simplest one possible. Looking for a real quick and basic example with a message broker.
/r/Python
https://redd.it/13eqxic
Reddit
r/Python on Reddit: Any good course on Python microservices?
Posted by u/darkcatpirate - No votes and 3 comments
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 title.
Thanks to everyone for answering questions in the previous thread!
/r/MachineLearning
https://redd.it/13as0ej
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 title.
Thanks to everyone for answering questions in the previous thread!
/r/MachineLearning
https://redd.it/13as0ej
Reddit
From the MachineLearning community on Reddit
Explore this post and more from the MachineLearning community
Faster CPython at PyCon, part one
https://lwn.net/SubscriberLink/930705/4bbe9c26d7884277/
/r/Python
https://redd.it/13eplm1
https://lwn.net/SubscriberLink/930705/4bbe9c26d7884277/
/r/Python
https://redd.it/13eplm1
lwn.net
Faster CPython at PyCon, part one
Two members of the Faster
CPython team, which was put together at Microsoft at the behest of Guido
van Rossum to work on major performance improvements for CPython, came
to PyCon 2023 to report on what the
team has been working on—and its plans for the future.…
CPython team, which was put together at Microsoft at the behest of Guido
van Rossum to work on major performance improvements for CPython, came
to PyCon 2023 to report on what the
team has been working on—and its plans for the future.…
N Anthropic - Introducing 100K Token Context Windows, Around 75,000 Words
Anthropic has announced a major update to its AI model, Claude, expanding its context window from 9K to 100K tokens, roughly equivalent to 75,000 words. This significant increase allows the model to analyze and comprehend hundreds of pages of content, enabling prolonged conversations and complex data analysis.
The 100K context windows are now available in Anthropic's API.
https://www.anthropic.com/index/100k-context-windows
/r/MachineLearning
https://redd.it/13etub0
Anthropic has announced a major update to its AI model, Claude, expanding its context window from 9K to 100K tokens, roughly equivalent to 75,000 words. This significant increase allows the model to analyze and comprehend hundreds of pages of content, enabling prolonged conversations and complex data analysis.
The 100K context windows are now available in Anthropic's API.
https://www.anthropic.com/index/100k-context-windows
/r/MachineLearning
https://redd.it/13etub0
Anthropic
Introducing 100K Context Windows
Anthropic is an AI safety and research company that's working to build reliable, interpretable, and steerable AI systems.
django project review
I build this site https://ottomantravels.com using django. now I am thinking was it worth when I could easily use WordPress. I know WordPress can be troublesome to handle.
one more suggestion should I leave the admin url with the site ? does it cause any security vulnerability.
/r/django
https://redd.it/13epprd
I build this site https://ottomantravels.com using django. now I am thinking was it worth when I could easily use WordPress. I know WordPress can be troublesome to handle.
one more suggestion should I leave the admin url with the site ? does it cause any security vulnerability.
/r/django
https://redd.it/13epprd
The Ottoman Group (TOG)
Ottoman Travels | Tourism and Travels Guide
The Ottoman Group is a group of companies that focuses on multiple business and services related to Turkey and Bangladesh .