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
[AF] why am i all of a sudden getting this error? Method Not Allowed The method is not allowed for the requested URL.

Hi all,

I am working on two machines. Mac and Linux. I work on linux during the day, do all my work, head home at night and continue on mac.

I use docker-compose to allow this to happen and I've had little to no troubles all this time.

I finalised another conversion script yesterday on the mac, works a treat. CSV files upload,get converted, life is good. I've made many of these scripts using my workflow.

This morning though I've loaded the same script on the linux machine and am getting `Method Not Allowed. The method is not allowed for the requested URL.`

I have never had this before. I'm simply using:

<form method=POST enctype=multipart/form-data action='convertData'>
<input type='file' name='file' class='UCSV_FileInput'></input>
<button type='submit' value='Upload'>Submit</button>
</form>

and on my views.py I'm doing this kind of thing:

@myroute.route('/convertData', methods=['GET', 'POST'])
def convertData():
if request.method == 'POST':
# all the upload stuff is here

I literally have dozens of these,

/r/flask
https://redd.it/amvbna
My "Python for Data Science" video series!

Finally, I am done with the recording of my "Python for Data Science" video series! This 32-part video series provides a brief yet comprehensive introduction of the basic Python libraries required for Data Science to the beginners.

[https://indianpythonista.tech/pyfds](https://indianpythonista.tech/pyfds)

\#python #data\_science #numpy #matplotlib #pandas #tutorial #beginners

/r/Python
https://redd.it/amyds2
This media is not supported in your browser
VIEW IN TELEGRAM
I used neuroevolution with python to beat OpenAI games!

/r/Python
https://redd.it/amwt0v
Is there a Marie Kondo technique for refactoring spaghetti code?

I've found *lots* of post about how not to get to unmanageable code, but lets face it most of the unmanageable code we inherit from someone else. I've recently inherited a *huge* amount of code that was hacked together by someone who has just started coding and i need to add new features to it but I'm having a hard time trying to figure out where to start and how I get it to where i want it.

I guess Marie Kondo makes others deal with their own piles junk, but in an age where being a good organiser can make you famous perhaps we need something equivalent in the programming world.

Anyone have a technique/strategy that worked for them?

/r/Python
https://redd.it/an00ho
DRF/Django/React/Redux/MaterialUI and Antd/ Heroku ready and complete User template set up Boilder Plate

Greetings all,

&#x200B;

I have created a Django/React w/Redux Postgesql/Heroku User Boiler Plate. This boiler plate includes a user sign up, log in, log out, AND get user information which is all created using Redux and Django Rest Framework API's. You can follow my models, views, and serializers to create your own data base objects (models) in Django and then make those calls follwoing my API calls to user information. Pretty simple! Create a model and view or post to it through api calls in redux. Just map your components to your store and you are done!

It takes about 20 minutes to get the site up and running on heroku. It's the only place I know how to deploy to. Maybe this could be expanded upon by other users. Anyways, any comments, suggestions are much appreciated! This is kinda my first time doing anything like this, I'm a total noob and haven't been programming for a year yet.

So I'd really appreciate any suggestions.

[https://github.com/barictj/djreactboiler](https://github.com/barictj/djreactboiler) for the git

[http://djreactboiler.herokuapp.com/](http://djreactboiler.herokuapp.com/) for the installation instructions/ readme

/r/django
https://redd.it/amx1yr
Writing data to django sqlite3 database from an exterior python script questions

OK- so I have a python script that is up and running and pushing data nicely to a sqlite3 database right now (not my django db). And I want to eventually have it write to my django sqlite3 database instead. I just have a few questions about doing this:

1. Is there anything special I must put in my Python script, relating to the django site/database? Right now, I am assuming all I have to do is just connect to my django db instead of outside db ie: sqlite3.connect('path\\to\\django\\db')
2. Do I need to re-create the sql table in [models.py](https://models.py) of my django site? If so, I assume it must match exactly to the SQL I am executing in Python currently..? Any tricks on doing this?

Any help would be much appreciated!

/r/django
https://redd.it/an2b23
DRF/Django/React/Redux/MaterialUI and Antd/ Heroku ready and complete User template set up Boilder Plate



Greetings all,

I have created a Django/React w/Redux Postgesql/Heroku User Boiler Plate. This boiler plate includes a user sign up, log in, log out, AND get user information which is all created using Redux and Django Rest Framework API's. You can follow my models, views, and serializers to create your own data base objects (models) in Django and then make those calls follwoing my API calls to user information. Pretty simple! Create a model and view or post to it through api calls in redux. Just map your components to your store and you are done!

It takes about 20 minutes to get the site up and running on heroku. It's the only place I know how to deploy to. Maybe this could be expanded upon by other users. Anyways, any comments, suggestions are much appreciated! This is kinda my first time doing anything like this, I'm a total noob and haven't been programming for a year yet.

So I'd really appreciate any suggestions.

[https://github.com/barictj/djreactboiler](https://github.com/barictj/djreactboiler) for the git

[http://djreactboiler.herokuapp.com/](http://djreactboiler.herokuapp.com/) for the installation instructions/ readme

/r/djangolearning
https://redd.it/amx8nw
[R] TuckER: Tensor Factorization for Knowledge Graph Completion

&#x200B;

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

&#x200B;

**Paper:** [**https://arxiv.org/abs/1901.09590**](https://arxiv.org/abs/1901.09590)

**PyTorch Code:** [**https://github.com/ibalazevic/TuckER**](https://github.com/ibalazevic/TuckER)

&#x200B;

**Key contributions:**

* proposing TuckER, a relatively simple **linear** model for **link prediction** in knowledge graphs that achieves **state-of-the-art results** across all standard datasets;
* proving that TuckER is **fully expressive** and deriving a bound on the entity and relation embedding dimensionality for full expressiveness which is several orders of magnitude lower than the bound of previous state-of-the-art models ComplEx and SimplE; and
* showing that TuckER **subsumes several previously proposed tensor factorization approaches** to link prediction, i.e. that RESCAL, DistMult, ComplEx and SimplE are all special cases of our model.

**Abstract:**

Knowledge graphs are structured representations of real world facts. However, they typically contain only a small subset of all possible facts. Link prediction is a task of inferring missing facts based on existing ones. We propose TuckER, a relatively simple but powerful linear model based on Tucker decomposition of the binary tensor representation of knowledge graph triples. TuckER outperforms all previous state-of-the-art models across standard link prediction datasets. We prove that TuckER is a fully expressive model, deriving the bound on its entity and relation embedding dimensionality for full expressiveness which is several orders of magnitude smaller than the bound of previous state-of-the-art models ComplEx and SimplE. We further show

/r/MachineLearning
https://redd.it/an09n8
How to keep the ML model of spaCy running for faster response

I am working on an NLP project in spaCy. I want to deploy my project on the internet, but I am facing a problem. The application checks individual sentences for their grammatical correctness and it is really quick once the ML model is loaded in the memory (with the command spacy.load('en')).
The problem is loading the ML model takes some time, around 30 seconds. How can I keep the model loaded so that it doesn't have to reload every time a new request comes in on the server?

/r/django
https://redd.it/an39k5
[Noob question] Should Django share a MySQL database with independent parts of the application?

There's two aspects to the database:

* The Django auto-created tables (auth_group, auth_user, django_session, etc.)

* The tables I will be creating separately. I have a crawler that's constantly inputting and modifying data in the db. This data will be used when rendering the HTML, as well as exposing it as a web service API.

I'm using Kubernetes and I have 3 containers in the pod:

* Django

* MySQL

* Crawler

I'm fairly inexperienced with all these technologies, and I'm just wondering if it's better to have all data under one database, or separate databases.

If I use just one database, should the source of truth (who creates the database) be Django?

/r/django
https://redd.it/an5bkd
[P] Mushroom: Reinforcement Learning library

Hi everyone,

during my PhD I worked on a RL python library which has the purpose to simplify the developing of RL experiments and which is highly customizable to let user add and test their own algorithms. It uses Gym and Pytorch (one can also use Tensorflow or other libraries transparently) to exploit already developed powerful libraries and just to focus on RL aspects. Recently, we added several policy gradient and actor-critic algorithms, such as the recent DPG. I'd really appreciate if you give a look to Mushroom and consider it for doing your research, or simply to give me a feedback on it. Here are the GitHub link: [https://github.com/AIRLab-POLIMI/mushroom](https://github.com/AIRLab-POLIMI/mushroom) and the doc link: [https://mushroomrl.readthedocs.io/en/latest/](https://mushroomrl.readthedocs.io/en/latest/).

Cheers!

/r/MachineLearning
https://redd.it/an3cqz
During logout on the web the DRF token is also logging out the native app, how do I stop this?

I have an API that is consumed by web client and native clients, when the user on the web logs out the token is invalidated and they are then logged out on mobile which is a bad user experience. How do I solve this?

It is conceivable to just forget the token on the web during logout but then it never changes and there is credit card data stored in the DB so that is not ideal.

/r/django
https://redd.it/an9wja
How to organize my django website

Hello all! I am super super super new to Django and python in general. I have begun the process of reading the documentation and going through tutorials and have come here for guidance.

The site I want to build would be for speakers at conferences to be able to upload their files prior to the event. I can easily wrap my head around having an app with a model of the general fields associated with this and a simple file upload form.

The part that I can't really figure out is how I would be able to have multiple conferences able to upload at the same time. As well as how non programming people would be able to set up a new conference to begin uploading to using only the admin interface.

Is there a way to create a new db table via admin interface? Should all of the entries just live in the same table with an entry determining which conference the entry belongs to? Am I being too ambitious for my first non-guided Django project?



/r/django
https://redd.it/an9jfe
Replacing a spreadsheet...

I've successfully used Jupyter before, as a beginner for a few machine learning lessons, but I'm wondering if it's possible to use/abuse Jupyter to behave more like a spreadsheet, just in terms of having cells depend on other cells and continually update.

I've always felt limited by Excel because I really want to document my thinking in the way that Jupyter allows, with markdown blocks etc. (Before getting into Jupyter I've also been using Calca for the mac.) I also feel limited by Excel's functions, while I'm very comfortable with software programming - there have been so many times I've thought, ugh, this would be so much easier if I could just call 'map' on this array of data...

So I've been hoping to find something like Jupyter, where I can actually write my own functions and document my thinking, but where I can also input new data and have it be persistently stored, and have other cells update to changed data.

I know this isn't exactly what Jupyter is usually used for, since it's more to explore data in a linear fashion rather than in a reactive-programming fashion. So I guess this is a dual question:

Is it possible to make Jupyter behave

/r/IPython
https://redd.it/anb73f