<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sumit goyal on Medium]]></title>
        <description><![CDATA[Stories by Sumit goyal on Medium]]></description>
        <link>https://medium.com/@qsys400?source=rss-976e1735e5e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4KcDS691G6D162Q4pRiBow.jpeg</url>
            <title>Stories by Sumit goyal on Medium</title>
            <link>https://medium.com/@qsys400?source=rss-976e1735e5e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:31:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@qsys400/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Django Class based views: 09 RedirectView]]></title>
            <link>https://medium.com/djangobasics/django-class-based-views-09-redirectview-d2e45c57901e?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2e45c57901e</guid>
            <category><![CDATA[djnago-clas]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Wed, 10 Sep 2025 14:54:49 GMT</pubDate>
            <atom:updated>2025-09-10T14:54:49.412Z</atom:updated>
            <content:encoded><![CDATA[<h3>RedirectView</h3><pre>from django.views.generic.base import RedirectView</pre><h3>Mixin and classes used:</h3><pre>RedirectView<br>├── TemplateResponseMixin<br>├── ContextMixin<br>└── View</pre><pre>| Mixin/Class               | Purpose                                                                 |<br>|---------------------------|-----------------------------------------------------------------------------|<br>| RedirectView              | Handles HTTP redirects (temporary or permanent).                           |<br>| TemplateResponseMixin     | Provides functionality for rendering templates (if needed).              |<br>| ContextMixin              | Adds extra context to the template (if applicable).                       |<br>| View                      | Base class for all views, handles HTTP method dispatching.                 |</pre><h3>Properties:</h3><pre>| Property          | Source                 | Description                                                                 |<br>|--------------------|-----------------------|---------------------------------------------------------------------------------|<br>| url                | RedirectView          | Specifies the target URL to redirect to.                                        |<br>| permanent          | RedirectView          | Determines whether the redirect is permanent (301) or temporary (302).      |<br>| query_string       | RedirectView          | Determines whether query parameters are passed to the redirect URL.             |<br>| pattern_name       | RedirectView          | Specifies the name of the URL pattern to reverse for the redirect.              |<br>| template_name      | TemplateResponseMixin | Specifies the name of the template to render (if applicable).                   |<br>| template_engine    | TemplateResponseMixin | Specifies the template engine to use.                                           |<br>| response_class     | TemplateResponseMixin | Specifies the response class used to render the template.                       |<br>| content_type       | TemplateResponseMixin | Specifies the content type of the response.                                     |<br>| extra_context      | ContextMixin          | A dictionary of additional context data to pass to the template (if applicable).|<br>| http_method_names  | View                  | A list of HTTP methods that the view can handle.                                |<br>| view_is_async      | View                  | Determines whether the view&#39;s HTTP handlers are synchronous or asynchronous.    |<br></pre><h3>Method call sequence:</h3><p><strong>For a GET Request:</strong></p><ol><li><strong>as_view():</strong></li><li><strong>setup():</strong></li><li><strong>dispatch():</strong></li><li><strong>get():</strong></li></ol><ul><li>Handles GET requests.</li><li>Calls get_redirect_url() to determine the URL to redirect to.</li><li>Returns an HttpResponseRedirect or HttpResponsePermanentRedirect based on the permanent attribute.</li></ul><p><strong>5. get_redirect_url():</strong></p><ul><li>Determines the URL to redirect to.</li><li>Uses the url or pattern_name attributes, and optionally appends query strings if query_string=True.</li></ul><pre>from django.views.generic.base import RedirectView<br>from django.urls import reverse_lazy<br><br>class StaticRedirectView(RedirectView):<br>    &quot;&quot;&quot;<br>    Redirects to a static URL.<br>    &quot;&quot;&quot;<br>    url = &#39;https://www.djangoproject.com/&#39;  # Target URL for the redirect<br>    permanent = True  # Use a permanent redirect (301)<br><br><br>class DynamicRedirectView(RedirectView):<br>    &quot;&quot;&quot;<br>    Redirects to a dynamic URL using a URL pattern name.<br>    &quot;&quot;&quot;<br>    pattern_name = &#39;target_view&#39;  # Reverse the URL pattern dynamically<br>    permanent = False  # Use a temporary redirect (302)<br>    query_string = True  # Pass query parameters to the redirect URL<br><br>    def get_redirect_url(https://medium.com/self,%20*args,%20**kwargs):<br>        &quot;&quot;&quot;<br>        Optionally override this method to customize the redirect URL.<br>        &quot;&quot;&quot;<br>        # Add custom logic if needed<br>        return super().get_redirect_url(https://medium.com/*args,%20**kwargs)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2e45c57901e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/djangobasics/django-class-based-views-09-redirectview-d2e45c57901e">Django Class based views: 09 RedirectView</a> was originally published in <a href="https://medium.com/djangobasics">DjangoBasics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django Class based views: 05 UpdateView]]></title>
            <link>https://medium.com/djangobasics/django-class-based-views-05-updateview-7bb98ab95ae3?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bb98ab95ae3</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[django-class-based-views]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Tue, 13 May 2025 18:10:00 GMT</pubDate>
            <atom:updated>2025-05-13T18:10:00.162Z</atom:updated>
            <content:encoded><![CDATA[<h3>UpdateView</h3><pre>from django.views.generic.edit import UpdateView</pre><h3>Mixin and classes used:</h3><pre>UpdateView<br>├── BaseUpdateView<br>│   ├── ModelFormMixin<br>│   ├── SingleObjectMixin<br>│   ├── ProcessFormView<br>├── TemplateResponseMixin<br>├── ContextMixin<br>└── View</pre><pre>| Mixin/Class             | Purpose                                                                 |<br>|-------------------------|-----------------------------------------------------------------------------|<br>| ModelFormMixin          | Handles model form initialization, validation, and saving updated objects. |<br>| SingleObjectMixin       | Retrieves a single object based on URL parameters (e.g., pk or slug).  |<br>| ProcessFormView         | Handles HTTP methods (GET and POST) for forms.                         |<br>| BaseUpdateView          | Combines ModelFormMixin and ProcessFormView for object updates.         |<br>| TemplateResponseMixin   | Provides functionality for rendering templates.                          |<br>| ContextMixin            | Adds extra context to the template.                                         |<br>| View                    | Base class for all views, handles HTTP method dispatching.                 |</pre><h3>Properties:</h3><pre>| Property           | Source                | Description                                                                 |<br>|--------------------|-----------------------|---------------------------------------------------------------------------------|<br>| model              | ModelFormMixin        | Specifies the model to use for updating the object.                             |<br>| fields             | ModelFormMixin        | Specifies the fields of the model to include in the form.                       |<br>| form_class         | ModelFormMixin        | Specifies the form class to use for rendering and processing the form.          |<br>| initial            | ModelFormMixin        | A dictionary of initial data to prepopulate the form fields.                    |<br>| success_url        | ModelFormMixin        | The URL to redirect to after successful form submission.                        |<br>| prefix             | ModelFormMixin        | A string to prefix form field names.                                            |<br>| queryset           | SingleObjectMixin     | Specifies the queryset to retrieve the object.                                  |<br>| pk_url_kwarg       | SingleObjectMixin     | The name of the URL parameter for the object&#39;s primary key.                     |<br>| slug_url_kwarg     | SingleObjectMixin     | The name of the URL parameter for the object&#39;s slug.                            |<br>| slug_field         | SingleObjectMixin     | The name of the model field to use for the slug.                                |<br>| template_name      | TemplateResponseMixin | Specifies the name of the template to render.                                   |<br>| template_engine    | TemplateResponseMixin | Specifies the template engine to use.                                           |<br>| response_class     | TemplateResponseMixin | Specifies the response class used to render the template.                       |<br>| content_type       | TemplateResponseMixin | Specifies the content type of the response.                                     |<br>| extra_context      | ContextMixin          | A dictionary of additional context data to pass to the template.                |<br>| http_method_names  | View                  | A list of HTTP methods that the view can handle.                                |<br>| view_is_async      | View                  | Determines whether the view&#39;s HTTP handlers are synchronous or asynchronous.    |<br></pre><h3>Method call sequence:</h3><p><strong>For a GET Request:</strong></p><ol><li>as_view():</li></ol><ul><li>Entry point for the request-response process.</li><li>Creates an instance of the view and calls dispatch().</li></ul><p><strong>2. setup():</strong></p><ul><li>Initializes attributes shared by all view methods, such as request, args, and kwargs.</li></ul><p><strong>3. dispatch():</strong></p><ul><li>Determines the HTTP method (e.g., GET, POST) and routes the request to the appropriate handler method (get()).</li></ul><p><strong>4. get():</strong></p><ul><li>Handles GET requests.</li><li>Calls get_object() to retrieve the object to be updated.</li><li>Calls get_form() to initialize the form with the object’s data.</li><li>Calls get_context_data() to prepare the context.</li><li>Calls render_to_response() to render the template with the form.</li></ul><p><strong>5. get_object()</strong>:</p><ul><li>Retrieves the object to be updated.</li><li>Uses the pk or slug from the URL to fetch the object.</li></ul><p><strong>6. get_form_kwargs()</strong>:</p><ul><li>Prepares the keyword arguments to pass to the form’s constructor.</li><li>Includes the instance (the object being updated).</li></ul><p><strong>7. get_initial()</strong>:</p><ul><li>Provides initial data for the form.</li></ul><p><strong>8. get_form()</strong>:</p><ul><li>Initializes the form instance using the form class and the keyword arguments.</li></ul><p><strong>9. get_context_data():</strong></p><ul><li>Prepares the context data for the template.</li></ul><p><strong>10. render_to_response():</strong></p><ul><li>Renders the template with the context data.</li></ul><p><strong>For a POST Request:</strong></p><ol><li><strong>as_view()</strong></li><li><strong>setup()</strong></li><li><strong>dispatch()</strong></li><li><strong>post():</strong></li></ol><ul><li>Handles POST requests.</li><li>Calls get_object() to retrieve the object to be updated.</li><li>Calls get_form() to initialize the form with submitted data.</li><li>Validates the form.</li></ul><p><strong>5. get_object()</strong></p><p><strong>6. get_form_kwargs()</strong></p><p><strong>7. get_initial()</strong></p><p><strong>8. get_form()</strong></p><p><strong>9. form_valid()</strong> (if the form is valid):</p><ul><li>Saves the form and updates the object.</li><li>Redirects to the success URL.</li></ul><p><strong>10. form_invalid()</strong> (if the form is invalid):</p><ul><li>Re-renders the form with error messages.</li></ul><p><strong>11. get_success_url()</strong>:</p><ul><li>Returns the URL to redirect to after successfully updating the object.</li></ul><p><strong>12. render_to_response()</strong> (if the form is invalid).</p><pre>from django.views.generic.edit import UpdateView<br>from django.urls import reverse_lazy<br>from .models import MyModel<br><br>class MyUpdateView(UpdateView):<br>    model = MyModel  # The model to update<br>    fields = [&#39;name&#39;, &#39;description&#39;]  # Fields to include in the form<br>    template_name = &quot;my_app/update_form.html&quot;  # Template to render the form<br>    success_url = reverse_lazy(&#39;success&#39;)  # URL to redirect to after successful update<br><br>    def form_valid(self, form):<br>        # Custom logic after the form is successfully validated<br>        print(&quot;Form is valid!&quot;)<br>        return super().form_valid(form)<br><br>    def form_invalid(self, form):<br>        # Custom logic when the form is invalid<br>        print(&quot;Form is invalid!&quot;)<br>        return super().form_invalid(form)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bb98ab95ae3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/djangobasics/django-class-based-views-05-updateview-7bb98ab95ae3">Django Class based views: 05 UpdateView</a> was originally published in <a href="https://medium.com/djangobasics">DjangoBasics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django Class based views: 04 CreateView]]></title>
            <link>https://medium.com/djangobasics/django-class-based-views-04-createview-dcdb36febd1a?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcdb36febd1a</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[django-class-based-views]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Tue, 13 May 2025 18:09:45 GMT</pubDate>
            <atom:updated>2025-05-13T18:09:45.848Z</atom:updated>
            <content:encoded><![CDATA[<h3>CreateView</h3><pre>from django.views.generic.edit import CreateView</pre><h3>Mixins and classes used:</h3><pre>CreateView<br>├── BaseCreateView<br>│   ├── ModelFormMixin<br>│   ├── ProcessFormView<br>├── TemplateResponseMixin<br>├── ContextMixin<br>└── View</pre><h3>Properties:</h3><pre>| Property           | Source                | Description                                                                     |<br>|--------------------|-----------------------|---------------------------------------------------------------------------------|<br>| model              | ModelFormMixin        | Specifies the model to use for creating the object.                             |<br>| fields             | ModelFormMixin        | Specifies the fields of the model to include in the form.                       |<br>| form_class         | ModelFormMixin        | Specifies the form class to use for rendering and processing the form.          |<br>| initial            | ModelFormMixin        | A dictionary of initial data to prepopulate the form fields.                    |<br>| success_url        | ModelFormMixin        | The URL to redirect to after successful form submission.                        |<br>| prefix             | ModelFormMixin        | A string to prefix form field names.                                            |<br>| template_name      | TemplateResponseMixin | Specifies the name of the template to render.                                   |<br>| template_engine    | TemplateResponseMixin | Specifies the template engine to use.                                           |<br>| response_class     | TemplateResponseMixin | Specifies the response class used to render the template.                       |<br>| content_type       | TemplateResponseMixin | Specifies the content type of the response.                                     |<br>| extra_context      | ContextMixin          | A dictionary of additional context data to pass to the template.                |<br>| http_method_names  | View                  | A list of HTTP methods that the view can handle.                                |<br>| view_is_async      | View                  | Determines whether the view&#39;s HTTP handlers are synchronous or asynchronous.    |</pre><h3>Method call sequence:</h3><p><strong>For a GET Request:</strong></p><ol><li><strong>as_view():</strong></li></ol><ul><li>Entry point for the request-response process.</li><li>Creates an instance of the view and calls dispatch().</li></ul><p><strong>2. setup():</strong></p><ul><li>Initializes attributes shared by all view methods, such as request, args, and kwargs.</li></ul><p><strong>3. dispatch():</strong></p><ul><li>Determines the HTTP method (e.g., GET, POST) and routes the request to the appropriate handler method (get()).</li></ul><p><strong>4. get():</strong></p><ul><li>Handles GET requests.</li><li>Calls get_form() to initialize the form.</li><li>Calls get_context_data() to prepare the context.</li><li>Calls render_to_response() to render the template with the form.</li></ul><p><strong>5. get_form_kwargs()</strong>:</p><ul><li>Prepares the keyword arguments to pass to the form’s constructor.</li></ul><p><strong>6. get_initial()</strong>:</p><ul><li>Provides initial data for the form.</li></ul><p><strong>7. get_form()</strong>:</p><ul><li>Initializes the form instance using the form class and the keyword arguments.</li></ul><p><strong>8. get_context_data()</strong>:</p><ul><li>Prepares the context data for the template.</li></ul><p><strong>9. render_to_response()</strong>:</p><ul><li>Renders the template with the context data.</li></ul><p><strong>For a POST Request:</strong></p><ol><li><strong>as_view()</strong></li><li><strong>setup()</strong></li><li><strong>dispatch()</strong></li><li><strong>post():</strong></li></ol><ul><li>Handles POST requests.</li><li>Calls get_form() to initialize the form with submitted data.</li><li>Validates the form.</li></ul><p><strong>5. get_form_kwargs()</strong></p><p><strong>6. get_initial()</strong></p><p><strong>7. get_form()</strong></p><p><strong>8. form_valid()</strong> (if the form is valid):</p><ul><li>Saves the form and creates the object.</li><li>Redirects to the success URL.</li></ul><pre>If the Form is Valid<br>post() → get_form() → is_valid() → form_valid() → save() → get_success_url() → Redirect to success_url.</pre><p><strong>9. form_invalid()</strong> (if the form is invalid):</p><ul><li>Re-renders the form with error messages.</li></ul><pre>If the Form is Invalid<br>post() → get_form() → is_valid() → form_invalid() → render_to_response() → Re-render the form with errors.</pre><p><strong>10. get_success_url()</strong>:</p><ul><li>Returns the URL to redirect to after successfully creating the object.</li></ul><p><strong>11. render_to_response() </strong>(if the form is invalid).</p><pre>from django.views.generic.edit import CreateView<br>from django.urls import reverse_lazy<br>from .models import MyModel<br><br>class MyCreateView(CreateView):<br>    model = MyModel  # The model to create<br>    fields = [&#39;name&#39;, &#39;description&#39;]  # Fields to include in the form<br>    template_name = &quot;my_app/create_form.html&quot;  # Template to render the form<br>    success_url = reverse_lazy(&#39;success&#39;)  # URL to redirect to after successful creation<br><br>    def form_valid(self, form):<br>        # Custom logic after the form is successfully validated<br>        print(&quot;Form is valid!&quot;)<br>        return super().form_valid(form)<br><br>    def form_invalid(self, form):<br>        # Custom logic when the form is invalid<br>        print(&quot;Form is invalid!&quot;)<br>        return super().form_invalid(form)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcdb36febd1a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/djangobasics/django-class-based-views-04-createview-dcdb36febd1a">Django Class based views: 04 CreateView</a> was originally published in <a href="https://medium.com/djangobasics">DjangoBasics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django Class based views: 03 FormView]]></title>
            <link>https://medium.com/djangobasics/django-class-based-views-03-formview-782dc0e2a4d2?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/782dc0e2a4d2</guid>
            <category><![CDATA[django-class-based-views]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Tue, 13 May 2025 17:47:43 GMT</pubDate>
            <atom:updated>2025-05-13T17:47:43.489Z</atom:updated>
            <content:encoded><![CDATA[<h3>FormView</h3><pre>from django.views.generic.edit import FormView</pre><h3>Mixins and classes used:</h3><pre>FormView<br>├── FormMixin<br>├── ProcessFormView<br>│   ├── View<br>├── TemplateResponseMixin<br>├── ContextMixin<br>└── View</pre><h3>Properties:</h3><pre>| Property              | Source                | Description                                                                 |<br>|-----------------------|-----------------------|---------------------------------------------------------------------------------|<br>| form_class            | FormMixin             | Specifies the form class to use for rendering and processing the form.          |<br>| initial               | FormMixin             | A dictionary of initial data to prepopulate the form fields.                    |<br>| success_url           | FormMixin             | The URL to redirect to after successful form submission.                        |<br>| prefix                | FormMixin             | A string to prefix form field names.                                            |<br>| template_name         | TemplateResponseMixin | Specifies the name of the template to render.                                   |<br>| template_engine       | TemplateResponseMixin | Specifies the template engine to use.                                           |<br>| response_class        | TemplateResponseMixin | Specifies the response class used to render the template.                       |<br>| content_type          | TemplateResponseMixin | Specifies the content type of the response.                                     |<br>| extra_context         | ContextMixin          | A dictionary of additional context data to pass to the template.                |<br>| http_method_names     | View                  | A list of HTTP methods that the view can handle.                                |<br>| view_is_async         | View                  | Determines whether the view&#39;s HTTP handlers are synchronous or asynchronous.    |</pre><h3>Method call sequence:</h3><p><strong>For a GET Request:</strong></p><ol><li><strong>as_view():</strong></li></ol><ul><li>Entry point for the request-response process.</li><li>Creates an instance of the view and calls dispatch().</li></ul><p><strong>2. setup():</strong></p><ul><li>Initializes attributes shared by all view methods, such as request, args, and kwargs.</li></ul><p><strong>3. dispatch():</strong></p><ul><li>Determines the HTTP method (e.g., GET, POST) and routes the request to the appropriate handler method (get()).</li></ul><p><strong>4. get():</strong></p><ul><li>Handles GET requests.</li><li>Calls get_form() to initialize the form.</li><li>Calls get_context_data() to prepare the context.</li><li>Calls render_to_response() to render the template with the form.</li></ul><p><strong>5. get_form_kwargs()</strong>:</p><ul><li>Prepares the keyword arguments to pass to the form’s constructor.</li></ul><p><strong>6. get_initial()</strong>:</p><ul><li>Provides initial data for the form.</li></ul><p><strong>7. get_form()</strong>:</p><ul><li>Initializes the form instance using the form class and the keyword arguments.</li></ul><p>8. <strong>get_context_data():</strong></p><ul><li>Prepares the context data for the template.</li></ul><p><strong>9. render_to_response():</strong></p><ul><li>Renders the template with the context data.</li></ul><p><strong>For a POST Request:</strong></p><ol><li><strong>as_view()</strong></li><li><strong>setup()</strong></li><li><strong>dispatch()</strong></li><li><strong>post():</strong></li></ol><ul><li>Handles POST requests.</li><li>Calls get_form() to initialize the form with submitted data.</li><li>Validates the form.</li></ul><p><strong>5. get_form_kwargs()</strong></p><p><strong>6. get_initial()</strong></p><p><strong>7. get_form()</strong></p><p><strong>8. form_valid()</strong> (if the form is valid):</p><ul><li>Processes the form data and redirects to the success URL.</li></ul><p><strong>9. form_invalid()</strong> (if the form is invalid):</p><ul><li>Re-renders the form with error messages.</li></ul><p><strong>10. get_success_url()</strong>:</p><ul><li>Returns the URL to redirect to after successfully processing the form.</li></ul><p><strong>11. render_to_response() </strong>(if the form is invalid).</p><pre>from django.views.generic.edit import FormView<br>from django import forms<br><br>class MyForm(forms.Form):<br>    name = forms.CharField(max_length=100, required=True)<br>    email = forms.EmailField(required=True)<br>    message = forms.CharField(widget=forms.Textarea, required=True)<br><br><br>class MyFormView(FormView):<br>    template_name = &quot;my_app/form.html&quot;  # Template to render the form<br>    form_class = MyForm  # The form class to use<br>    success_url = &quot;/success/&quot;  # URL to redirect to after successful form submission<br><br>    def form_valid(self, form):<br>        # Custom logic after the form is successfully validated<br>        print(&quot;Form is valid!&quot;)<br>        # You can access form.cleaned_data here<br>        print(form.cleaned_data)<br>        return super().form_valid(form)<br><br>    def form_invalid(self, form):<br>        # Custom logic when the form is invalid<br>        print(&quot;Form is invalid!&quot;)<br>        return super().form_invalid(form)<br><br>    def get_context_data(self, **kwargs):<br>        # Add extra context to the template<br>        context = super().get_context_data(**kwargs)<br>        context[&#39;extra_data&#39;] = &quot;Some extra data for the template&quot;<br>        return context</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=782dc0e2a4d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/djangobasics/django-class-based-views-03-formview-782dc0e2a4d2">Django Class based views: 03 FormView</a> was originally published in <a href="https://medium.com/djangobasics">DjangoBasics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django Class based views: 02 TemplateView]]></title>
            <link>https://medium.com/djangobasics/django-class-based-views-02-templateview-d54e55f09f7d?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d54e55f09f7d</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[django-class-based-views]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Fri, 11 Apr 2025 03:46:53 GMT</pubDate>
            <atom:updated>2025-04-11T03:46:53.573Z</atom:updated>
            <content:encoded><![CDATA[<h3>TemplateView</h3><pre>from django.views.generic.base import TemplateView</pre><h3>Mixins and classes used:</h3><pre>TemplateView<br>├── TemplateResponseMixin<br>├── ContextMixin<br>└── View</pre><ol><li><strong>TemplateResponseMixin</strong></li></ol><ul><li>Provides functionality for rendering templates.</li></ul><p>Key properties:</p><ul><li>template_name: Specifies the name of the template to render.</li><li>template_engine: Specifies the template engine to use.</li><li>response_class: Specifies the response class (default: TemplateResponse).</li><li>content_type: Specifies the content type of the response.</li></ul><p>Key method:</p><ul><li>render_to_response(context, **response_kwargs): Renders the template with the given context.</li></ul><p><strong>2. ContextMixin</strong></p><ul><li>Provides functionality for passing additional context to the template.</li></ul><p>Key property:</p><ul><li>extra_context: Allows adding custom context data.</li></ul><p>Key method:</p><ul><li>get_context_data(**kwargs): Returns the context data for the template.</li></ul><p><strong>3. View</strong></p><ul><li>The base class for all views.</li><li>Handles HTTP method dispatching (e.g., get, post, etc.).</li></ul><p>Key property:</p><ul><li>http_method_names: A list of allowed HTTP methods (default: [‘get’, ‘post’, ‘put’, ‘patch’, ‘delete’, ‘head’, ‘options’, ‘trace’]).</li></ul><h3>Properties:</h3><pre>| Property              | Source                   | Description                                                            |<br>|-----------------------|--------------------------|---------------------------------------------------------------------------------|<br>| template_name         | TemplateResponseMixin    | Specifies the name of the template to render.                                   |<br>| template_engine       | TemplateResponseMixin    | Specifies the template engine to use.                                           |<br>| response_class        | TemplateResponseMixin    | Specifies the response class used to render the template.                       |<br>| content_type          | TemplateResponseMixin    | Specifies the content type of the response.                                     |<br>| extra_context         | ContextMixin             | Allows adding additional context to the template.                               |<br>| http_method_names     | View                     | A list of HTTP methods that the view can handle.                                |<br>| view_is_async         | View                     | Determines whether the view&#39;s HTTP handlers are synchronous or asynchronous.    | </pre><h3>Method call sequence:</h3><p><strong>For a GET Request:</strong></p><ol><li><strong>as_view():</strong></li></ol><ul><li>Entry point for the request-response process.</li><li>Creates an instance of the view and calls dispatch().</li></ul><p>2. <strong>setup():</strong></p><ul><li>Initializes attributes shared by all view methods, such as request, args, and kwargs.</li></ul><p>3. <strong>dispatch():</strong></p><ul><li>Determines the HTTP method (e.g., GET, POST) and routes the request to the appropriate handler method (get()).</li></ul><p>4. <strong>get():</strong></p><ul><li>Handles GET requests.</li><li>Calls get_context_data() to prepare the context for the template.</li><li>Calls render_to_response() to render the template with the context.</li></ul><p>5. <strong>get_context_data():</strong></p><ul><li>Prepares the context data for the template.</li><li>Adds any extra context if defined.</li></ul><p>6. <strong>render_to_response():</strong></p><ul><li>Renders the template with the context data.</li><li>Uses the response_class (default: TemplateResponse) to generate the response.</li></ul><p>7. <strong>get_template_names():</strong></p><ul><li>Returns the list of template names to be used for rendering.</li></ul><pre>from django.views.generic.base import TemplateView<br><br>class MyTemplateView(TemplateView):<br>    template_name = &quot;my_app/example.html&quot;  # Specify the template to render<br><br>    def get_context_data(self, **kwargs):<br>        # Add extra context data to the template<br>        context = super().get_context_data(**kwargs)<br>        context[&#39;title&#39;] = &quot;Welcome to My Template View&quot;<br>        context[&#39;message&#39;] = &quot;This is a simple example of TemplateView.&quot;<br>        return context</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d54e55f09f7d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/djangobasics/django-class-based-views-02-templateview-d54e55f09f7d">Django Class based views: 02 TemplateView</a> was originally published in <a href="https://medium.com/djangobasics">DjangoBasics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django Class based views: 01 View]]></title>
            <link>https://medium.com/djangobasics/django-class-based-views-01-view-3a15f8c868b1?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a15f8c868b1</guid>
            <category><![CDATA[django-class-based-views]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Fri, 28 Mar 2025 13:30:44 GMT</pubDate>
            <atom:updated>2025-03-28T13:30:44.602Z</atom:updated>
            <content:encoded><![CDATA[<h3>View:</h3><pre>from django.views import View</pre><h3>Mixin and classes used</h3><ul><li><strong>Mixins Used</strong>: None</li><li><strong>Base Class</strong>: object (Python&#39;s default base class)</li></ul><h3>Properties:</h3><ol><li><strong>http_method_names</strong></li></ol><ul><li>A list of HTTP methods that the view can handle.</li><li>Default: [‘get’, ‘post’, ‘put’, ‘patch’, ‘delete’, ‘head’, ‘options’, ‘trace’]</li></ul><p>2. <strong>view_is_async</strong></p><ul><li>A class-level property that determines whether the view’s HTTP handlers are synchronous or asynchronous.</li><li>Ensures all HTTP handlers are either sync or async.</li></ul><h3>Method call sequence</h3><ol><li><strong>as_view():</strong></li></ol><ul><li>Entry point for the request-response process.</li><li>Creates an instance of the view and calls dispatch().</li></ul><p>2. <strong>setup():</strong></p><ul><li>Initializes attributes shared by all view methods, such as request, args, and kwargs.</li></ul><p>3. <strong>dispatch():</strong></p><ul><li>Determines the HTTP method (e.g., GET, POST) and routes the request to the corresponding method (e.g., get(), post()).</li><li>If the method is not implemented, it calls http_method_not_allowed().</li></ul><p>4. <strong>HTTP Method Handlers:</strong></p><ul><li>Calls the appropriate method based on the HTTP request:</li><li>get()</li><li>post()</li><li>put()</li><li>patch()</li><li>delete()</li><li>head()</li><li>options()</li><li>trace()</li></ul><p>5. <strong>http_method_not_allowed():</strong></p><ul><li>Called if the HTTP method is not implemented in the view.</li><li>Returns a 405 Method Not Allowed response.</li></ul><pre>from django.http import HttpResponse<br>from django.views import View<br><br>class MyCustomView(View):<br>    def get(self, request, *args, **kwargs):<br>        return HttpResponse(&quot;This is a GET request.&quot;)<br><br>    def post(self, request, *args, **kwargs):<br>        return HttpResponse(&quot;This is a POST request.&quot;)<br><br>    def put(self, request, *args, **kwargs):<br>        return HttpResponse(&quot;This is a PUT request.&quot;)<br><br>    def delete(self, request, *args, **kwargs):<br>        return HttpResponse(&quot;This is a DELETE request.&quot;)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a15f8c868b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/djangobasics/django-class-based-views-01-view-3a15f8c868b1">Django Class based views: 01 View</a> was originally published in <a href="https://medium.com/djangobasics">DjangoBasics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django available Class based views]]></title>
            <link>https://medium.com/djangobasics/django-available-class-based-views-7dc01198283d?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dc01198283d</guid>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Thu, 27 Mar 2025 21:59:50 GMT</pubDate>
            <atom:updated>2025-03-27T22:16:27.771Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a list of <strong>class-based views (CBVs)</strong> available in Django, categorized by their functionality:</p><h3><strong>Basic Views</strong></h3><ol><li><strong>View: </strong>The base class for all class-based views.</li></ol><ul><li>Provides basic request handling (dispatch, get, post, etc.).</li></ul><h3><strong>Template-Based Views</strong></h3><ol><li><strong>TemplateView</strong>: Renders a template with optional context data.</li></ol><h3><strong>Redirect Views</strong></h3><ol><li><strong>RedirectView</strong>: Redirects to a specific URL or URL pattern.</li></ol><h3><strong>Form Handling Views</strong></h3><ol><li><strong>FormView</strong>: Handles form rendering and processing.</li><li><strong>CreateView</strong>: Handles creating new objects using a form.</li><li><strong>UpdateView</strong>: Handles updating existing objects using a form.</li><li><strong>DeleteView</strong>: Handles deleting objects.</li></ol><h3><strong>Display Views</strong></h3><ol><li><strong>DetailView</strong>: Displays a single object.</li><li><strong>ListView</strong>: Displays a list of objects.</li></ol><h3><strong>Date-Based Views</strong></h3><ol><li><strong>ArchiveIndexView</strong>: Displays a list of objects grouped by a date field.</li><li><strong>YearArchiveView</strong>: Displays objects for a specific year.</li><li><strong>MonthArchiveView</strong>: Displays objects for a specific month.</li><li><strong>WeekArchiveView</strong>: Displays objects for a specific week.</li><li><strong>DayArchiveView</strong>: Displays objects for a specific day.</li><li><strong>TodayArchiveView</strong>: Displays objects for the current day.</li><li><strong>DateDetailView</strong>: Displays a single object for a specific date.</li></ol><h3><strong>Base Classes for Custom Views</strong></h3><p>These are base classes that can be extended to create custom views:</p><ol><li><strong>ContextMixin: </strong>Provides a default implementation of get_context_data().</li><li><strong>TemplateResponseMixin</strong>: Provides a render_to_response() method for rendering templates.</li><li><strong>SingleObjectMixin</strong>: Provides functionality for retrieving a single object.</li><li><strong>MultipleObjectMixin</strong>: Provides functionality for retrieving multiple objects.</li><li><strong>FormMixin</strong>: Provides functionality for handling forms.</li><li><strong>ModelFormMixin</strong>: Extends FormMixin to work with model forms.</li><li><strong>BaseDetailView</strong>: Base class for DetailView.</li><li><strong>BaseListView</strong>: Base class for ListView.</li><li><strong>BaseCreateView</strong>: Base class for CreateView.</li><li><strong>BaseUpdateView</strong>: Base class for UpdateView.</li><li><strong>BaseDeleteView</strong>: Base class for DeleteView.</li></ol><h3><strong>Authentication Views</strong></h3><p>Django provides authentication-related views in django.contrib.auth.views:</p><ol><li><strong>LoginView</strong>: Handles user login.</li><li><strong>LogoutView</strong>: Handles user logout.</li><li><strong>PasswordChangeView</strong>: Handles password change.</li><li><strong>PasswordChangeDoneView</strong>: Displays a success message after a password change.</li><li><strong>PasswordResetView</strong>: Handles password reset requests.</li><li><strong>PasswordResetDoneView</strong>: Displays a success message after a password reset request.</li><li><strong>PasswordResetConfirmView</strong>: Handles password reset confirmation.</li><li><strong>PasswordResetCompleteView</strong>: Displays a success message after a password reset is complete.</li></ol><h4><strong>Miscellaneous Views</strong></h4><ol><li><strong>StaticView</strong> (custom implementation): Used for serving static pages (not part of Django by default).</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dc01198283d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/djangobasics/django-available-class-based-views-7dc01198283d">Django available Class based views</a> was originally published in <a href="https://medium.com/djangobasics">DjangoBasics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Establishing an ODBC Connection from PASE to IBM i]]></title>
            <link>https://qsys400.medium.com/establishing-an-odbc-connection-from-pase-to-ibm-i-b2fe7d0398fc?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2fe7d0398fc</guid>
            <category><![CDATA[ibm-i-odbc]]></category>
            <category><![CDATA[ibm-i]]></category>
            <category><![CDATA[ibm-i-modernization]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Wed, 14 Aug 2024 11:48:42 GMT</pubDate>
            <atom:updated>2024-08-14T11:50:07.460Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Step 1: Install drivers</strong></p><pre>yum install ibm-iaccess</pre><p><strong>Step 2: Check Odbc setup</strong></p><pre>odbcinst -j</pre><p>Output will looks something like</p><pre>DRIVERS............: /QOpenSys/etc/odbcinst.ini<br>SYSTEM DATA SOURCES: /QOpenSys/etc/odbc.ini<br>FILE DATA SOURCES..: /QOpenSys/etc/ODBCDataSources<br>USER DATA SOURCES..: /home/SUMITG/.odbc.ini</pre><p><strong>Step 3: DNS setup: (in file /QOpenSys/etc/odbc.ini)</strong></p><p>IBM provides a default DSN with name “*LOCAL”</p><pre>### IBM provided DSN - do not remove this line ###<br>[*LOCAL]<br>Description = Default IBM i local database<br>Driver      = IBM i Access ODBC Driver<br>System      = localhost<br>UserID      = *CURRENT</pre><p><strong>Step 4: validate DSN</strong></p><pre>isql *local <br><br>SQL&gt; select * from sumitg1.qrpglesrc</pre><p>You can use the “*LOCAL DSN to make odbc connections from any programming language.</p><p>Python and golang example are here:</p><p><a href="https://qsys400.medium.com/establishing-an-odbc-connection-from-linux-to-ibm-i-8c62db962bc3">Establishing an ODBC Connection from Linux to IBM i</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2fe7d0398fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Establishing an ODBC Connection from Linux to IBM i]]></title>
            <link>https://qsys400.medium.com/establishing-an-odbc-connection-from-linux-to-ibm-i-8c62db962bc3?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c62db962bc3</guid>
            <category><![CDATA[ibm-i]]></category>
            <category><![CDATA[ibm-i-python]]></category>
            <category><![CDATA[ibm-i-odbc]]></category>
            <category><![CDATA[ibm-i-modernization]]></category>
            <category><![CDATA[ibm-i-golang]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Wed, 14 Aug 2024 11:06:45 GMT</pubDate>
            <atom:updated>2024-08-14T11:47:36.224Z</atom:updated>
            <content:encoded><![CDATA[<h3>Step 1: Install drivers</h3><p>Drivers are part of repositories located under <a href="https://public.dhe.ibm.com/software/ibmi/products/odbc/">https://public.dhe.ibm.com/software/ibmi/products/odbc/</a>.</p><p><strong>Red Hat-based Distribution Setup</strong></p><pre>curl https://public.dhe.ibm.com/software/ibmi/products/odbc/rpms/ibmi-acs.repo | sudo tee /etc/yum.repos.d/ibmi-acs.repo<br><br><br>sudo dnf install - refresh ibm-iaccess</pre><p><strong>SUSE-based Distribution Setup</strong></p><pre>curl https://public.dhe.ibm.com/software/ibmi/products/odbc/rpms/ibmi-acs.repo | sudo tee /etc/zypp/repos.d/ibmi-acs.repo<br><br>sudo zypper refresh<br><br>sudo zypper install ibm-iaccess</pre><p><strong>Debian-based and Ubuntu-based Distribution Setup</strong></p><pre>curl https://public.dhe.ibm.com/software/ibmi/products/odbc/debs/dists/1.1.0/ibmi-acs-1.1.0.list | sudo tee /etc/apt/sources.list.d/ibmi-acs-1.1.0.list<br><br>sudo apt update<br><br>sudo apt install ibm-iaccess</pre><p><strong>MAC-OS</strong></p><pre>brew tap ibm/iaccess https://public.dhe.ibm.com/software/ibmi/products/odbc/macos/tap/<br><br>brew install ibm-iaccess<br><br>brew upgrade ibm-iaccess</pre><blockquote>Reference: <a href="https://kadler.io/blog/2022-05-20-odbc-repos/">https://kadler.io/blog/2022-05-20-odbc-repos/</a></blockquote><h3>Step 2: Setup ODBC config files:</h3><ol><li><strong>/etc/odbcinst.ini : automatically generated and need NO modifications.</strong></li></ol><p>odbcinst.ini containt the drivers information. After installing the driver you should see few entries in this file like following</p><pre>[IBM i Access ODBC Driver]<br>Description=IBM i Access for Linux ODBC Driver<br>Driver=/opt/ibm/iaccess/lib/libcwbodbc.so<br>Setup=/opt/ibm/iaccess/lib/libcwbodbcs.so<br>Driver64=/opt/ibm/iaccess/lib64/libcwbodbc.so<br>Setup64=/opt/ibm/iaccess/lib64/libcwbodbcs.so<br>Threading=2<br>DontDLClose=1<br>UsageCount=1<br>Pooling=Yes<br>CPTimeout=120<br><br><br>[IBM i Access ODBC Driver 64-bit]<br>Description=IBM i Access for Linux 64-bit ODBC Driver<br>Driver=/opt/ibm/iaccess/lib64/libcwbodbc.so<br>Setup=/opt/ibm/iaccess/lib64/libcwbodbcs.so<br>Threading=2<br>DontDLClose=1<br>UsageCount=1<br>Pooling=Yes<br>CPTimeout=120<br>MinPoolSize=2<br>MaxPoolSize=10</pre><p><strong>2. /etc/odbc.ini : to setup DSN. You need to create an entry in this file</strong></p><p>You can connect without using the odbc.ini file. Check the python example below.</p><p>odbc.ini contains the connection parameters:</p><pre>[My_DSN_Name]<br>Description = pub400 Free server<br>Driver = IBM i Access ODBC Driver 64-bit<br>System = pub400.com<br>Name = pub400.com<br>Naming = 0<br>DefaultLibraries = *USRLIBL<br>ConnectionType = 0<br>CommitMode = 0<br>ExtendedDynamic = 1<br>ExtendedColInfo = 0<br>DefaultPkgLibrary = SQLPKG<br>DefaultPackage = A/DEFAULT(IBM),2,0,1,0,512<br>AllowDataCompression = 1<br>LibraryView = 0<br>AllowUnsupportedChar = 0<br>ForceTranslation = 0<br>Trace = 0<br>DEBUG = 65536<br>UserID = xxxxxxxxx<br>Password = xxxxxxx</pre><p>Following link contains all the available connection string keywords:</p><p><a href="https://www.ibm.com/docs/en/i/7.4?topic=details-connection-string-keywords">Connection string keywords</a></p><h3>Step 3: Connect and enjoy</h3><p><strong>Python example</strong></p><p>Language package required</p><p><a href="https://pypi.org/project/pyodbc/">pyodbc</a></p><p>With odbc.ini file:</p><pre>import pyodbc<br># Define the connection string<br>try:<br> # Establish the connection<br> conn = pyodbc.connect(&#39;DSN=My_DSN_Name&#39;)<br># conn = pyodbc.connect(&#39;DSN=My_DSN_Name;PWD=xxxx;UID=xxxx&#39;)<br># PWD = IBM I Password if not defined in odbc.ini<br># UID = IBM I User name if not defined in odbc.ini<br># Create a cursor object<br> cursor = conn.cursor()<br> <br> # Execute a query<br> cursor.execute(&quot;SELECT * FROM your_library.your_table&quot;)<br> <br> # Fetch and print the results<br> for row in cursor.fetchall():<br> print(row)<br> <br> # Close the cursor and connection<br> cursor.close()<br> conn.close()<br>except pyodbc.Error as e:<br> print(&quot;Error: &quot;, e)</pre><p>Without odbc.ini</p><pre>import pyodbc<br># Define the connection string<br>try:<br> # Establish the connection<br> conn = pyodbc.connect(&quot;&quot;&quot;Driver=IBM i Access ODBC Driver;<br>                            SYSTEM=pub400.com;<br>                            PWD=*******;<br>                            UID=******;<br>                             <br>                            &quot;&quot;&quot;)<br><br># &quot;Driver=IBM i Access ODBC Driver&quot; coming from odbcinst.ini file.<br># &quot;SYSTEM=pub400.com&quot; is the IBM I IP or Domain name<br><br> cursor = conn.cursor()<br> <br> # Execute a query<br> cursor.execute(&quot;SELECT * FROM your_library.your_table&quot;)<br> <br> # Fetch and print the results<br> for row in cursor.fetchall():<br> print(row)<br> <br> # Close the cursor and connection<br> cursor.close()<br> conn.close()<br>except pyodbc.Error as e:<br> print(&quot;Error: &quot;, e)</pre><p><strong>Golang example</strong></p><p>Language package required</p><p><a href="https://github.com/onlysumitg/godbc">https://github.com/onlysumitg/godbc</a></p><p>Or</p><p><a href="https://github.com/alexbrainman/odbc">https://github.com/alexbrainman/odbc</a></p><pre>package main<br><br>import (<br>    &quot;database/sql&quot;<br>    &quot;fmt&quot;<br>    &quot;log&quot;<br><br><br>    <br>    _  &quot;github.com/onlysumitg/godbc&quot;<br>)<br><br>func main() {<br>    // Define the connection string<br>    connStr := &quot;DSN=My_DSN_Name;UID=your_username;PWD=your_password&quot;<br><br>    //connStr := &quot;DSN=My_DSN_Name;UID=your_username;PWD=your_password&quot;<br>    // UID : IBM I user name if not defined in odbc.ini file<br>    // PWD : IBM I user password if not defined in odbc.ini file<br><br>// Open the connection<br>    db, err := sql.Open(&quot;godbc&quot;, connStr)<br>    if err != nil {<br>        log.Fatal(&quot;Error opening connection: &quot;, err)<br>    }<br>    defer db.Close()<br><br>    // Test the connection<br>    err = db.Ping()<br>    if err != nil {<br>        log.Fatal(&quot;Error pinging the database: &quot;, err)<br>    }<br>    fmt.Println(&quot;Successfully connected to the IBM i system!&quot;)<br><br>    // Execute a query<br>    rows, err := db.Query(&quot;SELECT * FROM your_library.your_table&quot;)<br>    if err != nil {<br>        log.Fatal(&quot;Error executing query: &quot;, err)<br>    }<br>    defer rows.Close()<br><br>    // Iterate over the rows<br>    for rows.Next() {<br>        var col1 string<br>        var col2 string<br>        // Adjust these types and variable names to match your table structure<br>        err := rows.Scan(&amp;col1, &amp;col2)<br>        if err != nil {<br>            log.Fatal(&quot;Error scanning row: &quot;, err)<br>        }<br>        fmt.Println(&quot;Col1:&quot;, col1, &quot;Col2:&quot;, col2)<br>    }<br><br>    // Check for errors after iterating through the rows<br>    err = rows.Err()<br>    if err != nil {<br>        log.Fatal(&quot;Error after row iteration: &quot;, err)<br>    }<br><br>    fmt.Println(&quot;Query execution completed.&quot;)<br>}</pre><p>A sample docker file</p><pre> # base image and other instructions ...<br> <br>################################<br># Install ODBC Drivers #<br>################################<br><br>RUN curl https://public.dhe.ibm.com/software/ibmi/products/odbc/debs/dists/1.1.0/ibmi-acs-1.1.0.list | tee /etc/apt/sources.list.d/ibmi-acs-1.1.0.list<br>RUN apt-get update<br>RUN apt-get install -y ibm-iaccess<br><br>################################<br># Add OBDC configuration files #<br>################################<br>ADD config/odbc/odbc.ini /etc/odbc.ini<br>ADD config/odbc/odbcinst.ini /etc/odbcinst.ini<br><br><br># remaining instructions ... <br></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c62db962bc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DB2 SQL GLOBAL TEMPORARY TABLE]]></title>
            <link>https://qsys400.medium.com/db2-sql-global-temporary-table-8b434409e193?source=rss-976e1735e5e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b434409e193</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[ibm-i]]></category>
            <category><![CDATA[ibm-i-series]]></category>
            <category><![CDATA[db2]]></category>
            <dc:creator><![CDATA[Sumit goyal]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 23:59:13 GMT</pubDate>
            <atom:updated>2021-07-21T23:59:13.866Z</atom:updated>
            <content:encoded><![CDATA[<p>DECLARE GLOBAL TEMPORARY TABLE gives you a handy option to create a table in QTEMP lib with some handy options.</p><ol><li>As DECLARE GLOBAL TEMPORARY TABLE creates a table in QTEMP lib so</li></ol><ul><li>Other sessions cannot share it.</li><li>It does not appear in the system catalog.</li><li>When you end your session, the table rows are deleted, and the table is dropped.</li></ul><p>2. Basic syntax of DECLARE GLOBAL TEMPORARY TABLE is almost the same as CREATE TABLE statement.</p><ul><li>For example, same as CREATE TABLE statement, You LIKE or AS clause can be used.</li></ul><p>3. They can store data with minimal infrastructure and resource requirements</p><p>4. They are not persistent database objects.</p><p>5. You can issue SELECT, INSERT, UPDATE, and DELETE statements against this table, the same as any other table.</p><p>6. You can drop this table by issuing the DROP TABLE statement</p><p>DECLARE GLOBAL TEMPORARY TABLE syntax for IBM I.</p><pre>DECLARE GLOBAL TEMPORARY TABLE table-name<br>{column-definition(s) | LIKE base-table-name | AS subquery }<br>[GTT-options]</pre><p>For example</p><pre>DECLARE GLOBAL TEMPORARY Table tempnewproj<br> (projname VARCHAR(24) , projsdate DATE, projedate DATE))<br>      ON COMMIT PRESERVE ROWS<br>      NOT LOGGED                   <br>      ON ROLLBACK PRESERVE ROWS     <br>      WITH REPLACE</pre><pre>DECLARE GLOBAL TEMPORARY TABLE TEMP_EMPLOYEE LIKE EMPLOYEE</pre><p><strong>GTT-options details</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YVlJheVgbanDUwEty6E8Uw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b434409e193" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>