Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8204917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:02:55+00:00 2026-06-07T08:02:55+00:00

How can I create a widget on the site, such as login forms, dynamic

  • 0

How can I create a widget on the site, such as login forms, dynamic menu (items taken from the database), site statistics?

I know that you can render a template that will extend out of a base template. And in the base template you can create these widgets.

But I do not know how to move the logic from the base template to my code. For example, the selection data for the block. Such actions certainly can be done in the template, but it would be a poor method in my opinion.

Sorry for my bad English. If you can not understand, I’ll try to rephrase.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:02:56+00:00Added an answer on June 7, 2026 at 8:02 am

    You would use a python library called WTForms. It helps you write code for creating forms and other widgets backed by database which you can render using jinja2 templates.

        class YourForm(Form):
             your_field1 = TextField()
             ....
             your_fieldn = SubmitField()
    
    
       @app.route('/')
       def view():
           form=YourForm()
           return render_template('your.html', form=form)
    
       In your.html
       <form >
         {{ form.your_field1 }}
         ....
         {{ form.your_fieldn }}
       </form>
    

    Check out this flask pattern for form validation and rendering to know more about it.

    Edit: To create global variables available to all templates,there are two ways:

    1. You can use global dict of jinja environment.
      This is the code:

         app.jinja_env.globals.update({'variable':1})
      
    2. You can use ContextProcessor. Code:

      @app.context_processor
      def inject_variable():
          return dict(variable=1)
      

    Now you can access variable in any template of your app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a widget so that my visitors can display it
I am looking to create a javascript widget that can be hosted on other
I want to create a Settings-Widget, where I can choose a Date. Because it
I'm trying to create an icon/widget (1 cell x 1 cell) that can be
I can create and use dynamic two dimensional array in Fortran (in 77 standard).
I can create database manually by going to cpanel. But I'd like to create
I'm doing my best to create a site badge or widget for my site
I am looking to create a widget that can be used with other solutions.
How can I create a widget layout compatible with all display and any density
jsFiddle: http://jsfiddle.net/4z2Vx/ I'm trying to create a multi-column dropdown/menu widget. The image on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.