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 <[email protected]> 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 <[email protected]>
> 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
> <[email protected]> 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
> <[email protected]> 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
> <[email protected]>
> >Â Â Â 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
> >Â Â Â Â <[email protected]>
> >Â Â Â Â >Â Â 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
> >Â Â Â Â >Â Â Â <[email protected]>
> >Â Â Â Â >Â Â Â >Â Â 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/generateds-users