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
Users, content, and scalability

Hi, I'm looking for some advice on how to go about creating models for, say, a site like reddit. All submitted content can have a number of fields that change over time - upvotes, downvotes, etc. If I try to imagine how that might work, just upvoting a submission and then refreshing the page incurs a number of queries already. How is something like this scalable without just throwing more silicon at the problem? Yes I know of caching but with so many updates, a page from 2 seconds ago is already old.

I guess my questions are: is there an efficient way to keep track of votes or will this inevitably cost many rows? How best to model and write views for scalability? Do sites ever cache pages for several minutes to help mitigate load? Thanks in advance

/r/django
https://redd.it/8rxi41
Looking for very basic django template repository

I'm doing a simple project and am looking for an open-source repo of templates to use, similar to the HTML and CSS the admin module uses.

Does something like this exist? I'm having trouble searching for it because I'm fixating on the word template, which confuses the search results.

Thanks!

/r/djangolearning
https://redd.it/8rwafs
How to support 2 languages in a model CharField?

Suppose I have a Book model that has a Title CharField. I want it to display english and spanish title when the page is displayed in respective language. How to do this? Also is it supported in default admin panel? Thanks!

/r/django
https://redd.it/8ry2bd
Django with RabbitMQ

Is there a way to connect to RabbitMQ without constantly haveing to open and close the connection?

Now I have to open a new connection for every message.

/r/django
https://redd.it/8ryj8u
give an API key for REST flask api

Hello

I made my rest api using flask. and I am using flask-jwt-extended for tokens. each request will generate access and refresh tokens. While testing everything worked perfectly

HOWEVER

I started learning react for my frontend. I pretty much followed this \[modern react with redux by stephen\]([https://www.udemy.com/react-redux/](https://www.udemy.com/react-redux/learn/v4/)). He used api keys on different occasions: youtube api, googlemap api, a weather api and a costume api he made to demonstrate.

Now I have also dealt with twitter and reddit api before. all of them give an "access" key of some sort. This key does not expire and it doesn't need any refresh.

my question is, how to make an "api" key for consumers? or more technically for my front-end usage?

Thank you

/r/flask
https://redd.it/8s2rzu
What's next after basic CRUD?

Hello guys,

It's me again with another dumb question.

I've "finished" few basic apps in my project. I have working CRUD for each app/model and I feel lost now. I'd like to add few things, but I'm not sure what's the best next step

\- Dashboard with charts, maybe few basic forms to add quickly object for specific model

\- Few simple "buttons" to do special actions eg. quickly increase/decrease amount in IntegerField

\- Ability to use custom script (It takes list of IDs and create pdfs of chosen ids), smth like form in which i could add ids and amounts of each id to pass it to the script

What should I do? Things like this require some frontend tools like react? Or can I do it with plain Django?

If I have to use frontend framework, which is better (for project and future job), react or vue?

If I use frontend framework, do I need to create REST API for each app in my project?

Thanks for any advices!

/r/djangolearning
https://redd.it/8s276j
Python is now the most frequent weekly tag on StackOverFlow

/r/Python
https://redd.it/8s2uaf
Overiq Djangobin - A project based tutorial for Django 1.11

Hello everyone!

I have just finished writing Django 1.11 tutorial, where we will build a pastebin application called djangobin.

Tutorial link: https://overiq.com/django/1.11/intro-to-django/

Live Demo: http://overiq.pythonanywhere.com/

Github source: https://github.com/overiq/djangobin


/r/django
https://redd.it/8rz0h4
i have prebinned data. how can i use pandas and seaborn to display histograms based on those bins

see title.

I have csv files of this form

mass (g),count

0-499,600

500-999,2244

1000-1499,3245

...

4500-4999,2095

5000-8165,201



i have 6 such csv files and i'd like to see 6 histograms. the fact that the data is prebinned is giving me issues. i'd appreciate a hint! thanks for your time.

/r/pystats
https://redd.it/8s5tty
MozartFlow: Doing analysis on audio like gender classification, instrument recognition, voice separation, genre classification | Not completed; If anyone interested, do collab.
https://github.com/techcentaur/MozartFlow

/r/Python
https://redd.it/8s6ll7
Need help with chart.js and django.

Im using chart.js to display charts in my django website. I am also using an API call that then parses out JSON data for the chart using python. Does anyone then know how to use an axios call within javascript to call and display the data through my index.html file?

/r/django
https://redd.it/8s89tb
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/8s95kt
queryset appears empty in debugger during testing, but not in console

Hello,

I'm testing REST APIs with `rest_framework.test.APITestCase`, using their client for making requests and `model_mommy` for creating objects in the `setUp()` method.

The general working is quite simple: the view is supposed to fetch a User and an object, and assign permissions for the former to the latter by means of django-guardian's `assign_perm`; the test creates a user and a group in the `setUp` method, then the actual test performs a POST passing their pk's as payload.

The issue I'm seeing, is that when the `User.objects.filter(pk__in=people_ids)` instruction is executed, the value I see in the debugger is that of an empty queryset, while if I type the exact same line in a console connected to the same session as the debugger I see the actual value being found.
Then the view gets to the `assign_perm` instruction, and it crashes with an `IndexError: list index out of range` error on the first evaluation of the queryset itself, which happens on the for loop at line 247 in the file core.py of the django-guardian library.

Is there something obvious that I should be looking at, because I really cannot wrap my head around this.

(django 1.11.13)

Thanks

/r/django
https://redd.it/8s9y48