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 much should a django freelance developer charge hourly

I am confused about how much amount I should charge. Also wanted to know whether doing django freelancing is worth it or not.

/r/django
https://redd.it/ca576e
Flask vs NodeJS for API that delegates calls to Python scripts: What are benefits/downsides for either case?

I'm about to build a Flask API that runs python scripts on requests.
Using Flask seems more logical and beautiful since then all code in my web-app will be in Python.
On the other hand, the front-end is Javascript/React, so for convenience-sake maybe it doesn't matter that much? Also, I've read that NodeJS can be faster. The biggest concern is that it needs to be scalable and fast.

What's your opinion on this?
Thanks!

/r/flask
https://redd.it/ca6m45
Limiting the amount (not size) of files a user may upload (based on groups)

So I’m a Django newb and really a python newb too but I’m making my first web app.

I want to allow my users to upload certain amounts of files based on membership level.

10 mp3 files at free tier, or unlimited at the paid tier. There will also be wav files in the same amount but irrelevant really I think, because it will be the wav version of the mp3.


So I haven’t created the groups yet, and I haven’t figured out how to make a user pay to become a member of the group, but I think there is a lot of info out there on that.


Currently the users upload files and I use a list view to populate an html5 based audio player with the songs filtered by the logged in user. So each user only sees their own songs in the player.

My question is, can I do something like have a validators.py file that says if a user is in group free group and the amount of files uploaded by user id >= 10, throw an error stating that they need to upgrade membership?


I know it will be more complicated than this, but am I thinking

/r/django
https://redd.it/ca9qne
[P] A little gadget that plays rock-paper-scissors slightly better than random using a small quantized RNN running on an 8-bit microcontroller

[Project video here](https://www.youtube.com/watch?v=iuTKBHW0OaU)

[Code and PCB/CAD design files here](https://github.com/PaulKlinger/rps-rnn)

I was looking for some kind of project that let me combine my love for building [small electronics/3d-printing projects](https://paulklinger.com/projects/) and machine learning, and this is what I came up with.

The machine learning side of this isn't too interesting, just [a small 3 layer vanilla RNN](https://raw.githubusercontent.com/PaulKlinger/rps-rnn/master/diagrams/rnn_architecture.png) (all layers with 10-d state, trained in tensorflow/keras) that takes as input the moves of the two players and outputs a prediction for the opponents next move. The data comes from human games played on [roshambo.me](https://roshambo.me) via this [blog article](https://justincollier.com/life-hacks/how-to-win-rock-paper-scissors/). I added some simulated data of periodic sequences, because that seems like the sort of thing people might try out when playing against an "AI".

Without the simulated data (which is easy to predict) the model gets something like 38% accuracy on the test set (compared to 33% playing randomly). One nice thing about rock-paper-scissors is that you can't do much better than random, so there isn't much pressure ;)

I had some problems getting training with larger batches to work (either with just padding or padding and masking the gradients) so I just trained it with batch_size=1, which wasn't too bad for such a small network.

The probably more interesting

/r/MachineLearning
https://redd.it/ca88r4
This media is not supported in your browser
VIEW IN TELEGRAM
I made a tool to download and set wallpapers from Reddit.

/r/Python
https://redd.it/caac6i
How fast can Django generate model instances?

Hey all. I've got what I think is a simple question about Django: How fast can it generate model instances?

I've got a CSV file with about 2.5 million rows and I want to generate a model instance for each row. They will all be the same model, basically with the headers of the CSV as fields and the rows as records.

It's easy to just read the CSV line by line and for each line, create the model w/ the given fields, but is this a terrible idea? How fast can Django create instances like that, and is this a common operation or should I reconsider my database design? Also, would it be accurate if I were to load all this data into sqlite and search/filter/write my code around that locally, if I plan to eventually push it into a Postgres database in production?

For what it's worth, my intention is to make this data searchable, where almost every query will be a `Thing.objects.filter(some_column__lte=value, some_other_column__gte=other_value)` and so on w/ the ability to filter on as many of the CSV headers as possible.

Any thoughts? Open to other questions/ideas that can help me solidify my plans here :)

Thanks!

/r/djangolearning
https://redd.it/cafgfs
[AF] [CRITICAL] WORKER TIMEOUT (pid:7) Can I extend the timeout to more than 10 minutes?

Hi all,

I'm running gunicorn / flask in a docker-compose setup and I'm processing a large set of CSV files in the background.

It's always worked fine but I have a particularly large set I'm working through and after about 10 minutes I get this error and the conversion of the CSV starts again from scratch.

website_1 | [2019-07-08 05:41:02 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:7)
website_1 | [2019-07-08 05:41:02 +0000] [7] [INFO] Worker exiting (pid: 7)
website_1 | [2019-07-08 05:41:02 +0000] [9] [INFO] Booting worker with pid: 9

This is obviously annoying as the file never finalises processing.

Is there a way to extend the timeout? Any guidance much appreciated.

/r/flask
https://redd.it/cah4hk
How To Intercept Email In Flask?

I would like to intercept the email before sending to client like ROR [https://guides.rubyonrails.org/action\_mailer\_basics.html#intercepting-emails](https://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails) , But is there anyway that we can do it in flask?

​

Thank you for helping me.

/r/flask
https://redd.it/cahqmd
I wanted to know how bad was the heat wave in my bedroom, so I use a cheap sensor and a raspberry and built an acquisition station !

Hello guys ! With the rising temperature, I wanted to observe the temperature variation in my bedroom (under the roof, hell on earth). So I scraped the sensor I bought some time ago, and connect a DHT sensor (humidity and temperature) in the Raspberry GPIO.

​

I wrote a small application in python with

​

\- data acquisition thanks to AdafruitDHT lib

\- data storage in a mongodb

\- web API with bottle

​

I put it into a repository if anyone interested to do the same at home !

​

[https://gitlab.com/celliern/sensor](https://gitlab.com/celliern/sensor)

​

Cheers

/r/Python
https://redd.it/caig3g
Django Oscar vs Saleor for Digital Products store?

We run [https://videoplasty.com/](https://videoplasty.com/) \- a pretty standard stock video marketplace (video animation, gif animation, vectors)

​

We want to start building a new custom Django platform using one of those two. Down the road, we'd like to add multivendor functionality (none of them have this at the moment)

​

Anyone have any experience with the two for digital products or knows the pros/cons of each? It's hard to find a comparison or pick one.

​

We're inclined to go with Saleor cause it looks and feels nicer (we're not developers), but some developer suggested Oscar might be better for us, so we're confused right now.

​

Would appreciate your thoughts :)

/r/django
https://redd.it/cajmmb
How to display date time like day/month/year 15:30 (24 hour time)

# Answered: { value|date:"d/m/Y G:i" }

​

Hi want it so my it show up like this: day/month/year 15:30 - with the time being 24 hour time (military time)?

I have tried this in my templates file

# dashboard.html
{ value|datetime:"SHORT_DATE_FORMAT"|time:"H:i" }

Now the date will display fine when I don't have the |time how do I add the time?

/r/django
https://redd.it/calmyn
Concepts/ideas to be known to make this Date and time selection for a django booking app.

I have here screenshots of a booking app that I like. I'll try to do it with django for learning. I'm still wondering if this functionality (see image), which is selecting date then it's respective time has something to do with django models (making time options for respective date in [models.py](https://models.py) ). I'm also thinking that this can be just done with javascript (but i don't know js).


Well i don't know what would be the best choice . Any ideas or terms that you can comment on how I could do it would be a great help for me.


I also looked for the DateTimePicker in django but i don't know if that can fit my need for this feature. I will surely appreciate your responses.

​

https://i.redd.it/bpwbzxygg3931.png

Just to show the full functionality of this app, I'll show this second screenshot. Once time and date has been selected, I'm planning to grab the employees from django models if they are free or not.


https://i.redd.it/o94awnpgh3931.png

/r/django
https://redd.it/cam82h
Help with getting currently logged in user's ID in views.py query

I am using and if else logic statement in my [views.py](https://views.py) file to return on template if is true and one template if is false.

​

Here is my code so far which is working with the user ID hard coded, I just cant figure out how to get the current users ID. When I try self.request.user i get self is undefined or request is not defined

​

class uploadNew(CreateView): # new
model = beat
fields = ['title', 'beat']

success_url = reverse_lazy('uploads')
def get_queryset():
return beat.objects.filter(producer="2")

if get_queryset().count() <= 1:
template_name = 'uploadNew.html'
else:
template_name = 'home.html'


/r/django
https://redd.it/caoo05
The opensource DeepNude is now banned from GitHub
https://github.com/deepinstruction/deepnude_official

/r/Python
https://redd.it/cakxcw
Awesome free open source software for data pipeline testing: Great Expectations

Check out this OSS for data pipeline testing with a lot of solid documentation and also has an active slack channel.

[Website](https://greatexpectations.io/?utm_source=reddit&utm_medium=post&utm_name=user-testing&utm_content=ml-v1)

[Github](https://github.com/great-expectations/great_expectations)

[Hello world blog](https://medium.com/@expectgreatdata/down-with-pipeline-debt-introducing-great-expectations-862ddc46782a)

&#x200B;

**Also---** We are looking for user testers to get some feedback. In exchange for feedback on our features beta data context, profiling, and data documentation features we want to provide you one on one video conference onboarding assistance to ensure successful integration with your project. Feel free to comment if you have any questions otherwise you can sign up here: [https://greatexpectations.typeform.com/to/mN4UdQ](https://greatexpectations.typeform.com/to/mN4UdQ)

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