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
Which javascript to use on the front end?

I've come a grudging acceptance that I will have to learn and add some javascript to a little personal project that I've been using to learn a few things as I go along. And I'm sure this comes up a lot, I'm just having trouble finding something relevant.

If I wanted to add a little bit of interactivity on pages, what is the best route to go down. Vanilla Javascript? JQuery? Can Vue be used for just scripts or does it have to be used as a full on framework? Something I'm not aware of?

/r/flask
https://redd.it/8rcjof
Django Or Rails

Hi currently I am using Rails to develop web apps, I want to know more what makes Django better than Rails
the first time I tried Django I feel like there is a lot magic syntax that I never know when using rails
Can someone give me a suggestion what make Django the best and what do people usually use Django for?
m

/r/django
https://redd.it/8rhy19
Converting an exe back to .py

hi guys,

I got discord bot created in python by someone few months ago, coder at that time just converted that to an exe file so its easy for me to run it. Now my coder has disappeared and i can not find him and i need to make small adjustments to script.

Is there a way to convert that .exe back to .py ?

Thanks,

/r/Python
https://redd.it/8rh2x2
Will the mega tutorial help me learn how to build more interactive apps than something like a blog?

I'm finished about a quarter of the mega tutorial and while it's very good, it also seems to be primarily focused on creating kind of a barebones blog style app without lots of user interactivity going on. My end goal is to make a speed reading app that can take text from an outside source (probably going to start with just taking wikipedia articles) and spacing the words into chunks of words you can read one at a time


ex: so instead of reading this word for word


[you would] [read it like] [this and] [read faster]

and maybe having every block highlighted with a different color.


 

Do you guys think the mega tutorial could help satisfy this?

/r/flask
https://redd.it/8rcebx
Django Graphene tutorial question

I went through the graphene tutorial and using relays. But I have am a bit confused on one thing

If you go through the normal tutorial when you do single queries the query part is defined by


class Query(object):
category = graphene.Field(CategoryType,
id=graphene.Int(),
name=graphene.String())
If you do the one with relay the query part is defined as

class Query(object):
category = relay.Node.Field(CategoryNode)

If I want both features (single queries and filters from relays) does that mean I have to define a new variable for one to have both features? or do I just used relays and somehow the typings for the fields are inherited. I am just kind of confused by the ambiguous way the tutorials are written.

/r/djangolearning
https://redd.it/8rhl1p
Masonite 2.0 Released - The Modern Python Web Framework!

I posted about the Masonite Python web framework a few months ago on this /r/python here and it received interesting feedback. During this time we received a few contributors who are just super awesome and contributed some awesome features.

We also were able to boost the speed of the framework to serve about twice as many requests in 30 seconds as Masonite 1.6 using some \`wrk\` benchmark testing.

Our contributors are extremely excited for this release and we can't wait to show it to the Python community. We think many of you will love the framework.

Here are a few useful links to checkout the framework:

The Github Repo: [https://github.com/MasoniteFramework/masonite](https://github.com/MasoniteFramework/masonite)

The Documentation: [https://docs.masoniteproject.com/prologue/introduction-and-installaton](https://docs.masoniteproject.com/prologue/introduction-and-installaton)

Whats New in Masonite 2.0: [https://docs.masoniteproject.com/whats-new/masonite-2.0](https://docs.masoniteproject.com/whats-new/masonite-2.0)

The Core Repository: [https://github.com/MasoniteFramework/core](https://github.com/MasoniteFramework/core)

Creating Your First Blog: [https://docs.masoniteproject.com/creating-your-first-blog/introduction](https://docs.masoniteproject.com/creating-your-first-blog/introduction)

Feedback for the Masonite community is appreciated and we'll be watching this thread for your thoughts on the framework! We hope to see you guys create some awesome web applications!

/r/Python
https://redd.it/8rjla6
Help with using public APIs

Edit-

day=datetime.datetime.today().strftime('%Y-%m-%d')#Get Todays Date, Daily Setting

my problem is below this

url = "https://demo.docusign.net/restapi/v2/accounts/"+accountId+"/envelopes"

querystring = {"from_date":Date,"status":"completed"}#if Envelope is completed

headers = { 'X-DocuSign-Authentication': "{\"Username\":\""+ email +"\",\"Password\":\""+Password+"\",\"IntegratorKey\": \""+IntegratorKey+"\"}", 'Content-Type': "application/json", 'Cache-Control': "no-cache", 'Postman-Token': "e53ceaba-512d-467b-9f95-1b89f6f65211" }

**my problem above this **

''' Envelope Response ''' response = requests.request("GET", url, headers=headers, params=querystring) envelopes=response.text

I currently have a python 3 program on my desktop. I run it with idle and everything is how I want it. What I want to do with Django is use this code to print its outputs on a webpage and have the user download it’s additional csv file output. I have managed to make a Django localhost and I am stuck at that point. I do not know how to use my python 3 code to run to webpage. The code is made up of api calls , I use postman to help me with sending the right parameters. I will add a example of code. All I want is for user to enter value such as “accountID” so that the api can complete the request and give them data for their own request. I would highly appreciate help on this

I have been trying for hours, from my understanding I have to make a view then send to HTML template

/r/django
https://redd.it/8ri846
Good flask apps to study from?

I'm about a quarter of the way done with the mega tutorial and want to see if I know just enough to get my hands dirty. I want to build something more engaged than a blog site (in particular I'm trying to build a speed reading saccade app) and I'm looking for any potential fully developed flask apps on github and such that I could study from.

/r/flask
https://redd.it/8rmqyg
What is a good first project for someone interested in machine learning?

I know a little bit of C but I am mainly learning on Python. I would like to start building something myself soon and I'm interested in machine learning and data science, but I am not sure where to start.

/r/Python
https://redd.it/8rm7m8
Question of how db.relationship() links databases together

Consider this bit of code from the mega tutorial:

class User(db.Model):
id = db.Column(db.Integer, primary_key = True)
username = db.Column(db.String(64), unique = True)
email = db.Column(db.String(120), unique=True)
password_hash = db.Column(db.String(128))
posts = db.relationship('Post', backref = 'author', lazy = 'dynamic')

def __repr__(self):
return '<User {}>'.format(self.username)

class Post(db.Model):
id = db.Column(db.Integer, primary_key = True)
body = db.Column(db.String(140))
timestap = db.Column(db.DateTime, index = True, default=datetime.utcnow)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

def __repr__(self):
return '<Post {}>'.format(self.body)


 

The general goal here is for every post to be linked to an author, in a one to many relationship (as in a user object can have many posts).

But I'm not exactly sure what the implementation doing.

In

`posts = db.relationship('Post', backref = 'author', lazy = 'dynamic')`

is backref just an additional field that `posts` is feeding to a Post object, that happens to be the `ForeignKey` defined in the `user_id` field? I'm just confused how `posts` and `user_id` link together so that each user can have various blog posts linked to him.

thanks in advance!

/r/flask
https://redd.it/8re0b5
How do I override the admin model delete action with confirmation beforehand?

I am trying to modify the bulk delete action that comes default with any registered model in the admin.

My goal is to override it and add in some extra functionality. This has actually been successful, but I lose the confirmation page beforehand. What happens instead is that the delete action fully executes and returns me back to the model's list view immediately. I want to keep the confirmation page as an intermediary *before* my action goes ahead and performs its customized deletion behavior on my selected objects.

Unfortunately, I've gotten a bit stuck on how to do this. Does anyone know how it can be done?

So far, my code is as follows:

class ImageAdmin( admin.ModelAdmin ):
form = ImageForm
actions = [ 'delete_selected' ]

def delete_selected( self, request, queryset ):
for obj in queryset:
obj.delete( )


admin.site.register( Image, ImageAdmin )

What can I do to make this work with the confirmation page?

/r/django
https://redd.it/8rnupm
Help in Python Simulation

Hello, i crunched numbers in calculating the position of the 3 body problem. I have 3.5 GB worth of data (x, y). But the problem is that i dont know how to use that data and plot it in such a way that it keeps updating in a reasonable amount of time (simulation visualization).

I just want a simple way to plot the 3 points and keeping it updating the positions while the program reads the file. Any help will be valuable.

/r/Python
https://redd.it/8rojtc
how could i make this, im a little lost

okay so ive been playing with django for some time and i have reached a point where im stuck i have this problem

lets say i have products and marketplaces
so i can create a product for example a cup, with their base values like name stock etc (i can already do that good)

then i can create marketplaces lets say i have one in the us and other in germany for example where i want to sell my cups and each marketplace has its own things also like name etc.

then my problem comes when i want to be able to put each product on X number of marketplaces independently with its own new values so for example my cup may have a german name on the german marketplace and the price in € for example.
thats where i have a problem right now i have 3 tables like
product
marketplace
product_marketplace

but i dont know how to make a form where you select a product and a marketplace and save them, thats my main problem
also i want the default values on that form to be the ones of the product for example the default name etc

i hope i was clear enought and thanks in advance!

/r/django
https://redd.it/8rpye2
Does anyone want a free Python or C tutor?

I'm really bored this summer and love teaching. We can do Skype lessons that are super flexible. PM me if you're interested

/r/Python
https://redd.it/8rq9z4
DataTables with Ajax

Hello everyone, I want to show a table on my website which will be automatically updated every X seconds (without refreshing the page). I really like what Django-Tables2 has to offer (filtering, pagination and etc), but it seems it cannot be used with JS for updates? Is there an another project which is updated regularly and has similar features?
Thanks in advance for the answers!

/r/django
https://redd.it/8rpbe2