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
I have created a collection of resources I used to learn python and Django! I'll post it here for everyone looking for a place to start!
https://mindweb.network/board/how-to-create-a-modern-website-with-django

/r/djangolearning
https://redd.it/6x0nob
Django Install Script for Ubuntu 16.04

Hey there, since I found this subreddit after already sharing this in the Django-subreddit, I wanna share my link to the original post here. :)

[Django Install on Ubuntu 16.04](https://www.reddit.com/r/django/comments/6wu4gu/django_install_i_am_just_a_newbie_and_i_did_this/?ref=share&ref_source=link)

Be free to comment here, or just use the real topic in /r/django as posted above.

/r/djangolearning
https://redd.it/6wxdxl
How dos createview trigger saving the model?

Digging through parts of the django 1.6 code (dont ask...) i was not able to find out how the basic CreateView issues saving the model, as is stated in its documentation (https://docs.djangoproject.com/en/1.11/ref/class-based-views/generic-editing/#django.views.generic.edit.CreateView)

Possibly (and hopefully) related things ive found out:

* CreateView's super classes dont handle saving in any way
* BaseModelForm seems to be the only part where the model instance of a form is pulled and actually saved
* BaseInlineFormSet has a save method, that actually calls save on a form, but i was not able to find out how that is related to actual forms, since most forms just inherit from Form, and not BaseModelForm...

Can someone please explain to me how all this works together?

/r/djangolearning
https://redd.it/6x363z
Tags for post

I was thinking if we can create tags for all the awesome resources that are shared on this sub?

For example we could have a tag for e books, online free courses, sample projects. Would be more than happy to contribute.

/r/Python
https://redd.it/6x5nol
What are the biggest drawbacks/cons of Python? And why choosing Python over JavaScript?

I want to be a Pentester (and It is my focus) and I like making the Front end side of websites and videogames. With JavaScript I can be a Frontend Developer and making games even for mobile thanks to React Native,Cordova and Ionic and inject Javascript on websites and many other things.

Actually I am interested on knowing more on Python and use It as a main language, but everyone say Python is only a "glue" language,It isn't easily scalable and maintainable than languages like Java and it isn't very suitable for concurrency and other things because it is slow.

On the other hand, I heard people very enthusiastic about Python and this language can do everything,but it is true?

Is Python more than a replacement of Bash?

Thank you!

/r/Python
https://redd.it/6x6oji
silly question about sessions

I'm using sessions in a current django project and recently got a 'Object of type 'date' is not JSON serializable' error.

Reading through the django docs on sessions I'm not clear why sessions use a serializer?

(I'm using the db to store the session)
From my understanding isn't just the session ID going to the browser in a cookie and the session data is stored in the db? The data in the session can be accessed via the ORM like a normal model. However when I look at the database table there is just one field, session_data (apart from expiry date and session id). Looking at the docs seems to be signed (but not encrypted? - not sure of the difference). So I'm not clear where the serializer is being used?

Additionally I was using django wizard before which stores intermediate data (such as the field causing the date issue above) in the session. I've now switched that part of the app to use seperate views for flexibility (signup wasn't just a linear path), but now have the 'not JSON serializable' error, how does django wizard get round this?

/r/djangolearning
https://redd.it/6x70xe
Search form with ManyToManyFields

I am creating a basic CRUD application using Django for the first time. I would love to have some guidance and direction regarding how to add a search form.

I need to create a search form for a `ServiceProvider` model. The search form has three text boxes to search for service providers by any or all of `location`, `memberships` and `expertise`. The latter two search fields are of `ManyToManyField` type.

These are the model definitions I have:

class ServiceProvider(models.Model):
provider_name = models.CharField(max_length=200)
created_date = models.DateTimeField(default=timezone.now)

# SEARCH FIELDS ->
location = models.CharField(max_length=100)
memberships = models.ManyToManyField(Memberships)
expertise = models.ManyToManyField(SkillAreas)


class Memberships(models.Model):
membership_name = models.CharField(max_length=200)
membership_description = models.TextField(blank=True, null=True)


class SkillAreas(models.Model):
skill_name = models.CharField(max_length=200)
skill_description = models.TextField(blank=True, null=True)



Though `memberships` is a multi select field in the backend, in the search field, user can only type one skill at the moment. Same goes for `expertise` field. How should I go about adding a search form for this `ServiceProvider`?

I found a solution for search for multiple fields in a stackoverflow [answer](https://stackoverflow.com/a/26640293): [Adding search to a Django site in a snap](https://www.julienphalip.com/blog/adding-search-to-a-django-site-in-a-snap/). In this solution, I didn't quite understand what Q is. Does this solution fit my need at all?

I also learned that there is something called `django-haystack`, but it feels a bit complex than the above solution and also I am not sure if it fits my need. Thanks in advance.


/r/djangolearning
https://redd.it/6wae1j
Conda can only be run in super

Hey everybody, just started to pick up Python and Django, and the class I'm following tells me to use conda to set up my venv. After a while of not getting anaconda to run, I fixed my .bash_profile so it can run, but when I run ``` $ conda``` it gives me the following error:

PermissionError: [Errno 13] Permission denied: '/Users/teddykoomen/anaconda3/lib/python3.6/site-packages/numba-0.33.0-py3.6-macosx-10.7-x86_64.egg-info/PKG-INFO'

When I run conda using ```$ sudo conda``` it does not give me the same error. I don't want to have to run conda as super every time. Any ideas? I've looked over stackoverflow and the anaconda docs and I couldn't find anything helpful. Thank you!

/r/Python
https://redd.it/6xci8y