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
ListView in views.py

Hi, I'm pretty new to Django, how would I change the below snippet to work with other data which needs to be passed through render()

urls.py

url(r'^$', ListView.as_view(queryset=Product.objects.all()
.order_by("-time_created")[:4], template_name="main_site/index.html")),

It works EXACTLY how I want it, however I can't pass other data through to the template in views.py

This is my view:

def index(request):

data = {
'categories':[
('footballs', 'Footballs'),
('accessories', 'Accessories'),
('kits', 'Football Kits'),
('training-equipment', 'Training Equipment'), ]
}


Also, feel free to criticize my code to help me improve! Thanks!

I've tried everything I know to pass it through..

/r/django
https://redd.it/5mdbpb
[D] Why is everything so quiet on the natural language processing front?

At NIPS this year, there was a clear focus GANs, image processing, Bayesian ML and reinforcement learning (as well as parties and RocketAI). I picked out a couple of interesting talks on natural language generation, but it seems to me things are generally quiet on that front, and there certainly was not much buzz in 2016 apart from some efforts in translation.

Is this due to blockers, secrecy or both? I'm fascinated that we can now generate photo-realistic content, but not realistic language utterances. Natural language is a discrete space and most people only use ~2000-3000 words to communicate or ~100-200 characters.

/r/MachineLearning
https://redd.it/5mcs0x
Form method POST, still allowing 'back' button. At risk for double submittal.

I'm still relatively new to Django, but I can't seem to find this answer anywhere.

Any change to database is being done through forms via 'post' method and not 'get'. However, I still seem to be able to go 'back' on the web browser navigation through multiple 'posted' forms. I'm afraid this may end up in a double submittal.

I figured that this would not be allowed by default, but is this something I have to code for? Is it because I'm using the built-in webserver instead of Apache, IIS, etc.? Any advice would be appreciated. Thanks.

/r/django
https://redd.it/5mgwxw
I made a GUI for Jupyter Notebook, let me know what you think!

I've called it Jupyter Wrapper. Here's the description I provide on the website.


Jupyter Wrapper provides a GUI for Jupyter Notebook server.

I developed this because I was tired of always needing to keep a cmd window open while the server is running,
and that configuring command line arguments and working directory required a custom batch file.

This tool also provides the ability to restart the Jupyter Server remotely via a browser.
To do so: select an available port, forward this port in your router, then visit the specified ip:port combination in a browser.
Eg. If you have an external ip address of 27.121.21.55 and you've chosen port number 65000, you would visit http://27.121.21.55:65000?server_restart to trigger a server restart


It can be found here: http://ashhall.net/projects/jupyterwrapper/

/r/IPython
https://redd.it/5mhn6g
What font do you use for development?

I generally use Consolas on Windows and Ubuntu Lite on Linux. I mostly use vim in terminal/cygwin these days with the occasional Notepad++ when I'm on Windows. The 2 fonts seem to work fine for the most part but there are a few letters, numbers, and characters that look too similar. There was a premium font that made specifically for developers that made a conscious effort to distinguish some of those characters. Naturally I went looking for it on the web but turned up empty handed. I did however stumble upon [this topic on Slant](https://www.slant.co/topics/67/~programming-fonts) and it made me wonder what other fonts developers use? Specifically Python developers

/r/Python
https://redd.it/5mif4u
Any Compelling Reason to Containerize?

I run a small and somewhat financially successful little startup geared towards K-12 education. My day job is DevOps, and we're moving to containers for new applications. I'd like to kick the tires on this a bit more to play with it, and my app seems like a good option. The app is of course written in Django. What am I gaining by containerizing an already mature production Django application? It already auto-scales application servers and has a good CI/CD pipeline with the help of Jenkins. Containers could certainly make my auto-scaling system simpler, but that code is already working and performing fine using Linode VPSs and their API. Any thoughts?

/r/django
https://redd.it/5mhpu7
Windows Subsystem Linux | Does it work well for you?

Hi All,

I'm currently using a late-2013 rMBP and learned Python while I had this machine. I understand people like OSx for development purposes because it has native unix shell support.

I was wondering how many people here use Windows 10 and have had some experience with WSL. Does it accomplish everything you need it to do? Do you feel like you're missing out on any important unix features?

Thanks for your inputs!

/r/Python
https://redd.it/5mjow0
How can i create a Procfile to deploy a flask app to heroku

So currently on dev I use `python manage.py runserver` to run my flask app locally (thanks to the flask-script extension)

I've seen that a standard Procfile online looks like:
web: gunicorn app:app

I imagine that I would need something like:
web: gunicorn manage:app

Although I am not sure? What does the bit after gunicorn actually mean, does it correspond to the file in the current dir?

/r/flask
https://redd.it/5lgcv3
Have a few problems setting up Django

When I enter: python -m django version, I get this output

/usr/bin/python: No module named django.__main__; 'django' is a package and cannot be directly executed

And when I enter: django-admin startproject mysite, I get

Traceback (most recent call last):

File "/usr/local/bin/django-admin", line 7, in <module>

from django.core.management import execute_from_command_line

ModuleNotFoundError: No module named 'django.core'



/r/django
https://redd.it/5mk8kl