flask restfull handle incorrect urls
I am using the Flask_restful package and I have a question. I have some paths like: /api/users/<int:id>/recepies. Everything works fine until you request this url without the id, like this: /api/users//recepies or /api/users/recepies, then it throws an error. Is there a way to catch this kind of errors?
/r/flask
https://redd.it/8gsqiz
I am using the Flask_restful package and I have a question. I have some paths like: /api/users/<int:id>/recepies. Everything works fine until you request this url without the id, like this: /api/users//recepies or /api/users/recepies, then it throws an error. Is there a way to catch this kind of errors?
/r/flask
https://redd.it/8gsqiz
reddit
r/flask - flask restfull handle incorrect urls
1 votes and 2 so far on reddit
migrating from sqlserver to postgres, issue with sqlserver_ado.fields.BigAutoField
I am trying to change our django from using M/S SQL server to postgres. One of the model fields is defined in the initial migration as sqlserver_ado.fields.BigAutoField(serialize=False, primary_key=True). After changing the database engine to postgres, the field is missing in the postgres database. If I try to migrate it to something like models.BigIntegerField(serialize=False, primary_key=True), I get the error "ValueError: Cannot alter field verosgui.MpWatchlistchange.chan_coun into verosgui.MpWatchlistchange.chan_coun - they do not properly define db_type (are you using PostGIS 1.5 or badly-written custom fields?)". Does anyone know how to migrate this field?
/r/django
https://redd.it/8h2q5c
I am trying to change our django from using M/S SQL server to postgres. One of the model fields is defined in the initial migration as sqlserver_ado.fields.BigAutoField(serialize=False, primary_key=True). After changing the database engine to postgres, the field is missing in the postgres database. If I try to migrate it to something like models.BigIntegerField(serialize=False, primary_key=True), I get the error "ValueError: Cannot alter field verosgui.MpWatchlistchange.chan_coun into verosgui.MpWatchlistchange.chan_coun - they do not properly define db_type (are you using PostGIS 1.5 or badly-written custom fields?)". Does anyone know how to migrate this field?
/r/django
https://redd.it/8h2q5c
reddit
migrating from sqlserver to postgres, issue with... β’ r/django
I am trying to change our django from using M/S SQL server to postgres. One of the model fields is defined in the initial migration as...
I figured you guys would enjoy this, Humble Bundle put together a nice Python Dev Kit. Happy coding!
https://www.humblebundle.com/software/python-dev-kit-bundle?hmb_source=navbar&hmb_medium=product_tile&hmb_campaign=tile_index_2
/r/Python
https://redd.it/8h5q4g
https://www.humblebundle.com/software/python-dev-kit-bundle?hmb_source=navbar&hmb_medium=product_tile&hmb_campaign=tile_index_2
/r/Python
https://redd.it/8h5q4g
Humble Bundle
Humble Software Bundle: Python Dev Kit
Pay what you want for a bundle of Python resources and support charity!
How to run a task after flask server starts?
Hey guys, I'm trying to run my flask site in a pyqt5 GUI interface however after app.run(), all functions afterward are ignored until I close the server. This results in me getting a 404 from the PyQT interface. Anyone know how to run the flask server and allow a function to run after it? If it is possible, it would actually be better if I could run them at the same time. Thanks guys
**EDIT**: solved this actually
did the following
def pyqt_function():
#thing to be done by pyqt
t = threading.Thread(target=pyqt_function)
t.daemon = True
t.start()
app.run()
/r/flask
https://redd.it/8gs9zq
Hey guys, I'm trying to run my flask site in a pyqt5 GUI interface however after app.run(), all functions afterward are ignored until I close the server. This results in me getting a 404 from the PyQT interface. Anyone know how to run the flask server and allow a function to run after it? If it is possible, it would actually be better if I could run them at the same time. Thanks guys
**EDIT**: solved this actually
did the following
def pyqt_function():
#thing to be done by pyqt
t = threading.Thread(target=pyqt_function)
t.daemon = True
t.start()
app.run()
/r/flask
https://redd.it/8gs9zq
reddit
r/flask - How to run a task after flask server starts?
0 votes and 0 so far on reddit
The first color-accurate Instagram-like filters reconstruction for apps
https://github.com/homm/color-filters-reconstruction#accurate-instagram-filters-reconstruction
/r/Python
https://redd.it/8h6wut
https://github.com/homm/color-filters-reconstruction#accurate-instagram-filters-reconstruction
/r/Python
https://redd.it/8h6wut
GitHub
GitHub - homm/color-filters-reconstruction: Very accurate color filters reconstruction tools based on 3D color LUTs
Very accurate color filters reconstruction tools based on 3D color LUTs - homm/color-filters-reconstruction
Python batch script in Windows
Need to run a python program multiple times with different arguments each time. Coming from Linux I would create a shell script and run a loop calling the python program. What is your preferred way to do this in Windows? Powershell? Open to all suggestions.
/r/Python
https://redd.it/8h7405
Need to run a python program multiple times with different arguments each time. Coming from Linux I would create a shell script and run a loop calling the python program. What is your preferred way to do this in Windows? Powershell? Open to all suggestions.
/r/Python
https://redd.it/8h7405
reddit
r/Python - Python batch script in Windows
1 votes and 0 so far on reddit
[P] Style2PaintsV3 released! Geometric Interactivity, Controllable Shadow Rendering, Better Skin Engine and More.
/r/MachineLearning
https://redd.it/8h2wzn
/r/MachineLearning
https://redd.it/8h2wzn
Build A Social Network With Python Flask Tutorial For Beginners
https://www.youtube.com/watch?v=GjJbaolBPAY
/r/Python
https://redd.it/8h70wv
https://www.youtube.com/watch?v=GjJbaolBPAY
/r/Python
https://redd.it/8h70wv
YouTube
build a social network with python: tutorial for beginners
Awesome to have you here TIME TO CODE π₯οΈ π§
Join the community on Discord! https://discordapp.com/invite/QZd3aaN
βββββββββββββββββββββββββββββββββββββββββββββββ
JOIN THE DEVELOPER COMMUNITY π¬:
βββββββββββββββββββββββββββββββββββββββββββββββ
πΊ SUBSCRIBE ONβ¦
Join the community on Discord! https://discordapp.com/invite/QZd3aaN
βββββββββββββββββββββββββββββββββββββββββββββββ
JOIN THE DEVELOPER COMMUNITY π¬:
βββββββββββββββββββββββββββββββββββββββββββββββ
πΊ SUBSCRIBE ONβ¦
Would /r/django be interested in a livestream/VOD series building real-world Django apps from the ground up?
I've been thinking of starting up a streaming/VOD series that builds real-world applications from start to finish. My plan for the first stream would be building an RSS reader from scratch and going over the various concepts along the way. I'm a little tired of seeing all of the "Learn Web Development for Absolute Beginners" series that end after part 2 popping up all over the place. I'd love to create some content that builds an app with real value and be able to answer questions from people as I go along.
I want to gauge interest from the different communities to see what they think and figured I'd start here since I'd be using Django. What are your thoughts on the idea? Would you be interested in watching/participating?
Thanks for any feedback.
EDIT: alone -> along
/r/django
https://redd.it/8h87o2
I've been thinking of starting up a streaming/VOD series that builds real-world applications from start to finish. My plan for the first stream would be building an RSS reader from scratch and going over the various concepts along the way. I'm a little tired of seeing all of the "Learn Web Development for Absolute Beginners" series that end after part 2 popping up all over the place. I'd love to create some content that builds an app with real value and be able to answer questions from people as I go along.
I want to gauge interest from the different communities to see what they think and figured I'd start here since I'd be using Django. What are your thoughts on the idea? Would you be interested in watching/participating?
Thanks for any feedback.
EDIT: alone -> along
/r/django
https://redd.it/8h87o2
reddit
Would /r/django be interested in a livestream/VOD... β’ r/django
I've been thinking of starting up a streaming/VOD series that builds real-world applications from start to finish. My plan for the first stream...
Configuring position of docstrings?
When I check the docstring of a Python function, it opens at the bottom of the browser window. However, since my screen has the standard shape of being wider than high, this means that when running the Jupyter notebook there's a lot of wasted space at the sides. It would therefore be terrific to have the docstring open at the side of the notebook cells, rather than underneath them. I could then have a docstring open without losing any notebook screen real-estate.
Can this be done?
/r/JupyterNotebooks
https://redd.it/8h6w2w
When I check the docstring of a Python function, it opens at the bottom of the browser window. However, since my screen has the standard shape of being wider than high, this means that when running the Jupyter notebook there's a lot of wasted space at the sides. It would therefore be terrific to have the docstring open at the side of the notebook cells, rather than underneath them. I could then have a docstring open without losing any notebook screen real-estate.
Can this be done?
/r/JupyterNotebooks
https://redd.it/8h6w2w
reddit
r/JupyterNotebooks - Configuring position of docstrings?
1 votes and 0 so far on reddit
Modern Django tooling and testing
Hi hackers,
I'm relatively new to Django but not to web development. What are some essential libraries and tools you use for modern Django development? What are some "must haves" in your Pipfile? And how are most folks testing these days?
Currently, I use:
[packages]
django = "*"
"psycopg2" = "*"
gunicorn = "*"
django-heroku = "*"
dj-database-url = "*"
whitenoise = "*"
django-dotenv = "*"
[dev-packages]
green = "*"
I am especially interested in testing, as the Python and/or Django test frameworks, aren't quite as powerful, out of the box, as what I'm used to from other ecosystems.
Bonus points for a "modern" guide to working with Django.
/r/django
https://redd.it/8har0u
Hi hackers,
I'm relatively new to Django but not to web development. What are some essential libraries and tools you use for modern Django development? What are some "must haves" in your Pipfile? And how are most folks testing these days?
Currently, I use:
[packages]
django = "*"
"psycopg2" = "*"
gunicorn = "*"
django-heroku = "*"
dj-database-url = "*"
whitenoise = "*"
django-dotenv = "*"
[dev-packages]
green = "*"
I am especially interested in testing, as the Python and/or Django test frameworks, aren't quite as powerful, out of the box, as what I'm used to from other ecosystems.
Bonus points for a "modern" guide to working with Django.
/r/django
https://redd.it/8har0u
reddit
r/django - Modern Django tooling and testing
2 votes and 2 so far on reddit
Conditional Counting
Let's say we have the following simplistic models:
class Category(models.Model):
name = models.CharField(max_length=264)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "categories"
class Status(models.Model):
name = models.CharField(max_length=264)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "status"
class Bet(models.Model):
title = models.CharField(max_length=264)
description = models.CharField(max_length=264)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
price = models.DecimalField(max_digits=10)
status = models.ForeignKey(Status, on_delete=models.CASCADE)
Status choices would be: Sold, Not Sold, Reserved, Withdrawn.
My aim is for each category to get the total amount of products and how many were Sold or Reserved.
This would get the total amount of products per category:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"))
Including how many were Sold or Reserved:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"), total_available=Count(Case(When(status__name__in=["Sold", "Reserved"], then=True), default=False, output_field=BooleanField())))
I am not sure if it's the correct way, total_available appears to return all the products per category.
/r/django
https://redd.it/8hbvca
Let's say we have the following simplistic models:
class Category(models.Model):
name = models.CharField(max_length=264)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "categories"
class Status(models.Model):
name = models.CharField(max_length=264)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "status"
class Bet(models.Model):
title = models.CharField(max_length=264)
description = models.CharField(max_length=264)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
price = models.DecimalField(max_digits=10)
status = models.ForeignKey(Status, on_delete=models.CASCADE)
Status choices would be: Sold, Not Sold, Reserved, Withdrawn.
My aim is for each category to get the total amount of products and how many were Sold or Reserved.
This would get the total amount of products per category:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"))
Including how many were Sold or Reserved:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"), total_available=Count(Case(When(status__name__in=["Sold", "Reserved"], then=True), default=False, output_field=BooleanField())))
I am not sure if it's the correct way, total_available appears to return all the products per category.
/r/django
https://redd.it/8hbvca
reddit
Conditional Counting β’ r/django
Let's say we have the following simplistic models: class Category(models.Model): name = models.CharField(max_length=264) ...
Nuitka Release 0.5.30
http://nuitka.net/posts/nuitka-release-0530.html
/r/Python
https://redd.it/8ha98n
http://nuitka.net/posts/nuitka-release-0530.html
/r/Python
https://redd.it/8ha98n
Nuitka Home
Nuitka Release 0.5.30
This is to inform you about the new stable release of Nuitka. It is the extremely compatible Python compiler. Please see the page "What is Nuitka?" for an overview.
This release has improvements in al
This release has improvements in al
[AF] How to prevent brute-force login attacks using flask-login?
Is there a standard way of doing this, or is it up to me to implement the logic?
Thanks
/r/flask
https://redd.it/8h8mja
Is there a standard way of doing this, or is it up to me to implement the logic?
Thanks
/r/flask
https://redd.it/8h8mja
reddit
r/flask - [AF] How to prevent brute-force login attacks using flask-login?
4 votes and 6 so far on reddit
how to display conditional html in a template shared between several routes ?
hello, so i have two different routes that return the same template,
@app.route('/')
def home:
...
return render_template('default.html')
@app.route('/name')
def name:
...
name = #some code
return render_template('default.html',name=name)
a chunk of code of that template is the following
{% if name is not none %}
<p>customer name is : {{ name }}</p>
{% endif %}
it appears that in the route ('/'), the name is evaluated as not none, so it goes through the if statement and the html is displayed (with blank where the name is supposed to be displayed)
i want my html part to be either fully displayed with the name if there is one, or nothing. how can i do ?
/r/flask
https://redd.it/8h765l
hello, so i have two different routes that return the same template,
@app.route('/')
def home:
...
return render_template('default.html')
@app.route('/name')
def name:
...
name = #some code
return render_template('default.html',name=name)
a chunk of code of that template is the following
{% if name is not none %}
<p>customer name is : {{ name }}</p>
{% endif %}
it appears that in the route ('/'), the name is evaluated as not none, so it goes through the if statement and the html is displayed (with blank where the name is supposed to be displayed)
i want my html part to be either fully displayed with the name if there is one, or nothing. how can i do ?
/r/flask
https://redd.it/8h765l
reddit
r/flask - how to display conditional html in a template shared between several routes ?
1 votes and 8 so far on reddit
Hello Qt for Python
https://blog.qt.io/blog/2018/05/04/hello-qt-for-python/
/r/Python
https://redd.it/8hdqsh
https://blog.qt.io/blog/2018/05/04/hello-qt-for-python/
/r/Python
https://redd.it/8hdqsh
www.qt.io
Hello Qt for Python
typing: How to use class in type hints while defining the class itself?
Hereβs an illustration of what I want to do:
class Foo(object):
def fn(self) -> Foo: # <-- error here
return Foo()
When doing this, the compiler complains:
NameError: name 'Foo' is not defined
How do I use `Foo` in a type hint while defining `Foo` itself?
/r/Python
https://redd.it/8hdnzz
Hereβs an illustration of what I want to do:
class Foo(object):
def fn(self) -> Foo: # <-- error here
return Foo()
When doing this, the compiler complains:
NameError: name 'Foo' is not defined
How do I use `Foo` in a type hint while defining `Foo` itself?
/r/Python
https://redd.it/8hdnzz
reddit
r/Python - typing: How to use class in type hints while defining the class itself?
9 votes and 3 so far on reddit
Conditional Counting
Let's say we have the following simplistic models:
class Category(models.Model):
name = models.CharField(max_length=264)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "categories"
class Status(models.Model):
name = models.CharField(max_length=264)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "status"
class Bet(models.Model):
title = models.CharField(max_length=264)
description = models.CharField(max_length=264)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
price = models.DecimalField(max_digits=10)
status = models.ForeignKey(Status, on_delete=models.CASCADE)
Status choices would be: Sold, Not Sold, Reserved, Withdrawn.
My aim is for each category to get the total amount of products and how many were Sold or Reserved.
This would get the total amount of products per category:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"))
Including how many were Sold or Reserved:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"), total_available=Count(Case(When(status__name__in=["Sold", "Reserved"], then=True), default=False, output_field=BooleanField())))
So, if you don't include default=True in the annotation it works as intented.
I want to go a little bit further, so the total_available is a percentage of the total products of each category:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"), total_available=Cast((Count(Case(When(status__name__in=["Sold", "Reserved"], then=True), default=False, output_field=BooleanField())) / Count("id")) * 100., FloatField()))
This way it really does not work properly, I wish I knew why.
/r/django
https://redd.it/8hbvca
Let's say we have the following simplistic models:
class Category(models.Model):
name = models.CharField(max_length=264)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "categories"
class Status(models.Model):
name = models.CharField(max_length=264)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "status"
class Bet(models.Model):
title = models.CharField(max_length=264)
description = models.CharField(max_length=264)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
price = models.DecimalField(max_digits=10)
status = models.ForeignKey(Status, on_delete=models.CASCADE)
Status choices would be: Sold, Not Sold, Reserved, Withdrawn.
My aim is for each category to get the total amount of products and how many were Sold or Reserved.
This would get the total amount of products per category:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"))
Including how many were Sold or Reserved:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"), total_available=Count(Case(When(status__name__in=["Sold", "Reserved"], then=True), default=False, output_field=BooleanField())))
So, if you don't include default=True in the annotation it works as intented.
I want to go a little bit further, so the total_available is a percentage of the total products of each category:
qs = Product.objects.all().values("category__name").annotate(total_products=Count("id"), total_available=Cast((Count(Case(When(status__name__in=["Sold", "Reserved"], then=True), default=False, output_field=BooleanField())) / Count("id")) * 100., FloatField()))
This way it really does not work properly, I wish I knew why.
/r/django
https://redd.it/8hbvca
reddit
Conditional Counting β’ r/django
Let's say we have the following simplistic models: class Category(models.Model): name = models.CharField(max_length=264) ...
Stay DRY in Django With Decorators [xpost r/python]
https://blog.bastions.co/dev/stay-dry-in-django/
/r/django
https://redd.it/8h7bw6
https://blog.bastions.co/dev/stay-dry-in-django/
/r/django
https://redd.it/8h7bw6
reddit
r/django - Stay DRY in Django With Decorators [xpost r/python]
10 votes and 3 so far on reddit