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
Plot spacing

Is there a way to add more space between histogram plots in the same output cell? I have 50 histograms generated from the same cell and they appear too close together to clearly read, Im curious if there is a way to add more space between them without having unique cells for each plot. [Here is an screenshot of what I'm talking about.](http://i65.tinypic.com/168a5ax.png)

I've have tried to google around for an answer but cant seem to find one.

/r/IPython
https://redd.it/892gta
Starting a plotly dash app from another py file

Hey guys,

I'm experiencing a weird issue with plotly dash that I can't seem to figure out.

When the dash app is run by itself, it works perfectly fine. The server starts up, gives the debug pin, and you can access it from the web browser.

Now here is the issue I am having.

I have created a text-based menu when you pick an option, it executes a def, and executes a specific part of the program.

When I import the dash app into the menu, and try and call it, it will run as I get the following:

* Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
* Restarting with stat

But after this, I don't get the debugger pin or anything else, and when I go to the page in firefox, it just spins as if it's loading but won't show anything.

How would I properly call this?

Thanks!


/r/Python
https://redd.it/89k7r1
Best way to handle categories in a generic ListView?

So on the Home page of my app (which is redirected to /issues/) I have a list of "Issues" that I'm generating with a generic ListView:

class IssueListView(generic.ListView):
model = Issue

This currently loads all the Issues. I am adding a sidebar to that page that can be clicked to load different categories of Issue, so I'd like the url to be updated like /issues/<category>/.

Do I need to write a new IssueCategoryView class to do this? Or maybe I should amend the app so that the Home page is /issues/all/ and have a default "all" category that all Issues belong to?

I'm sure this is straightforward but I just want to make sure I'm doing this correctly before proceeding.

Thanks

/r/django
https://redd.it/89jxrn
What are your freelance experiences with Django?

What kind of web app is probably the most requested? How much does such a project pay? Do the clients look specifically for Python in Django solution for their job or it just happens they stumble upon Python programmer who does it?

I'm wondering because I'm a hobbyist and I wondered how things look from progressional's perspective.

/r/djangolearning
https://redd.it/89ke00
Is it possible to have multiple post requests in one route() decorator?

Is it possible to have multiple post requests in one route() decorator?

What I'd like to achieve is to have one html page with multiple forms.

I tried something like this but doesn't seem to work.

@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
do_a= request.form['do_a'];
do_b= request.form['do_b'];
else:
....
return render_template('base.html')

Thanks

/r/flask
https://redd.it/89nlgx
ELI5 Why do I want to use a tuple instead of a list They seem basically the same other than mutable/immutable

I just don't see the value add. But I end up dealing with them a lot.

/r/Python
https://redd.it/89l4fi
[Ask Flask] Is there reason to use db.Column, db.String etc in flask-sqlalchemy instead of sqlalchemy Column, String etc?

I came into Python from languages with very strong language servers and autocompletion due to static typing and I really like Python 3 types system, because it helps very much to develop and avoid most common errors especially for newcomers like me (correct methods, properties and types are suggested by language server/autocomplete)

But I discovered that db from flask_sqlalchemy does not have many members which are being used in clean sqlalchemy environment in a snap with suggestions from editor.

Is there any reason documentation has db.String instead of

from sqlalchemy import String, Column, ...

?

Thanks!

P.S. (link to flask-sqlalchemy doc: http://flask-sqlalchemy.pocoo.org/2.3/models/#simple-example )

/r/flask
https://redd.it/89n3jd
Authentication Methods with DRF + React

I'm looking into my options to authenticate users/serve data from a DRF api call and a front-end built in React. Are there any options other than using tokens (JWT)? Can I make the request/authenticate via the header information in React's fetch method?

/r/django
https://redd.it/89nqqg
[AF} Are mostly integration tests "acceptable"?

Most tests that I've seen rely on integration tests with very few, if any unit tests. I haven't seen any mocks. Is this normal practice for Flask (and/or Django) projects? I'm trying to learn the best practices but I can't figure that out. Right now, I'm writing integration tests for my routes (using sqllite db) with few unit tests.

/r/flask
https://redd.it/89f2nz
Is there any recent app to keep track of transactions / account balances?

Hello there! Diggin' in Google i just found two:

The oscar's accounts app:
https://github.com/django-oscar/django-oscar-accounts
(This requires Oscar, which i don't need)

And this fork of the same project:
https://github.com/carver/django-account-balances
(Which is not updated, and doesn't work with recent Django versions)

I think i'll have to download the last one and try to upgrade it myself. I didn't want to make my own system off the ground mainly because of being afraid of transaction bugs, i would rather leave it to people that know better than me. Thank you very much!

/r/django
https://redd.it/89tbxn
LDAP auth in view (not system)

Hey all,

I'm trying to manually authenticate LDAP users through a view. All search results seem to focus on using LDAP for Django users, which I don't want.

In essence, I want to receive a user/pass combination as POST parameters, and connect to the LDAP server in the view, send the data, and process the result. Is there a library for this?

/r/django
https://redd.it/89scxu
What are the 'secrets' that should be kept secret?

Newbie here, I have read on guides and articles that when using version control and during deployment, there are stuff that should be kept secret.

1. Is this only necessary when the project involves multiple devs? Is it still required if it is a personal project and I keep the repo private?

2. The only secret variables that I know of are SECRET_KEY and DATABASES variables. Are there anything else that should be kept secret?

/r/django
https://redd.it/89rq18