ShouldnI store TZ information in a session or the User object?
I am working on a project that will have users in several different global time zones and time representation is important. I have defined my own user model by extending AbstractBaseUser. I’m using time zone aware datetime objects and would like to present these times to the users in their own selected time zone.
Reading through Django’s documentation, they provide an example of using middleware to activate the time zone based on data stored in the user’s session.
My question is, does it make a difference whether this data is stored in the session or simply read from the user object? The user object is already available in the request that the middleware has access to right? Or is this one of those situations where the user object will be queried multiple times as a result?
/r/django
https://redd.it/c9ntd7
I am working on a project that will have users in several different global time zones and time representation is important. I have defined my own user model by extending AbstractBaseUser. I’m using time zone aware datetime objects and would like to present these times to the users in their own selected time zone.
Reading through Django’s documentation, they provide an example of using middleware to activate the time zone based on data stored in the user’s session.
My question is, does it make a difference whether this data is stored in the session or simply read from the user object? The user object is already available in the request that the middleware has access to right? Or is this one of those situations where the user object will be queried multiple times as a result?
/r/django
https://redd.it/c9ntd7
reddit
r/django - ShouldnI store TZ information in a session or the User object?
2 votes and 2 comments so far on Reddit
This media is not supported in your browser
VIEW IN TELEGRAM
Simulating a source of light and a lens using Maxwell's Equations in Finite-difference time-domain method
/r/Python
https://redd.it/c9wetp
/r/Python
https://redd.it/c9wetp
PyCon 2019 | Introduction to Data Science with Python
https://liwaiwai.com/2019/07/07/pycon-2019-introduction-to-data-science-with-python/
/r/Python
https://redd.it/c9w5hi
https://liwaiwai.com/2019/07/07/pycon-2019-introduction-to-data-science-with-python/
/r/Python
https://redd.it/c9w5hi
Liwaiwai
PyCon 2019 | Introduction to Data Science with Python - Liwaiwai
PyCon 2019 | Introduction to Data Science with Python Speaker: Grishma Jena Wish to perform Data Science but don’t know how to? Have a dataset that you really want to analyze but not sure how to start? This hands-on session teaches how to explore datasets…
Deploying django app
Hey I am new to Django I have developed a simple Django web app and now I want to deploy it. Which platform is better to deploy a django website. Any suggestions ?
/r/djangolearning
https://redd.it/c9t1zk
Hey I am new to Django I have developed a simple Django web app and now I want to deploy it. Which platform is better to deploy a django website. Any suggestions ?
/r/djangolearning
https://redd.it/c9t1zk
reddit
r/djangolearning - Deploying django app
2 votes and 6 comments so far on Reddit
[Ask Flask] UUIDs or IDs for the primary key?
I've been developing an application and decided I would use UUIDs as the primary key instead of integers. I figured it can be helpful for doing lookups on objects you might not know the type of and also it reveals less information about the underlying data (no URLs that hint how many users or how old a user is).
It mostly works fine but there have been times where I've had to work around stuff. Especially when it comes to using plugins. Also, nearly all the tutorials I see online assume integer IDs.
I was thinking it might be better to use integer IDs internally, but have a UUID field for every model anyway. Then when you want to look something up, the URL just takes a UUID and the integer is used for plugins or internal lookups.
Any thoughts on the best approach? Should I just go with traditional integer, UUIDs or both? Are there any possible gotchas that might come up later I didn't think of?
https://github.com/theocranmore/bloodbike/blob/master/app/models.py
This is what my models file looks like at the moment.
Thank you!
/r/flask
https://redd.it/c9txos
I've been developing an application and decided I would use UUIDs as the primary key instead of integers. I figured it can be helpful for doing lookups on objects you might not know the type of and also it reveals less information about the underlying data (no URLs that hint how many users or how old a user is).
It mostly works fine but there have been times where I've had to work around stuff. Especially when it comes to using plugins. Also, nearly all the tutorials I see online assume integer IDs.
I was thinking it might be better to use integer IDs internally, but have a UUID field for every model anyway. Then when you want to look something up, the URL just takes a UUID and the integer is used for plugins or internal lookups.
Any thoughts on the best approach? Should I just go with traditional integer, UUIDs or both? Are there any possible gotchas that might come up later I didn't think of?
https://github.com/theocranmore/bloodbike/blob/master/app/models.py
This is what my models file looks like at the moment.
Thank you!
/r/flask
https://redd.it/c9txos
GitHub
theocranmore/bloodbike
Dispatch service for blood bikes charity. Contribute to theocranmore/bloodbike development by creating an account on GitHub.
From the Netflix series "Family Business". I rate it 10/10 for realism
/r/Python
https://redd.it/c9xxes
/r/Python
https://redd.it/c9xxes
This media is not supported in your browser
VIEW IN TELEGRAM
Massive update for the 3D renderer I made from scratch in Python. There is now a small, custom programming language for animating properties. Here is a short animation made with the frames rendered by the renderer:
/r/Python
https://redd.it/c9yf0f
/r/Python
https://redd.it/c9yf0f
Using SQLAlchemy JSON object type vs creating an extra relation for storing a list of URLs?
I am considering which option would be better, I basically want to store a list of URLs, which I can modify at will and delete if I need to.
Store a regular list in the table as a db.JSON? or create a separate table and relate it back to the original table (it'll only have one parameter, the URL)
/r/flask
https://redd.it/c9tsu4
I am considering which option would be better, I basically want to store a list of URLs, which I can modify at will and delete if I need to.
Store a regular list in the table as a db.JSON? or create a separate table and relate it back to the original table (it'll only have one parameter, the URL)
/r/flask
https://redd.it/c9tsu4
reddit
r/flask - Using SQLAlchemy JSON object type vs creating an extra relation for storing a list of URLs?
6 votes and 7 comments so far on Reddit
Django Beginner
Hi everyone! I am sort of new to Django, I have sucessfully used it a couple times for large/small projects. Right now I just want to get my project started and I am having a ton of trouble. I start off by creating a python environment. I then activate the environment. After that I use pip to install Django to the environment. After that I try to create my project with [django-admin.py](https://django-admin.py) startproject mysite. When I type this command, it always says "bad interpreter no such file or directory". However, it does start a new project if I do django-admin (without .py). But it seems to create a project using amn older version of Django. I just want to get past this barrier so I can start my project.
/r/django
https://redd.it/ca1h8o
Hi everyone! I am sort of new to Django, I have sucessfully used it a couple times for large/small projects. Right now I just want to get my project started and I am having a ton of trouble. I start off by creating a python environment. I then activate the environment. After that I use pip to install Django to the environment. After that I try to create my project with [django-admin.py](https://django-admin.py) startproject mysite. When I type this command, it always says "bad interpreter no such file or directory". However, it does start a new project if I do django-admin (without .py). But it seems to create a project using amn older version of Django. I just want to get past this barrier so I can start my project.
/r/django
https://redd.it/ca1h8o
Trouble with SQLite
Hey all,
This is my first web app project and I am having issues using SQLite for my database. I’m having trouble finding tutorials or documentation that describes how to implement this into my flask project easily for a complete beginner. I’ve gone through a few and was wondering if anyone had a good recommendation. The database I need is very simple and only has one table for right now.
Thanks!
/r/flask
https://redd.it/c9srir
Hey all,
This is my first web app project and I am having issues using SQLite for my database. I’m having trouble finding tutorials or documentation that describes how to implement this into my flask project easily for a complete beginner. I’ve gone through a few and was wondering if anyone had a good recommendation. The database I need is very simple and only has one table for right now.
Thanks!
/r/flask
https://redd.it/c9srir
reddit
r/flask - Trouble with SQLite
0 votes and 1 comment so far on Reddit
Excited to finally release the first version of my game made entirely with Python and pygame! This sub helped alot btw.
https://bobus-smith.itch.io/transporticular
/r/Python
https://redd.it/c9ygrh
https://bobus-smith.itch.io/transporticular
/r/Python
https://redd.it/c9ygrh
itch.io
Transporticular by Bobus Smith
A 2D Transport Tycoon game, where you must create a great transport empire. Available for Windows
What is the best way to refresh a token using the old token?
I'm using Djoser and it provides several endpoints, but I do not know how to update an X token in X minutes. There seems to be no endpoint for this.
​
Basically, I want to refresh the access token every 5 minutes by making api calls on my front end. But as for the back, I do not know what to do about it.
/r/djangolearning
https://redd.it/c9zm30
I'm using Djoser and it provides several endpoints, but I do not know how to update an X token in X minutes. There seems to be no endpoint for this.
​
Basically, I want to refresh the access token every 5 minutes by making api calls on my front end. But as for the back, I do not know what to do about it.
/r/djangolearning
https://redd.it/c9zm30
reddit
r/djangolearning - What is the best way to refresh a token using the old token?
2 votes and 1 comment so far on Reddit
How much should a django freelance developer charge hourly
I am confused about how much amount I should charge. Also wanted to know whether doing django freelancing is worth it or not.
/r/django
https://redd.it/ca576e
I am confused about how much amount I should charge. Also wanted to know whether doing django freelancing is worth it or not.
/r/django
https://redd.it/ca576e
reddit
r/django - How much should a django freelance developer charge hourly
2 votes and 12 comments so far on Reddit
Flask vs NodeJS for API that delegates calls to Python scripts: What are benefits/downsides for either case?
I'm about to build a Flask API that runs python scripts on requests.
Using Flask seems more logical and beautiful since then all code in my web-app will be in Python.
On the other hand, the front-end is Javascript/React, so for convenience-sake maybe it doesn't matter that much? Also, I've read that NodeJS can be faster. The biggest concern is that it needs to be scalable and fast.
What's your opinion on this?
Thanks!
/r/flask
https://redd.it/ca6m45
I'm about to build a Flask API that runs python scripts on requests.
Using Flask seems more logical and beautiful since then all code in my web-app will be in Python.
On the other hand, the front-end is Javascript/React, so for convenience-sake maybe it doesn't matter that much? Also, I've read that NodeJS can be faster. The biggest concern is that it needs to be scalable and fast.
What's your opinion on this?
Thanks!
/r/flask
https://redd.it/ca6m45
reddit
r/flask - Flask vs NodeJS for API that delegates calls to Python scripts: What are benefits/downsides for either case?
4 votes and 8 comments so far on Reddit
Limiting the amount (not size) of files a user may upload (based on groups)
So I’m a Django newb and really a python newb too but I’m making my first web app.
I want to allow my users to upload certain amounts of files based on membership level.
10 mp3 files at free tier, or unlimited at the paid tier. There will also be wav files in the same amount but irrelevant really I think, because it will be the wav version of the mp3.
So I haven’t created the groups yet, and I haven’t figured out how to make a user pay to become a member of the group, but I think there is a lot of info out there on that.
Currently the users upload files and I use a list view to populate an html5 based audio player with the songs filtered by the logged in user. So each user only sees their own songs in the player.
My question is, can I do something like have a validators.py file that says if a user is in group free group and the amount of files uploaded by user id >= 10, throw an error stating that they need to upgrade membership?
I know it will be more complicated than this, but am I thinking
/r/django
https://redd.it/ca9qne
So I’m a Django newb and really a python newb too but I’m making my first web app.
I want to allow my users to upload certain amounts of files based on membership level.
10 mp3 files at free tier, or unlimited at the paid tier. There will also be wav files in the same amount but irrelevant really I think, because it will be the wav version of the mp3.
So I haven’t created the groups yet, and I haven’t figured out how to make a user pay to become a member of the group, but I think there is a lot of info out there on that.
Currently the users upload files and I use a list view to populate an html5 based audio player with the songs filtered by the logged in user. So each user only sees their own songs in the player.
My question is, can I do something like have a validators.py file that says if a user is in group free group and the amount of files uploaded by user id >= 10, throw an error stating that they need to upgrade membership?
I know it will be more complicated than this, but am I thinking
/r/django
https://redd.it/ca9qne
reddit
r/django - Limiting the amount (not size) of files a user may upload (based on groups)
0 votes and 0 comments so far on Reddit
[P] A little gadget that plays rock-paper-scissors slightly better than random using a small quantized RNN running on an 8-bit microcontroller
[Project video here](https://www.youtube.com/watch?v=iuTKBHW0OaU)
[Code and PCB/CAD design files here](https://github.com/PaulKlinger/rps-rnn)
I was looking for some kind of project that let me combine my love for building [small electronics/3d-printing projects](https://paulklinger.com/projects/) and machine learning, and this is what I came up with.
The machine learning side of this isn't too interesting, just [a small 3 layer vanilla RNN](https://raw.githubusercontent.com/PaulKlinger/rps-rnn/master/diagrams/rnn_architecture.png) (all layers with 10-d state, trained in tensorflow/keras) that takes as input the moves of the two players and outputs a prediction for the opponents next move. The data comes from human games played on [roshambo.me](https://roshambo.me) via this [blog article](https://justincollier.com/life-hacks/how-to-win-rock-paper-scissors/). I added some simulated data of periodic sequences, because that seems like the sort of thing people might try out when playing against an "AI".
Without the simulated data (which is easy to predict) the model gets something like 38% accuracy on the test set (compared to 33% playing randomly). One nice thing about rock-paper-scissors is that you can't do much better than random, so there isn't much pressure ;)
I had some problems getting training with larger batches to work (either with just padding or padding and masking the gradients) so I just trained it with batch_size=1, which wasn't too bad for such a small network.
The probably more interesting
/r/MachineLearning
https://redd.it/ca88r4
[Project video here](https://www.youtube.com/watch?v=iuTKBHW0OaU)
[Code and PCB/CAD design files here](https://github.com/PaulKlinger/rps-rnn)
I was looking for some kind of project that let me combine my love for building [small electronics/3d-printing projects](https://paulklinger.com/projects/) and machine learning, and this is what I came up with.
The machine learning side of this isn't too interesting, just [a small 3 layer vanilla RNN](https://raw.githubusercontent.com/PaulKlinger/rps-rnn/master/diagrams/rnn_architecture.png) (all layers with 10-d state, trained in tensorflow/keras) that takes as input the moves of the two players and outputs a prediction for the opponents next move. The data comes from human games played on [roshambo.me](https://roshambo.me) via this [blog article](https://justincollier.com/life-hacks/how-to-win-rock-paper-scissors/). I added some simulated data of periodic sequences, because that seems like the sort of thing people might try out when playing against an "AI".
Without the simulated data (which is easy to predict) the model gets something like 38% accuracy on the test set (compared to 33% playing randomly). One nice thing about rock-paper-scissors is that you can't do much better than random, so there isn't much pressure ;)
I had some problems getting training with larger batches to work (either with just padding or padding and masking the gradients) so I just trained it with batch_size=1, which wasn't too bad for such a small network.
The probably more interesting
/r/MachineLearning
https://redd.it/ca88r4
YouTube
RPS-RNN
Playing rock-paper-scissors slightly better than random, using a recurrent neural network running on an 8-bit microcontroller. Code and design files availabl...
Looking for a highly recommended Django book. What would you recommend?
/r/django
https://redd.it/ca6tc8
/r/django
https://redd.it/ca6tc8
reddit
r/django - Looking for a highly recommended Django book. What would you recommend?
5 votes and 22 comments so far on Reddit
How fast can Django generate model instances?
Hey all. I've got what I think is a simple question about Django: How fast can it generate model instances?
I've got a CSV file with about 2.5 million rows and I want to generate a model instance for each row. They will all be the same model, basically with the headers of the CSV as fields and the rows as records.
It's easy to just read the CSV line by line and for each line, create the model w/ the given fields, but is this a terrible idea? How fast can Django create instances like that, and is this a common operation or should I reconsider my database design? Also, would it be accurate if I were to load all this data into sqlite and search/filter/write my code around that locally, if I plan to eventually push it into a Postgres database in production?
For what it's worth, my intention is to make this data searchable, where almost every query will be a `Thing.objects.filter(some_column__lte=value, some_other_column__gte=other_value)` and so on w/ the ability to filter on as many of the CSV headers as possible.
Any thoughts? Open to other questions/ideas that can help me solidify my plans here :)
Thanks!
/r/djangolearning
https://redd.it/cafgfs
Hey all. I've got what I think is a simple question about Django: How fast can it generate model instances?
I've got a CSV file with about 2.5 million rows and I want to generate a model instance for each row. They will all be the same model, basically with the headers of the CSV as fields and the rows as records.
It's easy to just read the CSV line by line and for each line, create the model w/ the given fields, but is this a terrible idea? How fast can Django create instances like that, and is this a common operation or should I reconsider my database design? Also, would it be accurate if I were to load all this data into sqlite and search/filter/write my code around that locally, if I plan to eventually push it into a Postgres database in production?
For what it's worth, my intention is to make this data searchable, where almost every query will be a `Thing.objects.filter(some_column__lte=value, some_other_column__gte=other_value)` and so on w/ the ability to filter on as many of the CSV headers as possible.
Any thoughts? Open to other questions/ideas that can help me solidify my plans here :)
Thanks!
/r/djangolearning
https://redd.it/cafgfs
reddit
r/djangolearning - How fast can Django generate model instances?
0 votes and 0 comments so far on Reddit