Re: Extend admin template without copying the whole template

2011-02-28 Thread AndyB
There a ticket or two for this already. For example: http://code.djangoproject.com/ticket/8158 (I think a workaround is to set your ModelAdmin's to use your own template name and in they pull in and override elements of the base templates. The only drawback is you are dependent on the built-in

contrib-admin in a multiuser environment is a bit scary

2010-09-30 Thread AndyB
I've been having bad dreams about the ways in which contrib-admin can eat your data when you have more than one administrator. As a worst-case scenario imagine a model with some list_editable fields: Admin1 has the changelist open for a considerable length of time Admin2 makes a load of changes

Re: Changing a model of place from the admin site

2010-08-17 Thread AndyB
I did something similar by subclassing AdminSite and overriding the index method. Copy the original method from contrib.admin and modify app_list before you render the template. It does break breadcrumbs and intermediate app pages (/admin/someapp/) but with some shameless hackery I fixed this

A puzzling problem with admin

2009-05-13 Thread AndyB
I've got a strange issue and I'm not even sure how to go about tracking down the source of the problem let alone fix it. I'm posting here in the hope someone can give me a clue rather than a solution. I've got an app that runs fine on the local development server. When I run it on a live server

How best to deal with non-abstract model inheritance in the admin

2009-04-10 Thread AndyB
Hi, I've got a model called Courses and a model that inherits from it called SpecialCourses that has some extra fields. It seems that any SpecialCourses I add also show up in the changelist for Courses which will be confusing for content editors ("remember to edit them under SpecialCourses or

Something is eating memory. How to track it down?

2009-04-07 Thread AndyB
I've got a Django app that seems to eat up a lot of memory. I posted a message on Stack Overflow and it got a little sidetracked into a debate about the merits of WSGI and Apache in Worker MPM mode. Webfaction have assured me that playing around withthat kind of thing is not going to make a

Overriding get_form to customize admin forms based on request

2009-03-28 Thread AndyB
I've tried various methods to achieve this. I decided against overriding formfield_for_dbfield as it's doesn't get a copy of the request object and I was hoping to avoid the thread_locals hack. I settled on overriding get_form in my ModelAdmin class and tried the following: class

Custom widgets in the admin for inline forms

2009-01-09 Thread AndyB
Hi, Has anyone got any pointers? I'm not even sure where to begin. For non- inlines I'm doing: def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == 'photo': kwargs['widget'] = AdminImageWidget() return db_field.formfield(**kwargs)

Re: NetBeans IDE for Python

2009-01-01 Thread AndyB
snotva...@gmail.com> > > > > It says for requesting username as password to access. Did I miss > > > anything here? > > > try guest:guest > > > > On Nov 27, 11:14 pm, Ovnicraft <ovnicr...@gmail.com> wrote: > > > > 2008/11/27 AndyB <andy.

Transactions, nested functions and logging

2008-12-12 Thread AndyB
Hi, I'm a little confused how I should handle transactions in a particular situation. I've got some code that boils down to this: def myview(request): result = important_money_stuff(request) widget = Widget.objects.get(request.get(something)) thingy =

Re: NetBeans IDE for Python

2008-11-27 Thread AndyB
More to the point - has anyone figured out how to! I couldn't even find a dowload or repository link for the Django branch. On Nov 27, 2:21 pm, Robin <[EMAIL PROTECTED]> wrote: > hello, > > I have also installed it and have seen there is this >

Re: easily getting all the admin functionality in your templates and views

2008-11-24 Thread AndyB
The amount of customization that is now possible with the Admin app really blurs the boundry between tweaking the admin itself and replacing it entirely. There is an entire spectrum between those two extremes and I've been surprised how far it's possible to take the customization while still

Re: Dynamic columns in admin changelists

2008-11-21 Thread AndyB
Thanks Malcolm, That was so much easier than I was expecting: class ItemOptions(admin.ModelAdmin): def changelist_view(self, request, extra_context=None): self.list_display = request.session['item_columns'] return super(ItemOptions, self).changelist_view(request,

Dynamic columns in admin changelists

2008-11-21 Thread AndyB
I basically would like some way for staff users to choose which columns are displaying in an object's changelist. So far I've got an ugly solution which I can actually have some idea how to implement and the 'correct' solution which requires quite a lot of digging in the django internals. The

Re: How can I create a new table without primary key filed?

2008-11-10 Thread AndyB
If it's one to one then the field that maps to the primary key in the other table should be unique. Why not designate that as a primary key? I was in a similar situation integrating a legacy Access app. I simply added an autonumber id field. Your old app will ignore it but it keeps Django happy.

Re: Using Django

2008-11-05 Thread AndyB
http://wiki.dreamhost.com/index.php/Django Have you got the .htaccess, dispatch.fcgi etc all set up? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Is this a quirk with the admin template override mechanism or is it me?

2008-10-29 Thread AndyB
I can see why it would fail - but I still wonder whether the current behaviour is ideal. I would say that it's more likely someone would want to override a template project wide and I can't see a neat way to do this. --~--~-~--~~~---~--~~ You received this message

Is this a quirk with the admin template override mechanism or is it me?

2008-10-29 Thread AndyB
Let's say I want to override change_list.html for an app called 'cms'. I create a /admin/cms/change_list.html and then call back to the original admin template overriding just want I want to change: {% extends "admin/change_list.html" %} {% block extrahead %} ... {% endblock %} However if I

Re: Receiving emails via app

2008-10-26 Thread AndyB
This sounds like exactly what I need to do. However my Unix-fu isn't up to coping with the sentence 'We have an alias set up in postfix that sends the e-mail to our script via a pipe.'... :( My naive assumption is that one could use something like poplib in the standard library to connect to a

Re: Confused by select_related()

2008-10-23 Thread AndyB
Apologies for not using DPaste. I thought the snippets were small enough. And I thought my question was cleared than it turned out to be! To clarify (where someobject_set is a related-object queryset): someobject_set.all().query.as_sql() someobject_set.select_related().query.as_sql() Both show

Confused by select_related()

2008-10-23 Thread AndyB
>>> p.residentialunitmix_set.all().query.as_sql() (u'SELECT `tbl_ResidentialUnitMix`.`id`, `tbl_ResidentialUnitMix`.`Planning-id`, `tbl_ResidentialUnitMix`.`quantity`, `tbl_ResidentialUnitMix`.`Bedrooms`, `tbl_ResidentialUnitMix`.`Type`, `tbl_ResidentialUnitMix`.`Tenure` FROM

Re: icontains case-sensitive on MySQL

2008-10-16 Thread AndyB
be abstracting away? On Oct 16, 7:10 pm, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote: > On Fri, Oct 17, 2008 at 12:55 AM, AndyB <[EMAIL PROTECTED]> wrote: > > I've googled and the only problems seem to be with people trying to do > > case-sensite lookups.

icontains case-sensitive on MySQL

2008-10-16 Thread AndyB
I've googled and the only problems seem to be with people trying to do case-sensite lookups. What could be going wrong here?: >>> b.filter(name__icontains='Saff') [] >>> b.filter(name__icontains='saff') [] MySql 5.0.51 Django 1.0 Tables are InnoDB UTF8 collation UTF8 bin Tried it on a my dev

Re: Recursive relationship - two models, same table

2008-10-05 Thread AndyB
- there is a point you reach where it would be quicker to write your own views but it's rather hard to see where that point is until you've tried pushing the boundries of what the admin can do. regards, AndyB On Oct 4, 9:48 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Will Temperley wrote: > >

Re: Type comparisons in templates - a Django wart?

2008-08-30 Thread AndyB
> Then you'd be tripped up and ends up completly confused by any raw > python code. Did you ever tried comparing a string and an int in > Python ??? Doh. I knew that. For some reason the fact that it was template code sent my brain to sleep. > > Does anyone else think that there should be an

Type comparisons in templates - a Django wart?

2008-08-30 Thread AndyB
I read the following snippet with interest: http://www.djangosnippets.org/snippets/1010/ I am trying to lock that tightly into brain as I can imagine being tripped up by that and ending up completely confused as to why my code doesn't work. Does anyone else think that there should be an elegant

Re: Web hosting control panel with django

2008-08-27 Thread AndyB
I also keep meaning to look at Pinax but I was rather put off by the apparent focus on social apps (in which I don't currently have much of an interest). I would like to see a some documentation about their proposed standard architecture. Does this exist other than in the current source code?

Re: Admin mass change screen

2008-08-18 Thread AndyB
I'm happily using this snippet that could be used for editing any column on the change list page: http://www.djangosnippets.org/snippets/568/ On Aug 17, 8:28 am, Donn <[EMAIL PROTECTED]> wrote: > Hi, > I have a model that I'd like to edit in a way that I can get to some of the > members going

Re: Complex URLs and numerous GET variables

2008-06-23 Thread AndyB
I've wondered about this myself. You could use an 'all' placeholder so that there was always three levels in the url: example.com/shop/all/all/Acme example.com/shop/all/250-500/all example.com/shop/widgets/all/all or your own separator and a flatter directory structure:

Re: Error saving unicode field

2008-06-04 Thread AndyB
e: > On Wed, Jun 4, 2008 at 5:23 AM, AndyB <[EMAIL PROTECTED]> wrote: > > > I'm struggling to understand the following: > >http://dpaste.com/54745/ > > > It's a legacy database that's had the data imported with a variety of > > tools - not all of them ve

Re: show reverse relationship on admin pages

2008-06-04 Thread AndyB
Hi Russ, Do you mean you can define a custom forms and get it to appear as the default change form in admin? Is there currently any documentation on this? There seems to be no end to delights you can get from newforms- admin ;) AndyB On Jun 4, 7:33 am, "Russell Keith-Magee" <[EM

Error saving unicode field

2008-06-04 Thread AndyB
I'm struggling to understand the following: http://dpaste.com/54745/ It's a legacy database that's had the data imported with a variety of tools - not all of them very well behaved when it comes to character encoding. The offending character is a UK pound sign (163 in unicode and latin1 I

Re: Building filter strings dynamically

2008-05-13 Thread AndyB
I struggled to work this out and it's one of those problems that's hard to work out what you should Google for. It would make a worthy addition to the docs IMHO. On May 10, 4:08 am, Greg Fuller <[EMAIL PROTECTED]> wrote: > Thanks to both.  Got it working. > > On May 9, 9:17 pm, Aaron Fay

Re: auto admin for production

2008-05-13 Thread AndyB
I've been down this road and I will say that although you can modify the Admin to do everything you need - it actually turns out to be more complex that just writing your own CRUD (which newforms makes a delight). It's a shame in some ways - Admin is so nearly ready for this kind of thing that

Avoiding the ThreadLocals hack - anything new in NewForms-Admin?

2008-04-23 Thread AndyB
I was reading this page http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser and was wondering how the advice on avoiding the hack applied to my own use case. I am using the ThreadLocals hack to get the current user in a model when overriding the save() method. Therefore I can't pass

Re: Strange login error in newforms-admin site: ViewDoesNotExist at /accounts/login/

2008-04-01 Thread AndyB
server) Anyway. I'll try your fix and report back. thanks AndyB On Apr 1, 2:47 am, Michael <[EMAIL PROTECTED]> wrote: > This is an instance of the AlreadyRegistered exception rearing its > head in the contrib.auth section, something I have been banging my > head against sin

Strange login error in newforms-admin site: ViewDoesNotExist at /accounts/login/

2008-03-31 Thread AndyB
Some code that has previously worked fine and still works fine on my development server has started giving the following error on a production server when I try and visit my login page: ViewDoesNotExist at /accounts/login/ Could not import django.contrib.auth.views. Error was: cannot import name

Re: Time estimation for a Django project

2007-11-14 Thread AndyB
I've found that the only problems I encountered on my first couple of Django projects were the following: 1. Unix problems due to not being very experienced with Unix shell stuff. 2. Spending way too long trying to customize the admin because I didn't realise how easy it would be to write my own

context_instance needs documenting on the same page as render_to_response?

2007-11-07 Thread AndyB
Just read James Bennett's excellent article here: http://www.b-list.org/weblog/2007/nov/01/django-tips-template-loading-and-rendering/ In it he mentioned request_context and the context_instance parameter to render_to_response and mentions that many people he talks to don't know of it's

Re: Authenticating static content when not using mod_python

2007-10-23 Thread AndyB
(my reply via email doesn't appear to have made it to the list - sorry if the first paragraph is a repeat for anyone) Thanks Chris, I didn't know about this and it would be the ideal solution if I could get Dreamhost to install mod_xsendfile! Still hopefully this will be useful for someone out

Re: Authenticating static content when not using mod_python

2007-10-18 Thread AndyB
solution then what would be the most CPU efficient way to read a file in and send it over HTTP? regards, Andy On Oct 16, 11:46 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Oct 16, 11:58 pm, AndyB <[EMAIL PROTECTED]> wrote: > > > Hi folks, > > > Am I rig

Authenticating static content when not using mod_python

2007-10-16 Thread AndyB
Hi folks, Am I right in thinking the only way to do is this under CGI etc. is to either: 1. To use raw HTTP authentication or 2. To pipe all content through Python by reading the file in and serving it from a view --~--~-~--~~~---~--~~ You received this message

Re: Strange 'if' behaviour in template

2007-10-02 Thread AndyB
I've just spotted something fairly obvious! The whole thing is wrapped in: {% if inline_admin_form.original or inline_admin_form.show_url %} That would explain it then! On Oct 2, 4:25 pm, AndyB <[EMAIL PROTECTED]> wrote: > Hi there, > > I'm overriding an admin templat

Strange 'if' behaviour in template

2007-10-02 Thread AndyB
Hi there, I'm overriding an admin template (but doubt uf that is particularly relevent) and am not sure why the following behaviour occurs. I've modified the line: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% endif %} to be: {% if inline_admin_form.original %}test1{{

Re: Forms vs. Admin?

2007-10-02 Thread AndyB
Although I think this view is mostly true at the moment I have a feeling that it will change in the near future. The admin pages are currently fairly customisable and newforms-admin expands this capability extensively. The problem is two-fold: 1. Documentation in this area is fairly weak and a

Editing FileFields inline (in newforms-admin)

2007-10-01 Thread AndyB
this although there were some other tickets on vaguely related issues: http://code.djangoproject.com/ticket/5628 http://code.djangoproject.com/ticket/5388 I'd be grateful if anyone can confirm/deny this on trunk. Anyone got any other thoughts on this? cheers, AndyB

Re: Union/join of two queryset?

2007-09-25 Thread AndyB
That's AND and OR to those of us who never had to learn set theory ;-) On Sep 24, 9:49 pm, jake elliott <[EMAIL PROTECTED]> wrote: > hi francesco > > cesco wrote: > > I have two QuerySets and I need to join them to pass them as first > > parameter to the ObjectPaginator class. > > How can I do

Re: dictionary access in templates

2007-09-25 Thread AndyB
Django templates use the dot syntax for several purposes: object attributes, dictionary lookups, list indexes and method calls. Have a look here: http://www.djangoproject.com/documentation/templates/#variables (note that you can't pass parameters to method calls so only methods calls that don't

Re: QuerySet filters. Making both sides of the comparison parametric

2007-09-24 Thread AndyB
Lovely. I'd never seen the function(**{expression}) syntax before. For anyone else in the same boat the rather terse official explanation is here: http://docs.python.org/ref/calls.html (search the page for '**expression') Tim Chase wrote: > > if (search_query['organisation']!=""): > >

QuerySet filters. Making both sides of the comparison parametric

2007-09-24 Thread AndyB
So if I've got code like this: if (search_query['organisation']!=""): jobs = jobs.filter(organisation=search_query['organisation']) if (search_query['region']!=""): jobs = jobs.filter(region=search_query['region']) if (search_query['category']!=""): jobs =

Re: Today's newform-admin branch, svn version 6364

2007-09-17 Thread AndyB
Yep. Spotted your second point. All my admin change pages are broken. Going to revert unless anyone knows a quick fix. On Sep 16, 8:56 pm, Rob J Goedman <[EMAIL PROTECTED]> wrote: > Hi, > > Today's version shows 2 problems, the first problem is related to > date/time formats in fixtures, the 2nd

Re: django-rendertext released

2007-09-11 Thread AndyB
For SEO (and accessibility) reasons. I would like to see this using an image replacement technique. I've used SIFR on a Django site and rather liked it but if you want an image rather than SWF based solution then there are several approaches with varying merits. (rather too many as a quick

Re: Overriding Admin templates on a per-app and per-model basis

2007-09-11 Thread AndyB
I just tried this against trunk and got the same results. >From a quick perusal of the admin code I can't see any special code for template loading. Where is this functionality supposed to reside? --~--~-~--~~~---~--~~ You received this message because you are

Overriding Admin templates on a per-app and per-model basis

2007-09-10 Thread AndyB
I was rather pleased to read that the above was possible according to the Django book: http://www.djangobook.com/en/beta/chapter18/ (scroll down to the section called 'Customizing admin templates') I've already been overriding the admin templates globally by putting custom templates in a folder

Simulating Row Level Permissions with newforms-admin hooks

2007-08-17 Thread AndyB
. thanks in advance, AndyB --~--~-~--~~~---~--~~ 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

Is there a hook to restrict ForeignKey choices in newforms-admin?

2007-08-14 Thread AndyB
I'm using code like this to simulate row level permissions: class JobOptions (admin.ModelAdmin): def queryset(self, request): userOrg = Organisation.objects.filter(contact=request.user.id) if (request.user.id==1): # admin can edit all jobs return Job.objects.all()

Re: How to make use of the hooks in newforms-admin?

2007-08-14 Thread AndyB
my admin options and hooks in models.py. Is there a consensus for where they should go now? It would be nice to have conventions for things like this. On 23 Jul, 22:09, Jonathan Buchanan <[EMAIL PROTECTED]> wrote: > AndyB wrote: > > Page 18 and 19 of this > > PDF:http://www

How to make use of the hooks in newforms-admin?

2007-07-23 Thread AndyB
Page 18 and 19 of this PDF: http://www.vanpyz.org/Djangojam/django_vancouver.pdf give examples of some of the new hooks available in newforms-admin. This is the only documentation I can find anywhere for this at the moment. The examples involve declaring a class called Admin. I think I might be

Re: Should I give up on dreamhost?

2007-07-23 Thread AndyB
Me too. I've had my share of problems but the two key things that got it working reliably was asking Dreamhost support to increase the servers 'softlimit' setting and to use the filename 'dispatch.fcgi' rather than 'django.fcgi' so that Dreamhost's process pruner doesn't keep killing Django.

Django on a shared host. The docs are scaring me ;)

2007-07-11 Thread AndyB
Despite having three live Django sites running from Apache and FCGI I have always felt there was a certain degree of black magic about the process and I've succeeded only by following instructions and keeping my fingers crossed. Quite often the process takes several hours of fiddling and it seems

Can managers take parameters? Or can you chain a filter in get_object_or_404?

2007-05-10 Thread AndyB
This could quite easily be another dumb question but here goes :( Can a model have a manager that either takes a parameter or can access the current logged in user? I simply want to filter any query sets returned from a table called Properties depending on the current user without having to

Re: Authentication of static files without mod_python?

2007-05-07 Thread AndyB
> You may be able to use something like mod_auth_mysql to access the db > directly for authentication (assuming you use mysql). Authorization > doesn't seem possible without using python. It's a shared server (or else I'd just install mod_python). When you say 'doesn't seem possible' what do

Authentication of static files without mod_python?

2007-05-07 Thread AndyB
to as well. I'm stuck with fcgi at the moment. The standard CGI method would be to keep all static files away from Apache and pipe them all through Python code. Is there any other solution or failing that does anyone have any advice/code on the most efficient way to go about this? AndyB

Simple next and previous index in templates

2007-01-26 Thread AndyB
I'm trying to have a list of images in a doc all hidden in css with next and prev links that unhide and hide to give the appearence of scrolling through. I'm struggling with the Django template system. I know this is putting logic into templates rather than views but it seems odd to move simple

Admin so nearly does what I want.

2006-09-03 Thread AndyB
Hi, I've been trying to find some documentation on extending the admin interface or reusing parts of it's functionality. I've found some talk on the django dev list about enhancing support for this but I can't quite figure out what's already possible. Some people have mentioned a copy the