I am done with this tutorial which shows how to use textX to write a java POJO.
I am thinking of adapting this to write Django model classes.
The issue is when I have to add custom model methods to the Django model class.
And then if I subsequently change the DSL, the generated model class will definitely remove the custom model methods.
How to I cater for custom model methods if using textX to generate Django model classes?
Well, you could use a diff/merge tool to merge the existing and newly-generated code but that will certainly require manual interventions to solve eventual merge conflicts.
FWIW, writing your model classes manually won't take much more time than writing them using a DSL (I slightly changed the DSL version to account for database-specific needs like charfields length):
vs from django.db import models
so I really don't think you'll gain anything with code generation here.
NB: if your problem is to generate "boostrap" models code from an existing DB schema, Django already knows how to do this without the need for a DSL.