Hello, >From what I see contact is a model & you want to create a new contact. So, instead of this;
c = contact(email='email',subject=‘ subject',message='message') c.save() just do this; c = *contact.objects.create*(email=email, subject=subject, message=message) Regards On Thu, 16 May 2019 at 2:32 AM, salimon jamiu olashile < tunedae1shi...@gmail.com> wrote: > Is “contact” a model? > > > On Wed, 15 May 2019 at 8:36 PM, Emmanuel klutse <nuelk...@gmail.com> > wrote: > >> Thanks Chetan Ganji, well appreciated. >> >> Hmmmm, I changed the method name but problem still persist. >> >> I have tried all I can to handle the new errors but failed again. >> >> When I changed the contact here to contacts "c = *contact* >> (email='email',subject='subject',message='message’)"NameError at /contact >> >> name 'contacts' is not defined >> >> Request Method: POST >> Request URL: http://127.0.0.1:8000/contact >> Django Version: 2.1.1 >> Exception Type: NameError >> Exception Value: >> >> name 'contacts' is not defined >> >> Exception Location: >> /Users/emmanuelklutse/Documents/djangodev/myPortfolio/emmanuel/views.py >> in contact, line 17 >> Python Executable: /anaconda3/envs/projectOne/bin/python >> Python Version: 3.5.6 >> Python Path: >> >> ['/Users/emmanuelklutse/Documents/djangodev/myPortfolio', >> '/anaconda3/envs/projectOne/lib/python35.zip', >> '/anaconda3/envs/projectOne/lib/python3.5', >> '/anaconda3/envs/projectOne/lib/python3.5/plat-darwin', >> '/anaconda3/envs/projectOne/lib/python3.5/lib-dynload', >> '/anaconda3/envs/projectOne/lib/python3.5/site-packages'] >> >> Server time: Wed, 15 May 2019 19:20:31 +0000 >> >> When I changed the contact in the function contacts “ def contacts(request)" >> >> >> AttributeError at /contact >> >> 'contact' object has no attribute 'get' >> >> Request Method: GET >> Request URL: http://127.0.0.1:8000/contact >> Django Version: 2.1.1 >> Exception Type: AttributeError >> Exception Value: >> >> 'contact' object has no attribute 'get' >> >> Exception Location: >> /anaconda3/envs/projectOne/lib/python3.5/site-packages/django/middleware/clickjacking.py >> in process_response, line 26 >> Python Executable: /anaconda3/envs/projectOne/bin/python >> Python Version: 3.5.6 >> Python Path: >> >> ['/Users/emmanuelklutse/Documents/djangodev/myPortfolio', >> '/anaconda3/envs/projectOne/lib/python35.zip', >> '/anaconda3/envs/projectOne/lib/python3.5', >> '/anaconda3/envs/projectOne/lib/python3.5/plat-darwin', >> '/anaconda3/envs/projectOne/lib/python3.5/lib-dynload', >> '/anaconda3/envs/projectOne/lib/python3.5/site-packages'] >> >> Server time: Wed, 15 May 2019 19:30:00 +0000 >> >> On May 15, 2019, at 3:32 PM, Chetan Ganji <ganji.che...@gmail.com> wrote: >> >> *Problem - * >> def *contact*(request): >> ...... >> c = *contact*(email='email',subject='subject',message='message') >> ...... >> >> The two methods that should be doing two separate things have the same >> name. So, the python interpreter is confused. >> >> *Solution - * >> Rename anyone of the above methods. >> >> Regards, >> Chetan Ganji >> +91-900-483-4183 >> ganji.che...@gmail.com >> http://ryucoder.in >> >> >> On Wed, May 15, 2019 at 3:50 PM Emmanuel klutse <nuelk...@gmail.com> >> wrote: >> >>> Hello Team, >>> I need help please, I’m try to save to my db from a FORM using the >>> command below. >>> I’ve all I could but the process keeps failing and I’m stack. >>> >>> File >>> "/Users/emmanuelklutse/Documents/djangodev/myPortfolio/emmanuel/views.py", l >>> ine 17, in contact >>> c = contact(email='email',subject='subject',message='message') >>> TypeError: contact() got an unexpected keyword argument ‘email' >>> >>> >>> def contact(request): >>> if request.method == 'POST': >>> email = request.POST.get('email') >>> subject = request.POST.get('subject') >>> message = request.POST.get('message') >>> >>> c = contact(email='email',subject='subject',message='message') >>> c.save() >>> >>> return render (request,'emmanuel/contact.html') >>> else: >>> return render (request,'emmanuel/contact.html’) >>> >>> >>> Thanks, >>> Emmanuel klutse. Best regards >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users+unsubscr...@googlegroups.com. >>> To post to this group, send email to django-users@googlegroups.com. >>> Visit this group at https://groups.google.com/group/django-users. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/D5902281-068C-448D-8C3B-4661EC37473A%40gmail.com >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@googlegroups.com. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAMKMUjv5c7WoQ8aZzZWgm%3DZxoEs0zX3nVeQC_yiTzKKiHGUVkw%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAMKMUjv5c7WoQ8aZzZWgm%3DZxoEs0zX3nVeQC_yiTzKKiHGUVkw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@googlegroups.com. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/04AC514D-B83C-4314-92AD-1EB5087EACDA%40gmail.com >> <https://groups.google.com/d/msgid/django-users/04AC514D-B83C-4314-92AD-1EB5087EACDA%40gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFhdOCM0etm8SRLAysgf004Nixsga%3Dwz83Fassxj0VUYtfW9CA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.