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
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?

Use this thread to chat about and share Python resources!

/r/Python
https://redd.it/10b9r0f
ChatGPT is coming for python devs

Today I met with a coworker to gather requirements for a new geospatial data feed he needed built. The meeting's outcome was a decision to script the process of comparing and merging 30+ CSV files into a single flattened schema for import into a cloud-based data store. Said data store was a non-negotiable constraint that only accepts a single CSV as the input. We've got two python devs in-house and a geospatial platform with python and Jupyter baked in, so python is usually our weapon of choice for scripts like this. I digress...

Based on the complexity of the task and requirements I asked for one day to write and test the script, a second day to test further, and then go-live. He was fine with that but said he wanted to try something first.

A few hours later he walked up to my desk, stuck out his hand and said "It's been nice working with you". I did that thing where you think someone's joking, but then the joke persists a little longer than you expect and you start to think they're serious, only to realize they are in fact joking....sort of.

He goes on to

/r/Python
https://redd.it/10bcjhy
ChatGPT-Desktop-Webview GUI app.

Is a Private ChatGPT Desktop Webview app made with QtWebView.

Features:

1. Private doesn't make any connections to Google, Mozilla, or Microsoft, Brave unless you login via Google etc..
2. Light Weight.
3. Page reloading can be done using a simple Right-click Reload if ChatGPT gets stuck/errors out.
4. Zoom in or out to configure text size.
5. Supports back button.
6. User-Agent is adjustable but not implemented by default see source code.

Compiled as a windows executable only using pyinstaller check releases or self compile.

You can Recommend extra features by opening a new issue on Github.

Github Repository Link

/r/Python
https://redd.it/10bijtd
Is there an equivalent of npmtrends.com but for python packages?

I really like python but other than mouth(youtube) to ear package recommendations and the occasional stackoverflow or github find I have been really struggling to find both popular (that are not obvious) and well-maintained packages and also compare them to other packages.

On the other hand, npm have this amazing website called npmtends which allow comparisons of packages and deeper understanding of the echo system when combined with npm's search and some basic googling...

Is there such a website for python package? what's your routine for finding new packages that are interesting and may or may not be popular?

/r/Python
https://redd.it/10b75mh
Best login method for DRF

When using drfjwt do you write your login function or you make use of the provided jwt token login views, and which do you think is more efficient and advisable to use?


“also for those who posts coding related stuffs on IG I’ll love to follow you guys😊 0
cisc is my username” .

/r/django
https://redd.it/10bme2f
django-auth-ldap warning

Hey guys, sorry if this isn't the right place to post this.


I have set up an LDAP backend for my organisation's internal website, but it is annoying to constantly receive warnings from it in the logs, particularly this one:


WARNING:django_auth_ldap:cn=REDACTED,ou=REDACTED,ou=REDACTED,dc=REDACTED,dc=REDACTED does not have a value for the attribute userPassword


I have it so that on any LDAP login, the LDAP user.set_unusable_password() function is run, so this warning doesn't interest me at all. Is there a way I can specifically prevent this warning from being spammed when tens of people are regularly logging into the dev server, so I can't just turn off debug=True?

/r/django
https://redd.it/10bphpp
brew

Does anyone know how to solve this problem, I'm wanting to use heroku, but I can't:

To use the Heroku CLI's autocomplete --

Via homebrew's shell completion:

Follow homebrew's install instructions https://docs.brew.sh/Shell-Completion

NOTE: For zsh, as the instructions mention, be sure compinit is autoloaded

and called, either explicitly or via a framework like oh-my-zsh.

2) Then run

$ heroku autocomplete --refresh-cache

OR

Use our standalone setup:

Run and follow the install steps:

$ heroku autocomplete


Bash completion has been installed to:

/home/linuxbrew/.linuxbrew/etc/bash_completion.d

==> Summary

🍺 /home/linuxbrew/.linuxbrew/Cellar/heroku/7.67.1: 22,567 files, 85.3MB, built in 6 seconds

==> Running `brew cleanup heroku`...

Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.

Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

/r/django
https://redd.it/10bnrin
URL not working

Hi I am currently finding problems with the following in Django:

urls.py:



from django.urls import path;
from . import views;
urlpatterns = [
path('', views.index, name = "index"),
path('/mail/', views.sendmail, name = 'mail')
\]

​

views.py:



from django import forms;
from django.shortcuts import render;
from django.http import HttpResponseRedirect;
from django.core.mail import send_mail;
from django.urls import reverse;
class PythonForm(forms.Form):
sub = forms.CharField(label = "subject");
name = forms.CharField(label = "name");
email = forms.EmailField();
msg = forms.CharField(label = "message");
def index(request):
return render(request, "site7/site7.html");
def sendmail(request):
if request.method == "POST":
form1 = PythonForm(request.POST);
if form1.is_valid():
n = forms.CharField(label = "name");
email = forms.EmailField();
sub = forms.CharField(label = "subject");
msg = forms.CharField(label = "message");
send_mail(
subject = sub,
message = msg+"\\n Sincerely, \\n"+n,
from_email = email,
recipient_list= 'interest20century@gmail.com'
            );
return HttpResponseRedirect(reverse("index"));
else:
return render(request, "site7/site7.html",{
"form": form1
     

/r/django
https://redd.it/10bu9z0
How to deny user A from seeing content meant for user B

Hello!

I am following along Dennis Ivy's tutorial "Django To Do List App With User Registration & Login" (amazing content btw, definitely recommend for django beginners).

To give some context before my question - the project is set up so that each user has their to do list which is visible only for them:

class TaskListView(LoginRequiredMixin, ListView):
model = Task
contextobjectname = 'tasks'

def getcontextdata(self, kwargs):
context = super().getcontextdata(kwargs)
context'tasks' = context'tasks'.filter(user=self.request.user)
context'count' = context'tasks'.filter(completed=False).count()
return context






There is one thing though that wasn't properly solved - let's say we have 2 users: User A and User B. If I am logged in as User A, I can still access the

/r/django
https://redd.it/10bnj6t
Django lists with models

Hi! I'm currently doing a course on Django and at the same time doing practice projects to learn the methods taught on the course. I have now learnt about models and I have one model called "Customer" which surprise surprise has customers in it. My app should log gym visits of these customers and that would be done with pythons datetime.now(), is it possible to include a list for the customer object that would update each visit to the object/model. So that it would be for example:

Customer:

name = "Mr X"

age="15"

visits=[01/02/2023, 01/05/2023, 01/08/2023\]

and then you could append these dates to this customer's model whenever he logged into the gym. Or what would be the best way to implement something like this?

/r/django
https://redd.it/10buss7
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