Programatically creating Application forms

Register or login to post to the forum.
21 Feb, 2016 21:36

Hi, I've successfully created several types of entry in Tendenci, but Application forms have thrown me. Is anyone able to offer a suggestion? In the example below there is no relationship set to Payment types or Membership types which i'm guessing is part of the problem but when I try to add those I am presented with different errors (which I can post here if it will be helpful).

This shows an example in django shell:

>>> from tendenci.apps.memberships.models import MembershipType
>>> from tendenci.apps.payments.models import PaymentMethod
>>>
>>> # This task
>>> from tendenci.apps.memberships.models import MembershipApp
>>>
>>> individual_application = MembershipApp(
...     name = 'Individuals application to join',
...     description = 'Complete this form to join.', # raw HTML
...     allow_multiple_membership = True,
...     include_tax = True,
...     tax_rate = '0.1000', # 10% in an ...unusual number format, see https://github.com/tendenci/tendenci/pull/485
...     use_for_corp = True
...     )
>>> individual_application.save()

After running this Tendenci generates an internal error when visiting http://192.168.56.102:8080/admin/memberships/membershipapp/ but I don't see any errors logged in the console (the site is running via manage.py run server).

Deleting the entry and refreshing the membership app page results in the proper page loading

>>> MembershipApp.objects.filter(name='Individuals application to join')
[<MembershipApp: Individuals application to join>]
>>> MembershipApp.objects.filter(name='Individuals application to join')[0].delete()
>>>
Edited 21 Feb, 2016 21:38
22 Feb, 2016 09:26

Thank you for reaching out about this issue. We'll take a look at this and sort it out what is going on there.

22 Feb, 2016 13:41

Since you didn't specify the slug field when creating the membership app, the error is most likely due to missing the slug.

If you just wanted to test something, it's fine. But we don't recommend to create a membership app programmatically as it would miss some key fields to make app function properly. Please use the admin interface at http://your-domain-name/admin/memberships/membershipapp/.

22 Feb, 2016 15:07

Hi jenny, I'll try creating an app with a slug to see if that helps, thanks.

I've had a look at the model for membership app, surely all required fields are in that model and its a case of working out which one/s are required?

Edited 22 Feb, 2016 15:07
22 Feb, 2016 19:04

Quick update: that was the problem, thanks!

23 Sep, 2016 19:47

Glad this one was resolved! smile