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
How to remember all this boilerplate

I wanted to open a discussion about Flask, but I also think I see that when you have too much boilerplate code, it might be time to crack open Django instead.

I've been learning Flask for a few weeks now, and as it get's into form and SQLAlchemy models and migrations, I wonder if people are really remembering all of this code, or copying/pasting from one project to another, and using tutorials and the like to just dip back into and remember the syntax.

What is your method for keeping this all straight, or is it just repetition? Some of it is sticking due to simple repetition, and I also have Miguel Grinberg's book that is helping me for quick reference.

Is there a point where you feel it's too much, and you switch to Django instead?

I don't need a rundown of Django vs Flask, I understand them well enough, but wanted to hear other's thoughts regarding this.

/r/flask
https://redd.it/al9bmq
Adding USER "$(id -u):$(id -g)" doesn't work in dockerfile

Hi all,

I want to add my current user to the dockerfile so when I run with docker-compose I will have access to the files written.

I have been creating CSV files with a converter I've written but they all are owned by Admin and I need my local user to have access.

I also want it to be able to move to any machine and have their local user have access.

How can I add the USER command to the Dockerfile and make it accept my local user?

Any advice greatly appreciated

/r/flask
https://redd.it/al87em
How do I access files within Jupyter Notebooks while using PGContents?

Hello,


Asking this question here as I was unable to find anything regarding accessing files stored in a SQL database. And the ContentManager documentation for Jupyter Notebook isn't really pointing at what I'm trying to find.


I'm running this: [https://github.com/pl31/heroku-jupyter](https://github.com/pl31/heroku-jupyter) on a Heroku server. This package utilizes PGContent to store and manage files, and it works great for GUI, but I'll need to access some data via notebooks and standard opening always refers to the system file path.


Is there any way I can default to or point at the files in the database to extract them in an easy way via PGContent?

/r/IPython
https://redd.it/alajek
Audit logs for DRF application

Hi, I'm looking for a solution to record and track actions performed by users in Angular 2 + Django Rest Framework application. There are multiple packages that track object history in Django (we use django-reversion a lot), but I'm looking for something that would be more business action oriented.

​

Example:

Patrick Smith created vacation request

John Doe logged in

John Doe accepted holiday request for Patrick Smith

​

These should be timestamped, of course. You should be able to access audit logs and related objects both programatically and from admin panel. Object and field history is nice to have.

​

Most of the solutions I found are based on model changes. E.g. User John Doe changed field status in HolidayRequest #13452. This is not what I need.

​

I'm fine with manually triggering the creation of log entry via a context manager, a signal, a decorator or any other way. I'll write my own solution if necessary.

​

Any suggestions?

/r/django
https://redd.it/albkvv
I wrote a text-based adventure game in Python.

As a followup to the thread I posted yesterday, here is the release for my text-based adventure game Foodstory, written in Python.

​

This is the result of \~20 hours of coding, writing story, and debugging. I'm very proud of it, and I hope you enjoy it.

​

[https://tydaljames.itch.io/foodstory](https://tydaljames.itch.io/foodstory)

​

/r/Python
https://redd.it/alcn7a
Dealing with user file uploads

Hi

Is there a simple way to deal with user uploaded files that have spaces in them, I was hoping there might have been a method that would clean an uploaded filename before passing it on, but googling this topic is somewhat tricky or no one has had this problem (unlikely it's been an issue for some 30 years to my understanding).

As this file is not required after uploading, the ideal would be to just save it as file.xlsx on uploading, as the name is irrelevant beyond the user finding it in his own file system.

How do you guys handle this issue?

/r/django
https://redd.it/aldp99
Server Error (500) but admin site works

Hello - I apologize if I'm missing information or if this is the wrong place, I'm new to django. I'm currently trying to get a website back up and running (i did not build it). The certificate expired so the new one was added. Since then, the site has a server 500 error however the admin login part of the site is running as expected. What could be causing this or where can I look? There are no error logs that I've found. Thank you!!

/r/django
https://redd.it/alfkba
Azure notebook running extremely slow, stuck on loading and not running cells.

I'm doing a course on EDX and its ran through Azure Notebooks. As said in the title it takes a really long time to load, will spend about 5-10 mins stuck on loading screen and sometimes unable to run cells. Any idea whats causing this?

/r/JupyterNotebooks
https://redd.it/al8ahb
First timer ideas?

I'm about to start sentdex's new tutorial on django and I don't really want to do exactly what he does. What can I create that's simple and works and could potentially give me the chance to do fancy stuff

/r/django
https://redd.it/aldzct
I wrote a program that downloads all my wallpapers and shuffles them!

Let me preface this with I'm a Security Analyst and not a programmer in anyway. My linting lights up like a Christmas tree.

​

Check it out! : [https://github.com/getsec/AutoWallPaper](https://github.com/getsec/AutoWallPaper)

​

I wrote a python script that will go to wallhaven and download what I want and how many pages of wallpapers, save them to my local machine, and I use another script that will shuffle them whenever I start a new shell. You can put it in your crontab too. Next is to work to ensure no NSFW images get downloaded :)

/r/Python
https://redd.it/alk08r
Undesirably creating new cells

I like to use Jupyter as a quick interface for writing, debugging, and running programs quickly. I don't like to use multiple cells, since this isn't a feature that is present in many other IDEs.

However, whenever I run my program with Control-Enter, it defaults to creating a new cell. Is there any way to turn this off? Does this bug anyone else?

/r/JupyterNotebooks
https://redd.it/al5oae
How to make ecommerce in django with shopify?

Hi guys, i am trying to make an ecommerce web site. I dont want to use shopify's store web. Hence i need to integrate shopify to my django application. But thats is confusing. If i want to integrate shopify, i need to connect my django app to shopify right? based on research shopify's python client helps on this. Also but shopify dashboard will post the products and i need to show them on my django app right, even then when user click add to cart button what should happen. if i use shopify 's dashboard for creating products do i really need database app like django?, should i use just js frameworks such as React, Angular, Ember? in this case?

​

Update:// I built MVP django app(add products, customer registration, login, see product details)

/r/django
https://redd.it/alkw2g
What are the biggest problems solved in corporations with Django?



Maybe I want to be fullstack expert on the front, so I would want to work with things like e-commerce, cms and these more common jobs.

However, I do not see vacancies requiring the most well-known python frameworks (wagtail cms, saleor and oscar for e-commerce) for these jobs. Unlike PHP, where there are many openings for wordpress, laravel and other e-commerce frameworks.

With that objective, is it worth keeping Django and using it to solve different problems like that? Or should I go to PHP!

/r/django
https://redd.it/alml4m