Skip to content

Instantly share code, notes, and snippets.

@thebookworm101
Last active December 10, 2015 12:49
Show Gist options
  • Save thebookworm101/4437119 to your computer and use it in GitHub Desktop.
Save thebookworm101/4437119 to your computer and use it in GitHub Desktop.
this is an error im getting in one of my views, and i dont get why.
#################im getting this type error from on of my views:
TypeError at /job/add/article/
must be type, not JobForm
Request Method: GET
Request URL: http://localhost:8000/job/add/article/
Django Version: 1.4.3
Exception Type: TypeError
Exception Value:
must be type, not JobForm
Exception Location: /job/forms.py in __init__, line 12
############## this is the view
class JobForm(forms.ModelForm):
""" this handles the start_time and end_time defaults"""
class Meta:
exclude = ['slug',]
model = Job
def __init__(self, *args, **kw):
super(JobForm,self).__init__( *args, **kw) #### <<<=== this is line 12, i dont get why i read it might be new vs ols style classes, but i dont know.
def save(self,user, *args, **kw):
instance = super(JobForm,self).save(commit=False)
#last_entry = Job.objects.filter(user__id=user.id).order_by('-id')[0]
last_entry = Job.objects.filter(user=user).aggregate(max_end_time=models.Max('end_time'))['max_end_time']
if last_entry:
instance.start_time = last_entry.end_time
else:
# this is the very first record do something
pass
instance.save()
return instance
@thebookworm101
Copy link
Author

changed according to :
mikef: try: super(JobForm, self).init(_args, *_kw)
from :
super(JobForm).init( self,_args, *_kw)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment