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
Django ADFS Question

Hello my application uses Django ADFS using Azure AD. It works as it should be I cannot seem to figure out how to get the users role from Azure or the package. Was wondering if anyone knew how to print out the users role as there is two groups users and admins

/r/django
https://redd.it/xlx8n6
Seeking professional data scientists for research study - 30 min virtual interview, compensation provided

Hello! My name is Aayushi Roy, I’m part of a research team at the University of Maryland studying how data scientists collaborate. We’re looking for professional data scientists to participate in a research interview study about how data scientists work together to perform data analysis (flyer).

Participants will be asked a set of questions regarding their collaborative environment and what tools they use to perform data analysis. The study will take about 30 minutes to complete and will be held over Zoom. Upon successful completion of the interview, participants will receive $20 in compensation.

Responses will be anonymized. This study has been approved by the Institutional Review Board at the University of Maryland, College Park.

To be eligible, you must:
- Be at least 18 years old
- Work with data and perform data science work as part of your job description
- Use computational notebooks
- Have experience in data science tools/workflows

Participation will entail:
- Completing a pre-study demographics questionnaire (5 minutes)
- Answering interview questions about your collaborative environment and the tools you use (30 min)

If you are or someone you know is interested, please DM me or email me at aroy2530@umd.edu. Thank you for your time and consideration!

/r/JupyterNotebooks
https://redd.it/xm1mku
I wrote my first real scripts today

I’m a water resource engineer by trade, learning to code partially for fun and partially in the hopes of making my job easier. Today I needed to convert a whole bunch of files from one format to another, edit some particular values in the header, and convert to a third format. Rather than spend all day doing it by hand, I spent all day writing a script that does it in seconds…and it works!

It’s a piddling little script, only about 50 lines, but it does exactly what I want it to do, and now in the future when I have to deal with this process again, I’ll be armed and ready.

I know this is nothing revolutionary, but honestly it feels pretty good to write working code to address a real life problem! Hopefully the next one goes a bit faster…

/r/Python
https://redd.it/xlgo4a
Brainfried: A Brainfuck to Assembly Compiler

A while back I worked on a project called Brainfried which takes Brainfuck source code and compiles it to Intel x86 64 assembly which then gets compiled using nasm. Because Brainfried compiles to assembly unlike a lot of other Brainfuck programs which interpret the code. Brainfried runs a lot faster.

Right now, because the generated assembly works of syscalls. It can only be used with Linux

/r/Python
https://redd.it/xm8n2h
How can I use crispy-forms with bootstrap-select?

I want to replace the crispy-forms default bootstrap select with the bootstrap-select (https://developer.snapappointments.com/bootstrap-select/)

​

It's like I'm fighting an uphill battle. I tried adding the "selectpicker" class to the widget but then the bootstrap-select appears INSIDE a normal bootstrap select. Then I tried defining my own field element for crispy-forms but now the bootstrap-select is not aligned with the rest of the form, it's missing the little required star, etc....

​

Is there an easy way to do this?

​

My form (I want the State to be a selectpicker):

class AddressForm(forms.Form):
email = forms.CharField(widget=forms.TextInput(attrs={"placeholder": "email"}))
password = forms.CharField(widget=forms.PasswordInput())
address1 = forms.CharField(
label="Address", widget=forms.TextInput(attrs={"placeholder": "1234 Main St"})
)
address
2 = forms.CharField(
widget=forms.TextInput(attrs={"placeholder": "Apartment, studio, or floor"})
)
city = forms.CharField()
state = forms.ChoiceField(choices=STATES)


/r/django
https://redd.it/xm3fzx
Could I use Django to create a fully functional employee scheduling system?

I'm thinking to use Django, React and PostgreSQL. I'm a newbie that just started working with Django (and coding in general) about half a year ago. I haven't done anything too crazy complex but I wanted to see if I could challenge myself to build an employee scheduler since it's something I could see really improving my uncle's life. My biggest question is, could I use Django for this? I know it's a powerful framework but I haven't really unlocked its full potential yet Here is the use case:

My uncle has to schedule hundreds of employees across 25\~ stores. He has to manually set schedules every month which is really painful as you might imagine since you have to ensure that every restaurant has enough staff at all times, employee time constraints and there are some floating managers that go where they are needed. I would love to be able to have a UI where my uncle can store employee info like their names, employee id, position, store, hours they can work, their pay rate, etc. I could see this as a microservice all on its own.

Another microservice can be restaurants' details which includes all the store hours

/r/django
https://redd.it/xmbidx
500 internal server error

I have jupyter notebook installed with conda which was done a few years ago. Just recently I've installed the latest version of python using pip and also installed jupyter notebook. When I use the terminal to run jupyter notebook I can open it but then I get a internal server error when trying to open the file. Is this because it conflicts with my existing jupyter notebook with conda? And if so how do I resolve this issue?

/r/JupyterNotebooks
https://redd.it/xizhr4
Best practice for an app with ML?

I'm working in project that uses ML for recommendation purposes. However, the ML part is implemented in a Fast API as another server. The problem is that since the ML part is in another app, the Django app must send request to this app and then retrieve it which causes a noticible performance delay.

Mind you, these requests are pretty frequent and are even worse in a deployed environment as the both apps are deployed seperatly.

My partner said that this is common in apps that utilize AI and is the best practic. However, I don't think this fits our case and introduces many issues that don't need to be solved. I think that we could just implement the whole in Django itself rather easily.

If you have had experience with a similar issue, I welcome your insight. What is really the best practice for project like this? Would it be better to just implement it in Django instead of using two separate apps?

/r/django
https://redd.it/xmtl92
Force the users to change the password before first login

Hi Guys,

I have a question about Flask, or better: about Flask-Security. I’m working on an app that should help to complete specific tasks as a team. I implemented Flask-Security-Too to handle login, logout, password change and very important to have certain user roles. However, users should be registered by admins only. The admin will set an initial password, that must be changed by the user before the first login. Admins will also be able to reset the password by changing it to a temporally one, which must then be changed by the user after it is used for login.

I’ve seen this concept in a lot of other apps and was wondering if it could be implemented with Flask/Flask-Security. And if yes, what would be the most practicable/secure way.

Any thoughts? :)

/r/flask
https://redd.it/xmxegk
Why django over asp.net core?

C# is a statically typed languages so you don’t really need to write tests to expose compile time issues in asp.net core whereas in django it is really necessary. Additionally the number of requests handled by asp.net core seems far superior than django (I found somewhere else a ratio of 10:6). So why do you all still use django?

I am looking for an honest opinions to present to my non-technical management that our decision to go with django over asp.net core is good.

We did go with django especially considering django admin panel, so we don’t need to write a lot of code but ask some of our stakeholders to complete a few things using django admin panel. This indeed decreased the delivery time. However now we found using different external tools the stakeholders could do the things still if we just provide them the database tables. Thank you.

/r/django
https://redd.it/xmpepd
ModuleNotFoundError: No module named 'Crypto' and more issues

Base Github I am using: bookwyrm-social/bookwyrm: Social reading and reviewing, decentralized with ActivityPub (github.com)

My Fork of team fork: cmorgan2016/bookwyrm-genres: Social reading and reviewing, decentralized with ActivityPub (github.com)

Note: I am struggling to get commit to work

Their tutorial: [Developer Environment (
joinbookwyrm.com)](https://docs.joinbookwyrm.com/install-dev.html)

What I am using: Git Bash and Virtual Studio Code

what happen when I debug:

crbug/1173575, non-JS module files deprecated. chromewebdata/(index)꞉6564:22:6789

https://preview.redd.it/hivvzp9fu0q91.png?width=730&format=png&auto=webp&s=3e58397c0085dfdf03e96b2d7569765134977ed6

I'm getting this error when I run $ python [manage.py](https://manage.py) makemigrations --merge and I have run

pip install Crypto
pip install pycrypto
pip install pycryptodome

When I run ./bw-dev build

+ case "$CMD" in
+ docker-compose build
Error response from daemon: i/o timeout: driver not connecting

When I run ./bw-dev setup

+ case "$CMD" in
+ migrate
+ runweb python manage.py migrate
+ docker-compose run --rm web python manage.py migrate
Error response from daemon: i/o timeout

When I run ./bw-dev up

+ case "$CMD" in
+ docker-compose up

/r/djangolearning
https://redd.it/xnqbjw
is installing jupyterthemes safe?

Hi there,

Just a curiosity - I get extreme strain and headaches from looking at monitors for to long so I installed juptyerthemes to enable darkmode since its not already a thing. Everything I could find didnt give a definite answer as to whether it was malicious or not...

/r/JupyterNotebooks
https://redd.it/xfjkee
Edit DB

Best approach to edit DB in production? For instance in case of a new group of users to register? I usually write a .py file using Alembic, but maybe there is a better approach. Writing raw SQL is not great I think, as I have many columns using SQLAlchemy's "default" param, so they would not be automatically set by raw SQL queries.

/r/flask
https://redd.it/xnkwyz
Sunday Daily Thread: 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/xn81cz
Monday Daily Thread: Project ideas!

Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, "The Big Book of Small Python Projects" which provides a list of projects and the code to make them work.

/r/Python
https://redd.it/xo37yn