diff --git a/django/generatedssuper.py b/django/generatedssuper.py
index e808cd6d5318c7113bdd7158ecd0e110419ceb88..60c5b46198305a352e9170dd4bef8352f39a9874 100644
--- a/django/generatedssuper.py
+++ b/django/generatedssuper.py
@@ -1,4 +1,5 @@
 
+from __future__ import print_function
 import sys
 from generateds_definedsimpletypes import Defined_simple_type_table
 
@@ -159,6 +160,7 @@ class GeneratedsSuper(object):
             name = spec.get_name()
             prefix, name = cls.get_prefix_name(name)
             data_type = spec.get_data_type()
+            is_optional = spec.get_optional()
             prefix, data_type = cls.get_prefix_name(data_type)
             if data_type in Defined_simple_type_table:
                 data_type = Defined_simple_type_table[data_type]
@@ -213,14 +215,23 @@ class GeneratedsSuper(object):
                         name, data_type, ))
             else:
                 wrtmodels(
-                    '    %s = models.ForeignKey("%s_model")\n' % (
+                    '    %s = models.ForeignKey(\n        "%s_model",\n' % (
                         name, data_type, ))
+                wrtmodels(
+                    '        related_name="{}_{}",\n'.format(
+                        name, data_type, ))
+                if is_optional:
+                    wrtmodels(
+                        '        blank=True, null=True,\n')
+                wrtmodels('    )\n')
                 wrtforms(
                     '    %s = forms.MultipleChoiceField(%s_model.objects'
                     '.all())\n' % (
                         name, data_type, ))
+        wrtmodels('\n')
         wrtmodels('    def __unicode__(self):\n')
         wrtmodels('        return "id: %s" % (self.id, )\n')
+        wrtmodels('\n')
 
 
 #
diff --git a/generateDS.html b/generateDS.html
index 257e460dd4c4f1414e95c3e432898eb1333ead60..1ee864e5614e1668266c452f280b4f67c2a7852f 100644
--- a/generateDS.html
+++ b/generateDS.html
@@ -220,7 +220,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.24b</td>
+<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.24c</td>
 </tr>
 </tbody>
 </table>
@@ -229,7 +229,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">date:</th><td class="field-body">January 16, 2017</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">March 01, 2017</td>
 </tr>
 </tbody>
 </table>
@@ -838,10 +838,10 @@ this flag is omitted, is the value returned by
 sys.getdefaultencoding().  You can find a list of standard
 encodings here: <a class="reference external" href="http://docs.python.org/library/codecs.html#id3">http://docs.python.org/library/codecs.html#id3</a>.
 Example use: --external-encoding='utf-8'.</dd>
-<dt>member-specs</dt>
-<dd>Generate member (type) specifications in each class: a
-dictionary of instances of class <tt class="docutils literal">MemberSpec_</tt> containing
-member name, type, and array or not.  See <a class="reference internal" href="#user-methods">User Methods</a>
+<dt>member-specs Generate member (type) specifications in each class</dt>
+<dd>A dictionary of instances of class <tt class="docutils literal">MemberSpec_</tt> containing
+member name, type, array or not, and whether the item is
+optional (i.e. defined with minOccurs=&quot;0&quot;).  See <a class="reference internal" href="#user-methods">User Methods</a>
 section for more information about <tt class="docutils literal">MemberSpec_</tt>.  Allowed
 values are &quot;list&quot; or &quot;dict&quot;.  Default: do <em>not</em> generate member
 specifications (unless --user-methods specified).</dd>
@@ -2593,6 +2593,9 @@ member variable is a single item or a list/container (i.e.
 generated from maxOccurs &gt; 0): 0 indicates a single item; 1
 indicates a list.</p>
 </li>
+<li><p class="first"><tt class="docutils literal">m.get_optional()</tt> -- (an integer) Returns 0 (zero) if the item
+is optional (defined with minOccurs=&quot;0&quot;), else returns 1.</p>
+</li>
 </ul>
 <p>There are a number of things of interest in this sample file
 (<a class="reference external" href="gends_user_methods.py">gends_user_methods.py</a>):</p>
@@ -3184,7 +3187,7 @@ following among others:</p>
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="generateDS.txt">View document source</a>.
-Generated on: 2017-01-17 00:01 UTC.
+Generated on: 2017-03-01 22:05 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>
diff --git a/generateDS.py b/generateDS.py
index 3e9335e0206a6cd94c98acdc848cc01c5f39d384..52b6ebb66c3855b60a58d3b05c427e057f04ed1d 100755
--- a/generateDS.py
+++ b/generateDS.py
@@ -204,7 +204,7 @@ logging.disable(logging.INFO)
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.24b'
+VERSION = '2.24c'
 ##VERSION##
 
 if sys.version_info.major == 2:
@@ -4774,13 +4774,14 @@ def generateMemberSpec(wrt, element):
             item3 = 1
         else:
             item3 = 0
+        item4 = 1 if child.getOptional() else 0
         if generateDict:
-            item = "        '%s': MemberSpec_('%s', %s, %d)," % (
-                item1, item1, item2, item3, )
+            item = "        '%s': MemberSpec_('%s', %s, %d, %d)," % (
+                item1, item1, item2, item3, item4, )
         else:
             #item = "        ('%s', '%s', %d)," % (item1, item2, item3, )
-            item = "        MemberSpec_('%s', %s, %d)," % (
-                item1, item2, item3, )
+            item = "        MemberSpec_('%s', %s, %d, %d)," % (
+                item1, item2, item3, item4, )
         add(item)
     simplebase = element.getSimpleBase()
     if element.getSimpleContent() or element.isMixed():
@@ -5584,10 +5585,11 @@ class MixedContainer:
 
 
 class MemberSpec_(object):
-    def __init__(self, name='', data_type='', container=0):
+    def __init__(self, name='', data_type='', container=0, optional=0):
         self.name = name
         self.data_type = data_type
         self.container = container
+        self.optional = optional
     def set_name(self, name): self.name = name
     def get_name(self): return self.name
     def set_data_type(self, data_type): self.data_type = data_type
@@ -5602,6 +5604,8 @@ class MemberSpec_(object):
             return self.data_type
     def set_container(self, container): self.container = container
     def get_container(self): return self.container
+    def set_optional(self, optional): self.optional = optional
+    def get_optional(self): return self.optional
 
 
 def _cast(typ, value):
diff --git a/generateDS.txt b/generateDS.txt
index eebc6344efc40d2b13ba2a59759dde2204958b25..d64c9ee86f5198ec78c3234737ef42ef6d6bdfbd 100644
--- a/generateDS.txt
+++ b/generateDS.txt
@@ -12,7 +12,7 @@ generateDS -- Generate Data Structures from XML Schema
 
 .. version
 
-:revision: 2.24b
+:revision: 2.24c
 
 .. version
 
@@ -551,10 +551,10 @@ external-encoding=<encoding>
     encodings here: http://docs.python.org/library/codecs.html#id3.
     Example use: --external-encoding='utf-8'.
 
-member-specs
-    Generate member (type) specifications in each class: a
-    dictionary of instances of class ``MemberSpec_`` containing
-    member name, type, and array or not.  See `User Methods`_
+member-specs Generate member (type) specifications in each class
+    A dictionary of instances of class ``MemberSpec_`` containing
+    member name, type, array or not, and whether the item is
+    optional (i.e. defined with minOccurs="0").  See `User Methods`_
     section for more information about ``MemberSpec_``.  Allowed
     values are "list" or "dict".  Default: do *not* generate member
     specifications (unless --user-methods specified).
@@ -2485,6 +2485,9 @@ information in each member specification:
   generated from maxOccurs > 0): 0 indicates a single item; 1
   indicates a list.
 
+- ``m.get_optional()`` -- (an integer) Returns 0 (zero) if the item
+  is optional (defined with minOccurs="0"), else returns 1.
+
 There are a number of things of interest in this sample file
 (`gends_user_methods.py`_):
 
diff --git a/generateds_gui_notes.html b/generateds_gui_notes.html
index 5593b50a61e34502e1b0fa39494eef95cd51c282..7c8b0d5a604089d10bea1a3bf5e4ee6467d46e5b 100644
--- a/generateds_gui_notes.html
+++ b/generateds_gui_notes.html
@@ -220,7 +220,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.24b</td>
+<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.24c</td>
 </tr>
 </tbody>
 </table>
@@ -229,7 +229,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">date:</th><td class="field-body">January 16, 2017</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">March 01, 2017</td>
 </tr>
 </tbody>
 </table>
@@ -401,7 +401,7 @@ $ mv generateds_gui.mo locale/ru/LC_MESSAGES/
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="generateds_gui_notes.txt">View document source</a>.
-Generated on: 2017-01-17 00:01 UTC.
+Generated on: 2017-03-01 22:05 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>
diff --git a/generateds_gui_notes.txt b/generateds_gui_notes.txt
index 25921ccd8217bc4be028236413d68d654087f937..9afb38eef8b8501bb292a168b5fa226244a8d12b 100644
--- a/generateds_gui_notes.txt
+++ b/generateds_gui_notes.txt
@@ -12,7 +12,7 @@ GenerateDS GUI Notes
 
 .. version
 
-:revision: 2.24b
+:revision: 2.24c
 
 .. version
 
diff --git a/gui/generateds_gui.py b/gui/generateds_gui.py
index 41864be0c2a302bfb12318ba2ed9bedb2b78aa60..c96bf5d4e0f94fdaba16a0f8597f1cf98fbdd8c4 100755
--- a/gui/generateds_gui.py
+++ b/gui/generateds_gui.py
@@ -41,7 +41,7 @@ from libgenerateDS.gui import generateds_gui_session
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.24b'
+VERSION = '2.24c'
 ##VERSION##
 
 
diff --git a/librarytemplate_howto.html b/librarytemplate_howto.html
index 47bc84a0441bff6c533b9ac6e41d4c615005092a..570a071d52e1cfcd0620b2a981f9fe30f23de9b7 100644
--- a/librarytemplate_howto.html
+++ b/librarytemplate_howto.html
@@ -217,7 +217,7 @@ dkuhlman (at) davekuhlman (dot) org
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.24b</td>
+<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.24c</td>
 </tr>
 </tbody>
 </table>
@@ -226,7 +226,7 @@ dkuhlman (at) davekuhlman (dot) org
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">date:</th><td class="field-body">January 16, 2017</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">March 01, 2017</td>
 </tr>
 </tbody>
 </table>
@@ -380,7 +380,7 @@ this command for your needs.  For example, you may need to use
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="librarytemplate_howto.txt">View document source</a>.
-Generated on: 2017-01-17 00:01 UTC.
+Generated on: 2017-03-01 22:05 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>
diff --git a/librarytemplate_howto.txt b/librarytemplate_howto.txt
index 6969b4d50bad613e00cf5535cdf32fe556ff5fd8..7a00efd2ce52795b8fde7944ad10080d4c29ad2c 100644
--- a/librarytemplate_howto.txt
+++ b/librarytemplate_howto.txt
@@ -8,7 +8,7 @@ How to package a generateDS.py generated library
 
 .. version
 
-:revision: 2.24b
+:revision: 2.24c
 
 .. version
 
diff --git a/process_includes.py b/process_includes.py
index 8fe549328ea4b044818d886a0a59f7da1daff7e4..10f5317bae696fe2e38809b00ad3544c46915b47 100755
--- a/process_includes.py
+++ b/process_includes.py
@@ -40,7 +40,7 @@ except ImportError:
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.24b'
+VERSION = '2.24c'
 ##VERSION##
 
 CatalogDict = {}
diff --git a/setup.py b/setup.py
index 79638511d94d972e0b8cf5488ab7ee0429ace4ea..a9055fd7b1e86840e8badeabd975b71100790918 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ setup(name="generateDS",
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-    version="2.24b",
+    version="2.24c",
 ##VERSION##
     author="Dave Kuhlman",
     author_email="dkuhlman@davekuhlman.org",
@@ -33,7 +33,7 @@ XML document.""",
 ##         "gui.generateds_gui_session",
 ##         ],
     py_modules=[
-        "process_includes", 
+        "process_includes",
         ],
     # include_package_data=True,
     packages = [
diff --git a/tutorial/generateds_tutorial.html b/tutorial/generateds_tutorial.html
index d4945ecac5e7e32c7ccf4ab748f84b0ac762085a..546272d9f1355466fa30086c0f194d05a1f5468d 100644
--- a/tutorial/generateds_tutorial.html
+++ b/tutorial/generateds_tutorial.html
@@ -219,7 +219,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.24b</td>
+<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.24c</td>
 </tr>
 </tbody>
 </table>
@@ -228,7 +228,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">date:</th><td class="field-body">January 16, 2017</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">March 01, 2017</td>
 </tr>
 </tbody>
 </table>
@@ -1210,7 +1210,7 @@ named <tt class="docutils literal">garden_api.py</tt>, you can create an instanc
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="generateds_tutorial.txt">View document source</a>.
-Generated on: 2017-01-17 00:01 UTC.
+Generated on: 2017-03-01 22:05 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>
diff --git a/tutorial/generateds_tutorial.txt b/tutorial/generateds_tutorial.txt
index 560634e328c156d83beb56c2bafcddeff6958f9d..d975b6adbb60f6670fd0af05fb5ff19fa89ff7f3 100644
--- a/tutorial/generateds_tutorial.txt
+++ b/tutorial/generateds_tutorial.txt
@@ -11,7 +11,7 @@ generateDS -- Introduction and Tutorial
 
 .. version
 
-:revision: 2.24b
+:revision: 2.24c
 
 .. version
 
diff --git a/tutorial/generateds_tutorial.zip b/tutorial/generateds_tutorial.zip
index 09649363daf7cb1b00b3b67705d890bd0aac6ec8..e016af18c91626367e07b8bafd18518d7e037bfd 100644
Binary files a/tutorial/generateds_tutorial.zip and b/tutorial/generateds_tutorial.zip differ