Shane, Thanks for catching these issues.
I'll add the decode call. Tomorrow, I'll look into the unique name issue, and will see about using the parent (super) class name. Dave On Wed, Mar 08, 2017 at 11:05:24AM +1100, Shane Rigby wrote: > Hi Dave, > > I forgot to mention that I needed to change one line in > gends_run_gen_django.py from: > >     sys.stdout.write(msg) > > to > >     sys.stdout.write(msg.decode('utf-8')) > > for it to work in my environment. > > Cheers, > > Shane > On Wed, Mar 8, 2017 at 11:03 AM, Shane Rigby <shaneri...@gmail.com> wrote: > > Hi Dave, > > Thanks again, I really appreciate it. > > I have tested this but found an issue. > > The related_names are not unique. > > I end up with an error in django when I try to use the model: > > testapp.ContactType16_model.HomePhone: (fields.E304) Reverse accessor > for 'ContactType16_model.HomePhone' clashes with reverse accessor for > 'ContactType41_model.HomePhone'. >        HINT: Add or change a related_name argument to the > definition for 'ContactType16_model.HomePhone' or > 'ContactType41_model.HomePhone'. > testapp.ContactType16_model.HomePhone: (fields.E305) Reverse query name > for 'ContactType16_model.HomePhone' clashes with reverse query name for > 'ContactType41_model.HomePhone'. >        HINT: Add or change a related_name argument to the > definition for 'ContactType16_model.HomePhone' or > 'ContactType41_model.HomePhone'. >  > I believe this is because the two contact types that use the same > phonetype_model now have the same related_name. > class ContactType16_model(models.Model): >    HomePhone = models.ForeignKey("phoneType_model", > related_name="HomePhone_phoneType",blank=True, null=True,) > > class ContactType41_model(models.Model): >    HomePhone = models.ForeignKey("phoneType_model", > related_name="HomePhone_phoneType", blank=True, null=True,) > > The related names should incorporate the name of the parent element > class rather than the attribute name. > for example: > > class ContactType16_model(models.Model): >    HomePhone = models.ForeignKey("phoneType_model", > related_name="ContactType16_model_HomePhone", blank=True, null=True) > > class ContactType41_model(models.Model): >    HomePhone = models.ForeignKey("phoneType_model", > related_name="ContactType41_model_HomePhone", blank=True, null=True,) > > Is this an easy change to make? > On Fri, Mar 3, 2017 at 5:39 AM, Dave Kuhlman <dkuhl...@davekuhlman.org> > wrote: > > Shane, > > I checked my "sent" folder, and it appears to be sent. However, I > sent it as a .tar.gz file (the entire distribution), so perhaps a > firewall blocked it. > > I've attached diff files and the changed files themselves to this > message. Use whichever is more convenient. Sorry for the > inconvenience, by the way. > Dave > On Thu, Mar 02, 2017 at 04:13:41PM +1100, Shane Rigby wrote: > >  Thank's Dave, > > > >  I'd love to test it. I'm just awaiting the arrival of the > patch. Have you > >  sent it yet? > >  On Thu, Mar 2, 2017 at 9:57 AM, Dave Kuhlman > <dkuhl...@davekuhlman.org> > >  wrote: > > > >   Shane, > > > >   I've got a patch that you can try. This change does the > following: > > > >   - When generating Django models, the ForeignKey related_name > is > >    unique. > > > >   - Also in the model, if the item is optional (defined with > >    minOccurs="0"), then "blank=True, null=True" is added. > > > >   A distribution file containing the patched files is attached > to a > >   subsequent message. > > > >   If you get a chance to try it, please let me know whether > this fixes > >   the issues you have identified. > > > >   And, thanks for taking the time to help me with > generateDS.py. > >   Dave > >   On Thu, Jan 12, 2017 at 08:22:34AM -0600, Shane Rigby 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 > > -- > > Dave Kuhlman > http://www.davekuhlman.org -- Dave Kuhlman http://www.davekuhlman.org ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users