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
How do you all document websocket urls in django

I know how to document django views, but how do I document websocket urls and the consumer events. Or should I write down a document literally and give it to the frontend guy ?

/r/django
https://redd.it/1052180
My celery-beat works locally but not in production?

my task:

@shared_task
def my_test():
# Executes every 2 minutes

UserStatisticStatus.objects.filter(id=1).update(loot_boxes=+234)

print('Hello from celery')



app.conf.beat_schedule = {
'my-task-every-10-seconds': {
'task': 'user_statistic_status.tasks.my_test',
'schedule': timedelta(seconds=10)
}
}

my settings:

if 'RDS_DB_NAME' in os.environ:
CELERY_BROKER_URL = 'redis://<myurl>/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_BROKER_TRANSPORT_OPTIONS = {
'region': 'eu-central-1',
'polling_interval': 20,


/r/django
https://redd.it/104pw7q
How to ensure password is hashed when saving User in model?

I'm using Djangos built in BaseUser and Abstract* for this, but when I create user on the model side using

u = User(... password="fsdfsd324")
u.fullclean()
u.save()

The DB still stores it in plain text. I've tried overriding clean and clean\
password within the model as I would in forms, but this doesn't work.

What's the cleanest way to do this without Forms/ModelForms? Thanks

/r/django
https://redd.it/104shkm
Cargo Shipping (Export/Import) in Django

Hello good day. i have this project i'm developing and its about exporting and importing like usps/dhl/ups. i have a feature that i want to add but i'm having an issue combining how it will work.
what i want is that i want a user to be able to track the list of items in their order like when a user has taken the items to be sent to another country, to usps, a shipping record should be created with tracking number on it, and once a user clicks on that record on their dashboard, it should display all the items of that shipping on another page. and how can one add multiple items to an order using django forms because the list of items would be added using forms and once saved, a shipping (import or export) history would be created in which users can view on their dashboard, click on any and see the lists of items on their shipping history including payment and all that. thats the issue i have and need clarity on. i'm using mvt.

/r/django
https://redd.it/104r65g
Free Copilot-like autocomplete for Jupyter notebooks

Hey everyone! I'm Anshul from the Codeium team, where we are building free AI-powered code autocomplete tooling, and today we are launching our integration on Jupyter notebooks, which has been the biggest ask from data scientists on our Discord since originally launching on VSCode and JetBrains. Currently no other major alternative (Github Copilot, Tabnine, Replit Ghostwriter, etc) supports standalone Jupyter notebooks. Hope you enjoy!

&#x200B;

https://reddit.com/link/105diit/video/5ppcv2tzajaa1/player

/r/JupyterNotebooks
https://redd.it/105diit
I made a self-hosted full stack kanban-style webapp using Flask and Vue

Hi!

After almost half year I'm ready to share my project. I made a kanban-style webapp which inspired by Trello. Still need a proper project name though (I'm open to suggestions :-) ).

https://preview.redd.it/sbdlw9lrhmaa1.png?width=1920&format=png&auto=webp&s=2e9945b64c937b064027cb671cd48269af69428b

https://preview.redd.it/3acx41lrhmaa1.png?width=1920&format=png&auto=webp&s=3668132fc6ffe1fb03214d3ab9c2fc6c3afa3bec

Stack looks like this:

\- PostgreSQL as database engine

\- Flask as backend using Socket.IO too,

\- Vue 3 with Typescript for frontend (I'm still new to TS and not frontend expert yet)

It's currently on alpha state, check roadmap for planned features.

Project link on Github

/r/flask
https://redd.it/105ozjo
Best IDE to practice python as a beginner?

As the title suggests, I am a complete beginner. Which IDE should I use to enhance my learning process?

/r/Python
https://redd.it/105tp9e
Does anyone else constantly have problems with Conda conflicts?

Conda is a cool Python environment manager, but it also has some very opinionated ideas about what a valid environment is.

One issue I run into a lot is if you install a newer package on PIP, which works fine mind you. This usually causes a conflict like your current env requiring libgen 3.27, but the package you downloaded using 3.29 for example. At this point your whole conda is nuked and there’s no way to patch the conflict except try to roll back. You can’t just tell conda to mind it’s own business and ignore conflicts because it will never be able to resolve your environment ever again which is the first step of asking conda to do anything.

How would the fine folks at r/Python go about dealing with this?

/r/Python
https://redd.it/105qinj
Released a new update for my visual website builder, looking for some feedback!




https://reddit.com/link/105pm8v/video/slfg8d1cnmaa1/player

We posted in here a few months ago and got some awesome reception for our project, Nimbus. We're excited to announce the latest update to Nimbus, our visual website builder that exports to perfect React code (and more coming soon!). Built with Django, Nimbus makes it easy for developers of all levels to create and maintain professional websites.

With this update, we've added a couple of new features that we think users will find useful. First up, we've improved the user interface to make it even easier to use. We've also added one click previews, which allow you to see what your site will look like without having to constantly export. This should save you some time and make the building process even smoother.

The next thing we're going to work on is adding custom code so you never have to leave Nimbus when building a site. You'll be able to add custom functions, API calls, etc. right from Nimbus! It will take some time to develop but it's going to be awesome.

We hope you find these updates useful. As always, we appreciate your feedback and suggestions and feel free to ask me questions about how it works, I'm

/r/django
https://redd.it/105pm8v
How do I "flatten" a nested serializer in DRF?

We have a nested serializer that we would like to "flatten". But I'm not having much luck finding how to achieve this in the docs.

Here is the current output.

{
"user_inventory": "UOHvaxFa11R5Z0bPYuihP0RKocn2",
"quantity": 1,
"player": {
"card_id": "c69c0808328fdc3e3f3ee8b9b7d4a7f8",
"game": "MLB The Show 22",
"name": "Jesus Tinoco",
"all_positions": [
"CP"
]
}
}

Here is what I'd like:

{
"user_inventory": "UOHvaxFa11R5Z0bPYuihP0RKocn2",
"quantity": 1,
"card_id": "c69c0808328fdc3e3f3ee8b9b7d4a7f8",
"game": "MLB

/r/django
https://redd.it/1061nro
How do you guys host your Django apps?

Hey guys, I recently picked up Django and just finished my first small web app. I ended up hosting it on Digital Ocean App Platform but had trouble setting up a cron job to run some scripts periodically (app platform doesn't have crontab and you can't install it with apt-get).

To avoid such issues down the line I'm considering switching to another platform for hosting. What platforms have you guys had success with and would recommend?

/r/django
https://redd.it/105mcot
Family Tree

Hello guys, I wanted to create a little project for myself. I wanted to create different interactive family trees (ex.: Simpsons, Game of Thrones, Naruto , etc). Could find any resources of where and how to start. Are they any tips you could give me?

/r/django
https://redd.it/105y7co
Error with docker and heroku hosting

Hello everyone, I'm trying to build a django app and host it on heroku & my home server using docker, I build a new one with truenas scale, when I'm trying to push the files to heroku the error "App not compatible with buildpack" comes and I don't know why and no tutorial worked with me, same thing with docker not working with me and just gives errors, I creat requirements.txt and still errors, help me please

/r/django
https://redd.it/105y5g4
Any free apps that allow custom html page creation?

I am looking for a way to create new pages in my django project through the admin panel. So I will log into admin panel and go to the section to create a new page. I will put in the title to the page and then be given a text area where I can put HTML or possibly have a WYSIWYG editor. After I save then it will create a new html page. Then I add the page to my header and it navigates to it.

Sort of like a blog but I am making new web pages instead of posts.

This is to prevent me from having to manually create a new html file in the server and make changes to it. I want to be able to handle it all from the Django admin panel.

/r/django
https://redd.it/105vkd9
All authentication errors from djoser and and simplejwt, how can get them?

We're working on our product and now we need to show these authentication errors to our users (and since our product is bilingual, we may go through some translations and stuff.

I searched a lot and most of the results were dedicated to how to resolve the auth error and not a well-crafted list of those errors. Is there any list of django, djoser and simplejwt errors?

Thanks.

/r/django
https://redd.it/105kqh9
Djnago chess app, won’t update page ws/game/room_code not found. Do i need another packages then websocket, channels-redis for this?

/r/django
https://redd.it/106fgqb
Search-as-you-type in Django/Django Rest Framework, how would you implement it?

I'm currently exploring a lower level stuff (sockets etc.) as I assume the best way would be to send a request with the `Connection: keep-alive` header and reuse that connection instead of opening and closing one for each character, however it looks like that's not so simple as there is no support for the `Keep-Alive` header in Gunicorn (at least for sync workers). Another idea is to use Django-Channels and WebSocket (although it doesn't make sense as my app won't be listening/waiting for anything other than a single response), is there any good resource about this problem (Keep-Alive, setting async workers, using async workers for a specific endpoint etc.) in relation to Django/Gunicorn?

I also have a different question, how would that look like (let's say I'm going with WebSocket) on a single CPU VPS what's going on when let's say 80 users wants to use my app at the same time, I guess it is Django-Channels (Daphne) responsibility to open as many sockets as it needs and if there are too many they will just process requests/responses very slowly, but what about memory, how much does it consumes and does it just crashes if there are too many

/r/djangolearning
https://redd.it/10636ad
Django SASS not updating custom bootstrap (development env)

I'm using django-compressor and django-libsass and have setup a scss file in mysite/static/theme/mytheme.scss

Inside the file I'm changing the primary colour to red for testing.

I'm using Wagtail so it's a multiple site but in my base.html I've added

````
{% compress css %}
<link rel="stylesheet" type="text/x-scss" href="{% static 'theme/' %}{{ current_site.site_name }}.scss" />
{% endcompress %}
````

It used to refresh automatically when I made any changes in mytheme.scss and everything used to work fine but it stopped working and I have a feeling it's when I ran collectstatic.

If I delete the static folder in the root directory it just generated the same CSS file in static/CACHE/css, the css file in there has old CSS in there that isn't updating.

I've tried:
python manage.py collectstatic --clear
python manage.py runserver --nostatic
python manage.py collectstatic --noinput --clear
python manage.py collectstatic --noinput --clear --no-post-process

I've also tried to collectstatic again in hopes it'll collect the changes but it doesn't.

I'm pretty new to this but hopefully that all makes sense.

/r/djangolearning
https://redd.it/1068r88