Last active
December 10, 2015 12:49
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
changed according to :
mikef: try: super(JobForm, self).init(_args, *_kw)
from :
super(JobForm).init( self,_args, *_kw)