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

  • SEARCH
  • Home
  • 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 7438537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:34:12+00:00 2026-05-29T10:34:12+00:00

I am quite new to django, and I have built a small page using

  • 0

I am quite new to django, and I have built a small page using forms.
When I go to the template and use the template tags, such as:

{{form.q}}

everthing is fine, and I see the form input field. However, I do not really like the input “box” it provides and I want to override this feature.

So, in my HTML, I would have something like:

<input id="customfield" name="q" type="text"/>

I tried the above, and everything seems to work fine. However, if I use for example:

<input id="customfield" name="{{form.q}}" type="text"/>

it dosent work. So, my question is:

[1] Is it ok to use name=”q” or how can one specify {{form.q}} if I have a custom input?
[2] Are there any disadvantages (like sql injection) when using name=”q” as opposed to simply using {{form.q}}?

Sorry for the 101 questions!

  • 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-05-29T10:34:13+00:00Added an answer on May 29, 2026 at 10:34 am

    This is exactly how you would build a form if you wanted this much control in the template.

    You’d take this course when other django shortcuts have failed, like one of the build in widgets that determine the way your field is rendered.

    Update: after reading your comment, if you just want to inject attributes to the input element, you can pass the widget a dictionary containing attribute:value pairs.

    q = forms.CharField(widget=forms.TextInput(attrs={'class': 'foobar'}))
    

    SQL injection is irrelevant here (you’d worry about this when a user has something to do with SQL written on your server) and there are no disadvantages, aside from the code being more difficult to write and maintain.

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

Sidebar

Related Questions

I'm quite new to Django Forms, and I'm facing a problem that I cannot
I'm quite new to Django and I just set up my first registration page
quite new to JQuery and Ive run into a problem. I have a form
I'm having a small problem with my setup. I'm quite new to the Django
I'm quite new to django, and moved to it from Drupal. In Drupal is
I am quite new to mongoid and rails. So I have some troubles to
I'm quite new to using Tornado Web as a web server, and am having
I am quite new with Django, and I was wondering if I could document
I'm new to Macs (and quite new to Django) and I'm setting up an
I'm quite new to Django and I'm working on a project with i18n, 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.