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 to start learning Django?

I have a fair experience in programming in C++ and I also know HTML and a bit of CSS. Any resources from where can I start learning?

/r/djangolearning
https://redd.it/7o92c2
Really??

/r/Python
https://redd.it/7oaay5
Python framework for data transport, parsing, ETLing

I'm struggling with setting up data ingestion ETL pipelines/processing pipelines/architectures.

I've been playing around with Apache Nifi and like the functionality of the job scheduling, the processors of things like "GetFile", "TailFile", "PutFile" etc. but to me it falls short quickly when you have to do any type of manipulation to the data. For example, if you are reading a CSV file that isn't ideal (e.g. no quote around a string but you know its the last column in each row), you have to write these god awful RegEx to parse the data to send it to the next stage of the pipeline. The same goes for any of the other tools like LogStash/Streamsets etc.

It almost feels like I need something of a "programmable" nifi/libarary/framework. I can tell the framework to simply "go tail these sets of files with X parameters" on this schedule, when it runs I get the context of that information back similar to nifi but I have it available directly in python (can be any just an example) where I can use pandas or some other libraries to manipulate that data as I see fit, do my processing on it, and then call other "nifi like" processors from within python directly to putfile, insert into a database, pass it to a message queue, or some other action.

With something like how I describe, I don't have to worry about writing all of the boilerplate of scheduling, running the job, file I/O. I simply call a process that Tails a file and it send it back to me when it gets something. I do the work on the data and then send it to the next stage. Everything is contained within code and I don't have to worry about "scripts" to handle little silos.

I do not feel that "pandas, odo, and csv "modules are the answer. I feel some combination of all of those tools + some framework of processors, job runners, where you are working within that frameworks context to move and send data around and manipulating it with those tools would be closer to the answer.

Is there any type of framework out there that will do this?

/r/Python
https://redd.it/7obtrz
Where do I put my own object instances?

Hi,
i'm woking with django channels and I have realtime data incoming into my django server wich I then write into a custom object. When I call update() on my object it submits the Data to a Vue.js frontend.

It works but I'm not shure where to put the instance of my object. I'm asking because on a server farm my guess is that the object would be in different RAMs and therefor have differnt values, is this correct? Where do I instaniate objects so that they are handled properly?

/r/django
https://redd.it/7oc1bt
Unsure which flask user system to use

I'm building a website and I need a user system. I have found multiple libraries that handle this but I'm having some difficulties finding the right one. I thought some of you might have experience with these.

I'm looking for a library that has all the basic stuff like login, logout, remembering the user's session, etc. But I'm also looking for some customisability like using something different for confirmations (when you forgot your password for example) than emails.

Help is much appreciated.

/r/flask
https://redd.it/7obuuc
Any Cactus forks/alternatives?

I've been tasked with rewriting a medium-sized e-commerce website where I work. The site is written in Django and uses Wagtail. (We've decided to re-write it because the company we outsourced it to did such a poor job on it that it's very difficult to work with.)

Anyway, nobody has actually made use of the Wagtail admin since the site was originally deployed over a year ago. So I've decided to make the site almost entirely static with a Django-Rest-Framework backend. I'm going to be reusing most of the templates and stylesheets from the original site, so I've decided to use [Cactus](https://github.com/eudicots/Cactus/). (It's a static site generator which uses Django to render templates.) However, after looking around a bit, it seems that Cactus is not a very active project -- its last version was released almost one year ago, and its last commit was over five months ago. And it uses Django version 1.6 to render the templates. However, I really like how it's set up and the fact that it uses Django templates means that I can do most of the conversion automatically.

Does anybody know of an active fork of Cactus, or of a similar alternative? I want to keep the Django templates in case we ever have to move it back to Wagtail or to be a full-on Django site, or if I want to write a custom CMS with Django to allow users here to edit pages. If there isn't anything more up to date, then I'll just continue with Cactus.

I appreciate any input. Thanks!

/r/django
https://redd.it/7oe31d
Deleting object that that has a M2M relation yields a None object.

Labor model has a M2M field of LaborSelections.

`LaborSelection.objects.get(pk=my_id).delete()`

This leaves an object in the database with as each field is set to None and the object has no `pk`.

How can I make sure these are properly getting deleted?

/r/djangolearning
https://redd.it/7od8hq
Your opinion on using permissions in Django?

So to start with, I'm no expert and this is basically based on my sole experience, so there may be some bias here and I would like to change that. I want to know what others think about this topic.

I've found that (once again, from my experience) that it is quite complicated to use the permission system of Django. Especially in cases where we have to give a user different capabilities where more than one kind of user is required.

I am working on a website for my local school and it required three kinds of users, admn, teacher and student. It was quite hard to implement the permission as i was still only starting out(still am a beginner).

So I found another way and made a custom user. I added three new fields along with other profile fields. The three new fields were boolean fields e.g is_teacher, is_student and is_parent and my project kind of runs around these three fields.

Now instead of using the permission or admin at all, I can just use these as conditionals in the views for example if someone tries to go the student page, I added some conditionals for verification e.g if the request.user is a student and request.user is an admin then show them the view otherwise return and http404.

This way, I don't think I'll have to use the permission at all. The project I mentioned, I'm still developing and haven't run into errors yet.

I've tried searching on the internet about making different kinds of users but no source actually tells what to do.

Can anyone guide me how to better utilize permissions? Or the way that I am working right now is okay? What are your experiences handling these types of situations?

This may be a noob discussion for the pros but please keep in mind I'm just a beginner and this is all new to me and I would really appreciate your advice.

Thanks!

/r/django
https://redd.it/7ohp07
[D] Uh oh. Stanford took down their old CS224n schedule and replaced it with a new one for the current semester, which only has 2 weeks worth of stuff on it. Anyone know if there's an archive?

http://web.stanford.edu/class/cs224n/syllabus.html

This had all the assignments, midterms, solutions, papers, notes, and projects, all gone :(

Anyone know is there is a backup of these files?

/r/MachineLearning
https://redd.it/7ohumt
What do you normally name the folder with settings.py, urls.py, and wsgi.py?

I see a lot of myproject and mysite's in sample code. I guess that turns me off because it reminds me of Windows

/r/djangolearning
https://redd.it/7o5tj0
Is there an easy way to view a project on a mobile device?

Right now, when I'm trying to test my site on a mobile device, I'm deploying it to a Heroku server and running the Heroku site on my phone. This is really tiresome because it takes awhile to deploy.

Is there an easier way to run a project on my phone, possibly without having to deploy it onto a server?

/r/django
https://redd.it/7onovt
What is your go-to charting solution with flask?

I am arriving at the stage where i can develop the dasboard for my little analytics side project. The app is data driven and i have little experience with programming/designing in general.

What library would you recommend and why? I have zero experience and can only select a library on the visual appeal but don't want to make a mistake early on and redo everything later.

Could be server or client side. Don't really know what i need..

/r/flask
https://redd.it/7olbfk
Starting your first project without a guide

I would like to start my first Django project a aboutMe page but wondering when to start. I am currently reading djangoboooks then test driven django next. Is it a good mix to start a project on your own while learning or should I just wait and keep following tutorial projects. So far I have done the poll app twice and been drilling in my brain what each folder does, just don't know exactly how to create yet.

/r/djangolearning
https://redd.it/7oot3y
Desperate for a Flask starter - gevent, sqlalchemy/postgres, gunicorn + supervisord + config , msgpack, celery/rq.

hi guys,
I'm desperate for a flask starter that shows all of these working in the *right* way. I have a legacy flask app that is a complete mess and I would like to see how to do it in the right way.
I see a lot of code on how to write an application - but very very little info on how to build a production ready system with all the nuts and pieces needed to make a great production ready system.

1. gevent + gunicorn + supervisord - get the flask app to work in production in the best way possible. How do you setup monkeypatching, etc ? Remember that sqlalchemy is also in this mix. And a huge pain is loading config files - staging and production. All of this is running using supervisord
2. sqlalchemy/postgres - autocommit or not ? autoflush or not ? How do you write a model in the way that you dont have to do this for every function you write (and you can do this once in the base model or decorator or something). This is a huge, huge PITA for me
3. celery/rq + supervisord - how do you run celery/rq and workers using supervisord ? One of the biggest questions for us is how to load the same sqlalchemy models (from the main flask app) into the celery workers. We invariably end up loading flask code as well.
4. msgpack - we want to return msgpack *OR* json data based on what the client has requested for. The api should also accept incoming msgpack *OR* json data. Obviously we dont want to write this code inside each and every function/endpoint. We would prefer doing this in a decorator... if we knew how to.

I'm looking for a starter template demonstrating these features. And I can run from there.
P.S. I'm actually willing to pay for this - not sure if it is kosher mentioning that here. But I'm happy to have someone take the time to do this and make it opensource for the community.

/r/flask
https://redd.it/7oirh1