Django error: needs to have a value for field "..." before this many-to-many relationship can be used
When saving a form I am getting this error:"" needs to have a value for field "surveythread" before this many-to-many relationship can be used.
Models.py:
class SurveyResult(models.Model): stay = models.OneToOneField(Stay, related_name='survey') created = models.DateTimeField(default=datetime.now) vote = models.BooleanField(default=False) vote_service = models.BooleanField(default=False) comment = models.TextField(blank=True, null=True) def getThreads(self): return SurveyThread.objects.filter(parent_survey = self) threads = property(getThreads) def __unicode__(self): return self.vote and 'Good' or 'Bad' class Meta: get_latest_by = '-created'class SurveyThread(models.Model): survey = models.ManyToManyField(SurveyResult, related_name='parent_survey') email = models.EmailField(max_length=200) comment = models.TextField(blank=True, null=True)
views.py:
survey_list = SurveyResult.objects.filter(stay__guest__user=request.user) \ .select_related('stay', 'stay__guest')forms = {}for survey in survey_list: forms[survey] = SurveyThreadForm(data=request.POST or None, survey=survey) if forms[survey].is_valid(): instance = forms[survey].save() return redirect('.')
forms.py
class SurveyThreadForm(forms.Form): comment = forms.CharField(required=False, widget=forms.Textarea) def __init__(self, *args, **kwargs): self.survey = kwargs.pop('survey', None) if not self.survey: raise NotImplementedError("SurveyResult object is required at this moment") super(SurveyThreadForm, self).__init__(*args, **kwargs) self.fields['comment'].label = "Message to send to guest:" def save(self, commit=True): s = SurveyThread() s.survey = self.survey s.email = "
[email protected]" s.comment = self.cleaned_data['comment'] if commit: s.save() return s
Error Message:
ValueError at /"<SurveyThread: SurveyThread object>" needs to have a value for field "surveythread" before this many-to-many relationship can be used.Request Method: POSTRequest URL: http://127.0.0.1:8000/Django Version: 1.5.1Exception Type: ValueErrorException Value: "<SurveyThread: SurveyThread object>" needs to have a value for field "surveythread" before this many-to-many relationship can be used.Exception Location: /Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/django/db/models/fields/related.py in __init__, line 586Python Executable: /Users/tlovett1/.virtualenvs/guestretain/bin/pythonPython Version: 2.7.2Python Path: ['/Users/tlovett1/guestretain', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg', '/Users/tlovett1/.virtualenvs/guestretain/lib/python27.zip', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/plat-darwin', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/plat-mac', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/tlovett1/.virtualenvs/guestretain/Extras/lib/python', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/lib-tk', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/lib-old', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages', '/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/PIL']Server time: Sun, 7 Jul 2013 10:22:55 -0500
Traceback:
Traceback Switch to copy-and-paste view/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/django/core/handlers/base.py in get_response response = callback(request, *callback_args, **callback_kwargs) ...▶ Local vars/Users/tlovett1/guestretain/retain/apps/profiles/utils.py in _wrapped_view return view_func(request, *args, **kwargs) ...▶ Local vars/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/endless_pagination/decorators.py in decorated return view(request, *args, **kwargs) ...▶ Local vars/Users/tlovett1/guestretain/retain/apps/dashboard/views.py in dashboard instance = forms[survey].save() ...▶ Local vars/Users/tlovett1/guestretain/retain/apps/surveys/forms.py in save s.survey = self.survey ...▶ Local vars/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/django/db/models/fields/related.py in __set__ manager = self.__get__(instance) ...▶ Local vars/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/django/db/models/fields/related.py in __get__ through=self.field.rel.through, ...▶ Local vars/Users/tlovett1/.virtualenvs/guestretain/lib/python2.7/site-packages/django/db/models/fields/related.py in __init__ (instance, source_field_name)) ...▶ Local vars
I'm new to Django and Python. I can post the debug trace or migration file if needed, but I have a feeling it's a simple fix. Obviously the point is I want to save multiple survey thread for each survey result.
Thanks!
https://codehunter.cc/a/django/django-error-needs-to-have-a-value-for-field-before-this-many-to-many-relationship-can-be-used
0 notes
Save what matters to preserve your heritage
5 min read
South Africans have had to navigate some of the worst effects of the Covid-19 pandemic since it emerged over 18-months ago. The upside of the pandemic is the opportunity and ability to reflect on what matters.
TymeBank women directors and executives share what matters to them, their early savings goals and perspectives on access to finances for women. The insights are consistent with the TymeBank Save What Matters Surveyresults, where culture preservation and saving for a more secure future are considerations for South Africans.
Kele Boakgomo
TymeBank board director, co-founder and CEO of Yugrow. She is a passionate supporter of diversity and inclusion as it relates to gender equality.
Savings lesson
When I started working, I took advantage of the fact that my financial needs were modest and saved as much as I could. Whatever money I saved, I later invested in building my first home - an important lesson in creating a saving culture early and anticipating the future.
Saving what matters
As a TymeBank director, I value the business culture of innovation and our challenger bank status. We need to continue to operate within a regulatory framework while pushing the envelope when it comes to delighting customers and building relevant products.
The pandemic and women’s financial well-being
The pandemic has had a disproportionate and long-lasting impact on women’s careers and livelihoods. Financial services institutions can help women recover from the setback by understanding their needs and tailoring solutions accordingly.
Thoughts on Heritage Month
As a South African, I treasure the spirit of hope through which we embraced the 1994 transition into democracy, and is the same spirit we need to manage these tough times. As diverse as we are, there was a sense of achievement in building an inclusive South Africa. That is part of our heritage and is something worth preserving.
Linda Appie
TymeBank Head of Marketing. Youth leadership mentor and passionate supporter of culture, tradition and heritage.
Saving what matters
I care about leaving a legacy for my son by ensuring the things I do positively affect him. My parents grew up poor but rose above their circumstances. Their humble upbringing gave me the self-confidence to believe I can achieve anything through determination.
Thoughts on Heritage Month
Many South Africans have mixed cultures - some are generations of immigrants from other parts of the continent and beyond. We should embrace our diversity, the way we speak and celebrate the ‘gees’ of South Africans, regardless of race. There is magic in our story.
Savings lesson
When I started working, I set aside my bonuses to save for a new home. I have now moved into the second home I bought off-plan. When building a home, wisdom from people who have different experiences and are open to giving advice is helpful.
Amrita Arjun
TymeBank Chief Internal Auditor and advocate for youth education and rights of those living with a disability.
Saving what matters
The pandemic has emphasised the need to preserve human connection and interaction. People have become afraid of personal interaction, even while practising social distancing. It is rewarding to reconnect with colleagues, friends, and family as soon as it is safe to do so – that is what makes us human.
Savings lesson
When I began my career, I heeded my mother’s advice. I would set a percentage of my earnings aside into a savings account as you never know what the future holds. Following that advice, my husband and I were able to afford our first home in our early twenties. Our savings came in handy where we had a deposit for our new home, could cover unforeseen expenses that come with purchasing a new home and were able to afford our wedding without placing financial strain on our families.
Women and financial literacy
There are many examples of women who hand over their earnings to their spouses. Some are unable to manage their own finances through no fault of their own. Regrettably, in some instances they are left to fend for themselves. Banks can have targeted financial literacy programmes for men and women to guide them to make the best financial decisions to protect their families and future.
Ayn Brown
TymeBank Chief Human Resources Officer, and supporter of early childhood development.
Saving what matters
As an HR professional, I would like to see a culture of kindness, compassion, courage, and unlocking greatness in others become common in the workplace. More generally, when I look at the world around us, there are more kind people in the world than selfish people - that’s worth preserving.
Savings lesson
I worked at several places after school to save for a car. On my 21st birthday, my godfather presented me with a dog-eared, handwritten bank book. He had saved R1 every month since the day I was born. With compound interest, the savings were enough to reach the R400 needed as a deposit – a fortune to me then. It set the example for a saving culture. I opened my initial savings account with my first formal salary in my early 20s. I have a nice little nest egg that aids my love of travel.
Women and access to finance
Many women struggle to find secure, regular employment for various reasons, including the responsibility of childcare. Although women are far more likely to hustle to meet their financial obligations, the traditional criteria for access to finance often work against them.
Tina Eboka
TymeBank Director, owner of Hextex Industries, former Group MD of NTP Radioisotopes SOC, member of various boards and a strong believer in making a difference in others’ lives.
Saving what matters
When it comes to saving what matters, I care about our youth and the lessons we share with them. Given the high rate of youth unemployment, creating opportunities to train young people, especially in finance and financial management, can open doors to a better future and entry into intergenerational wealth creation.
Thoughts on Heritage Month
More broadly, I care about protecting our climate for the sake of future generations. If we all play a part by reducing our ecological footprint, we can help preserve our children’s heritage. Indigenous knowledge systems and way of life was about respecting nature and using only what you need.
Savings lesson
I always wanted to have my own home, and my husband and I saved towards that goal. We are fortunate to now own a few properties.
Women and access to finance
I believe banks can do a lot more for women entrepreneurs, many of whom start businesses out of necessity or passion and are unfamiliar with what is required to access funding or who to approach in this regard.
About TymeBank
TymeBank is currently one of the world’s fastest-growing digital banks, with more than 4.3 million customers acquired since launching in February 2019. The bank is founded on simplicity, transparency and affordability and is designed to make digital banking accessible and affordable to all South Africans across the economic spectrum.
TymeBank is majority owned by Dr Patrice Motsepe’s African Rainbow Capital (‘ARC’). Recent investors include Tencent, internet and technology company based in China, and CDC Group, the UK’s development finance institution and impact investor. Other investors are UK based Apis Growth Fund II (‘Apis’), a fintech private equity fund based in the UK, JG Summit Holdings (JG Summit) a Philippines based conglomerate owned by the Gokongwei family, African Fig Tree (AFT), a ring-fenced vehicle established by the founders along with key individuals, and the Ethos AI Fund.
TymeBank is a member of the Tyme Group of companies with headquarters in Singapore. TymeBank and its sister company, Tyme, recently raised US$180 million, which is being deployed to enable growth both locally in South Africa and in the Philippines. TymeBank is currently one of the world’s fastest-growing digital banks, with more than 5 million customers acquired since launching in February 2019. The bank is founded on simplicity, transparency and affordability and is designed to make digital banking accessible and affordable to all South Africans across the economic spectrum.
TymeBank is a digital bank, that enables people to open a bank account onlineand provides low fee personal and business banking, internet banking, savings account, money transfer, medical aid, credit cardand Cell phone bankingproducts. In addition to offering market-leading interest rates, the bankalso provides customers with digital payment facilities for airtime, dataand prepaid electricity.
TymeBank is majority owned by Dr Patrice Motsepe’s African Rainbow Capital (‘ARC’). Recent investors include Tencent, internet and technology company based in China, and CDC Group, the UK’s development finance institution and impact investor. Other investors are UK based Apis Growth Fund II (‘Apis’), a fintech private equity fund based in the UK, JG Summit Holdings (JG Summit) a Philippines based conglomerate owned by the Gokongwei family, African Fig Tree (AFT), a ring-fenced vehicle established by the founders along with key individuals, and the Ethos AI Fund.
TymeBank is a member of the Tyme Group of companies with headquarters in Singapore. TymeBank and its sister company, Tyme, recently raised US$180 million, which is being deployed to enable growth both locally in South Africa and in the Philippines.
For more information visit www.TymeBank.co.za or visit a TymeBank kiosk in over 500 Pick n Pay and Boxer stores nationwide.
About Tyme
Tyme is a multi-country digital banking group, focused on bridging the digital divide in emerging markets, by integrating into physical retail ecosystems. Headquartered in Singapore with offices in Hong Kong and Ho Chi Min City, Tyme designs, builds, and operates digital banks for the mass market, with a particular expertise in serving the under-served and under-banked populations in these countries. Tyme recognises the unique challenges of emerging markets digital banks and builds financial education, a high tech – high touch approach, and efficient cash management solutions to meet the unique needs of the emerging mass market in these countries. Tyme is now launching operations in Asia, based on its successful experience in South Africa. Tyme powers its deployments through its loosely coupled microservice platform, with its design and engineering team based in Ho Chi Minh City, Vietnam.
For more information, please visit www.tyme.com
About ARC
African Rainbow Capital (ARC) is a black-owned and controlled investment holding company which focusses on the South African and African financial services industry and businesses that deliver exceptional returns on equity. The company is 100% owned by Ubuntu-Botho Investments, which was founded by Dr Patrice Motsepe in 2004, with the objective of building a world class financial services company. Ubuntu-Botho Investments became Sanlam’s anchor empowerment partner. In addition, another important objective of Ubuntu-Botho Investments, since its formation, was to contribute to the improvement of the living conditions and standards of living of poor, unemployed and marginalised South Africans.
ARC’s objective is to be a leading provider of financial services, covering the full spectrum of financial service needs, such as life insurance, healthcare, asset management, general financial services, short-term insurance, property and banking. This is achieved through building strategic partnerships, both in South Africa and further afield, by obtaining equity stakes in product providers.
For more information, please visit www.africanrainbowcapital.co.za
0 notes
April Fools Survey Results
A couple people have asked for the survey results for the April Fool’s comic a while back, so I figured this would be a good opportunity to show you guys what the results look like from our perspective!
49 of you are wrong and should feel bad
Gonna be honest, I’m not entirely sure how to interpret this. We got some pretty nice numbers in tho
Sheldon has 14 fans! And 31 haters.
In case you don’t know who Sheldon is........ I won’t tell you
45 of you need to get some food in your tummies
Good choice in letters.
Best letter awards go to this eldritch horror:
A smiley to brighten your day:
A cake that WASN’T a lie:
This wise guy:
And wait... is that...
AMOGUS?!!
55 of you should have studied! It was in the syllabus!
And finally:
I’ll just run through a few highlights:
Oh ok
...A... ARE you?
Dang, I knew I should’ve taken my pills today /s
you tell me.
Ď̶̲o̶͈͊e̶̙̊s̶̲̆ ̸̼̂t̷͇̏h̵̗̾í̸̬s̶̟͠ ̶̢̕a̵̻͗ņ̶̈́ş̶̆w̷̟̄è̶̡r̶̦͒ ̷̰͝ẏ̶̘ö̸͕́ű̸̙r̶͚̓ ̶͔͘q̵̙̈́u̶̮̇ë̶̦́s̴̮͂t̴͖̀i̴̡͑o̶͍͐n̶͔̓?̷̝̃
I, too, wish that Endertale would continue. :(
We’ve got so much to cover!! I wanna get to the juicy bits!!
I understand. The power that this survey exudes is beyond mortal comprehension.
thank u frand, moar comic comin sooon
We also received 3 bee movie scripts, one tragedy of darth plagueis the wise, and 4 rickrolls - and then there’s this anon!
Didn’t even try! At least put some effort into it!
And that’s about it! The april fools comic was a blast to create, so we hope you guys enjoyed it. : )
56 notes
·
View notes