I would like to use a view that I've created in MySQL as model in Django. I would like to show the status of unfinished processes going on at my company on my intranet site. I have found only rather old entries on forums, so is there an easy way to pass MySQL view through syncdb
?
If not, assume I have a two tables:
table with processess and subprocesses info as ID from table above :
My view in MySQL would do something like that. 4) So the outcome would be :
I would like to have only one model in my django APP, the outcome no.4.
What is the quickest way to get this ? Custom SQL query? Or do I need to have models for progress_tb
and proc_tb
and combine them? How do I refer to the same table few times (as in Access/MySQL I have progress_tb
as progress_tb_1
et c.) ? And by now I know only how to make a filtered query, but how can I "add" few columns from joined table ? I tried "extra" option from django, but I don't understand how it works :(
You can specify your view as not being managed by Django through a managed = False
field declaration on your nested Meta
class:
class MyViewModel(models.Model):
field1 = models.IntegerField()
[...]
class Meta:
managed = False
db_table = 'MyView' # your view name
managed = False
will cause python manage.py syncdb
to ignore that model for sync'ing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With