Shane, Oops. I did not get this on my to-do list, and forgot it. I apologize.
With respect to the duplicate names, I read this in the Django docs: ForeignKey.related_name The name to use for the relation from the related object back to this one. It’s also the default value for related_query_name (the name to use for the reverse filter name from the target model). See the related objects documentation for a full explanation and example. Note that you must set this value when defining relations on abstract models; and when you do so some special syntax is available. If you’d prefer Django not to create a backwards relation, set related_name to '+' or end it with '+'. Do you think there is any harm in *always* generating a related name? That should be easy to do. Would it be objectionable to have the `related_name` parameter even when not needed? With respect to the optional items, I can add the generation of ", blank=True, null=True" whenever we have minOccurs="0". Or, at least I think I can. I have to figure out how to determine whether minOccurs is zero. Might have to pass an additional piece of info from earlier in the process. [a bit later] Looks like that piece of information (minOccurs) is not in the module generated by generateDS.py, which is used to generate the `models.py` file, and would have to be added. It seems a bit icky to add that just for this one use, although that would work, I suppose. I need to study it a bit more to see if there is a cleaner way. Or, maybe convince myself that adding that piece of information (minOccurs) would be a good thing in any case. [just thinking out loud] Give me a little more time, and I'll send you a patch, I hope. Dave On Tue, Feb 28, 2017 at 12:28:51PM +1100, Shane Rigby wrote: > Hi Dave, > > I responded on Jan 13 but have not heard back. Did my response answer your > question fully? > On Fri, Jan 13, 2017 at 1:16 PM, Shane Rigby <shaneri...@gmail.com> wrote: > > Sorry- I didn't quite answer your question... "Is there something in the > XML schema that would tell us that we need > to generate the chances you had to make by hand?" > > Yes there is - If there are any sibling elements that use the same type > and that type is a complextype need to be treated differently. >  > Does this help? > On Thu, Jan 12, 2017 at 8:22 AM, Shane Rigby <shaneri...@gmail.com> > wrote: > > Thanks Dave, > > Here is a very small subset of one of the xsd's we can use as an > example. > > You can see the following three elements all use the same type > (phoneType) > > Package/Person/Contact/HomePhone > Package/Person/Contact/Mobile > Package/Person/Contact/WorkPhone > > Cheers, > > Shane > > On Wed, Jan 11, 2017 at 6:41 PM, Dave Kuhlman > <dkuhl...@davekuhlman.org> wrote: > > Shane, > > Is there something in the XML schema that would tell us that we need > to generate the chances you had to make by hand? If so, could you > share your XML schema with me, or at least the element definition > that you are talking about? If I had the schema, I would > hopefully able to try to generate the changes that you made > manually. > Dave > > On Tue, Jan 10, 2017 at 09:00:03AM -0500, Shane Rigby wrote: > >  Hi Dave, > > > >  I'm really enjoying playing around with all this - I just > wish I had more > >  time to commit to it. > > > >  In my schema, there are elements that represent a person, > each can have a > >  HomePhone and Mobile and a WorkPhone that use a single > complex type. > > > >  The GenerateDS created model file has duplicate foreign keys > so I needed > >  to manually update the model class to include a unique > related_name. > > > >  In addition, my model has a lot of non-mandatory elements and > attributes, > >  so I had to manually add blank=True, null=True to all the > attributes I > >  need to be non-mandatory. > > > >  So for example, I changed the following: > >  class ContactType16_model(models.Model): > >     HomePhone = models.ForeignKey("phoneType_model") > >     Mobile = models.ForeignKey("phoneType_model") > >     WorkPhone = models.ForeignKey("phoneType_model") > >  To this: > > > >  class ContactType16_model(models.Model): > >     HomePhone = models.ForeignKey("phoneType_model", > >  related_name="ContactType16_model_HomePhone", blank=True, > null=True) > >     Mobile = models.ForeignKey("phoneType_model", > >  related_name="ContactType16_model_Mobile", blank=True, > null=True) > >     WorkPhone = models.ForeignKey("phoneType_model", > >  related_name="ContactType16_model_WorkPhone", blank=True, > null=True) > >  Have you had anyone else that noted this kind of problem? > > > >  Cheers, > > > >  Shane > > > >  On Thu, Jan 5, 2017 at 6:03 PM, Shane Rigby > <shaneri...@gmail.com> wrote: > > > >   Thanks Dave, > > > >   Again - I really appreciate it. > > > >   Now the model, forms and admin files generate > successfully! > > > >   I'm getting some errors with Django though - there seems > to be some > >   conflicts - 30 errors like this: > > > >   "polls.ContactType16_model.HomePhone: (fields.E304) > Reverse accessor for > >   'ContactType16_model.HomePhone' clashes with reverse > accessor for > >   'ContactType16_model.Mobile'." > > > >   I'll dig a little deeper to figure it out - as I mentioned > before I am > >   new to Django. > >   Out of interest do use any of the continuous integration > and deployment > >   features of BitBucket? I've been using the GitLab CI > Runner using docker > >   container runners on hyper.sh for all my automation, but > I've got no > >   idea about what bitbucket offers. > >   Cheers, > > > >   Shane > > > >   On Thu, Jan 5, 2017 at 3:22 PM, Dave Kuhlman > <dkuhl...@davekuhlman.org> > >   wrote: > > > >    Shane, > > > >    Thanks for catching this issue. > > > >    I've added the following simple types to those > supported by the > >    Django code generator: xsd:gYear, xsd:gYearMonth, > xsd:gMonth, > >    xsd:gMonthDay, and xsd:gDay. Each of these XML schema > simple types > >    will generate: > > > >     - django.db.models.DateField (in the generated > Django models > >    module) > >     - django.forms.DateField (in the generated Django > forms module) > > > >    Django does not have more specific types for year, > year-month, > >    month, month-day, and day that I could find. If you > find them, let > >    me know. > > > >    I've also added the xsd:time simple type so that the > XML schema simple > >    types xsd:dateTime and xsd:time generate the Django > DateTimeField and > >    TimeField respectively. > > > >    You can look at the following for information on XML > schema simple > >    types: > https://www.w3.org/TR/xmlschema-0/#SimpleTypeFacets > > > >    If you spot additional simple types in that table that > you feel we > >    should also support, but do not, let me know. > > > >    I've pushed this change to the Bitbucket repository at: > >    https://bitbucket.org/dkuhlman/generateds. And, I've > attached a > >    distribution file in a separate email. > > > >    I've attached the XML schema file that I used for my > tests. You can > >    run it with any of the following command lines: > > > >      $ python gends_run_gen_django.py test01.xsd > >      $ python gends_run_gen_django.py --force > test01.xsd > >      $ python3 gends_run_gen_django.py test01.xsd > >      $ python3 gends_run_gen_django.py --force > test01.xsd > >    Dave > > > >    On Wed, Jan 04, 2017 at 08:44:25PM -0500, Shane Rigby > wrote: > >    >  Thanks Dave, > >    > > >    >  That's great - I really appreciate it. > >    > > >    >  That is now running through now, but I get an > warning/error > >    where my > >    >  schema uses a type of gYear > >    >  (http://www.datypic.com/sc/xsd/t-xsd_gYear.html) > and it gives a > >    >  warning/error of "Unhandled simple type: Year > gYear". Is this a > >    known > >    >  limitation? > >    > > >    >  Cheers, > >    > > >    >  Shane > >    >  On Wed, Jan 4, 2017 at 1:01 PM, Dave Kuhlman > >    <dkuhl...@davekuhlman.org> > >    >  wrote: > >    > > >    >   Shane, > >    > > >    >   My testing shows that the Django support now > runs under both > >    Python 2 > >    >   and Python 3. > >    > > >    >   I've attached a distribution file containing > these fixes in > >    a > >    >   separate email. You can also find the > Mercurial repository > >    with > >    >   these fixes at: > https://bitbucket.org/dkuhlman/generateds > >    > > >    >   If and when you try it, please let me know > about the > >    results, and > >    >   about any other suggestions and ideas you > have on > >    generateDS, too. > >    > > >    >   If you have not seen it already, take a look > at: > >    >   > >    > > http://www.davekuhlman.org/generateDS.html#django-generating-models-and-forms > >    > > >    >   And, the gends_run_gen_django.py script, > which automates the > >    >   generation process, may be helpful, too. > >    >   Dave > >    > > >    >   On Mon, Jan 02, 2017 at 06:20:54PM -0500, > Shane Rigby wrote: > >    >   >  Hi Dave, > >    >   > > >    >   >  That's awesome! > >    >   > > >    >   >  I look forward to hearing further from > you - I'm > >    running a docker > >    >   >  container on hyper.sh that contains a > gitlab runner > >    (our schema > >    >   is in > >    >   >  GitLab) that automatically generates > the python > >    classes using > >    >   GenerateDS > >    >   >  so I can quickly create test case xmls > from Excel. If > >    I can get > >    >   the Django > >    >   >  part working, I'd like to auto-deploy > the whole > >    shebang! It > >    >   would be > >    >   >  really neat. > >    >   > > >    >   >  Anyway, let me know if you want me to > test anything - > >    happy to > >    >   help in any > >    >   >  way I can. > >    >   >  On Mon, Jan 2, 2017 at 4:59 PM, Dave > Kuhlman > >    >   <dkuhl...@davekuhlman.org> > >    >   >  wrote: > >    >   > > >    >   >   Shane, > >    >   > > >    >   >   Good to hear from you. Sounds > like you are doing > >    some > >    >   interesting > >    >   >   work with XML. > >    >   > > >    >   >   Thanks for reporting the problems > which the Django > >    support and > >    >   >   Python 3. I'll look into that. > >    >   > > >    >   >   OK. I've done a little work on > the Python 3 > >    support for > >    >   Django. I > >    >   >   got the modules that generate the > Django code to > >    run > >    >   successfully > >    >   >   under both Python 2 and Python 3. > And, I believe > >    that the > >    >   generated > >    >   >   files (models.py, forms.py, and > admin.py), > >    themselves are > >    >   Python 3 > >    >   >   compatible. Give me a little time > to do some > >    more checking > >    >   and then > >    >   >   I'll > >    >   >   pass them along to you, hopefully > tomorrow (my > >    time/date in > >    >   >   California, U.S.A). > >    >   > > >    >   >   About whether I know of anyone > working in this > >    area, I'm not > >    >   sure > >    >   >   what you mean by "this area". If > you mean using > >    the Django > >    >   support > >    >   >   provided by generateDS, I usually > only get reports > >    when > >    >   something is > >    >   >   not working. I've had several of > those in the > >    past, and have > >    >   been > >    >   >   able to fix the reported > problems. But I don't > >    know where > >    >   those > >    >   >   projects went after that. > >    >   > > >    >   >   More later when I have a fix for > you. > >    >   > > >    >   >   Dave > >    >   > > >    >   >   On Sat, Dec 31, 2016 at 10:20:33AM > -0500, Shane > >    Rigby wrote: > >    >   >   > Hi Dave, > >    >   >   > > >    >   >   > I work for a LIXI a non-profit in > Australia that > >    manages the > >    >   xml data > >    >   >   > standards that are used widely > for applying for > >    residential > >    >   mortgages > >    >   >   in > >    >   >   > Australia. Simply put, we publish > xsd schema for > >    our members > >    >   to use to > >    >   >   > transmit credit applications to > each other. > >    >   >   > > >    >   >   > I've been learning python and > trying out your > >    project > >    >   GenerateDS to > >    >   >   > generate python code to create > and read > >    messages. I've been > >    >   trying to > >    >   >   get > >    >   >   > the Django model generation > working but notice > >    there is some > >    >   Python2 > >    >   >   > specific code that is causing me > problems (I'm > >    using > >    >   Python3). > >    >   >   > > >    >   >   > Do you know if anyone is working > in this area? > >    >   >   > > >    >   >   > I'm really new to open-source and > trying to > >    figure out how > >    >   to best > >    >   >   > contribute (I'm really pretty new > to Python). > >    >   >   > > >    >   >   > Cheers, > >    >   >   > > >    >   >   > Shane > >    >   > > >    >   >   -- > >    >   > > >    >   >   Dave Kuhlman > >    >   >   http://www.davekuhlman.org > >    > > >    >   -- > >    > > >    >   Dave Kuhlman > >    >   http://www.davekuhlman.org > > > >    -- > > > >    Dave Kuhlman > >    http://www.davekuhlman.org > > -- > > Dave Kuhlman > http://www.davekuhlman.org -- Dave Kuhlman http://www.davekuhlman.org ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users