Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#890 closed defect (fixed)

database tables should be imported directly, not thru django.models.[app_name].[table_name.lower()]s

Reported by: aaronsw Owned by: adrian
Component: Database layer (models, ORM) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


If I define a database table in the foo module, I sort of expect it to be there for me to get it out again. Having it appear inside the django code with a different name is bizarre and confusing and annoying.

Change History (6)

comment:1 Changed 10 years ago by aaronsw

  • Summary changed from database tables should be imported directly, not thru django.models.[app_name].[table_name.lower()] to database tables should be imported directly, not thru django.models.[app_name].[table_name.lower()]s

comment:2 Changed 10 years ago by adrian

Yeah, I feel the same way. The question is how we keep a distinction between record-level methods (Poll.get_choice_list()) and table-level methods (polls.get_list(), polls.get_object()). The table-level methods shouldn't just be simple class methods, because a given object instance shouldn't be able to call get_list() or get_object().

comment:3 Changed 10 years ago by rjwittams

Also the stuff in the django.models import hook has to be done somewhere else - when the first model is imported, all of them must be imported. This is not really easy, because by the time you know you are importing a model ( ie the meta.Model metaclass is run ), you are halfway through importing a module. You need to run the import hook when all modules have been imported. But you won't get told when the current module finishes being imported.

The only clean way I can see to do this is some kind of django.meta.init() call, which is called in the basehandler and does this stuff if it hasn't already been done, and anyone using the ORM outside of the handler needs to call that method too...

The unclean way is to treat the model modules being imported directly differently than modules being implicitly imported. IE when their metaclasses finish, go through and patch up anything needed. This would make startup O(mn) with m <- number of metaclasses directly imported and n <- number of metaclasses in total. Not good.

comment:4 Changed 10 years ago by anonymous

  • Component changed from Admin interface to Database wrapper
  • milestone set to Version 0.92
  • Version set to SVN

This bug can be closed with magic-removal drops.

comment:5 Changed 10 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in magic-removal.

comment:6 Changed 9 years ago by adrian

  • milestone Version 0.92 deleted

Milestone Version 0.92 deleted

Note: See TracTickets for help on using tickets.
Back to Top