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
Does Anybody Know How to Host an existing Django Project on Ubuntu

See title. I finished programming a website using Django, and I am ready to put it on a server, but I keep hitting dead ends. Does anybody know the steps I should take, or a website I should visit?

Edit: If it makes any difference, I am using a MySQL database. Also, I want this to be locally hosted.

/r/djangolearning
https://redd.it/1e75voa
Suddenly a package doesn't exist

I have a flask app that has been running fine for a couple of years. Today I tried to push an update to my host platform and the build failed because a package requirement could not be satisfied.

When I checked the logs I saw this error:

"ERROR: Could not find a version that satisfies the requirement install==1.3.5 (from versions: none)
ERROR: No matching distribution found for install==1.3.5"


Not recognizing the package and I looked into it and according to pypi.org that package doesn't exist.

I thought maybe it's some kind of dependency but I am unable to find any reference to it anywhere.

I removed it from my requirements.txt and tried to push again, now I received an error that said:

"Getting requirements to build wheel did not run successfully."

Does anyone have any idea of what could be happening here?

I went back and checked my recent updates and the package "install==1.3.5" was part of my requirements.txt for many months. I was able to push updates to my platform without issue and suddenly today the package doesn't exist and my app fails to build on my platform.

Any suggestions or knowledge you could share on what might be happening/a solution would

/r/flask
https://redd.it/1e7w9jl
Expose and deploy your Flask app from Linux virtual machine!

I'm new into coding and I want to expose my Flask app from my virtual machine so that when the user enters their password and username gets redirected. However, each time when I do it, there is an error in the console. Can you help me?

/r/flask
https://redd.it/1e7yre7
Django with Docker - access denied to volume

Anyone had issues running collectstatic inside a Docker container where your static files are mapped to a volume on the host? I keep getting permission denied.

I have done a bit of digging and the answer always seems to be 'give everything root privileges' which sounds a bit of a cop out.

I can run the command from outside via exec and have the files collect ok, but I will eventually also need to upload media to a shared volume and I'm assuming this is going to be an issue...

/r/django
https://redd.it/1e7yacx
Multiple Type of user login

I'm new to django. I have made an app where there are different type of users like vendors, clerks, delivery boys and simple users.

I have made different app for all of them.

I want them to have access to their app only. A vendor with his credentials cannot log into users account.

Each one of them have their own model.

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

# Weekly Thread: What's Everyone Working On This Week? πŸ› οΈ

Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!

## How it Works:

1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.

## Guidelines:

Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.

## Example Shares:

1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!

Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟

/r/Python
https://redd.it/1e89aai
AWS EC2 + RDS + S3 = so expensive, even with zero users

Hey folks!

I launched my SaaS project(and it has zero user) an he is my monthly cost:

AWS

Relational Database ServiceUSD - 17.91
Elastic Compute CloudUSD - 10.71
Virtual Private CloudUSD - 6.82
Route 53USD - 0.51
Simple Storage Service - 0.03

Total: 35.98$

Mailgul(email notification):

35$ - 50k monthly emails 10 domains

So it comes down to \~$70/mon

Two thoughts:

1. I used AWS because I new how to set it up quickly.
2. Mailgun was recommend to me by a friend. I though my project will get users, but unfortunately it is not getting any. I'm switching to a cheaper plan that is 15$ per month now.

Can you please recommend what is cheaper alternatives out there. I now data bases could get expensive, but in case I even didn't git 100 users and I'm already paying so much.

Thank you.

/r/django
https://redd.it/1e8dkwd
Dont really know how to structure/organize templates + static files in project.

I feel so much pain and cringe with my spaghetti ui/template but-functioning-as-for-now code

Dont know how to Connect all this insights or ideas into a "structured way" of doing things in Django UI part.

I have 3 different layouts one is full width other is with a drawer another is without the drawer.
There are elements/components/ in tables or forms that may be shared across apps.
From a DX perspective for JS code sometimes i prever "intra-file" script tag. Sometimes add it via Django Template Inheritance block feels ok. But also use webpack and may import js code directly to webpack entrypoint/entryfile.
My new best friend htmx and template-partials with or without the Carlton Gibson package

I would love if django provided an opinionated way of writing and storing html/js code and files. Taking into consideration the simple but diverse a fully functiong web Application could be in terms of ui related code and how easy it is to constantly repeat yourself and store code in all Parts of the project.

/r/django
https://redd.it/1e8eikq
I created a datestamp tool to add datestamps to your photos from metadata

# What My Project Does

I created a tool that extracts the date a photo was taken from the metadata and adds the datestamp to the photo. I was motivated to create this project, because I saw someone asking for a tool like this on a photography subreddit.

Flask was my web library of choice and pillow was used to extract metadata and edit the images. The frontend is a barebones HTML form without CSS and JavaScript. I am hosting this app on pythonanywhere.

# Target Audience

People who feel nostalgic about their old photos.

# Comparison

I haven't seen any web-hosted alternatives to this tool, but one possible option is to use the imagemagick CLI. My tool is more user friendly as it does not require the user to interact with a terminal application.

Repo: https://github.com/ch-iv/image-datestamp/

Website: https://datestamp.noivan.dev/

/r/Python
https://redd.it/1e82dqq
Flask wont serve audio on iOS

Hey guys,


I made a translator app and it uses elevenlabs to generate tts, but for some reason it wont serve the audio to my iphone, but works literally everywhere else.


Please help!

thanksss

/r/flask
https://redd.it/1e874k8
I’m thrilled to announce the release of my new Django package

πŸš€ Introducing Django Data Seed: Your Solution for Database Test Data! πŸš€I’m thrilled to announce the release of my new Django package, Django Data Seed! πŸŽ‰

This tool is designed to make the lives of developers easier by simplifying the process of populating databases with test data. Whether you’re working on a small project or a large-scale application, Django Data Seed helps you quickly generate realistic data for your development and testing needs.

With Django Data Seed, you can efficiently manage and populate your database with just a single command. It's perfect for ensuring that your applications are rigorously tested and ready for production.

I invite you to check out Django Data Seed on PyPI and GitHub:
πŸ”— PyPI: https://pypi.org/project/django-data-seed/
πŸ”— GitHub: https://github.com/rohith-baggam/django-data-seed
πŸ”— Linkedin : https://www.linkedin.com/in/rohith-raj-baggam/

Thank you for your support, and I look forward to seeing how Django Data Seed can help streamline your development process! Keep an eye on the PyPI package for exciting new features in upcoming versions.

u/django u/python u/backenddevelopment u/djangoorms

/r/Python
https://redd.it/1e8e3hh
Activation Email

I am new to django and was working on a project and got to this error while I was trying to build the auth system. I tried to send a activation email to the mail in the registerd field but got this error in a file called app_settings.py it is related to the allauth package.


Traceback (most recent call last):

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner

self.run()

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run

self._target(*self._args, **self._kwargs)

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper

fn(*args, **kwargs)

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run

autoreload.raise_last_exception()

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception

raise _exception[1\]

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/core/management/__init__.py", line 394, in execute

autoreload.check_errors(django.setup)()

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper

fn(*args, **kwargs)

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/__init__.py", line 24, in setup

apps.populate(settings.INSTALLED_APPS)

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate

app_config.import_models()

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models

self.models_module = import_module(models_module_name)

\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:\], package, level)

\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^

File "<frozen importlib._bootstrap>", line 1204, in _gcd_import

File "<frozen importlib._bootstrap>", line 1176, in _find_and_load

File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked

File "<frozen importlib._bootstrap>", line 690, in _load_unlocked

File "<frozen importlib._bootstrap_external>", line 940, in exec_module

File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/allauth/account/models.py", line

/r/django
https://redd.it/1e7xsj8
Extracting data from (tricky) PDFs for Excel using Python (both API and DIY)

Hey Python learners, I'd like to share how to use AI (specifically Google's new Gemini model) to extract structured data into a CSV/XLSX format from PDFs.

I'm sharing this because most traditional solutions that don't use AI seem to fail for very complicated PDFs.

These docs covers how to do this entirely with an API, and the API github linked in the guide has further instructions on how you can do this whole process for yourself with Python with an LLM provider.

Have fun!

/r/Python
https://redd.it/1e8m8l2
odex - python object index for fast, declarative retrieval

# What My Project Does

Odex provides a set-like collection called `IndexedSet` which allows for fast, declarative queries on native python objects:

from odex import IndexedSet, attr, and_

class X:
def __init__(self, a, b):
self.a = a
self.b = b

iset = IndexedSet(
[
X(a=1, b=4),
X(a=2, b=5),
X(a=2, b=6),
X(a=3, b=7),
],
indexes=["a"]
)

# Filter objects with SQL-like expressions:
iset.filter("a = 2 AND b = 5") == {X(a=2, b=5)}



/r/Python
https://redd.it/1e8o4jg
Pilgram, a texting based idle MMO RPG

Pilgram is a telegram bot entirely built in python that lets you play a grimdark idle MMO RPG powered by AI.

In Pilgram you can go on endless quests, fight endless monsters, craft powerful artifacts, cast spells, join guilds & cults, find powerful loot & become the ultimate adventurer!

# What my project does

The bot provides a text interface with wich you can play an endless online idle loot based adventure game

# Target audience

RPG players will probably like it. It's a toy project that i initially made out of boredom, also it sounded cool. I kept developing it after it got a small community by adding requested features like guild taxes, combat & loot.

# Comparison

The game is kind of similar to a MUD (Multi User Dungeon) but it has idle game elements & Diablo style loot generation.

# More info

How is it infinite? The secret is AI. Every quest, event, monster & artifact in the game is generated by AI depending on the demand of the players, so in practice you'll never run out of new stuff to see.

The interface is exclusively text based, but the command interpreter i wrote is pretty easy to integrate in other places, even in GUIs if

/r/Python
https://redd.it/1e8pt2b
Wrote some absolutely atrocious code and Im kinda proud of it.

In a project I was working on I needed to take out a username from a facebook link. Say the input is: "https://www.facebook.com/some.username/" the output should be a string: "some.username". Whats funny is this is genuinely the first idea I came up with when faced with this problem.


Without further a do here is my code:

def get_username(url):
return url[::-1][1 : url[::-1].find("/", 1)][::-1]



I know.
its bad.




/r/Python
https://redd.it/1e8p16u
500+ Python Questions Quiz

Compiled 500+ Python questions into a quiz. I'm trying to improve my understanding of Python so this was helpful.

Quiz

I'll keep refining the questions to make sure it covers all the important topics in Python.

If you come across a question whose answer you doubt, please leave a comment and I'll check it again. Any recommendations or changes, please let me know.

So what's your score?

PS. This was built for Applyre users, who might want to use it for interview prep.

/r/Python
https://redd.it/1e8ry4p
Monday Daily Thread: Project ideas!

# Weekly Thread: Project Ideas πŸ’‘

Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.

## How it Works:

1. **Suggest a Project**: Comment your project ideaβ€”be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.

## Guidelines:

* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.

# Example Submissions:

## Project Idea: Chatbot

**Difficulty**: Intermediate

**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar

**Description**: Create a chatbot that can answer FAQs for a website.

**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)

# Project Idea: Weather Dashboard

**Difficulty**: Beginner

**Tech Stack**: HTML, CSS, JavaScript, API

**Description**: Build a dashboard that displays real-time weather information using a weather API.

**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)

## Project Idea: File Organizer

**Difficulty**: Beginner

**Tech Stack**: Python, File I/O

**Description**: Create a script that organizes files in a directory into sub-folders based on file type.

**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)

Let's help each other grow. Happy

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