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
Render just one MultiValueField field?

Is it possible to render only one specific MultiValueField field in Django 1.10.5?


/r/django
https://redd.it/70h4hk
When is an application too big for Flask?

I am currently doing a project using Flask and it is the first real application I'm building with it (as in, not following a tutorial or doing a school project, single-page type stuff). I have experience with Django and have chosen that most of the time after hearing advice that Django was better for larger applications. Not that it should have mattered, but I tend to dream big...so, just in case, right?

I am really loving this project and using Flask, which seems like the perfect tool for this. I'm using Blueprints to keep things organized and in a structure that is clean and makes sense. Now I'm wondering, at what point is an application so large that Flask wouldn't be a good option and what would make that the case? Even though a lot of stuff isn't built in as in some frameworks, there seem to be a lot of extensions that provide functionality. Plus, its really easy to write code in Flask. I have some trouble when the framework is too opinionated.

Anyway, my main question is, does it have to do with functionality, or some inability to handle larger amounts of requests that it is often reserved for smaller projects? And about scalability, is it not able to grow with increased demand?

I am really enjoying using Flask so far and love how much I can do in it without the framework yelling at me too much.

/r/flask
https://redd.it/70ovzc
New to Django, Assistance with "Tango with Django: 4.2 Serving static Files."

Hey All,
I recently purchased and am working my way through Tango with Django 1.9/1.10. I specifically having issues with [Section 4.2 Serving Static Files](https://leanpub.com/tangowithdjango19/read_sample)

**tango_with_django_project/settings.py**

STATIC_DIR = os.path.join(BASE_DIR, 'static')
INSTALLED_APPS = [
'...stuff...'
'django.contrib.staticfiles',
'rango',
]
STATIC_ROOT = str(os.path.join(BASE_DIR, 'static'))
STATIC_URL = '/static/'

despite reloading the lightweight server and doing a collectstatic I still cannot get the static directory to show up when navigating to it.

**Example URL 1:**

127.0.0.1:8000/static

or

**Example URL 2:**

127.0.0.1:8000/static/images/rango.jpg

if any one could give me some direction or help that would be greatly appreciated!

**EDIT:** I potentially seem to have solved my problem. It looks like what was missing was a ` STATICFILES_DIRS = [STATIC_DIR, ] ' declaration. Once this was in there the tag from the book appears to work. now all that seem to be broke is the media directory.

/r/djangolearning
https://redd.it/70s3ch
Newbie question: How to structure Django apps?

Hi all,

I have just recently started using Django to develop a risk management system (think ISO compliance and similar).

At its core, it's just a CRUD application and I'd like to structure it the right way from the beginning.

If I understand correctly, I should create a separate application for each individual part of the system. In order to determine this, my approach is 'does this part of the system make sense as a separate service?' and I've come with the following:
- Organization (details that are specific to the org, including offices, departments, etc)
- Assets (anything that need to be managed)
- Risks (anything related to risk, like default classification, controls, etc)
- Audits (reviews of risk against assets, including actions and reports). This is the actual core of the application.

Does this make sense or am I overcomplicating things?

If I am to do this, what is the right way to write the Audit application, directly calling the models or (in my opinion, cleaner), creating business logic that abstracts those models behind an opaque API?

Also, speaking of models, is the accepted way of doing models having a single file with all of the models inside or should I split those once I get to the tens of models?

Thanks!

/r/django
https://redd.it/70ml82
crispy-forms does not show errors in django 1.11

I use django v1.11 with django-crispy-forms==1.6.1 and I would render forms using crispy-forms but I can't get errors if exist, but when I use django==1.9 I got the errors.
Can anyone tell me whats wrong.
Thank you in advance

/r/django
https://redd.it/70q7gk
Can you automate with your job search/applications with a python script?

Hi,

I am new to python, have no computer background/experience but I am willing to learn it and I have been using codeacademy to learn the basics and will hopefully advance my further development. So far, it has been enjoyable 😊

The main reason why I want to learn python is because I would like to automate my job search and job applications. At the moment, I’ve been visiting several job sites (seek, trademe, craiglist etc) as well as company websites and then customizing my generic cover letter to be specific to the listed job role at the respective company. It is already a streamlined process but it is mostly a manual process which I feel can be automated with a script to do the entire job search process automatically.

Can python achieve this application? And if so, what python skills should I be specifically learning to do this? how can I narrow my python focus to achieve this?

Thanks!



/r/Python
https://redd.it/70qvav
What is your end-to-end Pythonic Data Science Project Technology Stack in 2017

We are building a new predictive analytics system, and we are in the middle of discussing the technology choices.

We have seen a lot of people using SMACK(Spark, Mesos, Akka, and Kafka), others use Storm but couldn't find an ideal choice for Pythonic guys who do data science.

I'd like to hear from you, what are you using to end-to-end solution.

/r/Python
https://redd.it/70tgfv
dynamically filtering results forQuick view display via HTML modal


Currently I'm using non-hardcoded urls to redirect users to a page with similar products by matching a barcode number.

views.py

def ItemView(request, barcode):
template_name = "TESTcategories.html"
products = Product.objects.filter(barcode=barcode)

context = {
'products': products,
}


return render_to_response(template_name, context)

urls.py

url(r'^item/(?P<barcode>[0-9]+)$', ItemView, name='ItemView'),

items.html

<h3 class="product-title"><a href="{% url 'ItemView' result.object.barcode %}">{{result.object.title}}</a></h3>

I'm passing the barcode arguments through based on the URL re-direct. Can I achieve a similar effect but for a 'quick view' option that will launch a pop up modal view. This is my potential modal:


partials/modal.html

<!-- Large Modal-->
<div class="modal fade" id="modalLarge" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Quick Item Compare</h4>
<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
</div>
<div class="modal-body">

<!-- Product in modal -->
<div class="table-responsive">
<table class="table">

{% for result in page_obj.object_list %}
<thead>
<tr>
<th></th>
<th>{{result.object.title}}</th>
<th></th>
<th></th>
<th>£{{result.object.price}}</th>
<th class="text-center"><a class="btn btn-sm btn-btn btn-success" href="{{result.object.url}}">Visit Site</a></th>

</tr>
</thead>
{% endfor %}

</table>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary btn-sm" type="button" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>


EDIT: In my modal.html the results are iterating against page_obj.object_list as I am using djang-haystack with elastic-search.


/r/djangolearning
https://redd.it/70uq8a
How to protect against package typosquatting when using pip?

New to Django and just bumped into the skcsirt-sa-20170909-pypi security annoucement (http://www.nbu.gov.sk/skcsirt-sa-20170909-pypi/index.html).

As a new user, how do I protect against that type of issue, where an attacker typosquatts a known package? Given that don't have anything done yet, just started learning Django, figure may be a good time to learn best practices to safeguard against the above issue.

/r/django
https://redd.it/70vf95
New version of our Jupyter Notebook client for iPad is available for beta testing now — bringing code completion, fixes and more.
https://kernels.io/kernels-v-1-0-3-beta/

/r/IPython
https://redd.it/70vekf