Enough! I have battled with this for the past few hours, but to no avail.
I basically cannot get a QuerySet.Create or a model Save() to save some non mandatory URLField values. Below is the code cleaned up and commented, hoping I haven't cleaned up too much. Any help / explanation of what is wrong and how to solve it would be HUGELY appreciated. Thanks # JOB MODEL # Settting URLField to blank=True has worked elsewhere for me class Job(models.Model): company = models.ForeignKey(Company, related_name='companyjobs') jobtitle = models.CharField(max_length=100) jobdesc = models.TextField() joblink = models.URLField() jobweblink = models.URLField(verify_exists=False, blank=True), jobemaillink = models.URLField(verify_exists=False, blank=True), # COMPANY MODEL class Company(models.Model): companyadmin = models.ForeignKey(User) companyname = models.CharField(max_length=256) companywebsite = models.URLField(verify_exists=True) #CODE THAT TRIES TO SAVE JOB ASSOCIATED TO A COMPANY company_db = Company.objects.get(name='CompanyName') try: #NOTE - JOBS ARE SAVED IN INTERMEDIATE tempjob CLASS #APPROACH 1 FAILS - TRY TO SAVE JOB USING companyjobs JobSet #Following errors raised #Error adding job: 'emaillink' is an invalid keyword argument for this function # OR #Error adding job: 'weblink' is an invalid keyword argument for this function company_db.companyjobs.create( jobtitle = tempjob.title, joblink = tempjob.url, jobdesc = tempjob.desc, jobweblink = (tempjob.weblink if tempjob.weblink != None else None), jobemaillink = (tempjob.emaillink if tempjob.emaillink != None else None) ) #No save as per Django docs #APPROACH 2 SUCCEEDS USING QUERYSET.CREATE BUT WITHOUT SAVING jobweblink & jobemaillink #Jobs are created and the two fields are correctly set to NULL in DB company_db.companyjobs.create( jobtitle = tempjob.title, joblink = tempjob.url, jobdesc = tempjob.desc).save() #APPROACH 3 FAILS - TRY TO SAVE JOB USING CLASSIC APPROACH, and without conditional IF #No errors raised, but jobweblink and jobemail link are both NULL in DB job_db = Job( company=company_db, jobtitle = tempjob.title, joblink = tempjob.url, jobdesc = tempjob.desc, ).save(force_insert=True) job_db.jobweblink = tempjob.weblink job_db.jobemaillink = tempjob.weblink job_db.save() -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.