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
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
Json dump with django

hello there, i need to dump a json like;

{
['19191': 'foo'],
...
}

My best i can

{
['pk': '19191', 'name': 'foo'],
....
}

here my codes: https://paste.ee/p/uJa8R

i'll be glad if can someone guide me thanks..

/r/django
https://redd.it/5mkbhp
admin.TabularInline with model = MyModel.ManyToManyFieldName.through, disable add/edit/delete buttons.

class RoleInline(admin.TabularInline):
model = Team.people.through
fields = ['position', 'team']
# readonly_fields = ['team']
# can_delete_related = False # doesn't exist.
# can_delete = False

@admin.register(Person)
class PersonAdmin(admin.ModelAdmin):
list_display = ['get_name', 'email_address', 'receive_emails', 'get_teams']
fields = [('first_name', 'last_name'), ('email_address', 'receive_emails')]
inlines = [RoleInline,]

I'm trying to figure out how to disable add/edit buttons from the inline view only, without affecting anything else. `has_delete_permission` only disables deleting the Role line itself, `can_delete = False` is the same issue. and readonly_fields hides it completely.

Any help is greatly appreciated, thanks

/r/django
https://redd.it/5mi5xn
Django webapp 500 server error after running migrations

So I ran python manage.py migrate after making some code changes, and I end up getting a 500 server error when I run the app. I tried reverting the migration files but that didn't work, and when I try to run migrate again it tells me that there are No migrations to apply. Any general suggestions?

/r/djangolearning
https://redd.it/5mpkd9
How to upload/depoy static files/images files in Django

Hello everyone! I'm a beginner in django and to web development in general. I managed to succesfully deploy a django project with postgresql, gunicorn, and nginx on ubuntu 16.04 after following [this tutorial from digital ocean.](https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04)

With that said, I was following [the django tutorial](https://docs.djangoproject.com/en/1.10/intro/tutorial06/) and I came across this roadblock where I'm supposed to 'upload' an image and I have no idea how to. I haven't found a way to do it searching the django documentation either. I know that if I were using my local server I would simply upload it using a GUI but I don't have that luxury, a least not to my knowledge.

tried google and that did not favorable results. Any help will be greatly appreciated.

/r/django
https://redd.it/5mq4bo
[AF] cannot load scikit-learn from Flask app

I have a small Flask app that needs to use scikit-learn. However, it works if I test it on local machine, but when I test it using browser, the webpage just never load. It seems that there is something wrong with the line of import any functions from scikit-learn. Iit just doesn't allow me to import any function from scikit-learn. Any idea of the reason that might cause this? The Flask app is hosted under Apache. Could it be any setting related to Apache or mod_wsgi? Thanks

/r/flask
https://redd.it/5l6bex
Does the ORM have a bulk read function?

For example if there's a table with two columns: `id` and `city`, I have a list of cities and want to fetch their corresponding id's, can it be done efficiently in bulk? Or is it necessary to loop a round trip to Postgres for each city in the list?

This is mostly for the purposes of normalizing and conserving space.

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