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
Ive been working with Django professionally for a couple years now so Ive decided to make my home office more comfy!

/r/django
https://redd.it/1fdvkv0
cannot import apps.views

i am developing a django app to analyze some log files and extract data and store it to the sqlite database.one of the tasks i need is to monitor a txt file where the log lines are being written by my syslog server.for the same purpose i developed a watchlog file,which will keep monitoring this file.this setup works very well in pycharm.but when i want to install the watchlog.py file as a windows service i get an error which says cannot find module.this is the import :


files is an another app in my django project.

from files.views import uploadlogfilewithoutrequest

https://preview.redd.it/wln0z8nk15od1.jpg?width=449&format=pjpg&auto=webp&s=992e6faffc122d50a8869e0c5e06aaf0820ccea5

https://preview.redd.it/yju8tvml15od1.png?width=374&format=png&auto=webp&s=d9e3939f428adbba49c99e4635a4033c1159ec32



/r/djangolearning
https://redd.it/1fe4xnz
Implementing Python Bindings for Dust DDS with PyO3

Hi everyone! πŸ‘‹

I recently wrote an article for my company on how we created Python bindings for our native Rust implementation of the Data Distribution Service (DDS) middleware, called Dust DDS.

While the article isn't exclusively about Python, it dives deep into the process of using PyO3 for binding Rust to Python, going through the design decisions we made and how we programmatically generate the pyi file from the original Rust API. I thought it might be helpful or inspiring for anyone looking to bridge Rust and Python in their projects so you can check it out here: https://www.s2e-systems.com/2024/09/11/dust\_dds\_python\_bindings/

/r/Python
https://redd.it/1fe4w3m
Migrations

My company is making something i think it's stupid,

They don't track migrations with git, and in every environment stage, prod, local

They make migrations and migrate with every push

And every environment have different files

Is that fuckin normal, or this company is a shit? Cause i feel like I'm stupid

/r/django
https://redd.it/1fe603z
My first open-source project built with Python to inspect databases through CLI fast

What My Project Does:

peepDB is a CLI tool designed for rapid database table inspection without writing SQL. It supports MySQL, PostgreSQL, and MariaDB, allowing users to view all tables or a specific table with simple commands. The tool securely stores connection details, provides output in formatted table or JSON format.

Target Audience:

peepDB is aimed at developers debugging database-driven applications, DBAs performing quick checks or audits, data analysts exploring table structures, and those learning about databases who want an easy way to explore data. It's suitable for use in both development and production environments, providing a versatile tool for various database inspection needs.

Comparison:

peepDB distinguishes itself from alternatives by focusing solely on quick table viewing, supporting multiple databases out-of-the-box, and securely storing connection details. It requires no SQL knowledge to use, has a minimal footprint compared to larger database management tools, and offers both CLI and Python library interfaces for flexibility.

GitHub Repo: https://github.com/evangelosmeklis/peepdb
if you have any suggestions for the project or comments on how to improve let me know

/r/Python
https://redd.it/1febbx0
Integrating Stripe with Flask: A Step-by-Step Tutorial

I recently put together a beginner-friendly tutorial on how to integrate Stripe into your Flask application. If you're looking to implement payment processing but feel a bit overwhelmed, this guide breaks down the steps in a straightforward manner.

One of the key aspects of the tutorial is setting up user authentication to manage payments and subscriptions securely. We cover everything from user registration and login processes to implementing Stripe subscriptions and webhooks for handling payment events.

Additionally, you'll find snippets of code provided, which you can use as a handy template. By the end of it, you'll be equipped to start monetizing your Flask app with Stripe.

Here's what you can expect from the post:
- Setting up Stripe and your Flask app environment.
- Implementing user authentication using Flask-Login.
- Creating a checkout session for subscriptions.
- Handling webhooks to update subscription status in your database.
- Differentiating between free and premium content based on user subscriptions.

You only need a Stripe account to get started. For anyone interested, check out the full guide here: Integrating Stripe with Flask

/r/flask
https://redd.it/1fdzhr7
how to scale a system to handle millions of concurrent updates on the backend?

i was recently asked an interview question how i would scale an architecture currently consisting of 3 boxes (a web server, a frontend, and a backend) in order to handle millions of updates to the inventory field in the database?

this could be an ecommerce website where thousands of concurrent users come in to
purchase their items 24x7 and as such the inventory field is updated constantly
and every second of the day.

the question asked was what change or an additional box i would add to scale the
current architecture containing 3 boxes so that the latest and updated
inventory information can be accessed via APIs with low latency?

note that this question is in the the same context i asked another question here couple of
days ago about the inventory data.

in this post i wanted to lay out the exact scenario what was asked by the interviewer as i am still
puzzled if another box or change in the current architecture would be necessary. i think with various cache options available today (e.g. redis etc. which was my answer) there shouldn't be a need to add an additional box but the interviewer didn't think

/r/flask
https://redd.it/1feo261
Django Docker best practices for dummies?

I have created a fair few small (and one giant sprawling) Django project that are in use by small groups of consistent people (think work groups).

Up to this point, I've built sites inside python venv's and hosted with Apache mod_wsgi, all on a couple of AWS virtual machines (EC2 instances).

As I make more little Django sites, it seems like it's getting time to move into containers to keep a bit more explicit definition around package requirements/versions, transition between servers, easier local testing, etc. It seems like most tutorials out there are for toy projects on bare metal (raises hand) or using Django for Kubernetes style dynamic deployment, load balancing, etc.

Does anyone have a good resource for building / deploying relatively simple Django projects to a container for general containerization. Things like, packaging process, pros and cons of running the database in the same container / different container / bare metal, etc.

/r/django
https://redd.it/1fel39i
SEO in django



Hello, im next to build a tiny website with django and im going to deploy it. I've thinking if there is a way to configure the ceo tags with django or if i have to do it manualy.

Sorry if isn't related to django and i would be very grateful if somebody can give some advices with this.

/r/django
https://redd.it/1fevex2
Typical developer processes for developing features in Flask?

As a new Flask developer, I'm curious about the typical process or checklist people work through when developing a new feature.

My current flow has been working 'inside-out' in the following order:

1. Start with the models
2. Write migrations/upgrade scripts
3. Implement the view functions
4. Set up the routes
5. Build out the templates

Is this a common or recommended approach? My thinking is that I can often add new models and db migrations, etc without breaking the working app and build from there. This seems to suit the CRUD-style app I'm developing.

Or does the development approach change depending on the feature? For example, would it be different for something more complex like a stepped process, like a bank loan application form?

If so, are there a bunch of developer process patterns I should be aware of?

/r/flask
https://redd.it/1feqqr5
PayPal vs. Stripe for Django Donations: Which Payment Gateway is Best for a Charity Site?

I’m building a charity website where the admin can manage content and handle donations. Historically, the client used PayPal for donations, but I’m considering using Stripe instead, given the better-maintained Django modules for Stripe.

Has anyone implemented both in a Django project? Which would be more straightforward for maintaining a reliable donation system? Any advice on pros/cons of sticking with PayPal vs. switching to Stripe for this use case?

/r/django
https://redd.it/1fefwpv
how do you query a certain column without including it in the route's url?

Hey guys! I'll keep this concise,

Basically I'm trying to build a mini snowflake clone, and I have have this route which takes users to a SQL query interface for the worksheet they've selected (if you've used snowflake you'll know what I mean hahah).

@users.route("/<string:username>/query/<code>", methods='GET')
@loginrequired
def query(username, code):
    if username != current
user.username:
        abort(403)

    # what I currently have to do
    selectedworksheet = Worksheet.query.filterby(code=code)

    # what I'd like to be able to do
    selectedworksheet = Worksheet.query.getor404(worksheetid)

    # What I want to avoid doing as it seems to add the id to the url
    worksheetid = request.args.get('worksheetid', type=int)
    selectedworksheet = Worksheet.query.getor404(worksheetid)

    # remaining code ...


each worksheet has an id, but they also have a code so the url can look something

/r/flask
https://redd.it/1fexjlx
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏒

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

/r/Python
https://redd.it/1fep0y6
Which Python libraries would be most suitable for Time Series Forecasts and Multilinear Regression?

I am working on a project geared towards addressing the issue of software project time estimation bias. To gather data, I'm building a work-log system that gathers info with respect to time taken to accomplish commonly-known tasks. These data will subsequently be trained using time series and multi linear regression.

Which Python libraries would be the most suitable for achieving these goals?

/r/Python
https://redd.it/1fexk8e
Help with ORM query

I have 3 models: Activity, ActivityDates and ActivityAttendies. Activity has a M2M relationship with ActivityDates and ActivityAttendies has a M2M relationship with ActivityDates.

class Activity(models.Model):
    FREQUENCY =
        ('Weekly', 'Weekly'),
        ('Monthly', 'Monthly')
   
    activitydates = models.ManyToManyField('ActivityDates')
    activity
name = models.CharField(maxlength=200)
    activity
interest = models.ForeignKey(Interest, ondelete=models.CASCADE)
    additional
activitydates = models.ManyToManyField('AdditionalActivityDates')
    activity
frequency = models.CharField(maxlength=11, choices=FREQUENCY, default=None)
    activity
location = models.CharField(maxlength=200)
    activity
cost = models.DecimalField(maxdigits=6, decimalplaces=2)
    activitystartdate = models.DateField(blank=True, null=True)
    activityenddate = models.DateField(blank=True, null=True)
    activityartwork = models.ImageField(uploadto='activityartwork', blank=True)

class ActivityDates(models.Model):
    activity
date = models.DateField()
    activityattendies = models.ManyToManyField(Person, relatedname='ActivityAttendies', through='ActivityAttendies', blank=True)
    activitystarttime = models.TimeField()
    activityendtime = models.TimeField()

class ActivityAttendies(models.Model):
 

/r/djangolearning
https://redd.it/1fexg7p
Do you have any ideas for simple Django tools?

hey all,

I decided to try my hand in creating simple tools for Django users. The first one I made is a Django Secret Generator (i know, there are many such sites out there, just trying something new, and learning django while doing it, some cur me some slack πŸ™ˆ).

I'm planning to do a couple more. Here are some ideas I had:

Security checker (like, is admin page under /admin. I think there was one called django pony checker or something like that, but I'm not sure it still exists)
optimization checker (are your js and css files optimized)

I'm curious to hear from the community, if you have any ideas. Thanks a ton in advance.

/r/django
https://redd.it/1fezo43
Semantix : Make GenAI Functions easily

### What Semantix Does

Current methods for extracting structured outputs from LLMs often rely on libraries such as DSPy, OpenAI Structured Outputs, and Langchain JSON Schema. These libraries typically use Pydantic Models to create JSON schemas representing classes, enums, and types. However, this approach can be costly since many LLMs treat each element of the JSON schema (e.g., {}, :, "$") as separate tokens, leading to increased costs due to the numerous tokens present in JSON schemas.

Semantix offers a different and more cost-effective solution. Instead of using JSON schemas, Semantix represents classes, enums, and objects in a more textual manner, reducing the number of tokens and lowering inference costs. Additionally, Semantix leverages Python's built-in typing system with minor modifications to provide meaning to parameters, function signatures, classes, enums, and functions. This approach eliminates the need for unnecessary Pydantic models and various classes for different prompting methods. Semantix also makes it easy for developers to create GenAI-powered functions.

### Target Audience

Semantix is designed for developers who have worked with libraries like Langchain and DSPy and are tired of dealing with Pydantic models and JSON schemas. It is also ideal for those who want to add AI features to existing or new applications without

/r/IPython
https://redd.it/1ff2pi5
The a absolute high you get when you solve a coding problem.

2 years into my career that uses python. Cannot describe the high I get when solving a difficult coding problem after hours or days of dealing with it. I had to walk out one time and take a short walk due to the excitement.

Then again on the other side of that the absolute frustration feeling is awful haha.

/r/Python
https://redd.it/1ff847f