i am trying the save the date using formmodel but it is giving error "The Course could not be changed because the data didn't validate." i attched themodel.py ,form.py and view.py
-- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/1f9c2590-0f81-4a76-9f6e-e9b29eb44b91%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
from django import forms from student.models import Course class CourseForm(forms.ModelForm): course_id=forms.CharField(max_length=10, widget=forms.TextInput(attrs={ 'class' : 'form-control', 'placeholder':'enter course_id','id':'inputwarning' })) course_name=forms.CharField(max_length=10, widget=forms.TextInput(attrs={ 'class' : 'form-control', 'placeholder':'enter course Name' })) start_date= forms.DateField(widget=forms.TextInput(attrs={ 'type':'date', 'class':'form-control glyphicon glyphicon-calendar' })) end_date=forms.DateField(widget=forms.TextInput(attrs={ 'type':'date', 'class':'form-control glyphicon glyphicon-calendar' })) credits=forms.IntegerField( widget=forms.TextInput(attrs={ 'class' : 'form-control', 'placeholder':'enter course_id','id':'inputwarning' })) image = forms.FileField(widget=forms.TextInput(attrs={ 'type':'file', 'class':'form-control'})) class Meta: model=Course #def clean_message(self): #for varification of the data
from django.db import models # Create your models here. class course(models.Model): course_id=models.CharField(max_length=10) title=models.CharField(max_length=10) start_date=models.DateTimeField(auto_now_add=True) end_date=models.DateTimeField(auto_now_add=True) image=models.ImageField(upload_to = '/static/albums/') credits=models.IntegerField()
from django.contrib import admin # Register your models here.
from django.shortcuts import render from django.shortcuts import render_to_response from course.form import CourseForm from django.core.context_processors import csrf # Create your views here. def course(request): if(request.method == 'POST'): form=CourseForm(request.POST) form.save() else: form=CourseForm() return render(request,'course.html',{'form':form})