19 Jan 2021

feedDjango community aggregator: Community blog posts

Adding Social Authentication to Django

This tutorial details how to set up social auth with Django and Django Allauth.

19 Jan 2021 4:28am GMT

18 Jan 2021

feedDjango community aggregator: Community blog posts

Introducing JustDjango Salaries 💰

I'm excited to announce the launch of a new project: JustDjango Salaries - salary data for Django developers.

18 Jan 2021 2:47pm GMT

17 Jan 2021

feedDjango community aggregator: Community blog posts

How to implement Auto Expiring Token in Django Rest Framework

Describes how to implement custom token model and authentication backend in Django Rest Framework

17 Jan 2021 9:00am GMT

15 Jan 2021

feedDjango community aggregator: Community blog posts

Django News - CSS, PostgreSQL, Django Security with CI/CD, and more htmx resources - Jan 15th 2021

News

The State of CSS 2020: Trend Report

CSS is rapidly changing with utility-first frameworks like Tailwind CSS gaining rapid prominence. This is a fun, interactive look at a recent survey on current and future CSS trends.

stateofcss.com

Articles

Bringing Security along on the CI/CD journey

From Jacob Kaplan-Moss, a detailed look at how to integrate security with modern CI/CD practices.

jacobian.org

Re-Introducing Hash Indexes in PostgreSQL by Haki Benita

A very in-depth look at hash indexes within PostgreSQL and why they are more relevant than ever these days.

hakibenita.com

Detecting N+1 queries in Django with unit testing

A clever way to unit test for N+1 queries in your code.

valentinog.com

Interview with Andrew Godwin about deployment - Django deployment

From 2017 but still very relevant, an interview with on Django deployments with Andrew Godwin.

djangodeployment.com

Django migrations without downtimes

Originally from 2015 but updated a few times since then, this is a classic look at managing Django migrations on a large site without downtimes.

github.io

How to Override the gunicorn Server Header by Adam Johnson

Adam Johnson shows how to override Gunicorn's header which, by default, reports the complete version of Gunicorn being used: a security no-no.

adamj.eu

Sponsored Link

The Django SaaS Boilerplate

You want to get your project off the ground, but you're stuck re-implementing the same boring features. Pegasus handles the foundation of your application for you. Get a head start and launch faster than you dreamed possible. Use promo code "django-news" to get 20% off today.

saaspegasus.com

Podcasts

Django Riffs - Here, There, Middleware

On this episode, we will investigate Django middleware and see where it goes in your project. In the process, you'll see why middleware is useful and how you can work with it.

djangoriffs.com

Projects

hotwire-django/turbo-django

An early stage integration of Hotwire Turbo with Django

github.com

bigskysoftware/htmx

</> htmx - high power tools for HTML

github.com

adamchainz/django-htmx

Extensions for using Django with htmx.

github.com

Sponsorship

Sponsor Django News newsletter!

Reach over 1,600 engaged Django developers every week. Sponsorship availability, prices, and details are available here.

django-news.com


This RSS feed is published on https://django-news.com/. You can also subscribe via email.

15 Jan 2021 5:00pm GMT

Hangar's Dumb Security Questionnaire

Over on the Hangar tech blog, I've posted our Dumb Security Questionnaire (the questions we ask vendors to evaluate their security maturity). All DSQs are dumb, but I think ours is a little less dumb. If not, at least it's short.

15 Jan 2021 6:00am GMT

14 Jan 2021

feedDjango community aggregator: Community blog posts

Squashing Bugs - Building SaaS #87

In this episode, I fixed some critical issues that my customer discovered. My customer is putting the app through its real paces for a school year and since this is the first run, there were bound to be some bugs. We began with an explanation of the issues that my customer encountered. The problems related to scheduling. First, the daily page skipped a task and showed the task that was meant for two days in the future.

14 Jan 2021 6:00am GMT

13 Jan 2021

feedDjango community aggregator: Community blog posts

Why I'm excited to get a COVID vaccine

I'm terrifically excited to get a COVID vaccine. Not just "willing", but actually quite excited. mRNA vaccines are this generation's moonshot - a huge leap forward in science. Im terrifically excited to get to be part of it.

13 Jan 2021 6:00am GMT

12 Jan 2021

feedDjango community aggregator: Community blog posts

How to accept Paypal payments on your Django application

If you are developing a Django application and you want to accept Paypal payments, you are in the right place! In this tutorial you'll learn how to integrate Django and Paypal to accept payments in your Django web application.

Paypal is a popular solution for online payments. Even if nowadays there are many valid alternatives, Paypal is still a big player in the market with a solid reputation and it's trusted by millions of users.

Here is a simple step-by-step guide on how to integrate the django-paypal third party app on your website.

1. Install the django-paypal app

pip install django-paypal

2. Insert the app in your Django settings

INSTALLED_APPS = (
...
'paypal.standard.ipn', )

3. Insert a Paypal form on a view

Assuming you are using Django class-based views, you can use a FormView like this:

from django.views.generic import FormView
from django.urls import reverse
from paypal.standard.forms import PayPalPaymentsForm

class PaypalFormView(FormView):
    template_name = 'paypal_form.html'
    form_class = PaypalForm

    def get_initial(self):
        return {
            "business": 'your-paypal-business-address@example.com',
            "amount": 20,
"currency_code": "EUR", "item_name": 'Example item, "invoice": 1234, "notify_url": self.request.build_absolute_uri(reverse('paypal-ipn')), "return_url": self.request.build_absolute_uri(reverse('paypal-return')), "cancel_return": self.request.build_absolute_uri(reverse('paypal-cancel')), "lc": 'EN', "no_shipping": '1', }

This is a regular FormView and the template paypal_form.html is a standard Django template like this:

<html>
<body> {{ form.render }}
</body> </html>

Notice how we are settings some initial values for the Paypal form. Let us see all the parameters used here:

Some of this data will likely be dynamic, because it depends on the object you are selling.

4. Provide an URL for Paypal IPN

In your Django urls.py file, add an urlconf like this:

path('paypal/', include('paypal.standard.ipn.urls')),

5. Create views for success and failure of Paypal checkout

You can add two TemplateView to show your user a message upon success or failure of the Paypal checkout.

from django.views.generic import TemplateView

class PaypalReturnView(TemplateView):
    template_name = 'paypal_success.html'

class PaypalCancelView(TemplateView):
    template_name = 'paypal_cancel.html'

Then you can mount these views in your urls.py:

from . import views
urlpatterns = [
    path('/paypal-return/', views.PaypalReturnView.as_view(), name='paypal-return'),
    path('/paypal-cancel/', views.PaypalCancelView.as_view(), name='paypal-cancel'),
    ...
]

The names of the urls should match with those defined in the form initial data, as shown at step 3.

6. Setup a listener to detect successful Paypal payments

When a successful payment if performed on Paypal, you'll receive a so-called IPN: "Instant Payment Notification" from Paypal.

django-paypal uses the Django signal dispatcher to let you hook your code when a successful payment arrives. You can define a listener like this:

from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received @receiver(valid_ipn_received) def paypal_payment_received(sender, **kwargs): ipn_obj = sender if ipn_obj.payment_status == ST_PP_COMPLETED: # WARNING ! # Check that the receiver email is the same we previously # set on the `business` field. (The user could tamper with # that fields on the payment form before it goes to PayPal) if ipn_obj.receiver_email != 'your-paypal-business-address@example.com': # Not a valid payment return # ALSO: for the same reason, you need to check the amount # received, `custom` etc. are all what you expect or what # is allowed. try: my_pk = ipn_obj.invoice mytransaction = MyTransaction.objects.get(pk=my_pk) assert ipn_obj.mc_gross == mytransaction.amount and ipn_obj.mc_currency == 'EUR' except Exception: logger.exception('Paypal ipn_obj data not valid!') else: mytransaction.paid = True mytransaction.save() else: logger.debug('Paypal payment status not completed: %s' % ipn_obj.payment_status)

Here we assumed that you had a model MyTransaction on your Django application, and that you want to set the transaction as paid when the Paypal payment is confirmed.

That's it! Following these steps you should have a working Paypal integration in your Django project. Please let me know if you have questions or comments.

The post How to accept Paypal payments on your Django application appeared first on guguweb.com.

12 Jan 2021 6:34pm GMT

11 Jan 2021

feedDjango community aggregator: Community blog posts

Here, There, Middleware

Full show notes are available at https://www.mattlayman.com/django-riffs/11.

11 Jan 2021 9:19pm GMT

Episode 11 - Here, There, Middleware

On this episode, we will investigate Django middleware and see where it goes in your project. In the process, you'll see why middleware is useful and how you can work with it. Listen at djangoriffs.com. Last Episode On the last episode, we're going to look at working with users in a Django project. We'll see Django's tools for identifying users and checking what those users are permitted to do on your website.

11 Jan 2021 6:00am GMT

Bringing Security along on the CI/CD journey

Practical ways to bridge the gap between AppSec and Engineering.

11 Jan 2021 6:00am GMT

10 Jan 2021

feedDjango community aggregator: Community blog posts

Using MinIO to upload to a local S3 bucket in Django

Hi everyone! Some weeks ago I was doing a demo to my teammates, and one of the things that was more suprising for them was that I was able to do S3 uploads locally using "MinIO". Let me set the stage: Imagine you have a Django ImageField which uploads a picture to a AWS S3 bucket. How do you setup your local development environment without using a "development" AWS S3 Bucket?

10 Jan 2021 8:30pm GMT

08 Jan 2021

feedDjango community aggregator: Community blog posts

About Print Versions of "A Wedge of Django"

Due to a never ending set of logistical issues for the print versions of our Django Crash Course, A Wedge of Django, we have decided to cancel our attempt to handle printing it ourselves. This will free us up in order to finish it, as well as other books.

If you pre-ordered a print version of this book we have sent out emails asking if you want a refund or discount code for other purchases on this site, including the e-book version of Two Scoops of Django.

If you have not received this email and pre-ordered the book, please contact us at hi @ feldroy.com.

Finally, there is a significant possibility we will use Amazon's print-on-demand service to publish the book, in which case it will have to be purchased as an Amazon product.

Sincerely,
Daniel, Audrey, and Uma

08 Jan 2021 9:01pm GMT

Django News - Django 3.1.5 release - Jan 8th 2021

News

Django bugfix release: 3.1.5

A new bugfix release is out. As ever, staying on the latest version of Django is the #1 security step you can take on your projects. Here are the revelant docs for doing so.

djangoproject.com

htmx 1.1.0 Release

htmx is a promising new library that adds support for AJAX, CSS Transitions, WebSockets, and Server Sent Events directly in HTML.

htmx.org

Events

Python Web Conf 2021 CFP

The CFP closes on January 29, 2021.

papercall.io

Articles

My Python linting setup in 2020 :: sleepy yaks industries - Help teams delivering better products and applications

Linting is an automated style guide for personal or team use. Here's one approach for 2020 and beyond.

yaks.industries

Better Exception Output in Django's Test Runner With better-exceptions

Adding the better-exception package to Django's test runner which makes the standard assert statement much more usable.

adamj.eu

Designing Engineering Organizations

From Jacob Kaplan-Moss, a look at how to structure a larger engineering organizations.

jacobian.org

Using Django & AssemblyAI for More Accurate Twilio Call Transcriptions

In this tutorial, we'll record an outbound Twilio call recording to AssemblyAI's API to get significantly more accurate speech-to-text output.

fullstackpython.com

Understand Django: Serving Static Files

The 11th in a series from Matt Layman, this newest article focuses on serving static files within Django which is a non-trivial task. Matt is also featured on the Django Chat podcast this week!

mattlayman.com

Tutorials

Deploying Django to AWS ECS with Terraform

Terraform is an open-source infrastructure as code software tool that provides a consistent CLI workflow to manage hundreds of cloud services. This tutorial shows how to develop the high-level configuration files required to deploy a Django application to Amazon ECS.

testdriven.io

Sponsored Link

Find Django talent that will take your business to the next level.

We know how difficult it can be for businesses to acquire reliable talent that meets specific job needs. On more general job sites, your job listing can get buried under irrelevant or even bogus listings. Fortunately, we have a solution. With over 10k subscribers, our Django-specific job site has a large talent pool of developers from the Django community. We will help you get the Django developers your team needs.

Add your job listing (Use coupon code "50PERCENTOFF" to receive a 50% discount per listing)

djangocontracts.com

Podcasts

Django Chat: Telemedicine with Matt Layman

Matt is a Software Architect at Doctor on Demand and a prolific Django educator. We talk about Django at scale, leading a large engineering team, and teaching Django to newcomers.

djangochat.com

Projects

vinta/awesome-python

A curated list of awesome Python frameworks, libraries, software and resources.

github.com

benwilber/boltstream

Boltstream is a Live Video Streaming Website + Backend written in Django.

github.com

openwisp/django-loci

Reusable Django app for storing geographic and indoor coordinates. Maintained by the OpenWISP Project.

github.com

Qix-/better-exceptions

Pretty and useful exceptions in Python, automatically.

github.com

Django Blogs

A new website that is a directory of Django bloggers.

djangoblogs.com

Sponsorship

Sponsor Django News newsletter!

Reach over 1,500 engaged Django developers every week. Sponsorship availability, prices, and details are available here.

django-news.com


This RSS feed is published on https://django-news.com/. You can also subscribe via email.

08 Jan 2021 5:00pm GMT

07 Jan 2021

feedDjango community aggregator: Community blog posts

Testing Email Designs - Building SaaS #86

In this episode, I worked on the sign up confirmation email design. We customized the template and used MailHog to test the flow and see how the email appeared. After working on the email design, we switched to the landing page of the site to work on the pricing information. I started the stream by explaining that I'm working through some final tasks before launching the app more publicly. I covered why I am planning to send a sign up email and why I want to customize it.

07 Jan 2021 6:00am GMT

Telemedicine - Matt Layman

Support the Show

This podcast is a labor of love and does not have any ads or sponsors. To support the show, consider purchasing or recommending a book from LearnDjango.com or signing up for the free weekly Django News newsletter.

07 Jan 2021 12:00am GMT