Mandela’s Library of Alexandria

Man working with Internet-in-a-Box home page

Internet-in-a-Box learning content examples

Quality Content

Internet-in-a-Box shows you the latest Content Packs
installable in the languages your community needs (from online
libraries like
Kiwix,
OER2Go,
Archive.org)
then takes care of all the downloading details for you!

See

Mexico’s live demo

and our

medical examples

used by clinics in Asia and Africa especially, as hosted by
Wikipedia.

Schools can also choose among

almost 40 powerful apps

for teachers and students — optionally with a complete LMS
(learning management system) like Kolibri, Moodle, Nextcloud,
Sugarizer or WordPress.

Two Haitian schoolgirls working on a laptop

Friendly Community

Internet-in-a-Box is a

community product

enabled by professional volunteers working

side-by-side

with schools, clinics and libraries around the world — and the

Wikipedia community

especially.

Thank you everyone for humbly being part of this

OFF.NETWORK

grassroots learning

movement
.

Please consider

how you too might assist

this epic effort.
It’s astonishing how far we’ve come since Internet-in-a-Box’s
original demo in 2013 — and how far we will go together,
If You Too Can Help!

Read More

Django Views – The Right Way

Welcome to my opinionated guide on how to write views in Django!

It is the result of mistakes made and lessons learned in a range of
Django and Python projects over 15+ years.

It has also been prompted by the fact that “Class Based Views” (CBVs from now
on) seem to have become the default way to teach and learn Django views in some
circles, to the point that some are even scared to write “Function Based Views”
(FBVs).

Perhaps worst of all, some official Django documentation has well-intentioned
advise that will help to continue the torture of mixins
, but
without actually killing you and putting you out of your misery. (After a bit of
“git blaming” it turns out that I’m credited
in the commit log for that page. I hate it when that happens…)

So, in view of all this, here I am to save the day, and show you The Right Way
:-)

The essential part of this guide is very short, because FBVs are very easy and
simple. In fact, the Django tutorial for views already has all you
need to know. Just read that, and skip the bits about CBVs, and you’ll be fine.

But if you want a different take on the same things, this guide might be for
you. I’ve also added extra bits for common tasks and patterns in FBVs for which
CBVs are often suggested as the solution. I have a few aims:

  • I want to show how simple and easy views can be.

  • I want you to be freed from learning a whole stack of additional APIs that
    were only making your life harder (and teaching you bad patterns).

  • Instead of learning a bunch of Django specific APIs, I want to cover much more
    transferable knowledge:

    • HTTP principles

    • General OOP/multi-paradigm programming principles

    • General Python techniques

And there are some other goodies along the way, like how to type-check all the
URL parameters to your view functions.

Each page is composed of two parts, which have two different audiences.

First, the business — the what and how: a short, definitive guide to The
Right Way. As a less experienced developer, either in general or in terms of
knowledge of Django, this part is all you need. Since this guide is not intended
to be reference documentation, I’ll include various links to the official Django
reference docs. All example code can be found in full in the GitHub repo.

Second, discussion — the why: a longer, in-depth explanation of why everyone
else who tells you differently is wrong :-). It’s targeted at slightly more
experienced developers, and especially those who are responsible for teaching
other people, or making decisions about the patterns used in a code base. These
discussion sections are really about general programming principles, and how
they apply in Python and Django.

So let’s go!

Something missing? This guide is a work in progress, and no matter how much
I add it probably always will be! If you have requests for things to include,
you could file an issue on GitHub.

  1. Yes, there may in fact be more than one Right Way. But not in this guide!

  2. I’m assuming you are writing a ‘classic’ web app or web site — in which
    most of your pages are server-side rendered HTML, with perhaps some Javascript
    loaded onto those pages, as opposed to a site where your server mostly sends
    data (e.g. JSON) to a client-side Javascript web app that puts the pages together.

  3. My comments mainly apply to the CBVs that come with Django. Specifically,
    many of my criticisms don’t apply to Django Rest Framework, the Django admin
    (which uses a form of CBV), and possibly other implementations. See later
    discussion on this.

  4. Although I’m a Django core dev, I’m not speaking for all the Django
    developers. I was actually around when CBVs were first being added to Django,
    and even involved in the design of them a bit, and at the time didn’t see the
    things I’m expressing now. So please understand my criticisms as a form of
    “learning process debate”, rather than as attacks!

  5. I’m assuming Python 3.9 or later, and any “recent” version of Django (which
    is 3.2 or later at the time of writing). Almost everything will apply to
    older (or newer) versions.

Read More

By |2023-06-10T19:14:27+00:00June 10, 2023|Life and Health|0 Comments

About the Author:

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Go to Top