Full-length tutorial on deploying Flask app on AWS with Docker + RDS + Secrets Manager
https://www.youtube.com/watch?v=a1nnZDps_yM&list=PLbn3jWIXv_iZ566tBk_DTIPGY4fUW4qBn&index=1
/r/flask
https://redd.it/10291bb
https://www.youtube.com/watch?v=a1nnZDps_yM&list=PLbn3jWIXv_iZ566tBk_DTIPGY4fUW4qBn&index=1
/r/flask
https://redd.it/10291bb
YouTube
Flask to AWS ECS - Part 1: Introduction
Please consider supporting me on Patreon: https://www.patreon.com/programmingwithalex
GitHub link: https://github.com/programmingwithalex/aws_ecs_demo
Introduction of what will be covered in the video series of pushing a containerized flask application…
GitHub link: https://github.com/programmingwithalex/aws_ecs_demo
Introduction of what will be covered in the video series of pushing a containerized flask application…
Need a simple source code
I need to develop an application for my company to order material, internally. I'm still learning python, but they gave me ONE WEEK to do it using Django, not in Java that I develop. To build it using java is pretty easy, cos I just need an administrative module to create and manage products/users, and other to order products.
Anyone knows where can I find an open source code for this, so I can use during this time that I'm learning and maybe adapt/improve when i become skilled enough?
I don't know what to do and I'm a little worried.
/r/djangolearning
https://redd.it/102pkr7
I need to develop an application for my company to order material, internally. I'm still learning python, but they gave me ONE WEEK to do it using Django, not in Java that I develop. To build it using java is pretty easy, cos I just need an administrative module to create and manage products/users, and other to order products.
Anyone knows where can I find an open source code for this, so I can use during this time that I'm learning and maybe adapt/improve when i become skilled enough?
I don't know what to do and I'm a little worried.
/r/djangolearning
https://redd.it/102pkr7
reddit
Need a simple source code
I need to develop an application for my company to order material, internally. I'm still learning python, but they gave me ONE WEEK to do it using...
My Crispy form fields are not showing
Hello,
So I am in a strange situation here and I can't figure out what it is that I am doing wrong.
I am building a django app that requires user authentication (register, login, logout) and I am using Crispy forms and bootstrap4 to create the necessary forms. Everything looks fine with the code but the form fields are not showing.
The only thing I can see is the button. Here's an image.
https://preview.redd.it/4i2i7o9chy9a1.png?width=1220&format=png&auto=webp&s=afc7976c174dd3d99cc251985aa56e910a72520d
​
I am using this same code on another project and it seems to be working fine.
Here are my register_user views:
​
my forms:
​
URL path
and finally, my HTML code:
What I have tried so far:
1. I tried rewriting the code, obviously.
2. I also tried starting another app and using the same code
/r/djangolearning
https://redd.it/102u542
Hello,
So I am in a strange situation here and I can't figure out what it is that I am doing wrong.
I am building a django app that requires user authentication (register, login, logout) and I am using Crispy forms and bootstrap4 to create the necessary forms. Everything looks fine with the code but the form fields are not showing.
The only thing I can see is the button. Here's an image.
https://preview.redd.it/4i2i7o9chy9a1.png?width=1220&format=png&auto=webp&s=afc7976c174dd3d99cc251985aa56e910a72520d
​
I am using this same code on another project and it seems to be working fine.
Here are my register_user views:
def register_user(request):if request.method== "POST":form = NewUserForm(`request.POST`)if form.is_valid():user = `form.save`()login(request, user)messages.success(request, "Registration successful." )return redirect("/")messages.error(request, "Unsuccessful registration. Invalid information.")form = NewUserForm()return render(request, "register.html", {"register_form":form})​
my forms:
from django import formsfrom django.contrib.auth.forms import UserCreationFormfrom django.contrib.auth.models import Userclass NewUserForm(UserCreationForm):email = forms.EmailField(required = True)class Meta:model = Userfields = "email", "username", "password1", "password2"def save(self, commit = True):user= super(NewUserForm, self).save(commit=False)user.email = self.cleaned_data['email']if commit:`user.save`()return user​
URL path
path('register/', views.register_user, name='register'),and finally, my HTML code:
<div class="container py-5"><h1>Register Now</h1><form method="POST">{% csrf_token %}{{ register_form|crispy }}<button class="btn btn-primary" type="submit">Register</button></form><p class="text-center">If you already have an account, <a href="/login">login</a> instead.</p></div>The same case applies to my login page.What I have tried so far:
1. I tried rewriting the code, obviously.
2. I also tried starting another app and using the same code
/r/djangolearning
https://redd.it/102u542
Help With Model Inheritance
Hello all,
I was hoping someone could help me understand model inheritance a little better and figure out why I am getting an error. I am working on some helpers for the game Twilight Imperium. I will explain what I am trying to do and then the ask at the bottom of this post.
First, I have a model that represents a unit in a board game. The model code looks like this:
class Unit(models.Model):
name = models.CharField(max_length=32, primary_key=True)
wiki_url = models.URLField()
avatar = models.URLField()
extra_info = models.TextField(null=True, blank=True)
cost = models.IntegerField()
combat = models.IntegerField()
combat_quantity = models.IntegerField()
move = models.IntegerField()
capacity = models.IntegerField()
production_quantity = models.IntegerField()
upgrade_available = models.BooleanField()
/r/django
https://redd.it/102kib8
Hello all,
I was hoping someone could help me understand model inheritance a little better and figure out why I am getting an error. I am working on some helpers for the game Twilight Imperium. I will explain what I am trying to do and then the ask at the bottom of this post.
First, I have a model that represents a unit in a board game. The model code looks like this:
class Unit(models.Model):
name = models.CharField(max_length=32, primary_key=True)
wiki_url = models.URLField()
avatar = models.URLField()
extra_info = models.TextField(null=True, blank=True)
cost = models.IntegerField()
combat = models.IntegerField()
combat_quantity = models.IntegerField()
move = models.IntegerField()
capacity = models.IntegerField()
production_quantity = models.IntegerField()
upgrade_available = models.BooleanField()
/r/django
https://redd.it/102kib8
reddit
Help With Model Inheritance
Hello all, I was hoping someone could help me understand model inheritance a little better and figure out why I am getting an error. I am working...
Problems with bootstrap base template
The problem is this: when i put this code:
{% extends "base.html" %}
{% block title %}
Home
{% endblock %}
{% block content %}
Quiz list
{% endblock %}
Django just goes to the bootstrap base template and ignores the rest of the code. This is the bootstrap code (base.html):
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
/r/django
https://redd.it/102rmf9
The problem is this: when i put this code:
{% extends "base.html" %}
{% block title %}
Home
{% endblock %}
{% block content %}
Quiz list
{% endblock %}
Django just goes to the bootstrap base template and ignores the rest of the code. This is the bootstrap code (base.html):
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
/r/django
https://redd.it/102rmf9
reddit
Problems with bootstrap base template
The problem is this: when i put this code: {% extends "base.html" %} {% block title %} Home {% endblock %} {%...
Problem opening a thumbnail
Hi everyone!
I'm attempting to open a thumbnail of an image that was saved with django-versatileimagefield
https://django-versatileimagefield.readthedocs.io/en/latest/
file = instance.image.thumbnail'1920x1080'.open(mode='rb')
I'm getting the following error:
'SizedImageInstance' object has no attribute 'open'
I have success with the following line of code, but I want to open the smaller version as opposed to the original version
file = instance.image.open(mode='rb')
If it helps, the url of the image is instance.image.thumbnail['1920x1080'\].url
Thanks!
/r/django
https://redd.it/102qn4m
Hi everyone!
I'm attempting to open a thumbnail of an image that was saved with django-versatileimagefield
https://django-versatileimagefield.readthedocs.io/en/latest/
file = instance.image.thumbnail'1920x1080'.open(mode='rb')
I'm getting the following error:
'SizedImageInstance' object has no attribute 'open'
I have success with the following line of code, but I want to open the smaller version as opposed to the original version
file = instance.image.open(mode='rb')
If it helps, the url of the image is instance.image.thumbnail['1920x1080'\].url
Thanks!
/r/django
https://redd.it/102qn4m
Best practice for displaying local time
Hi!
What is the best practice in django for handling timezones?
If I understood correctly, it would be the best to have TIME_ZONE = 'UTC' and USE_TZ = True in settings.py, but I am really struggling to understand how to then display the correct time depending on the user's location.
Thank you very much in advance for your help!
/r/django
https://redd.it/102ia4p
Hi!
What is the best practice in django for handling timezones?
If I understood correctly, it would be the best to have TIME_ZONE = 'UTC' and USE_TZ = True in settings.py, but I am really struggling to understand how to then display the correct time depending on the user's location.
Thank you very much in advance for your help!
/r/django
https://redd.it/102ia4p
How to aggregate
I have two models, Journey, and Review in my models
class Journey(models.Model):
COUNTRY_CHOICES = [
('Malawi', (
('Lilongwe', 'LILONGWE'),
('Blantyre', 'BLANTYRE'),
('Mzuzu', 'MZUZU'),
('Zomba', 'ZOMBA'),
('Kasungu', 'KASUNGU'),
('Mangochi', 'MANGOCHI'),
('Karonga', 'KARONGA'),
('Salima', 'SALIMA'),
('Nkhotakota', 'NKHOTAKOTA'),
/r/django
https://redd.it/102bylp
I have two models, Journey, and Review in my models
class Journey(models.Model):
COUNTRY_CHOICES = [
('Malawi', (
('Lilongwe', 'LILONGWE'),
('Blantyre', 'BLANTYRE'),
('Mzuzu', 'MZUZU'),
('Zomba', 'ZOMBA'),
('Kasungu', 'KASUNGU'),
('Mangochi', 'MANGOCHI'),
('Karonga', 'KARONGA'),
('Salima', 'SALIMA'),
('Nkhotakota', 'NKHOTAKOTA'),
/r/django
https://redd.it/102bylp
reddit
How to aggregate
I have two models, Journey, and Review in my models class Journey(models.Model): COUNTRY_CHOICES = [ ('Malawi', ( ...
What's the proper way to pass data from JS to Python?
If I have a page that displays comments, and each comment has a delete button, then how do I implement the delete functionality using url_for?
My first attempt put the unique comment ID as a data attribute on the each Delete button, and JS extracts the ID from the clicked button and uses window.location to send the request. Unfortunately this requires passing the ID variable from JS to Python such that url_for can properly use it, but this isn't supported. It works fine if I simply generate the string manually though.
So is the proper solution to generate a unique JS function for each Delete button? Or is it to simply not rely on url_for, and have inconsistent url generation throughout the project based on the situation it's used in? Or is it something else? Thanks
/r/flask
https://redd.it/102r73t
If I have a page that displays comments, and each comment has a delete button, then how do I implement the delete functionality using url_for?
My first attempt put the unique comment ID as a data attribute on the each Delete button, and JS extracts the ID from the clicked button and uses window.location to send the request. Unfortunately this requires passing the ID variable from JS to Python such that url_for can properly use it, but this isn't supported. It works fine if I simply generate the string manually though.
So is the proper solution to generate a unique JS function for each Delete button? Or is it to simply not rely on url_for, and have inconsistent url generation throughout the project based on the situation it's used in? Or is it something else? Thanks
/r/flask
https://redd.it/102r73t
reddit
What's the proper way to pass data from JS to Python?
If I have a page that displays comments, and each comment has a delete button, then how do I implement the delete functionality using url_for? ...
Question regarding best practices with user uploaded images being used for templates, and how to properly set it up for production.
Hello. I'm currently in the final steps of deploying a small, largely static microblog using Flask. I think there's an important thing to point out: Authorized users will be able to log in, create a blog post, include a photo, and then from there the website will output their blog post. I am currently using Flask-Admin for this, and employ the ImageUploadField class within the form. The logic then sanitizes the filename, commits the filename to the blog's model as "img", then dumps the images themselves into the static folder. Then within the template, i simply point to that folder and populate article cards with the model's content. Though I know (and heard multiple times) that you should instead generate the path or the filename to the image and save that in the model. Currently, only one of the templates are properly serving the images, while the 4 others aren't. Their respective routes only query the db for each respective type of post, and send the bulk of the contents to be iterated over within the template.
Here's the thing: If the user uploaded images are the ones being served by the website, what is the best way to set this
/r/flask
https://redd.it/102ikfx
Hello. I'm currently in the final steps of deploying a small, largely static microblog using Flask. I think there's an important thing to point out: Authorized users will be able to log in, create a blog post, include a photo, and then from there the website will output their blog post. I am currently using Flask-Admin for this, and employ the ImageUploadField class within the form. The logic then sanitizes the filename, commits the filename to the blog's model as "img", then dumps the images themselves into the static folder. Then within the template, i simply point to that folder and populate article cards with the model's content. Though I know (and heard multiple times) that you should instead generate the path or the filename to the image and save that in the model. Currently, only one of the templates are properly serving the images, while the 4 others aren't. Their respective routes only query the db for each respective type of post, and send the bulk of the contents to be iterated over within the template.
Here's the thing: If the user uploaded images are the ones being served by the website, what is the best way to set this
/r/flask
https://redd.it/102ikfx
reddit
Question regarding best practices with user uploaded images being...
Hello. I'm currently in the final steps of deploying a small, largely static microblog using Flask. I think there's an important thing to point...
Structuring personnal code with existant UI Theme
Hello,
​
I am developing an application based on all my python scripts so i thought using Flask to convert them as web application. I downloaded a theme from AppSeed (https://docs.appseed.us/products/flask-dashboards/material-dashboard)
But i want to be sure how can i add my scripts and structure the application. I want to use blueprints and make one for each application component.
So i think i need to add folder like home or authentication and inside them a routes.py file, a models.py file and forms.py file and my scripts ?
Thank you for you help
https://preview.redd.it/ms02x2kw9u9a1.png?width=838&format=png&auto=webp&s=82724e4f366c05433c6fbbc598675015a0dfef67
/r/flask
https://redd.it/1029pwa
Hello,
​
I am developing an application based on all my python scripts so i thought using Flask to convert them as web application. I downloaded a theme from AppSeed (https://docs.appseed.us/products/flask-dashboards/material-dashboard)
But i want to be sure how can i add my scripts and structure the application. I want to use blueprints and make one for each application component.
So i think i need to add folder like home or authentication and inside them a routes.py file, a models.py file and forms.py file and my scripts ?
Thank you for you help
https://preview.redd.it/ms02x2kw9u9a1.png?width=838&format=png&auto=webp&s=82724e4f366c05433c6fbbc598675015a0dfef67
/r/flask
https://redd.it/1029pwa
docs.appseed.us
Flask Material Dashboard - Open-Source Starter | AppSeed Documentation
Open-source Flask Starter coded on top Argon Dashboard design (Free Version).
how to deploy flask
I created projects in flask and sqlite3. How to deploy/host project? As heroku is paid I cant afford.
/r/flask
https://redd.it/10234nd
I created projects in flask and sqlite3. How to deploy/host project? As heroku is paid I cant afford.
/r/flask
https://redd.it/10234nd
reddit
how to deploy flask
I created projects in flask and sqlite3. How to deploy/host project? As heroku is paid I cant afford.
Django Rest Framework authentication and Django Middleware: Why request.user is anonymous? A solution.
https://medium.com/@batiste/django-rest-framework-authentication-and-django-middleware-why-request-user-is-anonymous-d9d62bddf4f6
/r/django
https://redd.it/1035rtc
https://medium.com/@batiste/django-rest-framework-authentication-and-django-middleware-why-request-user-is-anonymous-d9d62bddf4f6
/r/django
https://redd.it/1035rtc
Medium
Django Rest Framework authentication and Django Middleware: Why request.user is anonymous?
When using DRF and in in the context of Django middleware I have often found to be the case that request.user is an AnonymousUser. Why is…
C on Jupyter Notebook Warnings
Hi so hope this is the right place for this, I am on MacBook Pro M1 Pro and have installed Jupyter Notebook on VSC and downloaded this c kernel and when I try to use it with the code below the code runs ok but I get these two warnings. I also tried on Jupyter notebook from anaconda and I get the same warning so Its not from vsc. Does anyone know how to remove these warnings? Any help in appreciated
https://preview.redd.it/rbh2x3itu2aa1.png?width=3248&format=png&auto=webp&s=0d89ae40160079f29c55dfb7c75d8724cd08337d
https://preview.redd.it/xyli6vitu2aa1.png?width=3248&format=png&auto=webp&s=f8ed647a8c64c6922e1a731f113c19582b55a751
/r/JupyterNotebooks
https://redd.it/103cl24
Hi so hope this is the right place for this, I am on MacBook Pro M1 Pro and have installed Jupyter Notebook on VSC and downloaded this c kernel and when I try to use it with the code below the code runs ok but I get these two warnings. I also tried on Jupyter notebook from anaconda and I get the same warning so Its not from vsc. Does anyone know how to remove these warnings? Any help in appreciated
https://preview.redd.it/rbh2x3itu2aa1.png?width=3248&format=png&auto=webp&s=0d89ae40160079f29c55dfb7c75d8724cd08337d
https://preview.redd.it/xyli6vitu2aa1.png?width=3248&format=png&auto=webp&s=f8ed647a8c64c6922e1a731f113c19582b55a751
/r/JupyterNotebooks
https://redd.it/103cl24
GitHub
GitHub - XaverKlemenschits/jupyter-c-kernel: Minimal Jupyter C kernel
Minimal Jupyter C kernel. Contribute to XaverKlemenschits/jupyter-c-kernel development by creating an account on GitHub.
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/103jifx
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/103jifx
reddit
Thursday Daily Thread: Python Careers, Courses, and Furthering...
Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python...
Script in Jupyter Notebook to run in Anaconda command window
I am trying to get a script to run a number of similar commands based on items in a dictionary, but I haven't been able to find the information to tell it to run this recurring command in an Anaconda command window. Here is my code:
import yt-dlp
​
​
dict = {
​
​
"folder1" : "url1",
​
​
}
​
​
​
​
​
for (x,y) in dict.items():
yt-dlp -f best -o "D:\\youtube-archive\\{}\\%(title)s.%(ext)s" {}.format(x,y)
​
print("hello world")
What I want this to do is cycle through the for loop for as many times as there is a key:value paring in the dictionary with the key being in between the slashes and the value being between the end quote and period. The hello world portion is just so that I know that at least something happened, which only happened when I dragged and dropped it into an open Anaconda command window. I vaguely remember something about import os being a way to make this happen, but that is for the windows command prompt, not anaconda. Is there an equivalent for Anaconda?
/r/JupyterNotebooks
https://redd.it/103jxm1
I am trying to get a script to run a number of similar commands based on items in a dictionary, but I haven't been able to find the information to tell it to run this recurring command in an Anaconda command window. Here is my code:
import yt-dlp
​
​
dict = {
​
​
"folder1" : "url1",
​
​
}
​
​
​
​
​
for (x,y) in dict.items():
yt-dlp -f best -o "D:\\youtube-archive\\{}\\%(title)s.%(ext)s" {}.format(x,y)
​
print("hello world")
What I want this to do is cycle through the for loop for as many times as there is a key:value paring in the dictionary with the key being in between the slashes and the value being between the end quote and period. The hello world portion is just so that I know that at least something happened, which only happened when I dragged and dropped it into an open Anaconda command window. I vaguely remember something about import os being a way to make this happen, but that is for the windows command prompt, not anaconda. Is there an equivalent for Anaconda?
/r/JupyterNotebooks
https://redd.it/103jxm1
reddit
Script in Jupyter Notebook to run in Anaconda command window
I am trying to get a script to run a number of similar commands based on items in a dictionary, but I haven't been able to find the information to...
urllib3 raised $26,000 and shipped v2.0 in 2022
https://sethmlarson.dev/urllib3-in-2022
/r/Python
https://redd.it/1035bdi
https://sethmlarson.dev/urllib3-in-2022
/r/Python
https://redd.it/1035bdi
Seth Michael Larson
urllib3 in 2022
Funding
In total urllib3 received $26,615 USD in financial support
and distributed $18,622 USD to maintainers and community contributors.
We're thankful for the financial support we receive from
o...
In total urllib3 received $26,615 USD in financial support
and distributed $18,622 USD to maintainers and community contributors.
We're thankful for the financial support we receive from
o...
Using the flask_login library I am not able to access a restricted route that requires login even though user is logged in
I cannot access a restricted route in my flask application whilst using the flask\_login library although I have "logged in" the user. Does anyone know the issue?
This is the [code](https://pastebin.com/zBBzXHfh) for the login route
This is the [code](https://pastebin.com/KaBA3yak) for the restricted route - I've tried both is\_authenticated method and the "**@login\_required**" decorater:
I've tried both
@login_required
and
if not current_user.is_authenticated:
however both do not work.
​
/r/flask
https://redd.it/103i43e
I cannot access a restricted route in my flask application whilst using the flask\_login library although I have "logged in" the user. Does anyone know the issue?
This is the [code](https://pastebin.com/zBBzXHfh) for the login route
This is the [code](https://pastebin.com/KaBA3yak) for the restricted route - I've tried both is\_authenticated method and the "**@login\_required**" decorater:
I've tried both
@login_required
and
if not current_user.is_authenticated:
however both do not work.
​
/r/flask
https://redd.it/103i43e
Pastebin
@app.route("/login", methods=['GET','POST'])def login(): login_form = L - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
How to rendertemplate to fetch post request?
I have a jinja template that needs JavaScripts fetch function to post a picture to the backend. The jinja template has a template variable called message, on the server I would like to return rendertemplate(index.HTML, message=“in correct image format”), obviously it doesn’t work as the response is handled by JavaScript. How can I achieve that same effect using window.location.attach()?
Or if you have a better way to handle this I’m open to suggestions!
/r/flask
https://redd.it/103gtti
I have a jinja template that needs JavaScripts fetch function to post a picture to the backend. The jinja template has a template variable called message, on the server I would like to return rendertemplate(index.HTML, message=“in correct image format”), obviously it doesn’t work as the response is handled by JavaScript. How can I achieve that same effect using window.location.attach()?
Or if you have a better way to handle this I’m open to suggestions!
/r/flask
https://redd.it/103gtti
reddit
How to render_template to fetch post request?
I have a jinja template that needs JavaScripts fetch function to post a picture to the backend. The jinja template has a template variable called...