Re: Considering Django: How simple is customising django-admin?

2010-04-09 Thread UnclaimedBaggage
Many thanks, folks - very helpful replies. I've googled a lot of the
information mentioned above and it seems Django is quite easily
capable of almost everything I've mentioned above.  After another
night juggling Django & Rails I've decided my PHP days are certainly
over - I just need to decide between those two.

My preference is tilting towards Django, but from what I've seen there
seems to be more freelance work available for rails. ...Decisions,
decisions.

Cheers,
   - JB

On Apr 9, 2:00 am, Jon  wrote:
> 1. 
> Inlineshttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodelad...
>
> 2. Form mediahttp://docs.djangoproject.com/en/dev/topics/forms/media/
>
> 3. Your example does not require custom template overrides for the
> admin HTML, it is possible to simply include a function from your
> Model in 
> 'list_display'.http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-...
> ... In your example the function must return the HTML for the
> thumbnail image, and it must escape it and allow tags so that the HTML
> shows correctly in the admin.  Example (from django-imagekit):
>
>
>
> >    def admin_thumbnail_view(self):
> >        if not self._imgfield:
> >            return None
> >        prop = getattr(self, self._ik.admin_thumbnail_spec, None)
> >        if prop is None:
> >            return 'An "%s" image spec has not been defined.' % \
> >              self._ik.admin_thumbnail_spec
> >        else:
> >            if hasattr(self, 'get_absolute_url'):
> >                return u'' % \
> >                    (escape(self.get_absolute_url()), escape(prop.url))
> >            else:
> >                return u'' % \
> >                    (escape(self._imgfield.url), escape(prop.url))
> >    admin_thumbnail_view.short_description = _('Thumbnail')
> >    admin_thumbnail_view.allow_tags = True
>
> You would then include 'admin_thumbnail_view' in 'list_display' in
> your Model's admin.
>
> 4. As for the thumbnail question, you can look at 'sorl-thumbnail' or
> 'django-imagekit'. I use my own amalgamation of both, for their
> different features.
>
> As for the rest of the question, you can add onto the admin app all
> you want with your own views, templates, etc. by hijacking the URL
> routing in urls.py to look for '/admin/my-report-page' and route that
> to your own app.  To integrate this into the admin you can simply edit
> the template for the main index, or use 'django-admin-tools' which
> gives you a much nicer way of adding onto the admin with your own
> dashboard links and modules.  Or you may watch out for 'django-
> grappelli' to soon integrate 'django-admin-tools' into its already
> existing body of work, like their Navigation sidebar which lets you
> add your own links to the admin index, and Bookmarks which appear at
> the top of every admin page. (The latest work is still not quite
> usable but still very impressive)
>
> 5. I've pondered on both examples myself, but haven't really gone
> anywhere with those ideas, so I can't tell you for sure whether it's
> possible or not. But my bet's on it being possible, because in the
> first example you're simply filtering out child categories based on
> the parent category selection, so this would be doable completely with
> JS it seems.  The second example seems doable as well, though I
> haven't tried it myself.
>
> On Apr 8, 6:15 am, UnclaimedBaggage  wrote:
>
>
>
> > Hi folks,
>
> > Long-time PHP/Zend user here who'd LOVE to switch to Python/Django for
> > webdev work. I've just spent a few hours snooping around Django and
> > really like what I see, but before I invest any real time in it I'd
> > really appreciate some advice on if (or how easily) a few things can
> > be done. My main concern is the flexibility of django-admin. I LOVE
> > the feature, but I'm a little concerned about flexibility. Any
> > suggestions on the following would be very appreciated:
>
> > #1.) For usability's sake, I'd like to have foreign key models
> > embedded in the same admin form as the model they're referencing. For
> > example, if there's a "products" model with a one-to-many relationship
> > to "product options", I'd like to add "product options" from within
> > the "product" admin form. (Eg javascript adds another field each time
> > all existing "product option" fields are filled out...or something).
> > Anything that will help (or hurt)  me in trying to add this sort of
> > functionality? Is this commonly done?
>
> > #2.) Adding javascript to individual admin forms. Simple?
>
> > #3.) Customising the HTML (not CSS) output of django-admin. For
> > example, putting a thumbnailed image next to each product in the
> > Admin-->Products table list. Simple?
>
> > #4.) A lot of what I do is basic (but custom) e-commerce & CMS stuff.
> > Django's CMS potential looks very solid, although I'm wondering if
> > tacking on basic e-commerce features to django-admin could be a little
> > cumbersome. 

Re: Considering Django: How simple is customising django-admin?

2010-04-08 Thread Jon
1. Inlines 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

2. Form media http://docs.djangoproject.com/en/dev/topics/forms/media/

3. Your example does not require custom template overrides for the
admin HTML, it is possible to simply include a function from your
Model in 'list_display'. 
http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-change-list
... In your example the function must return the HTML for the
thumbnail image, and it must escape it and allow tags so that the HTML
shows correctly in the admin.  Example (from django-imagekit):

>def admin_thumbnail_view(self):
>if not self._imgfield:
>return None
>prop = getattr(self, self._ik.admin_thumbnail_spec, None)
>if prop is None:
>return 'An "%s" image spec has not been defined.' % \
>  self._ik.admin_thumbnail_spec
>else:
>if hasattr(self, 'get_absolute_url'):
>return u'' % \
>(escape(self.get_absolute_url()), escape(prop.url))
>else:
>return u'' % \
>(escape(self._imgfield.url), escape(prop.url))
>admin_thumbnail_view.short_description = _('Thumbnail')
>admin_thumbnail_view.allow_tags = True

You would then include 'admin_thumbnail_view' in 'list_display' in
your Model's admin.

4. As for the thumbnail question, you can look at 'sorl-thumbnail' or
'django-imagekit'. I use my own amalgamation of both, for their
different features.

As for the rest of the question, you can add onto the admin app all
you want with your own views, templates, etc. by hijacking the URL
routing in urls.py to look for '/admin/my-report-page' and route that
to your own app.  To integrate this into the admin you can simply edit
the template for the main index, or use 'django-admin-tools' which
gives you a much nicer way of adding onto the admin with your own
dashboard links and modules.  Or you may watch out for 'django-
grappelli' to soon integrate 'django-admin-tools' into its already
existing body of work, like their Navigation sidebar which lets you
add your own links to the admin index, and Bookmarks which appear at
the top of every admin page. (The latest work is still not quite
usable but still very impressive)

5. I've pondered on both examples myself, but haven't really gone
anywhere with those ideas, so I can't tell you for sure whether it's
possible or not. But my bet's on it being possible, because in the
first example you're simply filtering out child categories based on
the parent category selection, so this would be doable completely with
JS it seems.  The second example seems doable as well, though I
haven't tried it myself.

On Apr 8, 6:15 am, UnclaimedBaggage  wrote:
> Hi folks,
>
> Long-time PHP/Zend user here who'd LOVE to switch to Python/Django for
> webdev work. I've just spent a few hours snooping around Django and
> really like what I see, but before I invest any real time in it I'd
> really appreciate some advice on if (or how easily) a few things can
> be done. My main concern is the flexibility of django-admin. I LOVE
> the feature, but I'm a little concerned about flexibility. Any
> suggestions on the following would be very appreciated:
>
> #1.) For usability's sake, I'd like to have foreign key models
> embedded in the same admin form as the model they're referencing. For
> example, if there's a "products" model with a one-to-many relationship
> to "product options", I'd like to add "product options" from within
> the "product" admin form. (Eg javascript adds another field each time
> all existing "product option" fields are filled out...or something).
> Anything that will help (or hurt)  me in trying to add this sort of
> functionality? Is this commonly done?
>
> #2.) Adding javascript to individual admin forms. Simple?
>
> #3.) Customising the HTML (not CSS) output of django-admin. For
> example, putting a thumbnailed image next to each product in the
> Admin-->Products table list. Simple?
>
> #4.) A lot of what I do is basic (but custom) e-commerce & CMS stuff.
> Django's CMS potential looks very solid, although I'm wondering if
> tacking on basic e-commerce features to django-admin could be a little
> cumbersome. Features such as basic order reports/stats etc don't seem
> to fit too freely into the django-admin approach. I'll also need to
> auto-create thumbnails from model.ImageField inputs. Easily doable?
>
> #5.) 'Convenience' form fields in admin forms. For example, a select
> box that lets you choose a parent category, which in turn presents a
> 'child category' select box, etc...or tree-structured checkboxes. I'm
> comfortable writing up the javascript, but from a quick inspection
> django-admin didn't seem to like the inclusion of select fields that
> weren't intended to interact with the model. Was this just my clumsy
> newbieness or is this going to be a problem?
>
> Many 

Re: Considering Django: How simple is customising django-admin?

2010-04-08 Thread Brian Neal
On Apr 8, 5:15 am, UnclaimedBaggage  wrote:
> Hi folks,
>
[..]
> Any
> suggestions on the following would be very appreciated:
>
> #1.) For usability's sake, I'd like to have foreign key models
> embedded in the same admin form as the model they're referencing. For
> example, if there's a "products" model with a one-to-many relationship
> to "product options", I'd like to add "product options" from within
> the "product" admin form. (Eg javascript adds another field each time
> all existing "product option" fields are filled out...or something).
> Anything that will help (or hurt)  me in trying to add this sort of
> functionality? Is this commonly done?

Yes. See InlineModelAdmin objects.
http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#inlinemodeladmin-objects

>
> #2.) Adding javascript to individual admin forms. Simple?

Yes, see model admin media:
http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#modeladmin-media-definitions

>
> #3.) Customising the HTML (not CSS) output of django-admin. For
> example, putting a thumbnailed image next to each product in the
> Admin-->Products table list. Simple?

I suspect this can be done in a variety of ways. One way may be to
define a method on a model to return the HTML for the thumbnail image
and using it in the list_display admin option.

>
> #4.) A lot of what I do is basic (but custom) e-commerce & CMS stuff.
> Django's CMS potential looks very solid, although I'm wondering if
> tacking on basic e-commerce features to django-admin could be a little
> cumbersome. Features such as basic order reports/stats etc don't seem
> to fit too freely into the django-admin approach.

You can create your own admin views to do arbitrary things.

>  I'll also need to
> auto-create thumbnails from model.ImageField inputs. Easily doable?

With the PIL library, yes. There are also third party snippets and
apps to help with this.

>
> #5.) 'Convenience' form fields in admin forms. For example, a select
> box that lets you choose a parent category, which in turn presents a
> 'child category' select box, etc...or tree-structured checkboxes. I'm
> comfortable writing up the javascript, but from a quick inspection
> django-admin didn't seem to like the inclusion of select fields that
> weren't intended to interact with the model. Was this just my clumsy
> newbieness or is this going to be a problem?

Not really sure what you mean, but you can supply your own forms,
templates, and custom javascript to the admin.

I think you'll find the admin pretty customizable for small and
moderately complex websites. If the complexity is very high you'll
likely have to write your own admin views.

The docs for the admin app are here:
http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#module-django.contrib.admin

Regards,
BN

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Considering Django: How simple is customising django-admin?

2010-04-08 Thread johan sommerfeld
#1 This can be done. One to Many and foreign keys shows up in django
admin as
multiple choice or select box. You can also make foreign key related
models
inline meaning that you can add one or possibly multiple entries to
another
model and automatically reference them to the entry you are about to
create
in the current model.

#2 don't know.

#3 You can copy the django admin templates and customize them to your
likning.
I even think you can override them on a per model basis (not 100%
about that).

#4 I think that even if django-admin is asome. Even more impressive is
the design
of the frameworks api. When you want something more specific that
django-admin
doesn't provide, you can quite easy create your own admin views. You
get great help
froms creation, validation etc.

#5 don't know.

Hope I could inspire you to make the jump to django / python.

/J

On Apr 8, 12:15 pm, UnclaimedBaggage  wrote:
> Hi folks,
>
> Long-time PHP/Zend user here who'd LOVE to switch to Python/Django for
> webdev work. I've just spent a few hours snooping around Django and
> really like what I see, but before I invest any real time in it I'd
> really appreciate some advice on if (or how easily) a few things can
> be done. My main concern is the flexibility of django-admin. I LOVE
> the feature, but I'm a little concerned about flexibility. Any
> suggestions on the following would be very appreciated:
>
> #1.) For usability's sake, I'd like to have foreign key models
> embedded in the same admin form as the model they're referencing. For
> example, if there's a "products" model with a one-to-many relationship
> to "product options", I'd like to add "product options" from within
> the "product" admin form. (Eg javascript adds another field each time
> all existing "product option" fields are filled out...or something).
> Anything that will help (or hurt)  me in trying to add this sort of
> functionality? Is this commonly done?
>
> #2.) Adding javascript to individual admin forms. Simple?
>
> #3.) Customising the HTML (not CSS) output of django-admin. For
> example, putting a thumbnailed image next to each product in the
> Admin-->Products table list. Simple?
>
> #4.) A lot of what I do is basic (but custom) e-commerce & CMS stuff.
> Django's CMS potential looks very solid, although I'm wondering if
> tacking on basic e-commerce features to django-admin could be a little
> cumbersome. Features such as basic order reports/stats etc don't seem
> to fit too freely into the django-admin approach. I'll also need to
> auto-create thumbnails from model.ImageField inputs. Easily doable?
>
> #5.) 'Convenience' form fields in admin forms. For example, a select
> box that lets you choose a parent category, which in turn presents a
> 'child category' select box, etc...or tree-structured checkboxes. I'm
> comfortable writing up the javascript, but from a quick inspection
> django-admin didn't seem to like the inclusion of select fields that
> weren't intended to interact with the model. Was this just my clumsy
> newbieness or is this going to be a problem?
>
> Many thanks - hope to be one of the django community soon. :-)
>
>  - Unclaimed Baggage

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.