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
Emacs as a Django IDE. What's the best way to do this these days?

**tl;dr: There hasn't been a discussion about this on this sub in over a year and I'm curious what tools there are available to configure Emacs as an effective "cloud-based" (over SSH) IDE for Django.**

I've been going through various text editors and IDEs and while I've found some I like, I'd really like to centrally host it myself instead of having synced environments between multiple machines and operating systems. Enter cloud-based IDEs. I want to self-host it so that immediately rules out the bulk of the options out there. The self-hosted options I've found haven't been terribly impressive. Then I remembered since I never bothered to learn Emacs or Vim, I had no idea what people who insisted on using them as IDEs were on about. After some research, I decided to try Emacs first.

So my first trial is going to be Emacs hosted in an LXD container that I just SSH into for development. While I'm not comfortable navigating it without a cheatsheet yet I very much like the layout and working in the terminal. My question is how best to configure it for modern versions of Django and Python development?

I found [this page on the wiki](https://code.djangoproject.com/wiki/Emacs) but it appears to be a bit outdated so I'd like to know if there are any other options I should try (and possibly add to the wiki). The first tool, python-django.el hasn't been updated in over two years and the intro link is dead. Pony Mode looks actively maintained and I intend to try it. New django-mode claims to be the newest and best but there's zero documentation and it doesn't look very actively maintained.

Anything else I should be looking into?

/r/django
https://redd.it/7c2pza
[AF] Explanation of `pip install --editable .`

The current [Flask documentation shows](http://flask.pocoo.org/docs/0.12/tutorial/packaging/) that flask apps should be created as a package. That includes a `setup.py` and `MANIFEST.in`.

If I'm not distributing my app for someone else to use, why would I do this?

If I didn't want to go through this setup, how would I configure my app so I could follow the example? e.g.


export FLASK_APP=flaskr
export FLASK_DEBUG=true
flask run


/r/flask
https://redd.it/7bz93o
How to work with Django in Windows 10?

Hi. In all my Django programming life I have been developing in Ubuntu Linux. I still use Ubuntu at home. It's awesome. Now I got a new job and I have to work on Windows (10). I have successfully installed WSL and bash terminal which I use for ssh connections and other things. So, now what? Should I keep using bash terminal in windows 10 for all my developing purposes? (Python, Django, vim, PostgreSQL, virtualenvrapper, etc) or should I go full-on-windows and install PyCharm (which is my main working IDE), Windows-PostgreSQL, windows-python, virtulanevwrapper-win, etc and use bash-terminal only for ssh?

/r/django
https://redd.it/7c6zk8
Tiket untuk peserta PyCon pertama di Indonesia telah tersedia. Grab it fast before you missed it, guys!

https://goo.gl/xDLgan
use python pandas to show csv to placeholder in web file

I have a csv file and need to convert it to view it in html. I know python pandas can do it with

df = pd.read_csv("myfile.csv")
df.to_html('output.html')'

but I don't want to show it in single web page, I have index.html file and I want to show it in there but in another section.

/r/Python
https://redd.it/7c6s75
Please help to improve the awesome-jupyter list on github!

You can *fork* and pull-request the [github](https://github.com/postpdm/awesome-jupyter) repo, or place the [issue](https://github.com/postpdm/awesome-jupyter/issues) to github repo, or post the interesting links here.

Thank you!

/r/IPython
https://redd.it/7c7ur6
Advice for starting a Flask application

I'm going to create a flask-rest api for my iOS app. When I'm developing the API should I deploy on heroku and every time I make a change commit the code and test it, or should I run everything locally then deploy when I'm finished with the API? I just feel I should test it on production servers then just on my computer locally.

/r/flask
https://redd.it/7bxuvg
Apache with wSGI Configuration

I have installed Apache2.4.18 on my Ubuntu machine. I can access the 'Apache2 Ubuntu Default Page' from outside my home network, so Apache seems to be working.

I have a working Django website that I can access at my localhost (127.0.0.1:8000).

I need to configure Apache to serve my Django website instead of its Default page.

[Django's guide](https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/modwsgi/) says to edit Apache's 'httpd.conf' file, but no such file exists on my machine.

[This guide](https://www.thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/) walks me through the creation of a file that looks similar to what the Django guide is talking about, but there seems to be some major differences between the two.

I don't know where the 'httpd.conf' file should be located. I'm not sure whether the filename needs to be 'httpd.conf' or not. I don't know what information should be contained within 'httpd.conf'.

Thanks for any help in advance!

/r/djangolearning
https://redd.it/7c9ams
To use Turbolinks 5 with Django, how can I automate inclusion of the Turbolinks-Location header when using redirect()?

According to the Turbolinks 5 documentation for "Following Redirects" (https://github.com/turbolinks/turbolinks#following-redirects):

> When you visit location `/one` and the server redirects you to location
> `/two`, you expect the browser’s address bar to display the redirected
> URL.
>
> However, Turbolinks makes requests using `XMLHttpRequest`, which
> transparently follows redirects. There’s no way for Turbolinks to tell
> whether a request resulted in a redirect without additional
> cooperation from the server.

And the solution for this is to:

> send the `Turbolinks-Location` header in response to a visit that was
> redirected, and Turbolinks will replace the browser’s topmost history
> entry with the value you provide.

>The Turbolinks Rails engine performs this optimization automatically for non-GET XHR requests that redirect with the `redirect_to` helper.

I have a great interest in using Turbolinks on my Django (1.11) project and I'm wondering if anyone could point me in the right direction of how to create a new Django redirect() function or modify the existing one to always include the Turbolinks-Location header that is needed for redirects to function as expected. I definitely do not want to be manually setting this header every time I do a redirect.

There is a similar entry in the 'Redirecting After a Form Submission' section (https://github.com/turbolinks/turbolinks#redirecting-after-a-form-submission) I would also appreciate any help in understanding how to implement:

> If form submission results in a state change on the server that
> affects cached pages, consider clearing Turbolinks’ cache with
> `Turbolinks.clearCache()`.
>
> The Turbolinks Rails engine performs this optimization automatically
> for non-GET XHR requests that redirect with the `redirect_to` helper.

I did see there is a "Drop-in turbolinks implementation for Django" package on github but this is forked from turbolinks-classic and sourcecode has no mentions of the Turbolinks-Location header so I am sure this is not what I'm looking for.

/r/django
https://redd.it/7c9wh4
A drop-in Erlang node implementation in Python, designed to allow access to existing Python projects from Erlang and the opposite. With just a few lines of startup code your Python program becomes a fully functional Erlang node.
https://github.com/esl/Pyrlang

/r/Python
https://redd.it/7cb2to
Python Library for implementing Publish Subscribe model on Raspberry Pi

Hey, guys. Which python library, do you think is best for implementing a Publish-Subscribe architecture.

More specifically, i want to implement such an architecture for passing information between various sensors and actuators in an asynchronous way on a Raspberry Pi, instead of using the traditional infinite main loop approach.

Kindly advise

/r/Python
https://redd.it/7c8x8d
Revamping design decisions - worth doing now?

So it's been about 1.5 months since I started building a project with Django. Looking at a lot of my old code, unsurprisingly I did not follow best practices. This is especially true with the names of views and models - instead of having a simple model name like **Subscriber**, I'd have something like **UserPremiumSubscription**. There are also major design decisions that I made which were bad, like creating 2 models when I should have just made 1.

I suppose my question applies to not just using Django, but all programming in general - Is it worth going back and changing all the minor nuances to follow best practices? Or should I just keep going and follow best practices for all the code in the future, and go back and do a final fix right before launching the project for production?

It would make sense to go back and fix things now, but what I am worried about is having to go back a 2nd or 3rd time in the future after I become more experienced with Django.

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