Python Daily – Telegram
Python Daily
2.56K subscribers
1.49K photos
53 videos
2 files
39.1K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
unable to access config from celery task

I am currently working on an app where i need to have scheduled tasks that perform som api calls to external service and store results in a db.

I use Celery to achieve this using this guide https://flask.palletsprojects.com/en/stable/patterns/celery/
, i am able to schedule my tasks but the config containing all the api endpoint details and stuff is empty.

here is my testing code if i instead pass currentapp.config in helloworld() the only config variable set is "rootpath"

### in app/tasks
from celery import shared
task
from flask import currentapp
from app import app, config

@sharedtask(ignoreresult=False)
def hello
world():
print(config.dict)




### in app/Config.py
CELERY = dict(
brokerurl="redis://",
result
backed="redis://",
taskignoreresult=True,


/r/flask
https://redd.it/1hhptwm
🌟 NanoDjango Enthusiasts, Assemble! 🚀

Hi everyone! 👋

I'm working on a small project using [NanoDjango](https://github.com/kracekumar/nanodjango), a lightweight Django-like framework, to build a **Provident Fund Tracker App**. I've got the app mostly set up, but I’m running into some challenges and would love some guidance from anyone who has experience with NanoDjango or Django in general.

# What I’ve Done So Far:

1. **Models:** I’ve defined `Company`, `Employee`, and `PFPayment` models for storing company and employee data.
2. **Data Fetching:** I implemented a custom management command to fetch data from an Excel file and an XML file and populate the database.
3. **Web Views:** I’ve created views for:
* A homepage listing all companies.
* A detailed view for each company, showing its employees.
* A detailed view for each employee, showing their payment history.
4. **Templates:** HTML templates are located in the `templates` folder and are working fine with the `render` function.

**Update: I can easily populate using admin panel but want to do with custom command which will take data from excel file.**

# The Problem:

I’m struggling with:

1. Running my custom management command to populate the database. What’s the correct command to use with NanoDjango ?.

I will share the repo if anyone intested in helping

/r/django
https://redd.it/1hhotil
D chat-gpt jailbreak to extract system prompt

### Instructions

https://github.com/AgarwalPragy/chatgpt-jailbreak

### Original author
https://www.reddit.com/r/LocalLLaMA/comments/1hhyvjc/iextractedmicrosoftcopilotssystem/

### Extracted System prompt

You are ChatGPT, a large language model trained by OpenAI.
You are chatting with the user via the ChatGPT Android app. This means most of the time your lines should be a sentence or two, unless the user's request requires reasoning or long-form outputs. Never use emojis, unless explicitly asked to.
Knowledge cutoff: 2023-10
Current date: 2024-12-20

Image input capabilities: Enabled
Personality: v2

# Tools

## bio

The bio tool is disabled. Do not send any messages to it.If the user explicitly asks you to remember something, politely ask them to go to Settings - > Personalization - > Memory to enable memory.

## dalle

// Whenever a denoscription of an image is given, create a prompt that dalle can use to generate the image and abide to the following policy:


/r/MachineLearning
https://redd.it/1hi429q
Friday Daily Thread: r/Python Meta and Free-Talk Fridays

# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

## How it Works:

1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

## Guidelines:

All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.

## Example Topics:

1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟

/r/Python
https://redd.it/1hi6vlj
Pytask Queue - Simple Job/Task Management

# What My Project Does
This is my first ever public python package, it is a job/task management queuing system using sqlite.

Using a worker, jobs are picked up off the queue, manipulated/edited, then reinserted.

It is meant to replace messaging services like RabbitMQ or Kafka, for smaller, lightweight apps. Could also be good for a benchmark tool, to run several processes and use the sqlite database to build reports on how long n number of processes took to run.

# Target Audience
Devs looking to not have to use a heavier messaging service, and not having to write your own database queries with sqlite to replace that.

# Comparison
I don't know of any packages that do queuing/messaging like this, so not sure.

Feel free to give it a try and leave it a star if you like it, also feel free to submit a PR if you are having issues.

https://github.com/jaypyles/pytask

/r/Python
https://redd.it/1hi52fe
Master the Fundamentals of Python - Free Course - Videos, text, projects, exercises and solutions

Master the Fundamentals of Python is a comprehensive course that I was recently selling for $99 but have now released for free.

[View the playlist here.](https://www.youtube.com/playlist?list=PLVyhfExBT1XC-5ls9DezJIqioVYhf-09t)

[Download the material here.](https://drive.google.com/drive/folders/1PcVbvPENdbMG1Bdax90kOl0GuT1EX9HZ?usp=drive_link)

The course comes with:

* 300 page PDF
* 20 modules
* Videos
* Projects
* Hundreds of exercises with solutions

This is a college-level course that requires over 50 hours of effort to complete.

Modules

1. Operators
2. What is Python
3. Objects and Types
4. Strings
5. Lists
6. Ranges and Constructors
7. Conditional Statements
8. Writing Entire Programs
9. Looping
10. List Comprehensions
11. Built-in Functions
12. User-defined Functions
13. Tic-Tac-Toe
14. Tuples, Sets, Dictionaries
15. Python Modules
16. User-defined Python Modules
17. Errors and Exceptions
18. Files
19. Classes
20. Texas Hold'em Poker

/r/Python
https://redd.it/1hhvja2
how to authenticate google oauth0 with flask

hello gurus i am new bie to flask and vue js how i make my login persistent and i have approach of sending data from frontend request body to backendband backend pull data from db and how to tell front end that i am authenticated and how sgould i persistently login

/r/flask
https://redd.it/1hi8vu3
Python in Finance/Controlling

Hi everyone! I've been working in the controlling department of my company for about 3 months. Generally, apart from SAP, I'm terrified by the amount of Excel, the amount of files that I prepare for analyses for other departments. Of course, every excel has queries from SQL... I'm thinking about switching to Python, but I'm afraid that people won't understand it. I used to work on production analyses, I did a lot of "live" Power BI reports and in Python for my calculations. My goal is to replace Excel with Python.

/r/Python
https://redd.it/1hi0jhp
D I don't see a point in rebuttals anymore.

This is a mixture of some contemplation and some rant but per the noscript, I just don't see a point in it. I recently got back results from a conference where I had two positive reviews and one negative. Then wrote a really nice rebuttal that addressed a fundamental misunderstanding of the reviewer (who, later, did increase their points so I guess the rebuttal was on mark?). But turns out, the meta-reviewer latched on to the negative review, didn't even read the rebuttal that addressed said review and rejected the paper.

What was even the point of me rebutting if concerned parties are _not even going to read them_? At this point, I am tempted to treat the rebuttal phase as an exercise in futility. Maybe I should withdraw papers in the first phase come any problems instead of trying to go through the agony of an ultimately meaningless labor.

/r/MachineLearning
https://redd.it/1hi9jt2
Display logs generated by class in flask page in real time

I want to display python logs generated when a class is getting executed by taking input from page.i want to display the logs generated as the class is executing in real time in flask page.but the class is getting executed only then the next page with logs is displayed.
Any idea how can I display logs in flask page as the class is executing ..

/r/flask
https://redd.it/1hid1vj
Look for some suggestions

/r/django
https://redd.it/1hihdnp
Can someone explain what sessions are, and why am I facing so much of a problem with my API permissions?

The problem I am facing is that I am not able to access my newly built APIs that require the [IsAuthenticated\] permissions to fetch the data in my Svelte frontend, whereas I am able to perform all the [IsAuthenticated\] API functions on the django restframework UI while testing my APIs. For example, whenever I login using my DRF UI, this is the output I get:
User: Turf Nation

Turf ID: 1, Date: 2024-12-18

[20/Dec/2024 16:46:42] "GET /enterprise/slot-status/?turf_id=1&date=2024-12-18 HTTP/1.1" 200 16716

and now whenever I do the same process using the Svelte frontend, I get this:

User: AnonymousUser

Turf ID: 1, Date: 2024-12-19

[20/Dec/2024 16:47:34] "GET /enterprise/slot-status/?turf_id=1&date=2024-12-19 HTTP/1.1" 200 4460

As you can see the user is being recognised using the DRF UI while not for the frontend. I asked chatGPT about this, and it said this is all related to sessions and cookies, and ISTG, I have never really used those before. The frontend logic is not wrong either because I can access the GET POST functions when they are [AllowAny\].

Can anyone help with this?

/r/django
https://redd.it/1hiicrb
Looking for a Django Collaborator(s). Why not building something together??

Hi all!

This is my first time posting here, so if this kind of request isn’t the norm, please be kind.

I’m a second-year CS student (female) learning Django on my own alongside a course I’ve already finished. I’m currently working on a project with deadline approaching (27th December, yikes!). The project has real-world potential, and if it’s good enough, I’ll get to present it to an employee or even secure school funding to develop it further.

I’d love to work on this project together with someone who’s interested in Django. If it turns into something bigger, we can both benefit from it— adding it to our portfolios and showcasing it as a real-world project.

If you’re interested in collaborating and also if u want to connect as coding buddies (Learning alone sometimes gets so lonely) dm me!

/r/djangolearning
https://redd.it/1hhyye3
Built my own link customization tool because paying $25/month wasn't my jam

Hey folks! I built shrlnk.icu, a free tool that lets you create and customize short links.

What My Project Does: You can tweak pretty much everything - from the actual short link to all the OG tags (image, noscript, denoscription). Plus, you get to see live previews of how your link will look on WhatsApp, Facebook, and LinkedIn. Type customization is coming soon too!

Target Audience: This is mainly for developers and creators who need a simple link customization tool for personal projects or small-scale use. While it's running on SQLite (not the best for production), it's perfect for side projects or if you just want to try out link customization without breaking the bank.

Comparison: Most link customization services out there either charge around $25/month or miss key features. shrlnk.icu gives you the essential customization options for free. While it might not have all the bells and whistles of paid services (like analytics or team collaboration), it nails the basics of link and preview customization without any cost.

Tech Stack:

Flask + SQLite DB (keeping it simple!)
Gunicorn & Nginx for serving
Running on a free EC2 instance
Domain from Namecheap ($2 - not too shabby)

Want to try it out? Check it

/r/Python
https://redd.it/1hij1l8
I need some websites with their sourcecode

Hi ! I teach web development using python (flask)
And i need some websites online that are built using flask for my students to learn by example.
Problem is i cant find a website like that with its source code available to public at a github repo.
I'll be happy if you could provide some examples down below ⬇️

/r/flask
https://redd.it/1hinlwu
bnap4000 - A simple music player made in made with true randomness in mind.

I have been working on a terminal music player for Linux and Windows. Feel free to suggest or report bugs on GitHub.

What does my project do: It's meant to be a simple, lightweight music player that runs right in your terminal. It's main purpose is to play music randomly and stay out of your way, you just drop music into your music folder and let it play.

Target Audience: Mostly meant for slightly tech savvy people who want something that won't take up a ton of resources, it only uses \~60mb of RAM on my system.

Comparison: I'd compare it to VLC Media player, what I think bnap4000 does better is with simplicity. It has a very simple UI that shows what song is playing, a couple things like volume, a progress bar, and a queue.

GitHub page: https://github.com/0hStormy/bnap4000
bnap stands for Badass New Audio Player if you were wondering.

/r/Python
https://redd.it/1hiqw7l
Where to deploy a flask application ?

Hello,

I have a flask app + a noscript than runs with a crontab to populate data into a database.

I was wondering, is it better to deploy the app on a linux cloud server ? Or should I use a web hosting plateforms that supports flask out of the box ?





/r/flask
https://redd.it/1hiqjrp
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

# Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

## How it Works:

1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.

## Guidelines:

Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.

## Example Shares:

1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.

## Example Requests:

1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟

/r/Python
https://redd.it/1hixdkr
ShortMoji: Emoji Shortcuts Made Easy for Your Keyboard! 🧑‍💻

# What My Project Does

ShortMoji is a lightweight, open-source program that lets you insert emojis anywhere using simple, intuitive keyboard shortcuts. Inspired by Discord's emoji system, it supports **89 unique emoji shortcuts** (and counting!) to make your conversations and workflows more expressive.

Simply type a shortcut like `:smi`, and it transforms into 😃 instantly. ShortMoji runs in the background and is designed for speed and ease of use.

**Features include:**

* Fast emoji insertion via shortcuts.
* Low resource consumption.
* Quick program termination by pressing `Esc` twice.
* Free and fully customizable under the MIT license.

# Target Audience

ShortMoji is for anyone who loves emojis and wants a faster way to use them. Whether you're:

* A developer looking for efficiency.
* A casual user who enjoys using emojis.
* A Discord enthusiast already familiar with emoji shortcuts.

# Comparison

While there are other emoji tools available, ShortMoji sets itself apart with:

* **Customizable shortcuts:** Familiar to Discord users and adaptable for others.
* **Open-source freedom:** Unlike proprietary software, you can modify and expand ShortMoji as you like.
* **Minimal resource impact:** A lightweight utility that doesn’t slow down your system.
* **Simple UX:** No need to navigate menus or GUIs—just type and see the magic !

Unlike system-level emoji menus or bloated applications, ShortMoji is

/r/Python
https://redd.it/1hiuasv
How to make a main consumer that dispatches requests to multiple sub-consumers

I need to accomplish three real-time tasks using Django Channels. I need to track the status of my users (if they are online or offline), I need to send them notifications while they're on the site and I need to manage a live chat. I could maintain three separate WebSocket connections to three different consumers but that would be a pretty inefficient use of ressources.

I would prefer to have one main WebSocket connection with a single consumer that dispatches the requests made to it to three sub-consumers to make it nice, clean and efficient while maintaining a clear separation between the three tasks.

How do I do this?

/r/django
https://redd.it/1hj0yq1