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
Why Django and Not...

Hey all, I work for a company that's considering a major redo of their e-commerce platform. We're considering a bunch of frameworks for this: Rails, Laravel, Django, and Node. So I thought I'd ask the community here what would be some good reasons for Django over these others? Thanks so much in advance. :)

/r/django
https://redd.it/iiaelg
I created a webapp for generating mock data
https://www.mockerdata.com/

/r/flask
https://redd.it/iiadxc
How to run all cells?

I tried to create a keyboard shortcut for it, but it doesn't work...

​

https://preview.redd.it/l0kzylrsyij51.png?width=879&format=png&auto=webp&s=c6309c76b35effba03f903480745af5d4a245010

/r/JupyterNotebooks
https://redd.it/ihitfy
This post has

961 upvotes,

197 downvotes,

and 125 comments!

Credit to u/Krukerfluk and Tom Scott!

Code: https://github.com/CalvinMiller190/reddit-post

This post uses the [praw module](https://praw.readthedocs.io/en/latest/) to get the information about the post, then edits the post every second based on the information that it got!

/r/Python
https://redd.it/iiamfv
Saturday megathread: Share your resources!

Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?

Use this thread to chat about and share Python resources!

/r/Python
https://redd.it/iiihwe
Is it worthy to use frontend framework like react or vue with Django?

Django comes up with DTL which has enough power to create pretty much everything.

But in the world full of JS frameworks I'd like to know is there any benefit if using javascript frontend frameworks along with Django?

Also give some use cases!

/r/django
https://redd.it/iilow7
NOT NULL constraint failed: mysite_customer.created_at.

I am getting this NOT NULL error when I try to submit data to my database from a default form ModelForm. My customerform is as follows: Please help!

​

def customerform(request):
if request.method == **'POST'**:
form = CustomerForm([request.POST](https://request.POST))
if form.is\_valid():
created\_at = request.POST.get(**"Created\_at"**, **''**)
name = request.POST.get(**"Name"**, **''**)
address = request.POST.get(**"Address"**, **''**)
Cell\_no = request.POST.get(**"Cell\_no"**, **''**)
*# image = models.ImageField(upload\_to='blog')*
description = request.POST.get(**"Description"**, **''**)
cust\_info= Customer( name = name,address = address,Cell\_no = Cell\_no, description =
description)
cust\_info.save()
return redirect(**'customerform'**)

/r/django
https://redd.it/iipgn9
Can't access image from media loaction

Hello ,

I configured media location to keep images (like several times already) for a project i am currently working on.

just to add that current project i am using on top of [Django Dashboard AdminLTE](https://github.com/app-generator/django-dashboard-adminlte)

In addition i extended the user properties for user image , when i upload the user related image its loading correctly to the path designated , but when i using in HTML tag to show current user image , don't get anything html tag is

 <img src="{ request.user.profile_image.url }" class="img-circle elevation-2" alt="User Image">

When i click show image its seems to follow the correct path but i get error that pic not found

I posted below my [settings.py](https://settings.py) and main [urls.py](https://urls.py) below , i run out of idea

Please advice

Thanks

&#x200B;

https://preview.redd.it/ih2hbf1drwj51.jpg?width=674&format=pjpg&auto=webp&s=b74440430e9e6602ba254d34c43b87a284ab92f6

the settings file is looks like following

# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = config('DEBUG', default=False)

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 Static files (CSS, JavaScript, Images)
 https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/'
 Extra places for collectstatic to find static files.
STATICFILES_DIRS = (     os.path.join(BASE_DIR, 'core/static'), )
#######################################################
#######################################################


/r/django
https://redd.it/iipg83
Configure environment-specific settings in Django framework.

Wrote a short blog on implementing environment-specific settings in Django Framework. Hope this will be useful!

[https://thequickblog.com/how-to-configure-environment-specific-settings-in-python-django-framework/](https://thequickblog.com/how-to-configure-environment-specific-settings-in-python-django-framework/)

/r/django
https://redd.it/iip1eq
Tasks - is APScheduler better than Cron/Schedule modules?

I want the best one to automate a task, my function makes an API call every 15 minutes and saves data to csv and then calculates that CSV data to show on a chart. What task module would be the best in my case? APScheduler/Cron/Schedule/Celery?

PS: I'll be deploying to Heroku, so I'd appreciate anyone telling me about compatibility issues with Heroku.

/r/flask
https://redd.it/iiu14x
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

Why do I get this error sometimes? I even get it when I don't let my computer turn off/sleep or similar.

/r/JupyterNotebooks
https://redd.it/iirl50
Can passing Flask app context to multiple processes lead to problems while performing database operations using Flask-SQLAlchemy?

I am developing a backend which requires some processes to be spawned automatically, and constantly perform database operations from there. I am making use of the Flask SQLAlchemy ORM to interact with the database.

I was able to pass the 'app' variable as an argument to a new process, and perform DB operations from there. But the application requires several such processes to be running at once. Thus, several processes can be making database operations using the Flask app context, in addition to the APIs created inside of Flask itself. Can someone please tell me if this will lead to some sort of a conflict/error?

Thanks in advance!

/r/flask
https://redd.it/iiwc3t
Long term impact of using UUID as a unique identifier for models

I am developing an app that enables users to post discussion questions and allows other users to react and rate the questions. However, instead of using pk or id to map question urls I'm thinking about creating unique ids for each question using UUID. This is to prevent users from both monitoring site usage and being able to quickly iterate through questions by incrementing id.

So far, I've decided to assign each question on creation a unique id: uuid.uuid4().hex\[:6\].upper(). However, I was wondering the long term effect of this implementation. Every time I create a new object, Django will have to iterate through all existing questions. Will this have a significant computational effect over time? If so, are there any other more efficient implementations of assigning unique ids? Perform some function on the id (but then wouldn't some original issues persist)?

/r/django
https://redd.it/ij0gp3
Sunday megathread: What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.

/r/Python
https://redd.it/ij317r
I’m learning Python, but I also came across my dads old BASIC textbook. The problem solving aspect of the book is almost better than any modern one I’ve read.

/r/Python
https://redd.it/iix2ru
I made an IMDB webscraper

So this is pretty beginner, but it's my first real project, and today I finished the first version of it. Without going into to much detail, the user pastes a link to IMDB and the program scrapes the shows, gets an average rating for each season, the entire show, creates a graph with the average of each season, and then shows the user IMDB's top 250 rated TV shows and gives them the option to search for a show and see if it's in the top 250. That's pretty simplified and I won't paste all 200+ lines of code but [here is the github](https://github.com/NerdyBread/IMDB-Webscraping) if anyone is interested. I'd love any feedback that anyone has, good or bad.

/r/Python
https://redd.it/iiu17w
I made some fanart

/r/Python
https://redd.it/ij60ct
How to use Django Model Managers? understanding the Django ORM

# Model managers, understanding the Django ORM

[A video in YouTube](https://preview.redd.it/gb9xndstl3k51.png?width=1280&format=png&auto=webp&s=962eb3a6e6e63e9e28d206348e2bd751e7f29171)

&#x200B;

Hey guys, recently while working on a project I bumped into model managers. I knew they existed but didn't bother to learn more about them. But then I had to work with my own custom user models in Django.

So I plowed through the documentation and learned it all.

I prepared a video for anyone who intends to learn more about them :) Keep Learning!!!

Link to video-

[How to use Django Model Managers?](https://youtu.be/gxeCoRr5zL8)

/r/Python
https://redd.it/ij9dm0