How do i render link to a url in html without appending the current one
I don't know how exactly to phrase my question but...
I am building a stock market app.
When I am at page 4 of the S&P 500 (http://127.0.0.1:5000/SANDP/4), The pages are generated with dynamic urls, and I click on a link with href Info/<symbol> The new url is http://127.0.0.1:5000/SANDP/Info/<symbol> so it appends the old one.I want to clear the old one so the new one will be http://127.0.0.1:5000/Info/<symbol>. I have tried url_for as well in jinja but it does not work.
/r/flask
https://redd.it/103g8un
I don't know how exactly to phrase my question but...
I am building a stock market app.
When I am at page 4 of the S&P 500 (http://127.0.0.1:5000/SANDP/4), The pages are generated with dynamic urls, and I click on a link with href Info/<symbol> The new url is http://127.0.0.1:5000/SANDP/Info/<symbol> so it appends the old one.I want to clear the old one so the new one will be http://127.0.0.1:5000/Info/<symbol>. I have tried url_for as well in jinja but it does not work.
/r/flask
https://redd.it/103g8un
reddit
How do i render link to a url in html without appending the...
I don't know how exactly to phrase my question but... I am building a stock market app. When I am at page 4 of the S&P 500...
Blueprints and import function from other file
Hello guys,
I am trying to develop a flask application with blueprints to keep it clear and structured.
And in a route.py file from a specific blueprints, i am trying to import a file containing functions from another blueprint.
​
​
https://preview.redd.it/k3dp4czhg0aa1.png?width=1118&format=png&auto=webp&s=d3b82be26cc8ecf9893ef30d7acc2880a975cedc
The file is located in apps > helper and his name is util.py
​
When i run flask, i got an ImportError function
​
https://preview.redd.it/6b2azg1ng0aa1.png?width=986&format=png&auto=webp&s=d03090a0b9850b657e94384b69800e771dd4790c
​
I searched a lot before creating this post but i am stil stucked.
Thank you
/r/flask
https://redd.it/10317ub
Hello guys,
I am trying to develop a flask application with blueprints to keep it clear and structured.
And in a route.py file from a specific blueprints, i am trying to import a file containing functions from another blueprint.
​
​
https://preview.redd.it/k3dp4czhg0aa1.png?width=1118&format=png&auto=webp&s=d3b82be26cc8ecf9893ef30d7acc2880a975cedc
The file is located in apps > helper and his name is util.py
​
When i run flask, i got an ImportError function
​
https://preview.redd.it/6b2azg1ng0aa1.png?width=986&format=png&auto=webp&s=d03090a0b9850b657e94384b69800e771dd4790c
​
I searched a lot before creating this post but i am stil stucked.
Thank you
/r/flask
https://redd.it/10317ub
Flask is not updating my CSS (but it is?)
Like the title says, I'm running a flask app and it is not updating my CSS file...is what I thought was happening. However, upon looking through inspect element, it turns out that it actually is updating those files. I can see files getting loaded in the Network panel, and checking them in the Sources list shows that they're indeed the latest version. So what's wrong? I guess the browser is just not using the updated versions...until I manually edit them? As soon as I make any change in those files (within inspect element), the layout gets updated perfectly. But it's not a browser issue either! I've turned off browser caching, I've done hard refresh a hundred times, tried loading the page in incognito mode, heck even tried a different browser (that should rule out any doubts, right?). In summary, this is what I've tried so far:
- hard refresh of the page
- disable browser cache
- clear all cache in the browser
- run the app in debug mode
- set app.config to to enable TEMPLATESAUTORELOAD and reduce SENDFILEMAXAGEDEFAULT to 0
- add custom tail to the CSS URL (like this one, and yes, the correct files are still
/r/flask
https://redd.it/10322q4
Like the title says, I'm running a flask app and it is not updating my CSS file...is what I thought was happening. However, upon looking through inspect element, it turns out that it actually is updating those files. I can see files getting loaded in the Network panel, and checking them in the Sources list shows that they're indeed the latest version. So what's wrong? I guess the browser is just not using the updated versions...until I manually edit them? As soon as I make any change in those files (within inspect element), the layout gets updated perfectly. But it's not a browser issue either! I've turned off browser caching, I've done hard refresh a hundred times, tried loading the page in incognito mode, heck even tried a different browser (that should rule out any doubts, right?). In summary, this is what I've tried so far:
- hard refresh of the page
- disable browser cache
- clear all cache in the browser
- run the app in debug mode
- set app.config to to enable TEMPLATESAUTORELOAD and reduce SENDFILEMAXAGEDEFAULT to 0
- add custom tail to the CSS URL (like this one, and yes, the correct files are still
/r/flask
https://redd.it/10322q4
Stack Overflow
Flask css not updating
I am using Flask (the python Package) on my mac, when I first wrote my css it displayed ok. However when I updated it and tried to check it, I only see the first css styles. I have tried restarting...
N Legal NLP Dataset With Over 39,000 Examples Released
Legal datasets are extremely expensive because lawyers are, and this has bottlenecked legal NLP.
To address this, we release the Merger Agreement Understand Dataset (MAUD), with over 39,000 multiple-choice reading comprehension examples for 152 merger agreements that have been manually labeled by legal experts. The dataset was created with the help of the American Bar Association; without their help the dataset would have cost over $5,000,000 to create.
MAUD has substantial room for improvement and can could serve as a research challenge for NLP researchers without any legal background.
Dataset and Baselines: https://github.com/TheAtticusProject/maud/
Paper: https://arxiv.org/abs/2301.00876
/r/MachineLearning
https://redd.it/103b1ck
Legal datasets are extremely expensive because lawyers are, and this has bottlenecked legal NLP.
To address this, we release the Merger Agreement Understand Dataset (MAUD), with over 39,000 multiple-choice reading comprehension examples for 152 merger agreements that have been manually labeled by legal experts. The dataset was created with the help of the American Bar Association; without their help the dataset would have cost over $5,000,000 to create.
MAUD has substantial room for improvement and can could serve as a research challenge for NLP researchers without any legal background.
Dataset and Baselines: https://github.com/TheAtticusProject/maud/
Paper: https://arxiv.org/abs/2301.00876
/r/MachineLearning
https://redd.it/103b1ck
GitHub
GitHub - TheAtticusProject/maud
Contribute to TheAtticusProject/maud development by creating an account on GitHub.
PyTorch discloses malicious dependency chain compromise over holidays
https://www.bleepingcomputer.com/news/security/pytorch-discloses-malicious-dependency-chain-compromise-over-holidays/
/r/Python
https://redd.it/103u5rr
https://www.bleepingcomputer.com/news/security/pytorch-discloses-malicious-dependency-chain-compromise-over-holidays/
/r/Python
https://redd.it/103u5rr
BleepingComputer
PyTorch discloses malicious dependency chain compromise over holidays
PyTorch has identified a malicious dependency with the same name as the framework's 'torchtriton' library. This has led to a successful compromise via the dependency confusion attack vector.
I made a game with Pygame in 10 Hours!
I made a game with Pygame in 10 hours! The game contains shaders created a a module called pygame\_shaders as well as procedural generation! The download and source code is available here
​
https://i.redd.it/b0wybty877aa1.gif
/r/Python
https://redd.it/103vc07
I made a game with Pygame in 10 hours! The game contains shaders created a a module called pygame\_shaders as well as procedural generation! The download and source code is available here
​
https://i.redd.it/b0wybty877aa1.gif
/r/Python
https://redd.it/103vc07
PyPI
pygame-shaders
a library to easily integrate shaders into your new or existing pygame projects
Kernel restart
Whenever I run a code for CartPole game in Jupyter notebook or spyder after render() th kernel dies and restart .. An solution?
/r/JupyterNotebooks
https://redd.it/1025cy5
Whenever I run a code for CartPole game in Jupyter notebook or spyder after render() th kernel dies and restart .. An solution?
/r/JupyterNotebooks
https://redd.it/1025cy5
reddit
Kernel restart
Whenever I run a code for CartPole game in Jupyter notebook or spyder after render() th kernel dies and restart .. An solution?
🚨New Django Project Alert 🚨 Effortlessly Combine Your iCalendar Feeds with Calmerge: The Open-Source Django Webap
Hi Django developers,
I just launched calmerge, an open-source Django webapp that allows you to merge multiple iCalendar feeds into a single feed. With calmerge, you can easily keep track of events from multiple sources in one place. Simply add your iCalendar feeds to your calmerge account, and then subscribe to the merged feed using your calendar client (e.g. Google Calendar).
As a first-time Django developer, I'm excited to share my project with the community and receive feedback on the code.
Calmerge was built with Python Django and utilizes Htmx. It's deployed on AWS and the source code is available on GitHub at github.com/abe-101/calmerge.
If you have experience with Django development, I would greatly appreciate any feedback or suggestions you may have on the code. Additionally, if you're interested in using calmerge to manage your own iCalendar feeds, you can access the webapp at calmerge.habet.dev.
Thank you for your time and I look forward to hearing your thoughts on calmerge!
/r/django
https://redd.it/1045zgp
Hi Django developers,
I just launched calmerge, an open-source Django webapp that allows you to merge multiple iCalendar feeds into a single feed. With calmerge, you can easily keep track of events from multiple sources in one place. Simply add your iCalendar feeds to your calmerge account, and then subscribe to the merged feed using your calendar client (e.g. Google Calendar).
As a first-time Django developer, I'm excited to share my project with the community and receive feedback on the code.
Calmerge was built with Python Django and utilizes Htmx. It's deployed on AWS and the source code is available on GitHub at github.com/abe-101/calmerge.
If you have experience with Django development, I would greatly appreciate any feedback or suggestions you may have on the code. Additionally, if you're interested in using calmerge to manage your own iCalendar feeds, you can access the webapp at calmerge.habet.dev.
Thank you for your time and I look forward to hearing your thoughts on calmerge!
/r/django
https://redd.it/1045zgp
GitHub
GitHub - abe-101/calmerge: Calmerge is a Django webapp that allows you to easily merge multiple iCalendar feeds into a single feed.
Calmerge is a Django webapp that allows you to easily merge multiple iCalendar feeds into a single feed. - GitHub - abe-101/calmerge: Calmerge is a Django webapp that allows you to easily merge mul...
The way I build new FastAPI projects
Some people were searching my GitHub profile for project examples after reading the article on FastAPI best practices.
Unfortunately, I didn't have useful public repositories, only my old proof-of-concept projects.
Hence, I have decided to fix that and show how I start projects nowadays, after getting some real-world experience. This repo is kind of a template I use when starting up new FastAPI projects:
- production-ready
- gunicorn with dynamic workers configuration (stolen from @tiangolo)
- Dockerfile optimized for small size and fast builds with a non-root user
- JSON logs
- sentry for deployed envs
- easy local development
- environment with configured postgres and redis
- script to lint code with
- configured pytest with
- fully typed to comply with
- SQLAlchemy with slightly configured
- async db calls with
- set up
- migrations set in easy to sort format (
- pre-installed JWT authorization
- short-lived access token
- long-lived refresh token which is stored in http-only cookies
- salted password storage with
- global pydantic model with
-
/r/Python
https://redd.it/1047tdb
Some people were searching my GitHub profile for project examples after reading the article on FastAPI best practices.
Unfortunately, I didn't have useful public repositories, only my old proof-of-concept projects.
Hence, I have decided to fix that and show how I start projects nowadays, after getting some real-world experience. This repo is kind of a template I use when starting up new FastAPI projects:
- production-ready
- gunicorn with dynamic workers configuration (stolen from @tiangolo)
- Dockerfile optimized for small size and fast builds with a non-root user
- JSON logs
- sentry for deployed envs
- easy local development
- environment with configured postgres and redis
- script to lint code with
black, autoflake, isort (also stolen from @tiangolo)- configured pytest with
async-asgi-testclient, pytest-env, pytest-asyncio- fully typed to comply with
mypy- SQLAlchemy with slightly configured
alembic- async db calls with
asyncpg- set up
sqlalchemy2-stubs- migrations set in easy to sort format (
YYYY-MM-DD_slug)- pre-installed JWT authorization
- short-lived access token
- long-lived refresh token which is stored in http-only cookies
- salted password storage with
bcrypt- global pydantic model with
-
orjson/r/Python
https://redd.it/1047tdb
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
Just released my much-improved YouTube archiver as v1.2 🎉🎉
I've been working hard for the last week and a bit to polish and finish off my new youtube archiver software for its first solid release and I'm really happy with the outcome:
The viewer in dark mode
It has a cool offline viewer for all the videos it downloads and everything is managed through the cli. Behind the scenes I'm using yt-dlp to quickly archive content with about 1.5k lines of python to make the whole thing work. There's still a long way to go until this project is finished, but I'd consider it "stable" enough now :)
You can find the repository here with a couple more images of it in action. Any feedback is appreciated (especially with code quality/structuring), not done a proper python project in ages
/r/Python
https://redd.it/1045ug4
I've been working hard for the last week and a bit to polish and finish off my new youtube archiver software for its first solid release and I'm really happy with the outcome:
The viewer in dark mode
It has a cool offline viewer for all the videos it downloads and everything is managed through the cli. Behind the scenes I'm using yt-dlp to quickly archive content with about 1.5k lines of python to make the whole thing work. There's still a long way to go until this project is finished, but I'd consider it "stable" enough now :)
You can find the repository here with a couple more images of it in action. Any feedback is appreciated (especially with code quality/structuring), not done a proper python project in ages
/r/Python
https://redd.it/1045ug4
Six is maintained by 1 person and used by 25% of the most popular packages. Is this our left-pad to be?
https://medium.com/p/a3b620dd8781
/r/Python
https://redd.it/103su3s
https://medium.com/p/a3b620dd8781
/r/Python
https://redd.it/103su3s
Medium
Using Neo4j to Find the Most Powerful Package
2:30 PM (Pacific Time) March 22, 2016. NPM packages broke for a few hours because Left-pad was unpublished. This showed us, as developers…
Check if user exist in login system Django
I'm struggling trying to figure out how to display the error message, but i don't know what else to try :(
It keeps showing the next error message: "Error al registrarse" instead of the one above.
​
views.py
def registroView(request):
if request.method == "POST":
form = CrearUsuarioForm(request.POST)
if form.isvalid():
user = form.save(commit=False)
if Usuario.objects.filter(
username=form.cleaneddata.get("username")
).exists():
messages.error(request, "Nombre de usuario ya utilizado!")
return redirect("registro")
/r/djangolearning
https://redd.it/104w69t
I'm struggling trying to figure out how to display the error message, but i don't know what else to try :(
It keeps showing the next error message: "Error al registrarse" instead of the one above.
​
views.py
def registroView(request):
if request.method == "POST":
form = CrearUsuarioForm(request.POST)
if form.isvalid():
user = form.save(commit=False)
if Usuario.objects.filter(
username=form.cleaneddata.get("username")
).exists():
messages.error(request, "Nombre de usuario ya utilizado!")
return redirect("registro")
/r/djangolearning
https://redd.it/104w69t
reddit
Check if user exist in login system Django
I'm struggling trying to figure out how to display the error message, but i don't know what else to try :( It keeps showing the next error...
Hot Reloading on Django Templates using ViteJS?
Is this possible? Laravel has a dedicated plugin to directly integrate ViteJS into your workflow.
/r/django
https://redd.it/1053a2c
Is this possible? Laravel has a dedicated plugin to directly integrate ViteJS into your workflow.
/r/django
https://redd.it/1053a2c
reddit
Hot Reloading on Django Templates using ViteJS?
Is this possible? Laravel has a dedicated plugin to directly integrate ViteJS into your workflow.
Trying to create an app that allows users (businesses) to be able to find other users (businesses) that are around them
Ive created an address model (fields for address, city, state, and zip) that will be linked to my user model via a one-to-one relationship. Are there any packages that would help me find the users in my DB nearby both by using either my address stored or via current location?
/r/djangolearning
https://redd.it/10532l3
Ive created an address model (fields for address, city, state, and zip) that will be linked to my user model via a one-to-one relationship. Are there any packages that would help me find the users in my DB nearby both by using either my address stored or via current location?
/r/djangolearning
https://redd.it/10532l3
reddit
Trying to create an app that allows users (businesses) to be able...
Ive created an address model (fields for address, city, state, and zip) that will be linked to my user model via a one-to-one relationship. Are...
Just showcasing this Flask app. Any feedback is appreciated!
https://www.fleetcardeal.com/
/r/flask
https://redd.it/1051elg
https://www.fleetcardeal.com/
/r/flask
https://redd.it/1051elg
How do I make another model a required field for abstractbaseuser model?
Here's a basic outline of what I've got
class Address(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
primary_key=True,
)
address = models.CharField(
max_length=200,
)
city = models.CharField(
max_length=100,
)
state = USStateField()
zipcode = USZipCodeField
class CustomUser(AbstractBaseUser):
...
required_fields = [
#How would I structure this to make the fields in Address required when
/r/django
https://redd.it/1055y71
Here's a basic outline of what I've got
class Address(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
primary_key=True,
)
address = models.CharField(
max_length=200,
)
city = models.CharField(
max_length=100,
)
state = USStateField()
zipcode = USZipCodeField
class CustomUser(AbstractBaseUser):
...
required_fields = [
#How would I structure this to make the fields in Address required when
/r/django
https://redd.it/1055y71
reddit
How do I make another model a required field for abstractbaseuser...
Here's a basic outline of what I've got class Address(models.Model): user = models.OneToOneField( ...
Saturday Daily Thread: Resource Request and Sharing! Daily Thread
Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?
Use this thread to chat about and share Python resources!
/r/Python
https://redd.it/1059w5c
Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?
Use this thread to chat about and share Python resources!
/r/Python
https://redd.it/1059w5c
reddit
Saturday Daily Thread: Resource Request and Sharing! Daily Thread
Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic? Use this thread to chat about and...
Call a view and pass form fields from a pagination button
I have a template that shows a question and multiple choice answers.
I have pagination on the template and show one question at a time.
How can I call a view that will save the users answers each time the next button is clicked. I can’t submit the form because that will end the quiz and calculate the score.
I have not been able to get this working, does anyone have a solution?
/r/django
https://redd.it/105ckyc
I have a template that shows a question and multiple choice answers.
I have pagination on the template and show one question at a time.
How can I call a view that will save the users answers each time the next button is clicked. I can’t submit the form because that will end the quiz and calculate the score.
I have not been able to get this working, does anyone have a solution?
/r/django
https://redd.it/105ckyc
reddit
Call a view and pass form fields from a pagination button
I have a template that shows a question and multiple choice answers. I have pagination on the template and show one question at a time. How...
Dockerise a Django application - Part 6 - Postgres database
https://www.webinative.com/blog/dockerise-django-application-part-6/?utm_source=reddit&utm_medium=social&utm_campaign=dockerise
/r/django
https://redd.it/104s05l
https://www.webinative.com/blog/dockerise-django-application-part-6/?utm_source=reddit&utm_medium=social&utm_campaign=dockerise
/r/django
https://redd.it/104s05l
Webinative Technologies
Dockerise a Django application - Part 6 - Postgres | Webinative Technologies
Learn how to set up a Postgres container and connect to your Django app.