Django model with XMLField

Viewed 2682

I'm new to python/django.

I'm using django 1.11, python 3.5.2 and Oracle 11g r2

I want to create a django model for the TABLE1 in oracle database

my TABLE1 has 4 fields:

ID (TYPE: NUMBER)

NAME (TYPE: VARCHAR2)

LASTNAME (TYPE: VARCHAR2)

INFO (TYPE: XMLTYPE)

This is the format of the xml field:

<?xml version = '1.0' encoding = 'UTF-8'?><extrainfo>
   <info>
      <movie>Titanic</movie>
      <sport>Tennis</sport>
   </info>
   <info>
      <movie>Troy</movie>
      <sport>Soccer</sport>
   </info>
</extrainfo>

I'm creating a django model for table1, but I don't know how to read the xml field in db using django.

This is my model

class Table1(models.Model):
    id = models.IntegerField(primary_key=True)
    name = models.TextField(blank=True)
    lastname = models.TextField(blank=True)
    info = (I dont know what to write here to read the xmltype in db)

    class Meta:
        managed = False
        db_table = 'TABLE1' 

What Should I do? What is the best way to do it?

I need to get the xmltype information.

Please help me, I'm stuck.

Thanks.

2 Answers

the latest version of cx_Oracle on github (7.1.0.dev0) can load an oracle xmltype field as a string in django.

Related