[AF] How should I go about unit testing my flask RESTplus API?
Can I use pytest? What else do I need?
/r/flask
https://redd.it/8s4mln
Can I use pytest? What else do I need?
/r/flask
https://redd.it/8s4mln
reddit
r/flask - [AF] How should I go about unit testing my flask RESTplus API?
8 votes and 4 so far on reddit
Is there a way to access a Flask Session variable outside of the context of a request?
I know session variables can only be accessed once there is a client -> server request but I have a thread that runs concurrently outside of a request. I tried the "with app context" conditional that didn't quite work.
Any ideas?
/r/flask
https://redd.it/8rytzd
I know session variables can only be accessed once there is a client -> server request but I have a thread that runs concurrently outside of a request. I tried the "with app context" conditional that didn't quite work.
Any ideas?
/r/flask
https://redd.it/8rytzd
reddit
r/flask - Is there a way to access a Flask Session variable outside of the context of a request?
2 votes and 5 so far on reddit
[N] Nvidia releases libraries for fast image augmentation
https://news.developer.nvidia.com/announcing-nvidia-dali-and-nvidia-nvjpeg/?ncid=--43656
/r/MachineLearning
https://redd.it/8sac1b
https://news.developer.nvidia.com/announcing-nvidia-dali-and-nvidia-nvjpeg/?ncid=--43656
/r/MachineLearning
https://redd.it/8sac1b
NVIDIA Developer Blog
Announcing NVIDIA DALI and NVIDIA nvJPEG | NVIDIA Developer Blog
Today at Computer Vision and Pattern Recognition (CVPR) conference, we’re making available new libraries for data augmentation and image decoding. NVIDIA DALI: A GPU-accelerated data augmentation and…
Telegram bot for self-testing of anxiety and depression (Open Source)
https://github.com/dizballanze/m00dbot
/r/Python
https://redd.it/8sgkgz
https://github.com/dizballanze/m00dbot
/r/Python
https://redd.it/8sgkgz
GitHub
GitHub - dizballanze/m00dbot: Telegram bot for self-testing of anxiety and depression
Telegram bot for self-testing of anxiety and depression - dizballanze/m00dbot
Need advice and recommendations to build a Blog Engine
Hi,
I'm to build a blog engine/CMS. Features I want to implement:
1. API based (totally)
2. reusable (can be easily embedded in larger projects)
3. database agnostic (SQL basically and PostgreSQL preferably)
4. internal good (but not complex) search engine
5. supports different post types (I want to know how to generalise the following post types)
1. gallery item (image with title and description)
2. blog post (ordinary post that might use images and videos inside)
3. project post (project title, description, url, image, embedded demo(like iframe)))
4. about us/contact us post (like pages)
6. with tags only (without categories --first tag should be the main category or so--)
7. media centre to upload images and files
8. resources (posts/images/files) should be also accessible via ID or Slugs
9. should I implement user roles and authentication? how?
10. What about testing? library to use, framework or just the standard
11. And Documentations?
12. Please feel free to add Your suggestions and how to implement it.
I've finished Miguel's tutorials and I want to do something big to apply what I learned and learn more. I want some insights on what I should and what I shouldn't do, libraries to use, things to consider, recommended methods, what to do first and what to do later? etc.
Mostly, I will use Vuejs to build the front-end, but I want to build the blog first because I want to embed it in a larger website. And I need it to be standalone so that I can share it.
Thanks in advance :)
/r/flask
https://redd.it/8si0pf
Hi,
I'm to build a blog engine/CMS. Features I want to implement:
1. API based (totally)
2. reusable (can be easily embedded in larger projects)
3. database agnostic (SQL basically and PostgreSQL preferably)
4. internal good (but not complex) search engine
5. supports different post types (I want to know how to generalise the following post types)
1. gallery item (image with title and description)
2. blog post (ordinary post that might use images and videos inside)
3. project post (project title, description, url, image, embedded demo(like iframe)))
4. about us/contact us post (like pages)
6. with tags only (without categories --first tag should be the main category or so--)
7. media centre to upload images and files
8. resources (posts/images/files) should be also accessible via ID or Slugs
9. should I implement user roles and authentication? how?
10. What about testing? library to use, framework or just the standard
11. And Documentations?
12. Please feel free to add Your suggestions and how to implement it.
I've finished Miguel's tutorials and I want to do something big to apply what I learned and learn more. I want some insights on what I should and what I shouldn't do, libraries to use, things to consider, recommended methods, what to do first and what to do later? etc.
Mostly, I will use Vuejs to build the front-end, but I want to build the blog first because I want to embed it in a larger website. And I need it to be standalone so that I can share it.
Thanks in advance :)
/r/flask
https://redd.it/8si0pf
reddit
r/flask - Need advice and recommendations to build a Blog Engine
1 votes and 0 so far on reddit
Django Class-Based/Generic Views - An Introduction
When starting out, you most likely used **function-based views**.
**Class-Based views** are an alternative to them. As the name suggests, you group your code into methods that
live inside of a class.
If you have a hard time understanding what they are or why they are used, keep reading ;)
This function-based view:
def book_list(self):
# Note: you can handle different request methods by checking for the appropriate
# value of request.METHOD with if/else statements
# e.g. 'GET', 'POST', ...
book_list = Book.objects.all()
return render(request, 'index.html', {'book_list': book_list})
Could roughly be written as this class-based view:
class BookListView(View):
# Note: you can handle different request methods using the appropriate function names
# e.g. get(), post(), ...
def get(self, request):
book_list = Book.objects.all()
return render(request, 'index.html', {'book_list': book_list})
Well, we didn't gain much, right?
But how about splitting our code into more meaningful functions that live inside of the same class?
class BookListView(View):
def get(self, request):
return render(request, 'index.html', {'book_list': self.get_queryset()})
def get_queryset(self):
return Book.objects.all()
Well, I now have two functions instead of one. So what?
1. **Separation of concerns** is easier this way.
2. This allows us to use **subclass** from another class and easily override some methods, while **inheriting** the other methods, which still will do their thing. Turns out, that django implements certain generic views for us, which take care of implementing the business logic of common web development tasks for us.
Let's get back to our example and rewrite it subclassing from a generic view:
class BookListView(ListView):
model = Book
template_name = 'index.html'
Well, that was short. Still, we will get the same result. There are many other generic views you can use, such as the **DetailView** for object detail pages or **FormView**, which makes form handling easy.
Of course, you can override context data as well by simply overriding certain functions on the listview.
If you want more information on that, check out my 6 minute video on the subject:
[**https://youtu.be/oA60bl\_HFIk**](https://youtu.be/oA60bl_HFIk)
Take care!
*(Note: code above is untested and doesn't include import statements. If you spot any errors, make sure to let me know.)*
/r/djangolearning
https://redd.it/8sja4x
When starting out, you most likely used **function-based views**.
**Class-Based views** are an alternative to them. As the name suggests, you group your code into methods that
live inside of a class.
If you have a hard time understanding what they are or why they are used, keep reading ;)
This function-based view:
def book_list(self):
# Note: you can handle different request methods by checking for the appropriate
# value of request.METHOD with if/else statements
# e.g. 'GET', 'POST', ...
book_list = Book.objects.all()
return render(request, 'index.html', {'book_list': book_list})
Could roughly be written as this class-based view:
class BookListView(View):
# Note: you can handle different request methods using the appropriate function names
# e.g. get(), post(), ...
def get(self, request):
book_list = Book.objects.all()
return render(request, 'index.html', {'book_list': book_list})
Well, we didn't gain much, right?
But how about splitting our code into more meaningful functions that live inside of the same class?
class BookListView(View):
def get(self, request):
return render(request, 'index.html', {'book_list': self.get_queryset()})
def get_queryset(self):
return Book.objects.all()
Well, I now have two functions instead of one. So what?
1. **Separation of concerns** is easier this way.
2. This allows us to use **subclass** from another class and easily override some methods, while **inheriting** the other methods, which still will do their thing. Turns out, that django implements certain generic views for us, which take care of implementing the business logic of common web development tasks for us.
Let's get back to our example and rewrite it subclassing from a generic view:
class BookListView(ListView):
model = Book
template_name = 'index.html'
Well, that was short. Still, we will get the same result. There are many other generic views you can use, such as the **DetailView** for object detail pages or **FormView**, which makes form handling easy.
Of course, you can override context data as well by simply overriding certain functions on the listview.
If you want more information on that, check out my 6 minute video on the subject:
[**https://youtu.be/oA60bl\_HFIk**](https://youtu.be/oA60bl_HFIk)
Take care!
*(Note: code above is untested and doesn't include import statements. If you spot any errors, make sure to let me know.)*
/r/djangolearning
https://redd.it/8sja4x
Learn Basic Python and scikit-learn Machine Learning Hands-On with My Course: Training Your Systems with Python Statistical Modelling
https://ntguardian.wordpress.com/2018/06/20/learn-basic-python-scikit-learn-machine-learning-hands-on-course-training-systems-python-statistical-modelling/
/r/pystats
https://redd.it/8sk2fv
https://ntguardian.wordpress.com/2018/06/20/learn-basic-python-scikit-learn-machine-learning-hands-on-course-training-systems-python-statistical-modelling/
/r/pystats
https://redd.it/8sk2fv
Curtis Miller's Personal Website
Learn Basic Python and scikit-learn Machine Learning Hands-On with My Course: Training Your Systems with Python Statistical Modelling
In this course I cover statistics and machine learning topics. The course assumes little knowledge about what statistics or machine learning involves. I touch lightly on the theory of statistics an…
relation "django_content_type" does not exist despite "manage.py migrate contenttypes" being run
Hello everyone,
when i run ```python -Wall manage.py test;``` to see what i'll need to see what i'll have to pay attention when updating to a newer django version i get the following error:
```django.db.utils.ProgrammingError: relation "django_content_type" does not exist```
according to the internet i should run ```python manage.py migrate contenttypes```
however when i do so it shows the following error:
```django.db.utils.ProgrammingError: relation "auth_permission" does not exist```
so i run:
```python manage.py migrate auth;``` which results in:
```django.db.utils.ProgrammingError: relation "django_site" does not exist```
which is solve by running:
```python manage.py migrate sites;```
but when i rerun ```python -Wall manage.py test;``` i get the same error again.
The only reason i'm including the migrations of auth and sites in here is because the three seem to have a cyclical dependency, auth depends on sites, contentypes depends on auth and sites depends on contentypes (going by the errors they print depending on which migration i try to run first).
The three of them are included in the installed apps as:
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sites',
Does anyone know what is causing this and how i can fix this?
/r/djangolearning
https://redd.it/8shzg5
Hello everyone,
when i run ```python -Wall manage.py test;``` to see what i'll need to see what i'll have to pay attention when updating to a newer django version i get the following error:
```django.db.utils.ProgrammingError: relation "django_content_type" does not exist```
according to the internet i should run ```python manage.py migrate contenttypes```
however when i do so it shows the following error:
```django.db.utils.ProgrammingError: relation "auth_permission" does not exist```
so i run:
```python manage.py migrate auth;``` which results in:
```django.db.utils.ProgrammingError: relation "django_site" does not exist```
which is solve by running:
```python manage.py migrate sites;```
but when i rerun ```python -Wall manage.py test;``` i get the same error again.
The only reason i'm including the migrations of auth and sites in here is because the three seem to have a cyclical dependency, auth depends on sites, contentypes depends on auth and sites depends on contentypes (going by the errors they print depending on which migration i try to run first).
The three of them are included in the installed apps as:
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sites',
Does anyone know what is causing this and how i can fix this?
/r/djangolearning
https://redd.it/8shzg5
reddit
r/djangolearning - relation "django_content_type" does not exist despite "manage.py migrate contenttypes" being run
1 votes and 0 so far on reddit
Sentdex on Udemy's awful business practices
https://youtu.be/X7jf70dNrUo
Very interesting perspective
/r/Python
https://redd.it/8sl76u
https://youtu.be/X7jf70dNrUo
Very interesting perspective
/r/Python
https://redd.it/8sl76u
Is Python getting slower?
[https://github.com/reinderien/py-cat-times](https://github.com/reinderien/py-cat-times)
In particular - for certain concatenation operations that I've profiled in the link above, why does it appear that some operations (e.g. `str join`) are getting slightly slower (in the 10s of %) while others (e.g. successive `+` on a "bytes") have gone from O(n) to O(n²)?
[One of the graphs from R, showing performance differences over Python versions](https://i.redd.it/h47304o4s6511.png)
[One of the graphs from R, showing some concatenation methods that are O\(n²\)](https://i.redd.it/fp9y8gihs6511.png)
Is it that `pyenv` is doing a poor job in compiling Python on my MacBook, or that my profiling technique has problems, or is this real?
/r/Python
https://redd.it/8sjybt
[https://github.com/reinderien/py-cat-times](https://github.com/reinderien/py-cat-times)
In particular - for certain concatenation operations that I've profiled in the link above, why does it appear that some operations (e.g. `str join`) are getting slightly slower (in the 10s of %) while others (e.g. successive `+` on a "bytes") have gone from O(n) to O(n²)?
[One of the graphs from R, showing performance differences over Python versions](https://i.redd.it/h47304o4s6511.png)
[One of the graphs from R, showing some concatenation methods that are O\(n²\)](https://i.redd.it/fp9y8gihs6511.png)
Is it that `pyenv` is doing a poor job in compiling Python on my MacBook, or that my profiling technique has problems, or is this real?
/r/Python
https://redd.it/8sjybt
GitHub
reinderien/py-cat-times
py-cat-times - Python concatenation profiling exploration
How to get comfortable in Django?
This might seem like a stupid question but I am an iOS developer so I'm not to familiar with python terminology.
I'm building a Rest API using DRF for my iOS app. I feel comfortable creating posts and users and simply sending them through JSON to the phone, but I don't know how to make custom function in Django like for example a `featured list` based off clicks or upvotes. I just don't know where to look to improve my python skills to where I can create custom features and functions.
Can anyone recommend a book or a path I can take so I can finish this backend and really customize things?
/r/django
https://redd.it/8snuo9
This might seem like a stupid question but I am an iOS developer so I'm not to familiar with python terminology.
I'm building a Rest API using DRF for my iOS app. I feel comfortable creating posts and users and simply sending them through JSON to the phone, but I don't know how to make custom function in Django like for example a `featured list` based off clicks or upvotes. I just don't know where to look to improve my python skills to where I can create custom features and functions.
Can anyone recommend a book or a path I can take so I can finish this backend and really customize things?
/r/django
https://redd.it/8snuo9
reddit
r/django - How to get comfortable in Django?
5 votes and 5 so far on reddit
[P] CS230 projects (Spring 2018)
http://cs230.stanford.edu/proj-spring-2018.html
/r/MachineLearning
https://redd.it/8sk4cv
http://cs230.stanford.edu/proj-spring-2018.html
/r/MachineLearning
https://redd.it/8sk4cv
reddit
r/MachineLearning - [P] CS230 projects (Spring 2018)
33 votes and 4 so far on reddit
The Pythonic Guide to Logging
https://timber.io/blog/the-pythonic-guide-to-logging/
/r/Python
https://redd.it/8sm80g
https://timber.io/blog/the-pythonic-guide-to-logging/
/r/Python
https://redd.it/8sm80g
Convert Django ORM query with large IN clause to table value constructor
I have a bit of Django code that builds a relatively complicated query in a programmatic fashion, with various filters getting applied to an initial dataset through a series of filter and exclude calls:
for filter in filters:
if filter['name'] == 'revenue':
accounts = accounts.filter(account_revenue__in: filter['values'])
if filter['name'] == 'some_other_type':
if filter['type'] == 'inclusion':
accounts = accounts.filter(account__some_relation__in: filter['values'])
if filter['type'] == 'exclusion':
accounts = accounts.exclude(account__some_relation__in: filter['values'])
...etc
return accounts
For most of these conditions, the possible values of the filters are relatively small and contained, so the IN clauses that Django's ORM generates are performant enough. However there are a few cases where the IN clauses can be much larger (10K - 100K items).
In plain postgres I can make this query much more optimal by using a table value constructor, e.g.:
SELECT domain
FROM accounts
INNER JOIN (
VALUES ('somedomain.com'), ('anotherdomain.com'), ...etc 10K more times
) VALS(v) ON accounts.domain=v
With a 30K+ IN clause in the original query it can take 60+ seconds to run, while the table value version of the query takes 1 second, a huge difference.
But I cannot figure out how to get Django ORM to build the query like I want, and because of the way all the other filters are constructed from ORM filters I can't really write the entire thing as raw SQL.
I was thinking I could get the raw SQL that Django's ORM is going to run, regexp parse it, but that seems very brittle (and surprisingly difficult to get the actual SQL that is about to be run, because of parameter handling etc). I don't see how I could annotate with RawSQL since I don't want to add a column to select, but instead want to add a join condition. Is there a simple solution I am missing?
/r/django
https://redd.it/8sp2p5
I have a bit of Django code that builds a relatively complicated query in a programmatic fashion, with various filters getting applied to an initial dataset through a series of filter and exclude calls:
for filter in filters:
if filter['name'] == 'revenue':
accounts = accounts.filter(account_revenue__in: filter['values'])
if filter['name'] == 'some_other_type':
if filter['type'] == 'inclusion':
accounts = accounts.filter(account__some_relation__in: filter['values'])
if filter['type'] == 'exclusion':
accounts = accounts.exclude(account__some_relation__in: filter['values'])
...etc
return accounts
For most of these conditions, the possible values of the filters are relatively small and contained, so the IN clauses that Django's ORM generates are performant enough. However there are a few cases where the IN clauses can be much larger (10K - 100K items).
In plain postgres I can make this query much more optimal by using a table value constructor, e.g.:
SELECT domain
FROM accounts
INNER JOIN (
VALUES ('somedomain.com'), ('anotherdomain.com'), ...etc 10K more times
) VALS(v) ON accounts.domain=v
With a 30K+ IN clause in the original query it can take 60+ seconds to run, while the table value version of the query takes 1 second, a huge difference.
But I cannot figure out how to get Django ORM to build the query like I want, and because of the way all the other filters are constructed from ORM filters I can't really write the entire thing as raw SQL.
I was thinking I could get the raw SQL that Django's ORM is going to run, regexp parse it, but that seems very brittle (and surprisingly difficult to get the actual SQL that is about to be run, because of parameter handling etc). I don't see how I could annotate with RawSQL since I don't want to add a column to select, but instead want to add a join condition. Is there a simple solution I am missing?
/r/django
https://redd.it/8sp2p5
reddit
r/django - Convert Django ORM query with large IN clause to table value constructor
3 votes and 3 so far on reddit
Open source Python libraries for Embedded and IoT: sensors, actuators, industrial protocols, cloud services and board definitions
https://www.zerynth.com/blog/python-libraries-for-embedded-and-iot-over-100-repositories-on-zerynth-github/
/r/Python
https://redd.it/8sqhi9
https://www.zerynth.com/blog/python-libraries-for-embedded-and-iot-over-100-repositories-on-zerynth-github/
/r/Python
https://redd.it/8sqhi9
Zerynth - Python for Microcontrollers, IoT and Embedded Solutions
Python libraries for Embedded and IoT - over 100 repositories on Zerynth GitHub
On the Zerynth GitHub repo, you can find over 100 Python libraries for sensors and actuators, industrial protocols and cloud services. Learn more!
New Django extension for VS Code
I just published version 0.8 of my try to write a very good Django extension for Visual Studio Code!
And at the same time, `vscode-icons` was released with support of icons for Django templates!
[https://marketplace.visualstudio.com/items?itemName=batisteo.vscode-django](https://marketplace.visualstudio.com/items?itemName=batisteo.vscode-django)
I put some effort into syntax, so that we can see tags and variables within HTML `class` or any attributes, highlighting known tags/filters and contribs, adding more scopes etc.
A support for non-HTML templates is also available (called `django-txt`), typically for emails.
From today it is also possible to click through (aka Go To Definiton) on the path in a `{% extends %}` or `{% include %}` tag.
And of course a bunch of snippets, some with support for pasting. Still needs some love and polishing.
[https://github.com/vscode-django/vscode-django](https://github.com/vscode-django/vscode-django)
Next steps:
* Having scoped Python snippets: model fields if in a models(/\*\*).py file, form fields on forms, same for admin…
* Autogenerating HTML snippets from Django introspection, so that’s easier to have up to date the extension
* Better support for Jinja and [Tera](https://github.com/Keats/tera/)
* Make you like it (please submit an issue if it’s not at your taste)
I hope VS Code users will enjoy it
/r/django
https://redd.it/8sqmoy
I just published version 0.8 of my try to write a very good Django extension for Visual Studio Code!
And at the same time, `vscode-icons` was released with support of icons for Django templates!
[https://marketplace.visualstudio.com/items?itemName=batisteo.vscode-django](https://marketplace.visualstudio.com/items?itemName=batisteo.vscode-django)
I put some effort into syntax, so that we can see tags and variables within HTML `class` or any attributes, highlighting known tags/filters and contribs, adding more scopes etc.
A support for non-HTML templates is also available (called `django-txt`), typically for emails.
From today it is also possible to click through (aka Go To Definiton) on the path in a `{% extends %}` or `{% include %}` tag.
And of course a bunch of snippets, some with support for pasting. Still needs some love and polishing.
[https://github.com/vscode-django/vscode-django](https://github.com/vscode-django/vscode-django)
Next steps:
* Having scoped Python snippets: model fields if in a models(/\*\*).py file, form fields on forms, same for admin…
* Autogenerating HTML snippets from Django introspection, so that’s easier to have up to date the extension
* Better support for Jinja and [Tera](https://github.com/Keats/tera/)
* Make you like it (please submit an issue if it’s not at your taste)
I hope VS Code users will enjoy it
/r/django
https://redd.it/8sqmoy
Visualstudio
Django - Visual Studio Marketplace
Extension for Visual Studio Code - Beautiful syntax and scoped snippets for perfectionists with deadlines
Using SelectFields with flask-wtforms !HELP!
I'm having issues using Select Field in flask . I'm unable to submit get data from the select fields , also when i use them with normal input fields none of the fields return any data . But the input fields work and return data if I remove the selectFields . Here's the code :
Models and form :
class City(db.Model):
id = db.Column(db.Integer, primary\_key=True)
city = db.Column(db.String(30), unique=True, nullable=False)
state = db.Column(db.String(30), nullable=False)
country = db.Column(db.String(30), nullable=False)
class CityForm(FlaskForm):
city = StringField('city', validators=\[InputRequired()\])
state = SelectField('state' , validators=\[InputRequired()\] , coerce = str)
country = SelectField('country' , validators=\[InputRequired()\] , coerce = str)
the select fields are populated in the views , like this :
form\_city.state.choices = \[(row\[0\],row\[0\]) for row in db.session.query(login\_model.State.state)\]
form\_city.country.choices = \[(row\[0\],row\[0\]) for row in db.session.query(login\_model.Country.country)\]
\~\~\~\~\~
if form\_city.validate\_on\_submit():
mssg = ""
prod = login\_model.City.query.filter\_by(city=form\_city.city.data).first()
print('okaaay')
if prod :
mssg = "Duplicate Data "
flash(mssg)
return redirect(url\_for('basic\_master'))
else:
new\_data = login\_model.City(city=form\_city.city.data.upper())
try:
db.session.add(new\_data)
db.session.commit()
mssg = "Data Successfully added 👍"
flash(mssg)
return redirect(url\_for('basic\_master'))
except Exception as e:
mssg = "Error occured while adding data 😵. Here's the error : "+str(e)
flash(mssg)
return redirect(url\_for('basic\_master'))
Nothing works if I have selectfields in my Form class , and If i remove them the normal input field works .
Any help is much appreciated thanks.
\#flask #sqlalchemy #wtforms #python
/r/flask
https://redd.it/8srquo
I'm having issues using Select Field in flask . I'm unable to submit get data from the select fields , also when i use them with normal input fields none of the fields return any data . But the input fields work and return data if I remove the selectFields . Here's the code :
Models and form :
class City(db.Model):
id = db.Column(db.Integer, primary\_key=True)
city = db.Column(db.String(30), unique=True, nullable=False)
state = db.Column(db.String(30), nullable=False)
country = db.Column(db.String(30), nullable=False)
class CityForm(FlaskForm):
city = StringField('city', validators=\[InputRequired()\])
state = SelectField('state' , validators=\[InputRequired()\] , coerce = str)
country = SelectField('country' , validators=\[InputRequired()\] , coerce = str)
the select fields are populated in the views , like this :
form\_city.state.choices = \[(row\[0\],row\[0\]) for row in db.session.query(login\_model.State.state)\]
form\_city.country.choices = \[(row\[0\],row\[0\]) for row in db.session.query(login\_model.Country.country)\]
\~\~\~\~\~
if form\_city.validate\_on\_submit():
mssg = ""
prod = login\_model.City.query.filter\_by(city=form\_city.city.data).first()
print('okaaay')
if prod :
mssg = "Duplicate Data "
flash(mssg)
return redirect(url\_for('basic\_master'))
else:
new\_data = login\_model.City(city=form\_city.city.data.upper())
try:
db.session.add(new\_data)
db.session.commit()
mssg = "Data Successfully added 👍"
flash(mssg)
return redirect(url\_for('basic\_master'))
except Exception as e:
mssg = "Error occured while adding data 😵. Here's the error : "+str(e)
flash(mssg)
return redirect(url\_for('basic\_master'))
Nothing works if I have selectfields in my Form class , and If i remove them the normal input field works .
Any help is much appreciated thanks.
\#flask #sqlalchemy #wtforms #python
/r/flask
https://redd.it/8srquo
reddit
r/flask - Using SelectFields with flask-wtforms !HELP!
1 votes and 3 so far on reddit
How to upload image file via binary file Not using form-data
Hi, I am trying to upload image files using postman binary file. I read \`[request.stream.read](https://request.stream.read)()\` but how can i save this file on specific folder.
/r/flask
https://redd.it/8sq8il
Hi, I am trying to upload image files using postman binary file. I read \`[request.stream.read](https://request.stream.read)()\` but how can i save this file on specific folder.
/r/flask
https://redd.it/8sq8il
A web application that allows you to test in real time which site is blocked in China.
[ezscale.science](http://ezscale.science)
This is my first django project. I hosted this project on a server in Beijing, since websites have to register domain in compliance with Chinese law, so I redirected to IP address from a remote server in Germany. This site uses ajax calls to remain on the same page and utilize a ping backend to test whether the website you called is blocked.
You can submit your own website to the list to see if they're blocked.
This is only the test phase - I have not yet been able to hook it on to apache - the tutorials online didn't work for me. Mobile doesn't work for real time ajax - I used :hover to show elements but I can't seem to get :active working on mobile.. Also, I'll be very appreciative if you find any bugs! Thanks in advance for any help.
EDIT: I currently reviewing all websites, if the new websites are not random they'll be added to the main lists. You'll be seeing new website you added but they only appear before you refresh the page..
EDIT2: I'm going to sleep and this might suffer a Reddit Hug of Death - I'm running this on a very small ECS. 1GB ram and 1mbps of link. But I'll hopefully get it on Apache tomorrow and if successful I'll enlarge the ECS and officially release it.
/r/Python
https://redd.it/8srnef
[ezscale.science](http://ezscale.science)
This is my first django project. I hosted this project on a server in Beijing, since websites have to register domain in compliance with Chinese law, so I redirected to IP address from a remote server in Germany. This site uses ajax calls to remain on the same page and utilize a ping backend to test whether the website you called is blocked.
You can submit your own website to the list to see if they're blocked.
This is only the test phase - I have not yet been able to hook it on to apache - the tutorials online didn't work for me. Mobile doesn't work for real time ajax - I used :hover to show elements but I can't seem to get :active working on mobile.. Also, I'll be very appreciative if you find any bugs! Thanks in advance for any help.
EDIT: I currently reviewing all websites, if the new websites are not random they'll be added to the main lists. You'll be seeing new website you added but they only appear before you refresh the page..
EDIT2: I'm going to sleep and this might suffer a Reddit Hug of Death - I'm running this on a very small ECS. 1GB ram and 1mbps of link. But I'll hopefully get it on Apache tomorrow and if successful I'll enlarge the ECS and officially release it.
/r/Python
https://redd.it/8srnef
PEP 572 and decision-making in Python
https://lwn.net/SubscriberLink/757713/2118c7722d957926/
/r/Python
https://redd.it/8stu3u
https://lwn.net/SubscriberLink/757713/2118c7722d957926/
/r/Python
https://redd.it/8stu3u
lwn.net
PEP 572 and decision-making in Python
The "PEP 572 mess" was the topic of a 2018 Python Language Summit session
led by benevolent dictator for life (BDFL) Guido van Rossum. PEP 572 seeks to add
assignment expressions (or "inline assignments") to the language, but it
has seen a prolonged
discussion…
led by benevolent dictator for life (BDFL) Guido van Rossum. PEP 572 seeks to add
assignment expressions (or "inline assignments") to the language, but it
has seen a prolonged
discussion…