For people who live in Cleveland, are there any PyCon events that are walk-in (i.e. free for poor undergrads)?
/r/Python
https://redd.it/8ik019
/r/Python
https://redd.it/8ik019
reddit
r/Python - For people who live in Cleveland, are there any PyCon events that are walk-in (i.e. free for poor undergrads)?
45 votes and 12 so far on reddit
Fabric 2.0 released, includes Python 3 compatibility
http://docs.fabfile.org/en/latest/upgrading.html#upgrading
/r/django
https://redd.it/8ikmwm
http://docs.fabfile.org/en/latest/upgrading.html#upgrading
/r/django
https://redd.it/8ikmwm
Advice o two-step user registration process with SMS verification
My Django app uses a subclass of Usercreationform, with a char field for an SMS code requested via ajax. I'm using the mobile # as the username.
When submitted, if form.is\_valid and the sms code submitted is the one sent \(saved in db\), form is saved and the newly created user is logged in.
I am breaking this up into 2 steps to prevent getting flooded with malicious/frivolous sms requests. The sms field is replaced with a django\-simple\-captcha field. If form.is\_valid, a user is created with is\_active=False. The request is then redirected to a page with a one\-time url to request and submit an sms code to verify account, which flips user.is\_active to True if successful.
I'm just realizing that a vulnerability is created if someone maliciously "registers" a whole bunch of real mobile numbers without verifying, and when the real owner of one of the numbers tries to register, my form subclassed from Usercreationform would complain that an account already exists with that username.
I guess I can do something on the frontend with JS to still make it 2\-step but submit the form in one go, and if everything is valid an active user gets created, otherwise nothing happens. But does Django have anything quick and simple that solves my problem?
Also, any general advice? I thought about rate limiting with Nginx my current structure instead. But what would be a sensible rate for user sign\-up? Something like 1r/s per IP seems way too high. But if I set a rate too restrictive, I run the risk of blocking potential customers behind a NAT with a mysterious error code.
Thanks!
/r/django
https://redd.it/8ik0ki
My Django app uses a subclass of Usercreationform, with a char field for an SMS code requested via ajax. I'm using the mobile # as the username.
When submitted, if form.is\_valid and the sms code submitted is the one sent \(saved in db\), form is saved and the newly created user is logged in.
I am breaking this up into 2 steps to prevent getting flooded with malicious/frivolous sms requests. The sms field is replaced with a django\-simple\-captcha field. If form.is\_valid, a user is created with is\_active=False. The request is then redirected to a page with a one\-time url to request and submit an sms code to verify account, which flips user.is\_active to True if successful.
I'm just realizing that a vulnerability is created if someone maliciously "registers" a whole bunch of real mobile numbers without verifying, and when the real owner of one of the numbers tries to register, my form subclassed from Usercreationform would complain that an account already exists with that username.
I guess I can do something on the frontend with JS to still make it 2\-step but submit the form in one go, and if everything is valid an active user gets created, otherwise nothing happens. But does Django have anything quick and simple that solves my problem?
Also, any general advice? I thought about rate limiting with Nginx my current structure instead. But what would be a sensible rate for user sign\-up? Something like 1r/s per IP seems way too high. But if I set a rate too restrictive, I run the risk of blocking potential customers behind a NAT with a mysterious error code.
Thanks!
/r/django
https://redd.it/8ik0ki
reddit
Advice o two-step user registration process with SMS... • r/django
My Django app uses a subclass of Usercreationform, with a char field for an SMS code requested via ajax. I'm using the mobile # as the...
Practicality Beats Purity: Microservices vs Monoliths
http://tryexceptpass.org/article/practicality-beats-purity-3/
/r/Python
https://redd.it/8iikd3
http://tryexceptpass.org/article/practicality-beats-purity-3/
/r/Python
https://redd.it/8iikd3
tryexceptpass.org
Practicality Beats Purity - Microservices vs Monoliths
Consequences of microservice architectures and the problems they solve.
[R] Full-body high-resolution Anime Generation with Progressive Structure-conditional GANs
http://dena.com/intl/anime-generation/
/r/MachineLearning
https://redd.it/8iky2y
http://dena.com/intl/anime-generation/
/r/MachineLearning
https://redd.it/8iky2y
Anyone wants to be my study-buddy for learning Flask?
Anyone wants to be my study-buddy for learning Flask using Miguel Grinberg's Flask Mega Tutorial?https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
Starting: May 14th
/r/flask
https://redd.it/8iiz6m
Anyone wants to be my study-buddy for learning Flask using Miguel Grinberg's Flask Mega Tutorial?https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
Starting: May 14th
/r/flask
https://redd.it/8iiz6m
Miguelgrinberg
The Flask Mega-Tutorial, Part I: Hello, World!
You are reading the 2024 edition of the Flask Mega-Tutorial. The complete course is also available to order in e-book and paperback formats from Amazon. Thank you for your support!If you are looking…
How to combat blog spam?
This is a bit of a meta post about r/python, rather than python itself. However, it seems to me that there is a very noticeable amount of blog spam, which I'll loosely define as having the following features:
* Poorly-written
* Unhelpful - sometimes just plain incorrect and misleading
* Heavily focused just on SEO
Have others noticed the same thing?
Can anything be done to limit the amount of blog spam? Require posts to be authorised by mods before going live? Other measures to be taken?
I just wanted to attempt to open it up for debate, so please discuss below, if this is appropriate.
/r/Python
https://redd.it/8in595
This is a bit of a meta post about r/python, rather than python itself. However, it seems to me that there is a very noticeable amount of blog spam, which I'll loosely define as having the following features:
* Poorly-written
* Unhelpful - sometimes just plain incorrect and misleading
* Heavily focused just on SEO
Have others noticed the same thing?
Can anything be done to limit the amount of blog spam? Require posts to be authorised by mods before going live? Other measures to be taken?
I just wanted to attempt to open it up for debate, so please discuss below, if this is appropriate.
/r/Python
https://redd.it/8in595
reddit
r/Python - How to combat blog spam?
91 votes and 31 so far on reddit
[D] ICML 2018 decisions are out
https://cmt.research.microsoft.com/ICML2018/Default.aspx
/r/MachineLearning
https://redd.it/8ioqrr
https://cmt.research.microsoft.com/ICML2018/Default.aspx
/r/MachineLearning
https://redd.it/8ioqrr
reddit
[D] ICML 2018 decisions are out • r/MachineLearning
15 points and 19 comments so far on reddit
[R] Noisin: Unbiased Regularization for Recurrent Neural Networks
https://arxiv.org/abs/1805.01500
/r/MachineLearning
https://redd.it/8ipmx0
https://arxiv.org/abs/1805.01500
/r/MachineLearning
https://redd.it/8ipmx0
reddit
[R] Noisin: Unbiased Regularization for... • r/MachineLearning
15 points and 0 comments so far on reddit
Wagtail Space US: a free, three day Wagtail event in Philadelphia
https://us.wagtail.space
/r/django
https://redd.it/8ir1ef
https://us.wagtail.space
/r/django
https://redd.it/8ir1ef
us.wagtail.space
Wagtail Space US 2024
json post issue
Ok, so here's the problem. I have a Notes form. It posts the information properly but lets say I'd like to post another post right after I hit submit note. It won't post it and it will fill the url eg: " [http://app.com/ticket/1?body=](http://app.com/ticket/1?body=)blahblah&?method=add ". If I want to post again I have to refresh the page, What am I doing wrong?
Here's my JS.
$('#noteform').submit(function(e) {
e.preventDefault();
var csrf_token = "{{ csrf_token() }}";
var ticketid = "{{ ticket.id }}";
var twoSecMin = $.Deferred();
$.ajax({
url: '/repair/addNote',
dataType: 'json',
type: 'post',
contentType: 'application/json',
data: JSON.stringify( {
"method": 'add',
"body": $('#body').val(),
"ticketid": ticketid,
"private_note": $('#private_note').prop('checked')
}),
processData: true,
success: function( data, textStatus, jQxhr ){
$('#notes').load(' #notes');
$('#notecount').load(' #notecount');
$('input[type=text], textarea').val('');
$('input[type=checkbox]').prop("checked", false);
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
alert('Error Posting Note!');
}
});
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrf_token);
}
}
});
});
and this is my controller logic.
@ticket.route('/addNote', methods=["POST"])
def addNote():
json = request.get_json()
method = json['method']
if method == 'add':
body = json['body']
private = json['private_note']
tid = json['ticketid']
# Create note!
newnote = Notes(
created_by = 0,
is_private = private,
ticket_id = tid,
body = body,
)
db.session.add(newnote)
db.session.commit()
elif method == 'delete':
noteid = json['noteid']
# Delete note.
notetodelete = Notes.query.filter_by(id=noteid).first_or_404()
db.session.delete(notetodelete)
db.session.commit()
elif method == 'update':
return None
return jsonify(result='done')
/r/flask
https://redd.it/8is6qf
Ok, so here's the problem. I have a Notes form. It posts the information properly but lets say I'd like to post another post right after I hit submit note. It won't post it and it will fill the url eg: " [http://app.com/ticket/1?body=](http://app.com/ticket/1?body=)blahblah&?method=add ". If I want to post again I have to refresh the page, What am I doing wrong?
Here's my JS.
$('#noteform').submit(function(e) {
e.preventDefault();
var csrf_token = "{{ csrf_token() }}";
var ticketid = "{{ ticket.id }}";
var twoSecMin = $.Deferred();
$.ajax({
url: '/repair/addNote',
dataType: 'json',
type: 'post',
contentType: 'application/json',
data: JSON.stringify( {
"method": 'add',
"body": $('#body').val(),
"ticketid": ticketid,
"private_note": $('#private_note').prop('checked')
}),
processData: true,
success: function( data, textStatus, jQxhr ){
$('#notes').load(' #notes');
$('#notecount').load(' #notecount');
$('input[type=text], textarea').val('');
$('input[type=checkbox]').prop("checked", false);
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
alert('Error Posting Note!');
}
});
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrf_token);
}
}
});
});
and this is my controller logic.
@ticket.route('/addNote', methods=["POST"])
def addNote():
json = request.get_json()
method = json['method']
if method == 'add':
body = json['body']
private = json['private_note']
tid = json['ticketid']
# Create note!
newnote = Notes(
created_by = 0,
is_private = private,
ticket_id = tid,
body = body,
)
db.session.add(newnote)
db.session.commit()
elif method == 'delete':
noteid = json['noteid']
# Delete note.
notetodelete = Notes.query.filter_by(id=noteid).first_or_404()
db.session.delete(notetodelete)
db.session.commit()
elif method == 'update':
return None
return jsonify(result='done')
/r/flask
https://redd.it/8is6qf
[P] TF-REX: AI learns to play Google Chrome's Dinosaur Game | No Emulators | All info in blogpost
https://www.youtube.com/watch?v=UM_wyrd0k-k
/r/MachineLearning
https://redd.it/8iujuu
https://www.youtube.com/watch?v=UM_wyrd0k-k
/r/MachineLearning
https://redd.it/8iujuu
YouTube
TF-REX: AI learns to play Google's Dinosaur Game | See Progress | No Emulators
This video shows how a Deep Q-network learns to play Google Chrome's T-rex game in under 12 hours. The algorithm and framework are implemented from scratch in Python using TensorFlow.
Compared to existing projects we do two things different:
1) No emulator…
Compared to existing projects we do two things different:
1) No emulator…
Upload Progress Bar
Hi everyone,
I was wondering if you could recommend a progress bar that will work with file uploads in Django. I see that there are several available, and I've tried several without any success. I was wondering if you could recommend one that you've been able to get working.
Thanks!
/r/django
https://redd.it/8iu3sl
Hi everyone,
I was wondering if you could recommend a progress bar that will work with file uploads in Django. I see that there are several available, and I've tried several without any success. I was wondering if you could recommend one that you've been able to get working.
Thanks!
/r/django
https://redd.it/8iu3sl
reddit
Upload Progress Bar • r/django
Hi everyone, I was wondering if you could recommend a progress bar that will work with file uploads in Django. I see that there are several...
Django cms on AWS Lambda
Has anyone ever hosted a Django cms mezzanine or wagtail on AWS Lambda. If so I need some direction on to go about doing it effectively. Any pointers would be appreciated.
PS: I have hosted a simple Django based website on Lambda so I have elementary experience in this area.
/r/django
https://redd.it/8iv3lr
Has anyone ever hosted a Django cms mezzanine or wagtail on AWS Lambda. If so I need some direction on to go about doing it effectively. Any pointers would be appreciated.
PS: I have hosted a simple Django based website on Lambda so I have elementary experience in this area.
/r/django
https://redd.it/8iv3lr
reddit
Django cms on AWS Lambda • r/django
Has anyone ever hosted a Django cms mezzanine or wagtail on AWS Lambda. If so I need some direction on to go about doing it effectively. Any...
[Flask-SQLAlchemy] Querying association table in flask-sqlalchemy?
Let's say I have two models **Posts** and **Tags** and an association table **post_tags** that connects these models in a many-to-many relationship (one post can have one or many tags and each tag can have one or more posts attached to it):
post_tags = db.Table(
'post_tags',
db.Column('post_id', db.Integer, db.ForeignKey('posts.id'), primary_key=True),
db.Column('tag_id', db.Integer, db.ForeignKey('tags.id'), primary_key=True),
)
class Post(db.Model):
__tablename__ = 'posts'
id = db.Column(db.Integer, primary_key=True)
text = db.Column(db.Text, nullable=False)
created_at = db.Column(db.Integer, nullable=False)
class Tag(db.Model):
__tablename__ = 'tags'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, unique=True, nullable=False)
I want to obtain the most frequently mentioned tags from the **post_tags** table. SQLite query for this roughly looks like:
SELECT tag_id, count(tag_id) FROM post_tags GROUP BY tag_id ORDER BY count(tag_id) DESC;
How can I accomplish this in SQLAlchemy? I am using Flask-SQLAlchemy extension and SQLite as a DB driver.
Edit: formatting and grammar
/r/flask
https://redd.it/8idv32
Let's say I have two models **Posts** and **Tags** and an association table **post_tags** that connects these models in a many-to-many relationship (one post can have one or many tags and each tag can have one or more posts attached to it):
post_tags = db.Table(
'post_tags',
db.Column('post_id', db.Integer, db.ForeignKey('posts.id'), primary_key=True),
db.Column('tag_id', db.Integer, db.ForeignKey('tags.id'), primary_key=True),
)
class Post(db.Model):
__tablename__ = 'posts'
id = db.Column(db.Integer, primary_key=True)
text = db.Column(db.Text, nullable=False)
created_at = db.Column(db.Integer, nullable=False)
class Tag(db.Model):
__tablename__ = 'tags'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, unique=True, nullable=False)
I want to obtain the most frequently mentioned tags from the **post_tags** table. SQLite query for this roughly looks like:
SELECT tag_id, count(tag_id) FROM post_tags GROUP BY tag_id ORDER BY count(tag_id) DESC;
How can I accomplish this in SQLAlchemy? I am using Flask-SQLAlchemy extension and SQLite as a DB driver.
Edit: formatting and grammar
/r/flask
https://redd.it/8idv32
reddit
r/flask - [Flask-SQLAlchemy] Querying association table in flask-sqlalchemy?
4 votes and 1 so far on reddit
Can I host Django website where i currently host my Wordpress website?
I have a hosting service for 1 year but I use it to host Wordpress.Can i host my Django website on the server instead of the Wordpress?
What are the requirements to host Django?
/r/django
https://redd.it/8itn2j
I have a hosting service for 1 year but I use it to host Wordpress.Can i host my Django website on the server instead of the Wordpress?
What are the requirements to host Django?
/r/django
https://redd.it/8itn2j
reddit
Can I host Django website where i currently host my... • r/django
I have a hosting service for 1 year but I use it to host Wordpress.Can i host my Django website on the server instead of the Wordpress? What are...
[AF] Pagination not working, has_next and has_prev always gives None
Hi, so as the title suggests I have a problem regarding pagination. Here is the code I have tried to use (taken from [Miguel Grinberg's tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-ix-pagination)).
def index():
"""View function for the index site, basically the main site.
Sorts posts by hotness"""
page = request.args.get('page', 1, type=int)
posts = Post.query.order_by(Post.hotness.desc()).paginate(
page, app.config['POSTS_PER_PAGE'], False)
next_url = url_for('index', page=posts.next_num) \
if posts.has_next else None
prev_url = url_for('index', page=posts.prev_num) \
if posts.has_prev else None
return render_template('index.html', title='Dopenet: You can do anything', posts=posts.items, next_url=next_url, prev_url=prev_url)
The index.html file is this:
{% extends "base.html" %}
{% block content %}
{% for post in posts if posts %}
{% include '_post.html' %}
{% endfor %}
{% if prev_url %}
<a href="{{ prev_url }}">Newer posts</a>
{% endif %}
{% if next_url %}
<a href="{{ next_url }}">Older posts</a>
{% endif %}
{% endblock %}
So I am guessing that both has_next and has_prev are giving `None` as a response, so hence no url for both prev and next.
What am I doing wrong and how can I fix this?
The rest of the code can be found here, if more context is needed:
https://www.github.com/ModoUnreal/Nuncio
/r/flask
https://redd.it/8ixivl
Hi, so as the title suggests I have a problem regarding pagination. Here is the code I have tried to use (taken from [Miguel Grinberg's tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-ix-pagination)).
def index():
"""View function for the index site, basically the main site.
Sorts posts by hotness"""
page = request.args.get('page', 1, type=int)
posts = Post.query.order_by(Post.hotness.desc()).paginate(
page, app.config['POSTS_PER_PAGE'], False)
next_url = url_for('index', page=posts.next_num) \
if posts.has_next else None
prev_url = url_for('index', page=posts.prev_num) \
if posts.has_prev else None
return render_template('index.html', title='Dopenet: You can do anything', posts=posts.items, next_url=next_url, prev_url=prev_url)
The index.html file is this:
{% extends "base.html" %}
{% block content %}
{% for post in posts if posts %}
{% include '_post.html' %}
{% endfor %}
{% if prev_url %}
<a href="{{ prev_url }}">Newer posts</a>
{% endif %}
{% if next_url %}
<a href="{{ next_url }}">Older posts</a>
{% endif %}
{% endblock %}
So I am guessing that both has_next and has_prev are giving `None` as a response, so hence no url for both prev and next.
What am I doing wrong and how can I fix this?
The rest of the code can be found here, if more context is needed:
https://www.github.com/ModoUnreal/Nuncio
/r/flask
https://redd.it/8ixivl
GitHub
ModoUnreal/nuncio
nuncio - The fair news website