Re: get admin url patch on db/models/base.py

2008-06-30 Thread Milan Andric



On Jun 29, 7:46 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-06-29 at 17:27 -0700, Milan Andric wrote:
> > I was just curious if anything like this get_admin_url patch was
> > already available in django trunk somewhere and I can eliminate the
> > patch from my patched version of django.  Or is there a more
> > appropriate way to do this so it doesn't cause a conflict?
>
> > Link:http://dpaste.com/59850/
>
> Code like that doesn't really have any place in the Models class, so
> it's not likely to be in core. It would promote the admin application to
> some kind of special treatment by hardcoding it in and we try very hard
> to avoid doing that. Remember that we are in the process of moving admin
> dependencies *out* of the Model class not putting them in.
>
> Adding a method like that to a class sounds more like something that
> would be done by the admin class (I'm thinking about newforms-admin
> here, since existing admin is on life-support only) as part of
> initialiasing that. However, it doesn't make sense to do it by default,
> since each model won't necessarily have a unique admin URL. But it's
> certainly something you could do as a custom addition to the admin class
> for particular models with newforms-admin.
>

Ok, I will revisit this when newforms-admin gets merged in trunk.
Thanks for the feedback Malcolm.

--
Milan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: get admin url patch on db/models/base.py

2008-06-29 Thread Malcolm Tredinnick


On Sun, 2008-06-29 at 17:27 -0700, Milan Andric wrote:
> I was just curious if anything like this get_admin_url patch was
> already available in django trunk somewhere and I can eliminate the
> patch from my patched version of django.  Or is there a more
> appropriate way to do this so it doesn't cause a conflict?
> 
> Link: http://dpaste.com/59850/

Code like that doesn't really have any place in the Models class, so
it's not likely to be in core. It would promote the admin application to
some kind of special treatment by hardcoding it in and we try very hard
to avoid doing that. Remember that we are in the process of moving admin
dependencies *out* of the Model class not putting them in.

Adding a method like that to a class sounds more like something that
would be done by the admin class (I'm thinking about newforms-admin
here, since existing admin is on life-support only) as part of
initialiasing that. However, it doesn't make sense to do it by default,
since each model won't necessarily have a unique admin URL. But it's
certainly something you could do as a custom addition to the admin class
for particular models with newforms-admin.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



get admin url patch on db/models/base.py

2008-06-29 Thread Milan Andric

I was just curious if anything like this get_admin_url patch was
already available in django trunk somewhere and I can eliminate the
patch from my patched version of django.  Or is there a more
appropriate way to do this so it doesn't cause a conflict?

Link: http://dpaste.com/59850/

Pasted:
svn diff /opt/local/lib/python2.5/site-packages/django/db/models/
base.py
Index: /opt/local/lib/python2.5/site-packages/django/db/models/base.py
===
--- /opt/local/lib/python2.5/site-packages/django/db/models/base.py
(revision 7787)
+++ /opt/local/lib/python2.5/site-packages/django/db/models/base.py
(working copy)
@@ -8,6 +8,7 @@
 import django.db.models.manager # Ditto.
 from django.core import validators
 from django.core.exceptions import ObjectDoesNotExist,
MultipleObjectsReturned, FieldError
+from django.core.urlresolvers import reverse
 from django.db.models.fields import AutoField, ImageField,
FieldDoesNotExist
 from django.db.models.fields.related import OneToOneRel,
ManyToOneRel, OneToOneField
 from django.db.models.query import delete_objects, Q,
CollectedObjects
@@ -524,6 +525,8 @@
 setattr(self, cachename, get_image_dimensions(filename))
 return getattr(self, cachename)

+def get_admin_url(self):
+return
reverse('django.contrib.admin.views.main.change_stage',
args=(self._meta.app_label, self._meta.module_name, self.pk,))
 
 # HELPER FUNCTIONS (CURRIED MODEL METHODS) #
 


--
Milan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---