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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:50:49+00:00 2026-06-15T09:50:49+00:00

I am a newb to django forms and I am trying to create a

  • 0

I am a newb to django forms and I am trying to create a very specific user interface, so I can’t use model forms (or can I?)

I created a custom form that looks like this:

but it won’t commit to the db?

This is my html form:

    <form method="POST" action='/create/' id="big_idea_form" class="tabscontent">{% csrf_token %}
        <label class="tabpage" id="tabpage_1" ><span>next</span><p>Give it a name!</p><input type="text" id="name"  placeholder="Type your title here" onblur='changeIt("name", "name_span")'/></label>
        <label class="tabpage" id="tabpage_2" ><p>What is it about?</p><input type="text" id="subtitle" name="subtitle" placeholder="Type your subtitle here" onblur='changeIt("subtitle", "subtitle_span")'/></label>
        <label class="tabpage" id="tabpage_3" ><p>Why is it important?</p><textarea id="description" name= "description" cols="42" rows="5" placeholder="this can be any description but it becomes more interesting if you can explain why it is important as part of your description" onblur='changeIt("description", "description_span")'></textarea></label>
        <label class="tabpage" id="tabpage_4" ><p id="success_title">What is  considered success?</p><textarea id="success" name="success" cols="42" rows="5" placeholder="describe what sucess means to your students... what does mastery look like?" onblur='changeIt("success", "success_span")'></textarea></label>
        <input type="submit" value="Submit"/>        
    </form>  

This is my form:

from django import forms
import urlparse
from models import Lesson

class CreateLesson(forms.Form):
    name=forms.CharField()
    subtitle=forms.CharField(required=False)
    creator=forms.CharField() #automate
    description=forms.CharField()
    success=forms.CharField()
    unit=forms.CharField(required=False)
    public=forms.BooleanField()

    def save(self, request):
    data=self.cleaned_data
    Lesson.creator = request.user
    Lesson.name=data.get('name', '')
    Lesson.subtitle=data.get('subtitle', '')
    Lesson.topic=data.get('topic', '')
    Lesson.description=data.get('description', '')
    Lesson.unit=data.get('unit', '')
    Lesson.public=data.get('public', True)
    Lesson.save()
    return Lesson

And here is my view:

from django.shortcuts import render
from django.http import HttpResponseRedirect
from forms import CreateLesson

def Create_Lesson(request):
    if request.method == 'POST': # If the form has been submitted...
        form = CreateLesson(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            form.save()
            return HttpResponseRedirect('/create/') # Redirect after POST
    else:
        form = CreateLesson() # An unbound form

    return render(request, 'create_lesson/new_ideas.html', {
        'form': form,
    })
  • 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-15T09:50:50+00:00Added an answer on June 15, 2026 at 9:50 am

    problem was that the form was not validating because there were fields in the model not represented on the form…
    i simplified the form by using ModelForm and exclude as such

    forms.py

    class CreateLessonModel(forms.ModelForm):
        class Meta:
        model = Lesson
        exclude =('unit', 'slug', 'topic', 'public', 'created_date', 'creator')
    

    views.py

    from django.shortcuts import render
    from django.http import HttpResponseRedirect
    from forms import CreateLessonModel
    from django.template.defaultfilters import slugify
    def Create_Lesson(request):
        if request.method == "POST": # If the form has been submitted...
            form = CreateLessonModel(request.POST) # A form bound to the POST data
            if form.is_valid(): # All validation rules pass
                lesson = form.save(commit=False)
                lesson.creator = request.user
                lesson.slug = slugify(lesson.name)
                lesson.save()
                return HttpResponseRedirect('') # Redirect after POST
        else:
            form = CreateLessonModel() # An unbound form
    
        return render(request, 'create_lesson/new_ideas.html', {
            'form': form,
        })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newb question. I'm trying to use z-index, but it doesn't seem to be working
Python newb here. I'm trying to re-use same browser throughout my testcases. However, I
Newb question. How can you know what the main launch Activity is? Learning Android.
Android newb here. Please use small words :-) I'd like to simulate typewriter output
Using Ruby (newb) and Regex, I'm trying to parse the street number from the
Sorry for the Newb-ness. I want to create a list of view elements in
I am trying to attach a file with a contact form. My code looks
Newb question of the day: I'm trying to select all the users with this
Python newb...beware! I am trying to recursively ftp some files. In the script below,
Python newb here. I m trying to count the number of letter as in

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.