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
[AF] Populating forums with url values?

Hello!

I have a search page on my Flask site that takes user input, when they submit it refreshes the page with the url changed to www.url.com/search?query=value

Is there a way to automatically populate the search bar with the value from the url? There are several search bars and drop down selectors with values to sync with the url.

Thanks!

/r/flask
https://redd.it/7mw98a
Flask Listens on Private IP vs Localhost

This might be the wrong place but I'm wondering, I'm just using a basic flask sample app from

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html

And I'm wondering, why when I use localhost/127.0.0.1 as the ip to host the server on port 80, I cannot connect to it from anywhere else, but when I use the private IP assigned to it by AWS, I can connect to it from my house.

So if I use app.run(host='172.16.1.15', port=80), I can put in the public IP in my browser and connect to it. But when I use localhost, I cannot connect to it, only from the instance itself.

I'm curious as to why using my private IP as the app host would make this available to anyone, and using just localhost would only have it available to that box. Does AWS automatically map incoming connections on the public IP to the private IP?

Thanks.

/r/flask
https://redd.it/7mvytj
opening .txt file from a specific folder

Hi guys, I am having some trouble opening files from a specific folder in my downloads. I need then to be from this specific folder because I am using a TfIdf Vectorizer later on in my code, and I want the edited files from that folder to be used in the dendogram I am making.
When I just put the files in the download folder I have no trouble opening them when I just use:

text = open('blabla.txt','r')
blabla = text.read()

But when I put them in the folder it can't read the file, so basically it can only find these files in the download folder.
Can anyone help me? Or at least maybe explain why this is the case?

/r/IPython
https://redd.it/7mxcvc
Hosting Flask App on Heroku

Hi there,

I've been working through deploying an application on Heroku.

On my local host I run my application with:
*python manage.py runserver*

As I understand it this runs a Development server and should not be used in production.

I am assuming i need to refactor my application to run on Heroku with the standard
*web: gunicorn app:app*

Any suggestions on how to refactor my code/file tree? Thanks!

FileTree:

* myApp(root)
* -templates
* -admin.py
* -__init__.py
* -auth.py
* -config.py
* -manage.py
* -models.py
* -Procfile
* -requirements.txt
* -.gitignore

/r/flask
https://redd.it/7mz2z5
Python Cheet Sheet for begineers

/r/Python
https://redd.it/7mwgtw
Examples of people reporting fee contribution from Django trademark usage?

From https://www.djangoproject.com/trademarks/

>You may incorporate the Django name into any website or product whose purpose is to organize, educate or inform the Django community, provided that:
>
> <snip>
>
> If a fee is to be charged for the product, or for access to any or all of the material on the website, a clear statement must exist declaring what proportion of those fees will be retained by the authors, and what proportion, if any, will be contributed back to the DSF. A link to this statement must be prominently displayed on the website or product.

Anyone got good examples of people doing this? I had a cursory browse of https://www.twoscoopspress.com/ and https://www.oreilly.com/ but couldn't find anything - I'd love to see example wording and example percentages!

/r/django
https://redd.it/7morjd
How bad have I screwed up?

So I made a web application that is going to be used by multiple users, but at a low frequency (let's say around 10-20 applications a day). I haven't tested what happens if I submit multiple applications concurrently...

What is the best way to test this? I'm using SQLAlchemy if that means anything.

/r/flask
https://redd.it/7n2wpt
Nitpicking: Naming convention for forms and view functions

I want to be consistent with the naming convention of my forms and view functions so that I can better memorize their exact names without needing to look them up. The question is the order of nouns and verbs.

Example: You have a view where you can add and remove members from a party invite list, and also assign someone else to be the party host if you are the current host. The view will be called `party_members`.

You will need 3 form classes. What should they be called?

* Option A - VerbNoun: `AddMemberForm`, `RemoveMemberForm`, `ChangeHostForm`
* Option B - NounVerb: `MemberAddForm`, `MemberRemoveForm`, `HostChangeForm`. (Actually, should it be called `MemberAdditionForm` and `MemberRemovalForm`? This case makes option A easier...)

And the view should call subfunctions. What should they be called?

* Option A: `add_member`, `remove_member`, `change_host`
* Option B: `member_add`, `member_remove`, `host_change`

And if you choose option A for the form, must you also choose A for the view, and vice versa? Sorry for the nitpicking, I couldn't find this in pep8. It really bothers me when I mix my conventions because then I'm always guessing what the functions/forms are called.

/r/django
https://redd.it/7n5gie
Pyfiddle v 1.1 released!

I wrote https://pyfiddle.io, an online Python IDE for running, saving and sharing light weight Python with ease

Also support features like file uploads, argument passing and package installation.

Happy fiddling at pyfiddle.io !!

Love, a pythonista

/r/Python
https://redd.it/7n5ivo
Why aren't urls.py of individual apps generated automatically upon creating?

Is there a reason why it is like that? I always have to copy or rewrite the `urls.py` from another app. Couldn't it just be automatically generated like the project's urls? Is there any situation where you would not want it to be generated automatically?

/r/djangolearning
https://redd.it/7n4vzg
Feedback wanted for the new docker support in my django-base-site

I recently added docker support to my django-base-site. I would be interested in getting feedback on how it works for everyone. The documenation can be found here, http://django-base-site.readthedocs.io/en/latest/docker.html and the repository can be found here, https://github.com/epicserve/django-base-site.

/r/django
https://redd.it/7n3lbh
#PyCon 2016. Guido van Rossum the founder of Python programming language explained very beautifully why does python exists in the World today.
https://v.redd.it/m3ai8et157701

/r/Python
https://redd.it/7n6wyo
[Help] How to embed a Django Admin table view (change_list?) for a single model in a user template?

Usual disclaimer: I'm working on my first larger-scale Django project, and have all the basics figured out.

What I would like to do is have both site admins and trusted users. Site admins get access to full-blown Django Admin interface. Trusted users get access to pages in my apps that allow for limited table updates. I would like just grab the basic admin table functionality, customize it, and drop it in a template for some page in my app.

For example, in my "Events" app, there are multiple models. Of these, there would be a event model that would have a page available to trusted users with an area(div) that listed upcoming events and allows edits to event fields for title, description, date, and time - but no deletion, nor edits to any other fields in that model.

Also, for all users - it would be nice to use the Admin filtering interface, especially the date filter functionality. So this feels like another specialization of the same thing - insert the admin table view (change_list?) into a regular page and disallow any editing, but use the filtering tools.

I am thinking there is a way to leverage the functionality already built for Admin site to do this, so that all the filtering options, etc. come along with it - rather than recreate from the ground up.

My searching has found a lot of information on how to customize and extend the Admin interface itself, but am thinking I am missing some important keyword in Django-lingo that would yield better results.

Mainly just looking for a push in the right direction here - or feel free to redirect my thoughts on this one if I'm out in left field. Thanks!

/r/django
https://redd.it/7n8nt8