Re: cache.get_model() vs. models.get_model()
Ah I didn't realize - thanks for the quick response! On Feb 16, 3:14 pm, Alex Gaynor wrote: > On Mon, Feb 16, 2009 at 3:10 PM, richleland wrote: > > > Is there any advantage/disadvantage to using cache.get_model() vs. > > models.get_model() in an admin.py file? I'm assuming that > > cache.get_model() provides quicker access, but just wanted to see if > > there were any drawbacks. > > > A simple example of each usage is below: > > > from django.contrib import admin > > from django.db.models import get_model > > > ... > > model admin code here > > ... > > > admin.site.register(get_model('app', 'model), MyModelAdmin) > > > OR > > > from django.contrib import admin > > from django.db.models.loading import cache > > > ... > > model admin code here > > ... > > > admin.site.register(cache.get_model('app', 'model), MyModelAdmin) > > > Thanks in advance! > > Rich > > They are exactly the same as you can see from the > source:http://code.djangoproject.com/browser/django/trunk/django/db/models/l... > > access without the .cache. exists solely for backwards compatibility. > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: cache.get_model() vs. models.get_model()
On Mon, Feb 16, 2009 at 3:10 PM, richleland wrote: > > Is there any advantage/disadvantage to using cache.get_model() vs. > models.get_model() in an admin.py file? I'm assuming that > cache.get_model() provides quicker access, but just wanted to see if > there were any drawbacks. > > A simple example of each usage is below: > > from django.contrib import admin > from django.db.models import get_model > > ... > model admin code here > ... > > admin.site.register(get_model('app', 'model), MyModelAdmin) > > OR > > from django.contrib import admin > from django.db.models.loading import cache > > ... > model admin code here > ... > > admin.site.register(cache.get_model('app', 'model), MyModelAdmin) > > Thanks in advance! > Rich > > > > They are exactly the same as you can see from the source: http://code.djangoproject.com/browser/django/trunk/django/db/models/loading.py#L178 access without the .cache. exists solely for backwards compatibility. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
cache.get_model() vs. models.get_model()
Is there any advantage/disadvantage to using cache.get_model() vs. models.get_model() in an admin.py file? I'm assuming that cache.get_model() provides quicker access, but just wanted to see if there were any drawbacks. A simple example of each usage is below: from django.contrib import admin from django.db.models import get_model ... model admin code here ... admin.site.register(get_model('app', 'model), MyModelAdmin) OR from django.contrib import admin from django.db.models.loading import cache ... model admin code here ... admin.site.register(cache.get_model('app', 'model), MyModelAdmin) Thanks in advance! Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---