In fact, the same problem applies to the admin.py, lines 125, 128 and 132.
So here is the patch for that.

Cheers,
Sven

2017-10-21 23:59 GMT+02:00 Sven Prevrhal <sprev...@gmail.com>:

> I believe there is a bug in the generatedssuper related to the _model
> suffix: The suffix optinial argument is not used in the generation of the
> ForeignKey lines.
>
> In line 239
>                 wrtmodels(
>                     '    %s = models.ForeignKey(\n        "%s_model",\n' %
> (
>                         name, clean_data_type, ))
>
> the _model should be replaced with a %s -> model_suffix . Ditto in lines
> 171 and 250. A patch is attached.
>
> Please be lenient on a GenerateDS noob.
>
> Sven
>
diff --git a/django/gends_generate_django.py b/django/gends_generate_django.py
--- a/django/gends_generate_django.py
+++ b/django/gends_generate_django.py
@@ -69,6 +69,14 @@
 #
 
 def generate_model(options, module_name):
+
+    if options.class_suffixes:
+        model_suffix = '_model'
+        form_suffix = '_form'
+    else:
+        model_suffix = ''
+        form_suffix = ''
+
     global supermod
     try:
         import generatedssuper
@@ -122,14 +130,14 @@
     for class_name in supermod.__all__:
         class_name = unique_name_map.get(class_name)
         if first_time:
-            wrtadmin('    %s_model' % (class_name, ))
+            wrtadmin('    %s%s' % (class_name, model_suffix ))
             first_time = False
         else:
-            wrtadmin(', \\\n    %s_model' % (class_name, ))
+            wrtadmin(', \\\n    %s%s' % (class_name, model_suffix ))
     wrtadmin('\n\n')
     for class_name in supermod.__all__:
         class_name = unique_name_map.get(class_name)
-        wrtadmin('admin.site.register(%s_model)\n' % (class_name, ))
+        wrtadmin('admin.site.register(%s%s)\n' % (class_name, model_suffix ))
     wrtadmin('\n')
     models_writer.close()
     forms_writer.close()
------------------------------------------------------------------------------
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

Reply via email to