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
Proxy Model

I've a model "Approval" and its inherited model "ApprovalType" where i have put proxy = True. In the Approval model I've this "type":

type = models.CharField(max_length=30)

so when I'm creating the entries in the model using Approval.objects.create() my manager has asked me to (call the proxy model) or (create) the entries without actually putting type="abc" in the create(). I don't know how to this. please help me out on this

/r/django
https://redd.it/10blk9u
Need to restart the Kernel frequently

Basically the title. The Kernel dies to frequently. Any solution?

/r/JupyterNotebooks
https://redd.it/10bk5sf
Cannot figure out how to get dictionary values to show up on the page

I am very new to Django, so please be patient if this is something trivial. I have been trying to figure out a way to solve it for hours.

The problem:

I have a json file that looks something like this:


{
"Estonia": {
"dialcode": "+372",
"country
code": "EE",
"emoji": "🇪🇪",
"imageurl": "https://www.flagpictures.com/static/images/flags/ee.png",
"flag
colors":
"Blue",
"Black",
"White"

},
"Eswatini": {


/r/django
https://redd.it/10caeh1
API response time

After clean instalation of django and django-rest-framework simple APIView that returns one serialized objects {id:1,name:"test"} has response time around 45ms. While FastAPI response time is around 10ms.

Why is that?

/r/django
https://redd.it/10c566t
Is there an platform dedicated to deploy django application like laravel Forge ?

Hi,

I have been using django since many years now and i always wonder if there was a platform that could be use to deploy a django project without pain and followong the same process regardless of where it's deployed.

I mean if you deploy on AWS ECS the process is different than on Digital Ocean, even if you are using Docker. So I thought maybe there is a platform providing such service, so i can deploy any of my project and client's project very quicly and easily.

/r/django
https://redd.it/10avt4h
Django (Both in backend and frontend) or Django Rest Framework + React?

I would like to develop a website (like Zillow) by myself and I don't know if it would be easier to do it using only Django (with Django templates and vanilla Javascript for functionality and interactivity) or Django Rest Framework and React.

I have experience in React but I do not enjoy writing a separate backend and frontend. Also I don't like React that much. Is it possible, easier and better for only one dev to use only Django for a project like that?

/r/django
https://redd.it/10ai8h7
Django AWS S3 image files working locally but not in production

I'm creating a website with a blog that allows users to upload their own profile pictures, and this works locally. However, in deployment on OpenShift it returns an error ' The requested resource was not found on this server.'

​

My code in settings:

​

MEDIAROOT = os.path.join(BASEDIR, 'media')
MEDIAURL = '/media/'

AWS
ACCESSKEYID = 'xxx'
AWSSECRETACCESSKEY = 'xxx'
AWS
STORAGEBUCKETNAME = 'xxx'
AWSS3REGIONNAME = 'eu-west-2'
AWS
S3ADDRESSINGSTYLE = "virtual"
AWSS3SIGNATUREVERSION = 's3v4'

AWS
S3FILEOVERWRITE = False
AWSDEFAULTACL = None
DEFAULTFILESTORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

Locally, the link to an example image is: https://personal-portfolio-website-files.s3.amazonaws.com/profile\_pics/dog.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA5HK62K4UKN4EU6UQ%2F20230111%2Feu-west-2%2Fs3%2Faws4\_request&X-Amz-Date=20230111T120246Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=7ca52e78c5c266d18d24d4fc1bdb6ddb22267d06c09ba3eae1f6853fba7f1b91

​

Whereas on OpenShift, it's: http://personal-portfolio-web-personal-portfolio.apps.openshift.cs.cf.ac.uk/media/profile\_pics/dog.jpg

​

Does anyone know what's causing this?

I've tried changing all the permissions of my bucket to allow everything.

/r/django
https://redd.it/1093i83
Django Knox login endpoint not working

I used files from "https://github.com/Omkar0231/Django-Login-API" with no change. But, the login request from Postman is resulting in error, "detail": "JSON parse error - Expecting value: line 1 column 1 (char 0)", while the terminal shows "Bad request...".

The source code developer in above git also explained it in a video, "https://www.youtube.com/watch?v=6d0fiPj0dsA", however, in video everything seems to be working as expected.

Whatever I understood from Googling, I thought that a bearer token is to be included in the login request as header. But I don't know where to find the bearer token in my Django app. However, in the video, the original author/developer did not include any such header token for the login request from Postman.

Please help me figure out the issue.

/r/django
https://redd.it/108yj85
Sunday Daily Thread: What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.

/r/Python
https://redd.it/10c4t91
What are people using to organize virtual environments these days?

Thinking multiple Python versions and packages

Is Anaconda still a go to? Are there any better options in circulation that I could look into?

/r/Python
https://redd.it/10bxkjp
Total beginner - Could Python be interesting for sales?

Hi there kind Python people.

Thank you for taking the time to read my question! It might be different to what normally gets posted in this sub. It's not about programming, but about career choices.

I am a 28 year old with a masters degree in Communication Sciences. Ever since finishing my studies I have been very interested in programming, AI, big data... Yet for the last years I preferred a life of travelling around and parties instead of really sharpening my skills. The time has really come for me to dedicate myself. I have taken up routines and discipline, and I have an ambitious mindset.

At this moment I am about to start a sales job (wholesale in medical disposables) in a very small but growth-oriented company. It is far from my dream job, but I want to view this as a very important step on my ladder. I want to learn a lot.

I believe there would be an awful lot to learn before it even could become useful, but as far as I understand what this language does it could come in handy for creating and managing databases of (potential) customers, sales histories, keeping track of inventory

/r/Python
https://redd.it/10c4o15
Check out AWESOME PANEL SHARING - An easy to use sharing service for Panel data apps

In 2022 Pyodide and PyScript paved the way for Python in the Browser. On top of that, the data app framework Panel made it easy to panel convert your data app to run in the browser only.

On top of that I created AWESOME PANEL SHARING that is a easy to use sharing service for Panel data apps.

Check out the growing Gallery of inspirational examples.

Awesome Panel Sharing Gallery

Or share your data app with the world.

https://reddit.com/link/10cbt17/video/caafvw9595ca1/player

/r/Python
https://redd.it/10cbt17
(Maybe) Everything You'll Ever Need to Know about Python Imports and Project Structure

It isn’t that hard, but it is a well-kept secret. And for good reason. I’ve had a draft of this article in my head for months, but it wasn’t until I started using Poetry that I found a method I could explain in a two-minute read.

(Maybe) Everything You'll Ever Need to Know About Python Imports and Project Structure (foundationsafety.com)

/r/Python
https://redd.it/10c49jo
Web based GUI Application

I know that this question has been asked by many so Please bear me.
What is the best way to go about making web based GUIs using Python as backend ?
I don’t know anything about HTML CSS or JavaScript.
If you can suggest any designer tool that will be helpful Thanks

/r/flask
https://redd.it/10cfufj
Discord Bot pretending to be human using Chat GPT

Python script for a Discord bot that uses Chat GPT to generate responses for a conversation between multiple discord users.

The bot can converse in a conversation distinguishing between different people and responding like a friendly discord user. It understands the distinction between being involved in conversation and not being included.

These features only partially work, with the bot easily being able to be taken out of the immersion of being a "discord user". However, it was an interesting experiment to test the limits of GPT using the limited functionality we're currently available to. I believe it would definitely be possible to make a very convincing human! Hopefully API for Chat GPT will be released in the near future.

GitHub Link: https://github.com/karkin2002/Chat-GPT-Discord-Bot

Example conversations:

https://preview.redd.it/zk7ap6a9i7ca1.png?width=2085&format=png&auto=webp&v=enabled&s=a6d975e72e22323e115b19ad25a4da9d8b1004c6

https://preview.redd.it/dmdhmrpfi7ca1.png?width=2048&format=png&auto=webp&v=enabled&s=24102d01745ef3bfa3704e32750b5a9cfa3d216b

https://preview.redd.it/kqypicfvi7ca1.png?width=1657&format=png&auto=webp&v=enabled&s=5eb908593aa8b2a5b93e029bb46bd9756c8fd0d4

Example of distinguishing between being in conversation and not. For this test I made the bot respond with "N/A" if it thought it wasn't included in the conversation ("Friend" is the Discord bots name, "Kiwi" is another users name):

https://preview.redd.it/4sxdyhkuh7ca1.png?width=1116&format=png&auto=webp&v=enabled&s=91ba5271894d387b9d1d0bd941b7133fba562906

/r/Python
https://redd.it/10cjm62
Activities to keep in touch with python programming

Hello Everyone, I am a working professional(chip designer), I just finished the python course (Udemy) and gained fair knowledge. I have already used the knowledge gained to automate some of the reports review in the current company and have also started doing few simple projects for university students. Could you guys please suggest me some activities/habits to keep in touch with the python programing and explore much more? . Appreciate the help in advance.

/r/Python
https://redd.it/10chz9y
Yellowpage scraper powered by Python

Hey everyone,

I've been working on a web scraping project using Python to extract data from YellowPage and I wanted to share my experience and some tips for anyone else looking to do the same.

First, I used the popular library BeautifulSoup and Playwright to navigate and automate the website. The script asks user to enter a business name, location and number of pages to scrape and save it into an excel database accordingly. It extracts all the necessary data including emails as well. I feel I used lots of try and except clause, if someone has better approach them please free to share.

Another thing to watch out for is that the website structure can change frequently, so it's important to regularly check and update your code accordingly.

Overall, it was a fun and challenging project that taught me a lot about web scraping and working with dynamic websites.

Let me know if you have any questions or tips of your own to share!

/r/Python
https://redd.it/10cc17r
send a list of ids using ajax

i am trying to send a list of ids which are collected from the selected checkboxes in django template to django views using ajax as below,but doesn't seems to work.what could be wrong.i suspect the url part.

<script>
$(document).ready(function(){
$('.bulk_delete').click(function(){
if(confirm("Sure you want to delete?")){
var id=[];

var csrf=$('input[name=csrfmiddlewaretoken]').val();
$(':checkbox:checked').each(function(i){
id[i]=$(this).val()
})


/r/djangolearning
https://redd.it/10cfl7m