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
This media is not supported in your browser
VIEW IN TELEGRAM
Kroger CLI, automation utility to save on shopping, earn points, get purchases summary and more

/r/Python
https://redd.it/gr4jjn
Flask Form To SQL Server - 400 Bad Request

Hi everyone,

In my current project I have a Flask form I'm trying to send to a SQL server.

I am successfully pulling data from the SQL server (using pyodbc ) for employee data but it's a form for adding employees that's causing me a headache.

`@app.route('/add-employee', methods=['POST'])`

`def add_employee():`

`if request.method == "POST":`

`employee_id = request.form['employee_id']`

`first_name = request.form['first_name'],`

`surname = request.form['surname'],`

`location = request.form['location'],`

`reports_to = request.form['reports_to'],`

`business_unit = request.form['business_unit'],`

`address_1 = request.form['address_1'],`

`address_2 = request.form['address_2'],`

`address_3 = request.form['address_3'],`

`eircode = request.form['eircode'],`

`mobile_number = request.form['mobile_number'],`

`alt_email_address = request.form['alt_email_address'],`

`pps_number = request.form['pps_number']`

`insert_query = '''INSERT INTO hr_employee_data (employee_id, first_name, surname, address_1, address_2, address_3, eircode, mobile_number, employment_status, gender, start_date, birth_date, pps_number , holiday_allowance, service_days, alt_email_address, emergency_contact, emergency_number, working_day_hours, working_days, job_title, location, reports_to, business_unit, part_orfulltime, handbook_received , induction_form, prob_expiry, prob_completed, salary, salary_changedate, pension, healthcare, bonus_scheme, company_vehicle, vehicle_details, vehicle_issuedate, other_assets, asset_details , asset_issuedate, profile_url, username, password) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);'''`

`cursor = cnxn.cursor()`

`cursor.execute(insert_query, (first_name, surname, location, reports_to, business_unit, address_1 , address_2, address_3, eircode, mobile_number, alt_email_address, pps_number))`

`cnxn.commit()`

`return redirect (url_for('hr_homepage'))`

`return render_template("add-employee.html")`

I am aiming to have two pages for the forms so I have tried changing the insert\_query to only the fields I need for this page but when I submit, it still gives me the 400 Bad

/r/flask
https://redd.it/grgw26
Convincing a (dinosaur) organization to adopt Flask?

Has anyone had any experience introducing such technologies into their organization? I've been amazed by what web applications (i.e. Flask) can do in terms of customisability and dB management, and want to share it with my company.

However, they have the usual concerns of security and all.

While there is login functionality present, what else can I use to market the security of the entire application?b

/r/flask
https://redd.it/grigm3
Digital Ocean hosting

Hi

Does Digital Ocean shared droplet comes with database if yes what type?

I would like to host my flask app.

/r/flask
https://redd.it/grod2w
Circle Evolution v0.1 is now available on PyPI. My first big project as a 16 year old. [Github repo & desc in comments]

/r/Python
https://redd.it/grglgp
Everybody knows that instagram is made with django but why can we not see all that input tags in the page source of their sign up page if I assume that they use django forms. Also we cannot see any hard-coded text on the website like that "Instagram" header or "sign up to see photos videos...".



/r/djangolearning
https://redd.it/grnkyn
Why is the documentation so hard to navigate?

Like seriously. It's a complete mess.

There should be a sidebar with each concept neatly organized. For example, check out the \[Bootstrap Documentation\]([https://getbootstrap.com/docs/4.5/getting-started/introduction/](https://getbootstrap.com/docs/4.5/getting-started/introduction/))

Nice, neatly organized sidebar. It's simple, minimal and easy to find stuff.

But Django decides to be unique by not having a sidebar and instead scattering links everywhere. If you don't think it's bad, go to [https://docs.djangoproject.com/en/3.0/](https://docs.djangoproject.com/en/3.0/) and find the neat, organized section on how to use Django with postgresql. Because I couldn't find it and had to watch a YouTube tutorial instead. It should not suck this bad.

Don't get me wrong. Django is a beautiful, well-made web framework. I just think its documentation should be organized better.

/r/django
https://redd.it/grwatk
startproject with a period, or no period?

See below image. Do you use folder structure A, or folder structure B, and why?

[https://imgur.com/a/Vx3q82t](https://imgur.com/a/Vx3q82t)

​

**Source of image:**

Django for Beginners: Build websites with Python and Django by Vincent, William S.

/r/django
https://redd.it/grw144
This media is not supported in your browser
VIEW IN TELEGRAM
2D Raycasting along with Rendered view - Visualization was done using Pygame! People who love games would definitely love this! Link to the Github repository in the comments!

/r/Python
https://redd.it/grwueh
Fast QR-ticket scanning

Not sure if this is the right place to ask, as i suspect the solution maybe isn't directly related to Django, however maybe someone has had a similar situation.


I have developed a very simple ticket system with QR-codes on a django website. It works by simply creating QR-codes which contains the link to register the attendance of that particular ticket, which must be done with an admin account.
A link looks like: mysite.com/qr-ticket/register/<event\_id>/<ticket\_id>.


This works rather well, with the exception of the registry process being a little slower than desired. Each time a QR-code is scanned, the person scanning has to open the link and visit the website in order to register attendance. What I ideally would want is that when the QR-code is scanned (by a phone), a post request is sent to the server, which returns a response of success/fail or something similar, i.e. not needing to visit the website in order to register attendance. Does anyone know of a clever way to achieve this, without developing a custom app?

/r/django
https://redd.it/grrc0y
Promises in the backend

I've been using Flask which doesn't have async built in. Lately I have been comparing Flask to other backend frameworks like ExpressJS which does have async built in as it is JavaScript based. My question is for a backend framework do you actually need async features that often? One of the only use case I can think of is if you wanted the backend to fetch some APIs. Are there any other times you would really need async in the backend as part of your web framework? Thanks.

/r/flask
https://redd.it/grzmlx
PyTorch fails on me when using local Jupyter to run epochs

/home/onur/.local/lib/python3.6/site-packages/torch/nn/functional.py:2854: UserWarning: The default behavior for interpolate/upsample with float scale_factor will change in 1.6.0 to align with other frameworks/libraries, and use scale_factor directly, instead of relying on the computed output size. If you wish to keep the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details.

Hi.

I am trying to run a classifier on my local notebook to use my own GPU instead of relying on Colab. When I try to run a single epoch to find the learning rate, I get many repeats of the above message.

I get that its just a warning but my epoch does not run at all.

/r/IPython
https://redd.it/grym25
How do you divide your website into apps

Hi! I’m very new to Django, planning to transfer from Node.js as it seems be more comvenient for me. I’ve just finished a small polls site from the official Django documentation, and am wondering particularly about the apps. How do you usually divide the functionalities of the apps? How do you determine how to divide them? For example, I’m planning to make a simple registration + login system to test out my fundamental Django knowledge, how many apps would you create for that?

Looking forward to your insights! Thanks in advance!

/r/django
https://redd.it/gs3aev
How to Handle Computationally Expensive Tasks under Load?

My site's core function takes about a second to run; I'm worried that if there's spikes in traffic, this might cause the site to be unresponsive.

Some common solutions seem to be calling it asynchronously or using message brokers. I'm not super experienced, so I can't really tell if I should use one of these.

What's the best way to handle CPU-bound expensive functions in Flask?

/r/flask
https://redd.it/gs5sjx
Is the action option in the form tag is necessary?

Hey, I'm building a project with Flask and python. I have signup route with signup form in it. I'm using werkzeug.security.generate\_password\_hash to encrypt the given password, but I'm doing it in the route function of the signup route (@app.route('/signup'...)).

I have 2 questions:

1. Is it fine? I want to encrypt the password on the client-side.
2. In the HTML file of the signup route, the form tag I'm specifying has no action=... attribute. so how does it knows where to send the data? and do I need to have the action attribute?

/r/flask
https://redd.it/gs98nf
A Python GUI for uninstalling the default Windows 10 apps.

/r/Python
https://redd.it/gs7xdb
Real Time Object Detection with yolov3 in tensorflow 2.2

Hello, I would like to share with you my implementation of yolov3 object detector in tensorflow 2.2

[yolov3-keras-tf2](https://github.com/emadboctorx/yolov3-keras-tf2)

&#x200B;

https://reddit.com/link/gs0olx/video/4m6zvqqb1g151/player

**Features**

* tensorflow-2.X--keras-functional-api
* cpu-gpu support
* Random weights and DarkNet weights support
* csv-xml annotation parsers.
* Anchor generator.
* \`matplotlib\` visualization of all stages.
* \`tf.data\` input pipeline.
* \`pandas\` & \`numpy\` data handling.
* \`imgaug\` augmentation pipeline
* \`logging\` coverage.
* All-in-1 custom trainer.
* Stop and resume training support.
* Fully vectorized mAP evaluation.
* \`labelpix\` support.
* Photo & video detection

&#x200B;

https://preview.redd.it/8albre2uff151.png?width=640&format=png&auto=webp&s=c0c8ff14ab13f6149b333d1a016ca0e66cecc975

https://preview.redd.it/nwklye2uff151.png?width=1712&format=png&auto=webp&s=c5ef0fe3bfb4650437bf75cc95b834025980f964

https://preview.redd.it/o9pvhf2uff151.png?width=900&format=png&auto=webp&s=7b4074a050121a7f507ef5c0c50d4d8e38479e3a

https://preview.redd.it/vvlwef2uff151.png?width=640&format=png&auto=webp&s=8abe3084e913fe16f01d34d014b0a4d095f9d701

/r/IPython
https://redd.it/gs0olx