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 export data from JSON file to database

models.py
class Stock(models.Model):
company = models.CharField()
sector = models.CharField()
per_asset = models.DecimalField()

serializers.py
class StockSerializer(serializers)
class Meta:
fields = '__all__'

views.py
class StockAPI(generics.ListCreateAPI):
queryset = Stock.objects.all
serializer_class = StockSerializer


I scraped down the stock informations for my model, in a dictionary and dumped dictionary to a JSON output file.
This is going to be one time scraping to load the data. But I am not sure what will be the next step going forward, how can I export the data from JSON file to my Stock model database?

/r/django
https://redd.it/kxqoc9
Anyone used scipy.optimize?

Trying to get my head around the scipy optimize library and especially minimize function. Part of it is the bewildering assortment of methods like Brent and Krylow methods etc. Are their any good tutorials on using the multivariate versions of these? I am having trouble with the minimization terminating early without deviating far from my initial x0. Any thoughts?

/r/IPython
https://redd.it/kxqi4d
Tutorial: React/SPA with httpOnly Django Sessions instead of JWT Authorization

Hey all, I've created an honestly somewhat-dysfunctional tutorial on how to integrate Django httpOnly cookie sessions with React for the sake of security and avoiding stateless authorization on browsers. I couldn't find any tutorials online that included httpOnly cookies, and honestly the DSF is pretty negative against JWTs (and JS accessible session cookies...). So here's a full breakdown tutorial!

https://github.com/Andrew-Chen-Wang/SPA-with-sessions

The demo is found here: https://acwpython.pythonanywhere.com/authenticated/ When you go to the authenticated URL, you'll find your session cookie and csrftoken set. (You can change the csrftoken to also be httpOnly in the settings). Static is deployed on GitHub pages every time you update the React app and does not delete old static files in case of delays in server deployment.

Please provide feedback! Also look at issue #3 of the repo. I just have haunting memories of working on SimpleJWT (disclaimer, I'm a maintainer) + JWT Authorization integration to becoming httpOnly cookies at PR #157.

/r/django
https://redd.it/kxyudo
Site themes: pitfalls to look out for?

I have a Django e-commerce project I am working on, and while I'm capable of getting the front-end all themed up nice and pretty, I'm looking at simply purchasing a pre-built theme from Themeforest or a similar provider.

Obviously I can't just go find a Wordpress or Shopify theme or something. I assume it should pretty much just be plain HTML+CSS+JS and I will have to modify the markup in their templates to be used with Django's templating syntax, but outside of that, is there anything specific I should avoid?

I've always just built my own front-end stuff but this time I'd like to skip that since I'm in a time crunch and pretty much any typical theme that has the basics will be good enough for me.

/r/django
https://redd.it/ky2v49
Django concurrent users estimate

I want to build an E-learning platform with Django and wanted to know aprox. how many concurrent users can an average Django web app handle right off the bat, with no optimization, since i want to make a pretty agressive marketing strategy and not feel bad about choosing Django. Want to host the app on linode, their 20$/40$ VM.


I know it depends on a lot of factors, but from your own experience?

/r/django
https://redd.it/ky4yac
Live flight sim tracker built in flask

I got fed up with the terrible visual map in Microsoft Flight Simulator.

I wanted a solution that would allow me to load a visual map of my plane location on a separate device - iPad, phone, chromebook, laptop.

So I built an app comprising: a small client which runs on the computer running the flight simulator, which sends flight data to a flask server which then serves up a visual map.

It uses flask, javascript, bootstrap and leaflet.js for the mapping.

​

https://preview.redd.it/bdbpojfidib61.png?width=930&format=png&auto=webp&s=5bd74be2059b72473f50d80de801272c49918f12

Website: https://findmyplane.live/

Server repo: https://github.com/hankhank10/findmyplane-server

Client repo: https://github.com/hankhank10/findmyplane-client

/r/flask
https://redd.it/kxvvyc
Saturday Daily Thread: 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/ky7bib
Django rest - Testing

Hi!

Im my work im using django rest framework with Reactjs an im testing the frontend. My question is, is there any way that i can make a mock database just for testing in a request made in the frontend? idk if im clear about the question, let me know

thanks in advanced

/r/django
https://redd.it/ky3jfe
Second version of my first Django App

I want to show you how my project is going. The first pic is when I was learning django basics and the last one is the app with django + vuejs.

​

Learning Django basics \(How it started\)

​

Current version built with DRF + Vue.js \(How it's going\)

​

Left aside on hover event

Rigth now i'm very happy for the results and I'm very close to have a mvp of this app so I want to know if you guys want to help me proving that, looking for possible bugs and giving me feedback when this app be ready.

Also I want to know if you would like that I write a blog telling how I built it or what was my learning proccess or tell me what kind of thing you would like that I write about.

/r/django
https://redd.it/kyc3yy
How can I perform push notifications in flask?

The only library I can find that the provides what I need is called Flask-Notifications but is no longer hosted on pypi and it is almost 6 years old now. Is there any modern flask library or something similar that allows me to perform web push notifications?

/r/flask
https://redd.it/ky4kbc
P best-of-jupyter: A ranked list of awesome Jupyter Notebook, Hub, and Lab projects

https://i.redd.it/pq6h29f3qbb61.gif

We've curated a list of the best Jupyter Notebook, Hub, and Lab open-source projects!

The list is fully automated via GitHub Actions, so it will never get outdated. Every week it collects metadata from GitHub and package managers, calculates quality scores to rank projects inside categories, and identifies trending projects.

🔗 GitHub: https://github.com/ml-tooling/best-of-jupyter

🎉 We also released a few other best-of lists on Reddit today:

[best-of-ml-python](https://www.reddit.com/r/MachineLearning/comments/kx8e13/p_bestofmlpython_a_ranked_list_of_awesome_machine/): Python libraries for machine learning.
best-of-web-python: Python libraries for web development.
[best-of-python-dev](https://github.com/ml-tooling/best-of-python-dev): Python developer tools and libraries.
best-of-python: General overview of Python libraries & tools.

📫 For updates on trending projects, new additions and detailed comparisons, follow us on Twitter or subscribe to our weekly newsletter.

/r/IPython
https://redd.it/kx8v15
RepostSleuthBot - Now Public

I've been working on this project for the last 2 years. It has gotten super popular and I've had a ton of requests to open the code up. I was always resistant since I considered it kind of a mess. I decided to take some time to clean it up a bit and make the repo public.

It has a lot going on, but nothing very complicated.

It makes heavy use of Celery for scheduling jobs and runs \~20 Docker containers for the various services.

It's not something you would easily be able to deploy on your own, however, I figured some people might be interested in seeing the workings.

https://github.com/barrycarey/RedditRepostSleuth

/r/Python
https://redd.it/kyb9rc
Rock Paper Scissors by a Beginner

Just a little game I programmed to test and improve my skills and I am pretty much satisfied with the end-product.

My first program where input function hasn't been used so no need to press ENTER key and you can play it by pressing "R", "S" and "P" keys.

Rock Paper Scissors Game

Thank You.

/r/Python
https://redd.it/kyhpm2
How to disable "searching..." message in django-autocomplete-light dropdown

Hey everyone,

I've been struggling with something I guess should be simple: I'm using django-autocomplete-light and django-taggit to autocomplete a tag select. The dropdown briefly shows a "searching ..." message at the top of the result list, even when all the results are already there.

I'd like to disable it, but have difficulties figuring out how.

It's possible that I should overwrite a javascript function, but I'm not sure and my javascript knowledge is limited, so debugging is hard. Any pointers would be greatly appreciated.

Thanks!

/r/django
https://redd.it/kyhu6s
Package that allows you to import files like modules

Hi everyone! Just made a package that allows you import data files (like .json , .yaml and more) like they are python modules

Link to github: https://github.com/mishankov/crazy-imports

And a question: does anyone know other packages that do similar things?

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