#3163: [patch] Optionally disable DB table creation from model
------------------------------------------+---------------------------------
Reporter: [EMAIL PROTECTED] | Owner: nobody
Status: reopened | Component: Database
wrapper
Version: SVN | Resolution:
Keywords: raw SQL view | Stage: Design
decision needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 1 | Needs_better_patch: 0
------------------------------------------+---------------------------------
Comment (by honeyman):
Replying to [comment:21 wolfram]:
> If I understand you right you are doing the following inside models.py
> {{{
> from db_myview1 import myview1
> }}}
> if thats the case, remove it form there.
>
> You must not do it in the models,py but only in the place where you need
teh db-views.
> So for example inside app/core/views.py you can do the import, but not
inside the models.py!
Not quite so. I do something close to this:
models.py:
{{{
from db_model1 import model1
from db_model2 import model2
}}}
db_model1.py:
{{{
class MyModel1(models.Model):
f1 = models.# ...
f2 = models.# ...
f3 = models.# ...
}}}
db_myview1:
{{{
# Myview1 SQL view is based upon the Model1 table
class MyView1(models.Model):
class Meta:
sql_generation_required = False # by my patch
# Fields similar to Model1
f1 = models.# ...
f2 = models.# ...
f3 = models.# ...
# Some fields calculated by the SQL view
xf1 = models.# ...
xf2 = models.# ...
xf3 = models.# ...
}}}
db_model2.py:
{{{
from db_myview1 import myview1
class MyModel2(models.Model):
fkey = models.ForeignKey(myview1, db_column = 'id') # This is why I need
"import myview1" at the top
# I could have done fkey = models.ForeignKey(db_model1), but then fkey
wouldn't have xf1, xf2 and xf3,
# and more complex queries would be needed to retrieve them.
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/3163#comment:23>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---