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
Djagno Advanced Roadmap

hi! I started learning django about a year ago I've covered all the basics I also learned DRF with a few advanced topics models, views, cbv, fbv etc... I want to reach the point where I qualify to apply for jobs in companies I want a complete and comprehensive roadmap for Django so that I can evaluate my level through it I learned node js , react & react native also as a matter of knowledge So that I will be aware of how the frontend works specifically, which will contribute to raising my level

​

I have already completed several projects as a freelancer

The last one was an ecommerce shop

But I could not determine whether my code was clean and of a high level of quality

any help?

​

iam thinking about switching to node js - express - mongoose

i feel like iam lost rn :)

/r/django
https://redd.it/1cej5ct
Error thrown by VS Code when Main.py is Run

Dear team,

Error : raise AssertionError(

AssertionError: View function mapping is overwriting an existing endpoint function: form

Code:

from flask import Flask, render_template,request
import joblib
model=joblib.load('E:\\Courses\\LearnBay\\Deployment\\Pickle\\diabetic_joblib.pkl')
app=Flask(__name__)
u/app.route('/')
def hello():
return render_template("main.html")
u/app.route('/ConsellingForm')
def form():
return render_template("form.html")
u/app.route('/SubmitForm',methods=['post'\])
def SubmitForm():
pregnancies=int(request.form.get('Pregnancies'))
Glucose=int(request.form.get('Glucose'))
BloodPressure=int(request.form.get('BloodPressure'))
SkinThickness=int(request.form.get('BloodPressure'))
Insulin=int(request.form.get('Insulin'))
Age=int(request.form.get('Age'))
BMI=int(request.form.get('BMI'))
DiabetesPedigreeFunction=int(request.form.get('DiabetesPedigreeFunction'))
prediction=model.predict([pregnancies,Glucose,BloodPressure,SkinThickness,Insulin,Age,BMI,DiabetesPedigreeFunction\])
if prediction[0\]==1:
return 'You are diabetic'
else:
return 'You are Non diabetic'
app.run(debug=True)

​

please guide on how to resolve the error.

/r/flask
https://redd.it/1cghpzv
How to set foreign key to str method of a model without making alot of db calls?

I'm having two models
class A(models.Model):
name = models.CharField()


class B(models.Model):
model_a = models.ForeignKey(A)

def __str__(self):
return self.model_a.name



This is making alot of db calls. how to fix it?

​

/r/django
https://redd.it/1cglc6y
CS50 Finance project: Stocks list does not display into index.html

Source: [https://cs50.harvard.edu/x/2024/psets/9/finance/](https://cs50.harvard.edu/x/2024/psets/9/finance/)

​

https://preview.redd.it/yfz8wyn52rxc1.png?width=1024&format=png&auto=webp&s=9e476a46fff8ee9e44542beb3b9893329f043ad0

[App.py](https://App.py) (index route)

@app.route("/")
@login_required
def index():
"""Show portfolio of stocks"""
# Retrieve user's portfolio from the database
portfolio = db.execute(
"SELECT symbol, shares FROM portfolio WHERE user_id = ?", session["user_id"]
)

# Initialize variables to store total portfolio value and a list to hold individual stock details
total_value = 0
stocks = []

# Loop through each stock in the portfolio
for stock in portfolio:
# Lookup current stock price
quote = lookup(stock["symbol"])
if

/r/flask
https://redd.it/1chekm9
One pytest marker to track the performance of your tests

Hello Pythonistas!
I just wrote a blog post about measuring performance inside pytest test cases. We dive into why it’s important to test for performance and how to integrate the measurements in the CI.
Here is the link to the blog: https://codspeed.io/blog/one-pytest-marker-to-track-the-performance-of-your-tests

​

/r/Python
https://redd.it/1ci7m95
I made a python bot that plays minesweeper

Hello,

I made this Minesweeper bot that I wanted to share with you all.

What My Project Does \-

The bot takes a screenshot of the board and runs a classification algorithm to extract the contents of the board. It then analyzes the board, finds as many mines as it can, and sends clicks. If it cannot find any mines then it guesses the most probable position of a mine.

Target Audience \-

It's a toy project for anyone interested in algorithms or problem-solving.

Comparison \-

This is just my attempt at making a minesweeper bot. I'm sure there are many bots out there that are much more efficient than this.

do let me know, if you feel anything can be done better :)

​

/r/Python
https://redd.it/1csd77f
D How successful are ML projects?

Our team just deployed our first ML solution. We have several people with DS/ML certificates, and have done ML in side projects and hackathons, but no one has a degree in stats or math or DS and no one's ever done ML professionally. We regularly consulted multiple DS / ML experts, but never had a dedicated DS on our team. It cost us \~$400K to implement, is expected to save $50K a year, and have operational costs of $20K a year.

​

It seems like pursuing this wasn't worth it. Was this a miscalculation on our part? What's the success rate of the projects you work on? How much do you cost the company vs how much money do you generate (or save)?

​

/r/MachineLearning
https://redd.it/1cxtro6
Cookies are not being stored in the browser. Django Backend and react frontend.

So My backend code is in django and frontend code is in react. Backend has been hosted in render and frontend is not yet hosted. i.e. I work in localhost:3000.

​

Iam using cookies to store session data.

When I login I expect the sessionid and csrf id to be store in the browser, When I tested the API endpoint in POSTMAN It worked fine i.e. it stored the session id and csrf tokein in the cookies and all the other endpoint that required login worked fine.

​

Here is what happened when I integrated react with backend.

​

When I log in cookies are being generated and these are valid cookies, cause I have copy pasted then into postman and they work fine.

​

But after login when I see that no cookies is being stored. So as a result I cannot use other endpoint where login is required.

Here is the configuration of my backend

​

https://preview.redd.it/ni4ymqh6yc4d1.png?width=967&format=png&auto=webp&s=677b995fd173c3f79cc2809cfb7e0538cdb686f9

I have two session engines. django.contrib.sessions.middleware.SessionMiddleware and the one in the screenshot. But nothing has stored the cookie data.

If you want to see anything else I have given my github repo link at the end cd Backend/bacend/backend/backend/settings.py

​

This is the endpoint that will check if the user is logged in or not based

/r/django
[https://redd.it/1d74fww
R I finetuned GPT-2 and BERT 135,000 times to see if it's fair to pretrain on unlabeled text from the test set

TL;DR: seems fair.

Everyone knows that training on labeled test data is a big no-no if you wanna use that data for evaluation.

But if you pretrain on unlabeled test data, can you still use that data during evaluation?

Let's run an experiment on 25 text classification datasets, two LMs whose pretraining data we're pretty sure are not already contaminated, and across a few settings for the number of training and test observations.

For each dataset, the experiment sanity checks that pretraining on unlabeled text (independent of the test set) helps, i.e., that there's an effect to detect. Call this the pretraining boost. Next, the experiment evaluates the bias from pretraining on unlabeled text from the test set instead of unlabeled independent text. Call this the evaluation bias.

# Results

​

m=50 is based on the Real-world Annotated Few-shot Tasks \(RAFT\) benchmark \(https:\/\/arxiv.org\/abs\/2109.14076\), which also contains the inspiration for this question: “For each task, we release a public training set with 50 examples and a larger unlabeled test set. We encourage unsupervised pre-training on the unlabelled examples…”. The distributions above are those of marginal effects: averaged across 2 LM types, the 25 classification tasks, and their subsamples.

Stretching the intention of “few” in few-shot here. I wanted to

/r/MachineLearning
[https://redd.it/1do2g03
D Monthly Who's Hiring and Who wants to be Hired?

For Job Postings please use this template

>Hiring: [Location\], Salary:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] and [Brief overview, what you're looking for\]

For Those looking for jobs please use this template

>Want to be Hired: [Location\], Salary Expectation:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] Resume: [Link to resume\] and [Brief overview, what you're looking for\]

​

Please remember that this community is geared towards those with experience.

/r/MachineLearning
https://redd.it/1egc1um