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
4001 x 4001 px Maze generated by a python script I wrote, (blue line is solution)

/r/Python
https://redd.it/ioq0d4
I’ve made a sub for testing your reddit bots, so you don’t have to annoy moderators

Join r/TestRedditBots, you can also submit tutorials

/r/Python
https://redd.it/iopvl2
Running a Machine Learning Model in Django.

I am using Django REST Framework to run my ML model, in the views class. My model runs everytime a post request is made. Is there any better place to run the model? Some way to preload the model or do it in the background?

/r/django
https://redd.it/ioqm4k
What's expected from a Junior/Mid/Senior Django developer?

This is a question I have in mind because I've not been put in an enterprise-grade work before. I've lots of experience tampering around myself in lots of things, I find myself knowing many things in the technologies I use that mid-seniors don't know (but I can't work in a team...etc). I can't judge my skills from my own perspective. I need someone to help me judge what's the perfect level of a job for me to apply to or how to know that. I've been in programming for more than 5 years, but only 1 in Django, I worked 2 years as a freelancer, but my CV is still empty except probably the skills section and some personal projects.

/r/django
https://redd.it/ioua0o
Sources

Can I ask for some good sources to learn django?

/r/django
https://redd.it/ioxuz4
@app.route can't grab by id

I want to grab by **id** but I can't seem to get it right. my code below

@app.route('/post/delete/<int:id>')
def delete(id):
posts = BlogPost.query.get_or_404(id)
db.session.delete(posts)
db.session.commit()
return redirect('/post')


@app.route('/post/edit/<int:id>', methods=['GET' 'POST'])
def edit(id):
if request.method == 'POST':
posts = BlogPost.query.get_or_404(id)
posts.title = request.form['title']
posts.content = request.form['content']
posts.author = request.form['author']
db.session.commit()
return redirect('/post')
else:
return render_template('edit.html')

ninja syntax in

/r/flask
https://redd.it/iozbxv
Real life examples of using Flask for data container (register, information management), machine learning/analytical pipeline?

I need real life examples which I can refer to as an example were Flask is used. I am interested in cases were Flask is used for:

1. As data container (register, information management system; some system where data is entered and retrieved on demand).

2. Machine learning/analytical pipeline.

/r/flask
https://redd.it/ip4jo5
Django TalkTo: Seamlessly use Django without DB

I just developed a django app that allows you to talk to a REST API using the django modules. I called it Django TalkTo. It allows you to literally use django in a "djangoic" way without a database

You can check it out at

https://github.com/sirrobot01/djangotalkto


Note: It is still in developmental stage. Opinions are welcome on how to improve it.

Thanks

/r/django
https://redd.it/ip9vx5
Wednesday megathread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

/r/Python
https://redd.it/ip5722
Hired to a new intern position! Thank you all

Hey everyone! I am an electrical engineer student who is an intern at an engineering company but had a really boring business position. I didnt like my position at all since it was just making reports by copying and pasting. I didn’t know how to code, but I was interested in learning python. So I decided maybe I could make a project of automating those tedious reports so that I didn’t have to do it.
Over a month ago I asked if it was possible to automate the really boring stuff I have to do for my job since it was just super boring. Some of you guys suggested I learned to use pandas. I decided to take up my free time to learn python and study up on pandas. I finally finished creating a program where it automates all the reports instantly, saving about five hours per report.
My manager was really impressed and showed his manager. I was able to move position into a hardware engineer intern, where I can still continue to better my coding skills as well as do what I want to do as an engineer! Thank you all for your help!

/r/Python
https://redd.it/ip4ute
adding sqlalchemy database from separate python file

Can anyone tell me how to add a database to a flask web app if I have the model in another file.

I am making a web app for a file management system.

I have made a models.py file where I have written the code for all the tables and relationships and now I have to call it in my main.py file where I have declared the flask app .

Can anybody tell me how to do it ?

/r/flask
https://redd.it/ipciv4
Change you pass Django Users database into other database

Hello;

I want to ask if it’s possible to pass the default User database into other databases.

My problem: I have both signUp page and admin page. Both of the page can create a user with admin page have extra fields as compared to the signUp page
My use case:
I want to make an admin table that contains standard user credentials plus fields that will contain access level and their roles. My understanding is that if I created a user and stored on this table, I cannot use this credentials for the login process.

I figured if I can store those credentials into both of the database it will works.

Sorry if the question seems lacking in details, I will be glad to provide extra information. Thanks

/r/djangolearning
https://redd.it/ipd4rh
How do I get multiple models (+/- 5) on a single form ?

Hi,

I'm still pretty much a newbie at django, but am finding it pretty useful and interesting. What I've done is to build a few models that looks after a software delivery process that keeps track of what deliverable is with what department. As such I have made 5 models

&#x200B;

**models.py**

class Release(models.Model):
RELEASE_STATES = (('PRE', 'Pre Release'),
('A', 'Department A'),
('B', 'Department B'),
('C', 'Department C'),
('D', 'Department D'))
release_name = models.CharField(max_length=250, null=True)
current_state = models.CharField(choices=RELEASE_STATES, default="PRE", max_length=50)
release_note = models.FileField(null=True, blank=True)
archived = models.BooleanField(default=False)

def __str__(self):
return self.release_name

def get_absolute_url(self):


/r/django
https://redd.it/ipggnp
session not persisting in chrome and safari, but is in opera!?

i have a simple login system using sessions, with a flag showing if the user is logged in. the session is set to be "permanent", but have a life span of 1 day.

it was all working as intended until a few weeks ago where it suddenly decided to drop the session.

The usual path that user takes would be:

login screen *\[home() route\]* \-> correct details, create session, go to index, use session data to build index *\[home() route with post data\]* \-> click link to go to content, check session and return home if it doesn't exist (aka they have logged out at some point) *\[read() route\]*

now what happens:

login screen -> correct details, create session, use session data to build index -> click link and it returns home because the flag has a value of "None", as though the session was cleared or the user logged out (impossible)

so the session behaves as intended in the first 2 screens, but out of nowhere stopped persisting through to the third screen

the thing i don't understand is that if i use a different browser instead of chrome (or safari as some of my testers have been using) then everything works perfectly.

does anyone

/r/flask
https://redd.it/ipfwc1
Can we get a new rule on library submissions/updates?

I browse r/Python a lot, and it's great to see new libraries or updates to existing ones, but most of them give little to no information on what the library is about and they usually link to a medium/blog post that can take a bit of reading to work out what the library actually does.

The Seaborn library (currently on the front page) is a prime example.

I'd therefore suggest a requirement for library submission/update posts to have at least a short description of what they do, as well as a link to where it's actually hosted (pypi preferably or github). I know its a bit more work, but there's been quite a few of these posts recently which just feel like adverts for someones medium blog.

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