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
DjangoCon Europe 2020 is FREE

Hi all,

Just to let you know that DjangoCon Europe 2020 has already published their schedule:
[https://cfp.2020.djangocon.eu/porto/schedule/](https://cfp.2020.djangocon.eu/porto/schedule/)

And the tickets are FREE!
[https://pretix.eu/djceu2020/tickets/](https://pretix.eu/djceu2020/tickets/)

Website: [https://2020.djangocon.eu/](https://2020.djangocon.eu/)
Twitter: [https://twitter.com/DjangoConEurope](https://twitter.com/DjangoConEurope)

Cheers!

/r/django
https://redd.it/iq0dfg
Add Audio Tag to Django Admin

Hello there,

I'm making a music app where the Admin can listen audios available in a database.

Is there away that I can add a section in Django Admin where I can reproduce audio using html <audio/> tag

/r/django
https://redd.it/iq7loy
Dynamically create raw SQL query without running risk of SQL injection?

I can no longer battle with the Django ORM, so we need to write our queries in raw SQL using \`connection.cursor()\`. But how can we conditionally build parts of a query without doing string interpolation and thereby risking SQL injection?

For example, saw we have the following query:

`cursor = connection.cursor()`

`cursor.execute("SELECT * FROM sometable WHERE soemetable.thing = 'foo' ")`

&#x200B;

But we only want to have the WHERE statement in the query depending upon other conditions and we can't just leave the WHERE statement equaling NULL or empty string or whatever?

/r/django
https://redd.it/iq827d
Stop users from accessing my API?

Hello everyone,

I'm a big noob, so I don't know if this question even makes sense, but regardless:

Is it possible to stop users from sending API requests programmatically? That is, still allow API requests from users in my frontend, but stop them sending API requests from something such as Python's `requests` library.

For example, most popular services (Twitter, Youtube, etc.) have (at least I think) an API that the public is allowed to use (with limits), and an API that is used when you do something such as tweet.

I know about decorators like `@permission_classes([IsAuthenticated])`, but I don't think that would help since you can still send authentication credentials in the headers.

Any help is much appreciated!

/r/django
https://redd.it/iq9ob9
Friday megathread: Free chat Friday!

Use this thread to talk about anything Python related! Questions, news, projects and any relevant discussion around Python is permitted!

/r/Python
https://redd.it/iqfher
Very nice 👍

/r/Python
https://redd.it/iqer5r
Skeleton of a green tree python

/r/Python
https://redd.it/iqhlvk
What's the best way to add a single HTML button that updates a model?

I'm working on a project similar to Reddit, where the user can join and leave communities. I'm currently stuck on how to add a functional "join"/"leave" button to the page.

The models I use are a many-to-many relationship between User and Community, so joining adds the current user to <community_name>.members.all().

I'm not sure how to make the buttons do this. I thought about making a Join form whose only element is the submit button and using JavaScript to switch to the Leave form when it's clicked. Would that even work, and would it be the best way to approach this? I've only got a basic knowledge of JavaScript so I wouldn't know where to begin if it requires JQuery or something like that.

/r/djangolearning
https://redd.it/iqjc36
How is Django 3.1 so far? I'm coming from 1.11 LTS

For those of you using Django 3.1, how is it? Is it worth using over the 2.2 LTS?

My last project was 1.11 LTS and I did enjoy using it.

I would prefer an LTS version so there is less pressure to upgrade. But 3.1 looks pretty shiny.

/r/django
https://redd.it/iqe6dr
As long as you code, you’ll have these feelings !

/r/Python
https://redd.it/iqp2nh
How to make flaks site https?

Not sure if this is directly ima flask question, but I built a flask site with react front end. I deployed on Ubuntu 18.02 ec2 and I’m using Apache. I set up an elastic up to point my tld and works fine, but I don’t understand how to set up ssl. Any help? I have a let encrypt ssl certifícate.

/r/flask
https://redd.it/iqgj5z
[P] 🤗Datasets: First stable version of our open-access datasets & metrics library

Hi all,

We just released 🤗**Datasets** **v1.0** at HuggingFace. It's a library that gives you access to **150+ datasets** and 10+ metrics.

This v1.0 release brings many interesting features including strong speed improvements, efficient indexing capabilities, multi-modality for image and text datasets as well as many reproducibility and traceability improvements.

You can install it with

pip install datasets

or find it at [https://github.com/huggingface/datasets](https://github.com/huggingface/datasets)

Loading datasets is easy:

from datasets import load_dataset, list_datasets

print(list_datasets())
# ['aeslc', 'ag_news', 'ai2_arc', 'allocine', 'anli', 'arcd', 'art', 'billsum',
# 'biomrc', 'blended_skill_talk', 'blimp', 'blog_authorship_corpus', 'bookcorpus'
# ...
# 'wikipedia', 'wikisql', 'wikitext', 'winogrande', 'wiqa', 'wmt14', 'wmt15',
# 'wmt16', 'wmt17', 'wmt18', 'wmt19', 'wmt_t2t', 'wnut_17', 'x_stance', 'xcopa',
# 'xnli', 'xquad', 'xsum', 'xtreme', 'yelp_polarity']

mnli = load_dataset("glue", "mnli", split="train")
wikipedia = load_dataset("wikipedia", "20200501.en")
my_dataset = load_dataset("text", data_files='./my_book.txt') # or your own file

The library is backed by Apache Arrow for **memory mapping**: it means that loading and using datasets is fast and don't fill your RAM. For example loading the 18GB of

/r/MachineLearning
https://redd.it/iqp9mc
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/ir28yx
Anaconda is not free for commercial use (anymore) - alternatives ?

Hey guys,

I recently started a job in the industry and wanted to use my python environment I got comfortable with as a researcher - the Anaconda Python Individual edition. And just to be clear, I love it :)

I thought, Individual edition - no worries - I can use it anyhow I want it even commercially. It seems, I was wrong.

After talking to my boss about it, I contacted Anaconda, and I got the message, that due to explosive growth over the last 6 months they had to update our Terms of Service and can no longer offer commercial use of the Anaconda Repository. Just to be complete on this, they offered an entry of $5k per year which sadly is no option for me.

I thought I had done my homework, after having read the EULA, where nothing is stated, that you cannot use it commercially. [https://docs.anaconda.com/anaconda/eula/](https://docs.anaconda.com/anaconda/eula/)

It says: BSD license ---

So I talked back and asked for the document which said that commercial use is not allowed, which led to the TOS, as the individual edition is (also) using the repository.

The link to the document is this one: [https://know.anaconda.com/TOS.html](https://salesloft.anaconda.com/t/101683/c/c1fb6dfc-2949-4963-9924-7b511547c2d8/NB2HI4DTHIXS623ON53S4YLOMFRW63TEMEXGG33NF5KE6UZONB2G23A=/know-anaconda-com-tos-html)

where it is stated:

>

/r/Python
https://redd.it/iqsk3y
Jupyter notebook is not working through anaconda prompt.

shows this when executing the command on a virtual env:

&#x200B;

&#x200B;

(ox) C:\\Users\\dell>jupyter-notebook

Unable to create process using 'C:\\Users\\dell\\Anaconda3\\envs\\ox\\python.exe C:\\Users\\dell\\Anaconda3\\envs\\ox\\Scripts\\[jupyter-notebook-script.py](https://jupyter-notebook-script.py) '

/r/IPython
https://redd.it/iqp55l
Is it possible to make PyCharm cloud-based? Like google docs where it saves on all PC's you have and you can open it on any PC and it'll be updated.

I probably phrased that really poorly so I'm sorry about that.

Anyway I have a school laptop and an at home computer and so I was wondering if it would be possible to make it where whenever I make/edit a file in PyCharm it could save the file in the other computer's PyCharm or have it ready for me to download or something. Also for all the changes I make to be automatically updated.

I hope this made sense I'm a newbie to PyCharm.

/r/Python
https://redd.it/ir3zha
Problem while using matplot lib in jupyter notebook. It does not generate any plot. Any solutions?

/r/JupyterNotebooks
https://redd.it/iqv3s2
Can I make a Desktop app using ky existing Django webapp?

Is it possible to make an electronjs app using existing Django webapp?

Btw electron js is not compulsory. I just need a performant Desktop App made out of my existing Django webapp. It must be as good as desktop apps made with electron Js.

Any suggestions?

/r/django
https://redd.it/ir5onz
[D] Tip of my tongue - Joke paper about computing SVD from an image of a matrix

I'm trying to find this paper, and my google-fu is failing.

&#x200B;

What I remember about the paper was that they train a neural network to learn to compute the SVD of a matrix based on a colored image of that matrix. They joke about why would you use an exact algorithm when you can approximately do it with learning, or something like that. Also one of the authors is a dog.

/r/MachineLearning
https://redd.it/iqxgcv