Act22-29Sep - Demo Mode in Apps - Refact of Django Views - Pythonanywhere - from Linux to Windows 11

Video thumbnail

    Welcome to another week of updates. I will comment on all the content I uploaded for the week of September 22nd to September 29th, which is the current date.

    Community Books

    As always, we start with the community books. We already have a ton of them, and this week CodeIgniter 4 is added with the first chapters.
    Remember that you can check the community books playlist section to see the details of each one. This time it corresponds mainly to the CRUD part:

    We also have books on Laravel, Django, Livewire, Bootstrap, Electron, FastAPI, and customizable animations with Flutter:

    
    And don't forget that the Django Shopping course and book are now available at academia.net
    . I recommend acquiring them as a package, to have the best of both worlds.

    YouTube and Blog

    Demo Mode

    I showed how to create a demo mode for the applications I upload to production. The idea is to block certain operations simply.
    This can be done with environment variables or, more elegantly, using a middleware that blocks POST requests if you are in demo mode.

    Create a DEMO Mode for your Application - EASY - https://youtu.be/XKlVWfUHh_k 

    View Refactoring

    A very interesting topic that is part of the Django Shopping course and book. Here we work with class-based views, which allows us to better encapsulate the logic and handle product payments, whether for books (specific) or generic products (like a desk), all from the same flow.

    From duplicate code to clean code in Django + AI - https://youtu.be/782phUsCHp0

    Gemini for translating Python .po files

    Another feature we tested was using Gemini (AI) to automatically translate .po files to Spanish.
    This saves us manual work and keeps the translation structure intact. A practical and almost foolproof integration.

    Using Gemini CLI and ChatGTP to Translate .po files for Django - https://youtu.be/tgbzFjrZJG8

    Deploy with PythonAnywhere

    I explained how to deploy a Django project on PythonAnywhere. The process includes:

  •         Create account and upload project via GitHub or file.    
  •      Configure requirements.txt, allowed_hosts, and static files.    
  •      Create virtual environment and migrate the database.    
  •      Define the WSGI file.    
  •      All of this can be done for free and easily.    

    Deploying a Web App in Django with PythonAnywhere - https://youtu.be/4O3cS7yqrbU

    Linux vs Windows

    I commented on an interesting video of a user who returned to Windows after 8 years on Linux.
    Although Linux offers more control and freedom, many configurations require time and not all programs are available. In the end, it depends on how you want to invest your time: learning and configuring Linux, or using Windows to focus directly on working.

    Tested Windows 11 after years on Linux and changed his mind - https://youtu.be/eYc-jWigfbk

    Generate 3D Models from Images

    I showed how, starting from a 2D image, we can generate a basic 3D mesh for sculpting in Blender.
    We use NanoBanana to obtain poses, load images into another program, and obtain an initial mesh which is then retopologized and customized.

    Convert images into 3D models in 5 minutes for modeling in Blender  - https://youtu.be/hKvbw4i-Yi0

    Course and Book on Django Shopping

  •         We continue working on internal configurations, such as the coupon system, so that it works with both types of products.
            The logic is organized into reusable base classes, which allows for creating new types of products modularly.    
  •      Template and Class Adaptation    
  •      For the payment part, we adjusted several templates (4 approx.) and server classes (5 or 6). The idea is to have an abstract and scalable system for reuse with any product.    
  •      Alerts and Dark Mode    
  •      We added a product purchased alert and enabled dark mode with Tailwind.
            Although I had a problem with Git (I forgot to pull and had to resolve a merge), it finally worked: now you can switch between light and dark mode.    

    Conclusion

    This would be all the content uploaded for the week: book updates, new features in the store, experiments with AI, deployments on PythonAnywhere, and visual improvements like dark mode.

        Django - Online Store    

        Various changes    

  1.             Coupon: Attribute to define the step                           

    1.                     We created an attribute to manage when we show the 'pay now' button and coupon input or the payment buttons.                

                      

  2.             Coupon: Pay now button                           

    1.                     We are going to implement the 'pay now' button                

                      

  3.             Coupon: Do not redirect to the next step if the coupon is invalid                           

    1.                     Do not go to the second step if the entered coupon is invalid.                

                      

  4.             Extra: Coupon: Client-side rendering logic                           

    1.                     We implemented a script with Alpine to avoid reloading the page when clicking 'pay now'.                

                      

  5.             Coupon: Display applied coupon information                           

    1.                     We display the coupon information, whether it was applied or an error occurred.                

                      

  6.             Coupon: Stripe, Adapt generating SessionID                           

    1.                     We show the changes made in the class that generates Stripe's SessionID.                

                      

  7.             Coupon: Process coupon in the purchase                           

    1.                     We are going to process the purchase and register the coupon.                

                      

  8.             Payment gateway, summary                           

    1.                     We provide a summary of the already finalized payment gateway                

                      

  9.             Coupon: Mark as consumed                           

    1.                     We implemented the function to mark a coupon as consumed                

                      

  10.             Abstract Class for the detail of purchasable products                           

    1.                     We generated the abstract class for the detail of the purchasable house.                

                      

  11.             Replicate in book                           

    1.                     We applied the changes to the purchasable book entity.                

                      

  12.             Coupon: Display applied coupon in the dashboard and search                           

    1.                     We are going to show whether or not a coupon is applied in the listing.                

                      

  13.             Coupon: Search by coupon in payments                           

    1.                     We are going to define a link to view the consumed coupon in the payments                

                      

  14.             Product purchased alert                           

    1.                     We show an alert to indicate that the product has already been purchased.                

                      

  15.             Dark Mode: How it works in Tailwind 4                           

    1.                     We talk about how dark mode works.                

                      

  16.             Dark Mode: Implement                           

    1.                     We allow switching between light and dark mode.                

                      

I agree to receive announcements of interest about this Blog.

Community Books YouTube/Blog - Demo Mode in Apps - Refactoring Views/Classes in Django - Pythonanywhere - From Linux to Windows 11 - Image to 3D Model in Blender Django Shopping Course/Book - Refactoring, Coupon Management

| 👤 Andrés Cruz

🇪🇸 En español