Wednesday, May 24, 2017

UI for a legacy database

Hello everyone,

I am working on designing a user interface for a legacy database.
Using python manage.py inspectdb I got the following models:

class Columnnames(models.Model):                                                
    id = models.BigAutoField(primary_key=True)                                  
    name = models.TextField(blank=True, null=True)                              
                                                                                
    class Meta:                                                                 
        managed = False                                                         
        db_table = 'columnnames'                                                
                                                                                
                                                                                
class Columns(models.Model):                                                    
    id = models.BigAutoField(primary_key=True)                                  
    name = models.TextField(blank=True, null=True)                              
    dataset = models.ForeignKey('Datasets', models.DO_NOTHING)                  
    columnname = models.ForeignKey(Columnnames, models.DO_NOTHING)              
                                                                                
    class Meta:                                                                 
        managed = False                                                         
        db_table = 'columns'


where as my current view is:

class IndexView(generic.ListView):                                              
    template_name = "db/index.html"                                           
    paginate_by = 50                                                            
    context_object_name = 'Columns'                                             
    queryset = Columns.objects.all()


However, this gives me entries that end up looking like this:

            [name]                                [Dataset]                      [Columnnames ]
Ave_rent_1_bedroom       Datasets object          Columnnames object
....

Is there a way of spaning the relationship between `Columns` and `Columnnames` so that Columns.objects.all() outputs the actual entry for the [Columnnames ] field instead of just "Columnnames object"?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a410b3a3-cc71-489e-98c9-3eeaeb0c0285%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment