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
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
[AF] Update web site dynamically with Python script output

Hi,

I am pretty new to Flask and just learning the basics. How can I update my web site dynamically with the output from Python script?

I am fetching data from my temperature sensor which works well but I would like to bring that data to my simple web site. That web site should automatically update newest readings without reloading the whole page.

/r/flask
https://redd.it/7optfy
Flask-OAuthlib custom response

Hi. I'm implementing my own OAuth2 server using Flask-OAuthlib and password grant type. Everything is working fine, I just have one small issue that I can't figure out. I would like to return some custom login errors like 'user not active'. Is there a way to do this? As far as I can see the usergetter method only returns user object or None.

/r/flask
https://redd.it/7nq6e2
Adding Ability to Log In to Site With Facebook

I want to add the ability for users to log into a website using Facebook to a project that I'm working on.
I found a bunch of references to `social-auth-app-django`, but the last commit to the Github repository was almost three years ago. Is there a more modern/up to date alternative, or is that still the best option?

/r/django
https://redd.it/7opcxd
Any recommended tutorials or documentation on building unit tests with a MongoDB and Flask?



/r/flask
https://redd.it/7nq4dx
How do you pass a queryset to a JS variable? I want to take a queryset and pass it to js as a simple json array. Can't find any help but surely this is obvious!



/r/django
https://redd.it/7or3dx
Interactive branching?

I was reading about [inkle/ink](https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md), a scripting language for interactive fiction, and I thought some interactive branching functionality would be a great feature for Jupyter notebooks. E.g. imagine a tutorial that is not just read front-to-back but which has quizzes that depending on your answer leads you to different sections. This could let advanced people skip over whole sections they know and beginners can take deep dives into topics that they don't understand as well yet. And it would allow for some "gamification" of tutorial notebooks.

Do plugins like that exist for Jupyter, by any chance?

/r/IPython
https://redd.it/7oqfco