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 6708553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:46:25+00:00 2026-05-26T07:46:25+00:00

This is a beginner level task. I am trying to implement a calendar widget

  • 0

This is a beginner level task. I am trying to implement a calendar widget in django using the following
example: http://djangosnippets.org/snippets/1629/

I am putting this calendar inside a form with that already has a submit button.
The problem I am having is that my calendar button submits my form rather than
displaying the calendar widget. The calendar icon and button display properly and I can
see that it has the right code from firebug, but that’s about it.

What I really need is an EASY calendar to go along with a ModelForm. I don’t
care so much about using the JSCal2 as much as making any calendar work.

Why is my calbutton submitting my form? How do I make it display the widget
and work properly? Any other suggestions to easily get a working calendar?

————-widgets.py ———————

calbtn = u"""<input id="calendar-inputField" /><button id="calendar-trigger"> <img src="%simages/calbutton.gif" alt="calendar" id="%s_btn"
style="cursor: pointer; height="20"; width="20"; border: 1px solid #8888aa;" title="Select date and
time"
            onmouseover="this.style.background='#444444';"
            onmouseout="this.style.background=''" />
</button>
<script type="text/javascript">
    Calendar.setup({
        trigger    : "calendar-trigger",
        inputField : "calendar-inputField"
        inputField     :    "%s",
        ifFormat       :    "%s",
        button         :    "%s_btn",
        singleClick    :    true,
        showsTime      :    true
        onSelect   : function() { this.hide() }
    });
</script>"""

class DateTimeWidget(forms.widgets.TextInput):
    dformat = '%Y-%m-%d %H:%M'
    def render(self, name, value, attrs=None):
        # Same as the example   ...

    def value_from_datadict(self, data, files, name):
        # Same as the example   ...

    class Media:
        css = {            
            'all': ('/static/calendar/gold.css', )    
        }
        js = ('/static/calendar/jscal2.js',
              '/static/calendar/en.js',
              )

————- forms.py —————-

class CustMainForm(ModelForm):
  lastName = forms.CharField(max_length=20)
  firstName = forms.CharField(max_length=20)

  class Meta:
      model = Customer
      fields = ('notes', 'saleDate' )
      widgets = {
          'notes': Textarea(attrs={'cols': 80, 'rows': 20}),
          'saleDate' : DateTimeWidget(),  # shown above
      }
  • 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-26T07:46:26+00:00Added an answer on May 26, 2026 at 7:46 am

    Your button probably just needs a type attribute so it doesn’t behave as a submit button. In all browsers but IE the button tags have a default type of “submit”.

    How to prevent buttons from submitting forms

    http://www.w3schools.com/tags/tag_button.asp

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

Sidebar

Related Questions

This is a beginner level question for asp.net MVC I have the following code
Excuse the beginner level of this question. I have the following simple code, but
This is a beginner-level question. I have a catalog of mtypes: mtype_id name 1
level: beginner the following code will print 'False' def function(x): if len(x) == 5:
I'm at beginner level in C programming language. I'm trying to print out a
I am a beginner level php programmer. I was trying to use the MVC
This is a beginner-best-practice question in perl. I'm new to this language. The question
This is a beginner's rails learning confusion. When I learn rails, from time to
I believe this is a beginner's CSS question. I am utilizing the method described
I'm sure this is a beginner error... So I have a Java EE 6

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.