You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I let Django name the DB tables, it prefixes each one with the name of the app. For example, the table for the Assessment class gets named peer_review_data_assessment, which I don't like.
I don't understand why 3/8 of the programmatic table namings don't work. They required me to hard-code them. I'd like an alternate technique that gives better table names programmatically without the occasional unexplained error.
After digging into the import situation a bit, it looks like you are defining db_table in many cases (not all) by using the internal name of the class from canvasapi. It's probably okay, but I guess I'd lean towards hard-coding the names, or letting Django generate them based on the class name, to avoid any possible downstream effects of changes in the library classes or structure.
The text was updated successfully, but these errors were encountered:
# Should this class be abstract? Is base class correct?classMyModelBase(models.base.ModelBase):
def__new__(cls, name, bases, attrs, **kwargs):
classNewMeta:
db_table=nameattrs['Meta'] =NewMetar=super().__new__(cls, name, bases, attrs, **kwargs)
returnr# Is the base class correct, or should it be models.base.Model?classMyModel(models.Model, metaclass=MyModelBase):
classMeta:
abstract=TrueclassCourse(MyModel):
# etc.
However, this code gives the error…
django.core.exceptions.FieldError: Local field 'id' in class 'Course' clashes with field of the same name from base class 'MyModel'.
If I let Django name the DB tables, it prefixes each one with the name of the app. For example, the table for the
Assessment
class gets namedpeer_review_data_assessment
, which I don't like.I don't understand why 3/8 of the programmatic table namings don't work. They required me to hard-code them. I'd like an alternate technique that gives better table names programmatically without the occasional unexplained error.
Originally posted by @ssciolla in #11 (comment):
The text was updated successfully, but these errors were encountered: