Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Thumbnail in form or formset

Hi everyone,

What's the easiest way to display the image that has been uploaded to the form in addition to or rather than just the filepath of the image within a form or formset. Really struggling with this one.

Thanks!


/r/django
https://redd.it/8as2gu
Allowing user to add details to flask-mail message

So I have a modal on my site from which I want my user to be able to enter their email, hit submit, and then the app to message me with the users email. So far I've got the site sending a message but I'm unsure how to get the users email into the message. Any help would be much appreciated.

My code for sending the email


@app.route('/sendmail/', methods=['POST','GET'])
def send_mail():
try:
#emaiil = request.form['email']
msg = Message("Access request",
sender="SENDING_EMAIL",
recipients=["MY_EMAIL"])
msg.body = "Users email is"
mail.send(msg)
flash('Request sent!')
return redirect(url_for('main'))
except Exception, e:
return(str(e))

My modal for which the user enters their email


<div class="modal-body">
<p>Password can be obtained from somewhere</p>
<form action="{% print url_for('send_mail') %}" class ="form- inline" method="post">
<input type = "email" class = "form-control" placeholder="Email" name = "email">
<a href="/sendmail" class ="btn btn-default">Submit</a>
<button type="button" class="btn btn-secondary" data- dismiss="modal modal2">Close</button>
</form>

The modal is called from here


@app.route("/", methods=['POST','GET'])
def main():
return render_template('main.html')

/r/flask
https://redd.it/8at9sg
How do you code in css without running collectstatic with each change?

How do you guys write css without collecting static on each change to see the effect?

Thanks!

/r/django
https://redd.it/8atv09
Domain Tree Structure Best Practices?

I'm curious as to what judgement criteria is generally used when organizing the placement of apps (or sections) of a website within the tree structure?

In particular, when is it best practice to place an app name in front of your domain www.appname.domain.com vs behind it www.domain/appname.com? Is this related more to SPA's?


/r/django
https://redd.it/8atrk0
Combinations in Python

Need help counting the different ways I can get 10 pairs of couples from a ballroom dance club with 10 males and 12 females to choose from. I was thinking importing itertools would be helpful.

/r/Python
https://redd.it/8auuzu
[D] Machine Learning - WAYR (What Are You Reading) - Week 44

This is a place to share machine learning research papers, journals, and articles that you're reading this week. If it relates to what you're researching, by all means elaborate and give us your insight, otherwise it could just be an interesting paper you've read.

Please try to provide some insight from your understanding and please don't post things which are present in wiki.

Preferably you should link the arxiv page (not the PDF, you can easily access the PDF from the summary page but not the other way around) or any other pertinent links.

Previous weeks :

|1-10|11-20|21-30|31-40|41-50|
|----|-----|-----|-----|-----|
|[Week 1](https://www.reddit.com/r/MachineLearning/comments/4qyjiq/machine_learning_wayr_what_are_you_reading_week_1/)|[Week 11](https://www.reddit.com/r/MachineLearning/comments/57xw56/discussion_machine_learning_wayr_what_are_you/)|[Week 21](https://www.reddit.com/r/MachineLearning/comments/60ildf/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 31](https://www.reddit.com/r/MachineLearning/comments/6s0k1u/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 41](https://www.reddit.com/r/MachineLearning/comments/7tn2ax/d_machine_learning_wayr_what_are_you_reading_week/)|||
|[Week 2](https://www.reddit.com/r/MachineLearning/comments/4s2xqm/machine_learning_wayr_what_are_you_reading_week_2/)|[Week 12](https://www.reddit.com/r/MachineLearning/comments/5acb1t/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 22](https://www.reddit.com/r/MachineLearning/comments/64jwde/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 32](https://www.reddit.com/r/MachineLearning/comments/72ab5y/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 42](https://www.reddit.com/r/MachineLearning/comments/7wvjfk/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 3](https://www.reddit.com/r/MachineLearning/comments/4t7mqm/machine_learning_wayr_what_are_you_reading_week_3/)|[Week 13](https://www.reddit.com/r/MachineLearning/comments/5cwfb6/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 23](https://www.reddit.com/r/MachineLearning/comments/674331/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 33](https://www.reddit.com/r/MachineLearning/comments/75405d/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 43](https://www.reddit.com/r/MachineLearning/comments/807ex4/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 4](https://www.reddit.com/r/MachineLearning/comments/4ub2kw/machine_learning_wayr_what_are_you_reading_week_4/)|[Week 14](https://www.reddit.com/r/MachineLearning/comments/5fc5mh/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 24](https://www.reddit.com/r/MachineLearning/comments/68hhhb/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 34](https://www.reddit.com/r/MachineLearning/comments/782js9/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 5](https://www.reddit.com/r/MachineLearning/comments/4xomf7/machine_learning_wayr_what_are_you_reading_week_5/)|[Week 15](https://www.reddit.com/r/MachineLearning/comments/5hy4ur/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 25](https://www.reddit.com/r/MachineLearning/comments/69teiz/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 35](https://www.reddit.com/r/MachineLearning/comments/7b0av0/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 6](https://www.reddit.com/r/MachineLearning/comments/4zcyvk/machine_learning_wayr_what_are_you_reading_week_6/)|[Week 16](https://www.reddit.com/r/MachineLearning/comments/5kd6vd/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 26](https://www.reddit.com/r/MachineLearning/comments/6d7nb1/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 36](https://www.reddit.com/r/MachineLearning/comments/7e3fx6/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 7](https://www.reddit.com/r/MachineLearning/comments/52t6mo/machine_learning_wayr_what_are_you_reading_week_7/)|[Week 17](https://www.reddit.com/r/MachineLearning/comments/5o
b7dx/discussion_machine_learning_wayr_what_are_you/)|[Week 27](https://www.reddit.com/r/MachineLearning/comments/6gngwc/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 37](https://www.reddit.com/r/MachineLearning/comments/7hcc2c/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 8](https://www.reddit.com/r/MachineLearning/comments/53heol/machine_learning_wayr_what_are_you_reading_week_8/)|[Week 18](https://www.reddit.com/r/MachineLearning/comments/5r14yd/discussion_machine_learning_wayr_what_are_you/)|[Week 28](https://www.reddit.com/r/MachineLearning/comments/6jgdva/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 38](https://www.reddit.com/r/MachineLearning/comments/7kgcqr/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 9](https://www.reddit.com/r/MachineLearning/comments/54kvsu/machine_learning_wayr_what_are_you_reading_week_9/)|[Week 19](https://www.reddit.com/r/MachineLearning/comments/5tt9cz/discussion_machine_learning_wayr_what_are_you/)|[Week 29](https://www.reddit.com/r/MachineLearning/comments/6m9l1v/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 39](https://www.reddit.com/r/MachineLearning/comments/7nayri/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 10](https://www.reddit.com/r/MachineLearning/comments/56s2oa/discussion_machine_learning_wayr_what_are_you/)|[Week 20](https://www.reddit.com/r/MachineLearning/comments/5wh2wb/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 30](https://www.reddit.com/r/MachineLearning/comments/6p3ha7/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 40](https://www.reddit.com/r/MachineLearning/comments/7qel9p/d_machine_learning_wayr_what_are_you_reading_week/)||

Most upvoted papers two weeks ago:

/u/marcossilva_604: https://arxiv.org/abs/1802.06006.

/u/hohomomo1212: Learning to Play with Intrinsically-Motivated Self-Aware Agents (https://arxiv.org/abs/1802.07442). It is a paper on a form of reinforcement learning without extrinsic rewards. Think of a robot wandering around in the world without being told what to do but instead figuring out what to do by itself using a model of its own abilities. That's why they call it self-aware. Pretty cool :)

Besides that, there are no rules, have fun.

/r/MachineLearning
https://redd.it/8aluhs
What are some fun things to do with Python?

I became fluent in Python a few years ago but never used it for anything besides assigned coursework or job related tasks. I’ve been looking to apply my skills in a way that would inspire me to excel while being enjoyable and have been having a fairly hard time with it.

So what are the most fun things you’ve used Python for that can be turned into a long term hobby?

/r/Python
https://redd.it/8axg0p
Never put DEBUG = True in any django server that is accessible from outside your LAN

While this is quiet obvious and must have already read it in django docs, many people (me included) still do it sometimes.

**Why?**

Mainly because ~~most recommended django configurations,~~ Django doesn't serve static/media files if `Debug = False`. So you might be tempted to temporarily set `Debug = True` while your client is reviewing the website and making the final changes before deployment.

**Why `Debug = True` is Evil?**

When any exception happen, django expose all your settings, environment variables to the world.
Remember that `SECRET_KEY` settings that django tells you never reveal? It's there for anyone across the globe to view freely.
Database password? Yep, it's there also.
Email credentials? API for external services? All there.

I know some of you would call me stupid for setting `Debug = True` on a test site that is accessible online and I would agree.
I'm writing this so that no one else would be doing that stupid mistake

/r/django
https://redd.it/8ax6cb
My first automated web scraping for Lego sets.

Using Python and selenium, I made a crude script which web scraps and extracts the Title, item number, Numbers of Pieces and Product Details for different Lego sets.

[Code](https://github.com/WillPhillipsCVdemo/LegoSets_scan/blob/master/Lego_Scan_loop.py)

/r/Python
https://redd.it/8axbvj
store app config in sqlite

I have an app that will be polling info from an api.

I want to be able to store the credentials and other config components in sqlite.

Is there already a framework for this ?

Thanks

/r/flask
https://redd.it/8b0fgc
Django WordPress competitor?

What is the WordPress framework of the Django world? I want to throw up a site that's blog oriented and I'm contemplating brushing up on PHP 7 or just scrapping that and learning Python to throw up some kind of Django solution. Thanks for the direction.

/r/django
https://redd.it/8b3zk1
How do you implement reset password functionality with Django Rest Framework?

Hi devs,

I'm having a bit of trouble to understand this, without DRF I did it successfully by using Django's default auth views and creating my templates but what about DRF?

Should I create a model that stores a token on the database and them verify if the token is valid for the user? If so, how to best generate this token, what to keep in mind to make the implementation as safe as possible?

Can I use Django's own mechanism which, by what I read, takes into account the last login, the current password (?), and adds some salt? This seems to be a very well thought implementation but can I borrow that mechanism into my RESTful views?

How are you (more experienced) guys doing this?

PS: I'm using only Simple JWT, not using other auth libraries like allauth or social login, don't know if this is relevant to the case.

/r/django
https://redd.it/8b3bur