Re: form.save_m2m and intermediary models

2009-03-19 Thread Delta20
On Mar 19, 6:50 pm, Malcolm Tredinnick wrote: > The error is telling you exactly what the problem is. You can't do the > automatic assignment to many-to-many relations that use an intermediate > table. The reason being that the whole point of an intermediate table is >

Re: form.save_m2m and intermediary models

2009-03-19 Thread Delta20
I forgot to add: the full error message is: "Cannot set values on a ManyToManyField which specifies an intermediary model. Use SystemTicket's Manager instead." I'm not sure how I'd use the manager in this particular case though. On Mar 19, 5:21 pm, Delta20 <digital_illumin

form.save_m2m and intermediary models

2009-03-19 Thread Delta20
I'm getting the error "Cannot set values on a ManyToManyField which specifies an intermediary model." when I try to call form.save_m2m() and I would appreciate any tips as to how to work around this. Here's some code that illustrates what I am doing: --- # Using a basic form in a view function:

Re: Custom authentication backend and User passwords

2009-01-29 Thread Delta20
Thanks Malcolm. For anyone interested in this topic, I have created a snippet with my solution: http://www.djangosnippets.org/snippets/1301/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To

Custom authentication backend and User passwords

2009-01-28 Thread Delta20
Is there a way to make it so that when you create a User in admin, the password is set such that the user cannot login using ModelBackend? I'm using two authentication backends, a custom backend and Modelbackend: i.e.: AUTHENTICATION_BACKENDS = ('myapp.auth.ActiveDirectoryBackend',

Fixtures in production use - best practices

2009-01-22 Thread Delta20
Fixtures are geared towards unit testing; I'm wondering if they are considered a good way to populate the database with some initial default values. For example, say we have a model TicketState, and the applications must be guaranteed to have two TicketStates representing the states "Open" and

Re: Enforce requirement for a UserProfile in admin

2009-01-21 Thread Delta20
Anybody have any ideas? The validators approach I mentioned can't work because UserProfile is not a field of UserChangeForm. Is there a way I can add a validation requirement to UserAdmin (i.e. the ModelAdmin)? --~--~-~--~~~---~--~~ You received this message

Enforce requirement for a UserProfile in admin

2009-01-16 Thread Delta20
I have a UserProfile admin form inline with the admin form for Users, and I was wondering if there is a simple way to enforce a requirement to have a UserProfile. It looks like I need to create a custom form to use in a custom UserAdmin (ModelAdmin) class for User, so I can add the appropriate

Re: Model manager natural sort order

2009-01-15 Thread Delta20
Natural sort order is a pretty common requirement - Windows Explorer and the Mac Finder are both examples of natural sort in action. It's true there are lots of edge cases, but just handling letters and digits in a human-reabable way is enough in many cases. It seems the solution is to add a

Model manager natural sort order

2009-01-14 Thread Delta20
Is there a way to make a model manager get_query_set function return items sorted in natural alphanumeric order? order_by returns things in rather than the ASCII order, which is not generally what users expect. For example, sorting by name for a set of objects with names: img10, img1, img103,

Re: Generating a slug from an m2m field

2008-12-15 Thread Delta20
In case anyone else is looking for a solution to this, here's the work- around I came up with: In the ModelAdmin class for Ticket, override the save_model function and force the m2m relations to be saved. For example: class TicketAdmin(admin.ModelAdmin): model = Ticket def

Generating a slug from an m2m field

2008-12-11 Thread Delta20
I'm trying to generate a slug for a model, based on the contents of many2many field, but my approaches so far don't seem to work. I'd be grateful if anyone point me towards a better approach. Here's a simple example of what I'm doing: class Item(models.Model): name = models.CharField()

NetBeans IDE for Python

2008-11-19 Thread Delta20
NetBeans for Python has been released and based on the NB Python roadmap, it looks interesting for those of us working with Django. I haven't had much of a chance to play with it yet since it just came out today, but here's the info for anyone interested: NetBeans IDE for Python:

dynamic choices iterator in model field

2008-11-19 Thread Delta20
A model field may have a 'choices' option to which you assign an iterable object -- typically a list, but this can also be an iterable function. Is there a way to assign a class method/function rather than a module function? Here's what I'm trying to do: I have a model, "Ticket" that can be in

Re: How to log the cause of a 500 error

2008-11-05 Thread Delta20
I just realized that I accidentally named the template 400.html not 404.html... d'oh. I definitely need a better way of diagnosing 500 errors. Thanks to the pointer to the email settings. I will set that up, but I'm wondering if there's a way to direct django to log those errors rather than

How to log the cause of a 500 error

2008-11-05 Thread Delta20
Is there a way to have django log 500 errors to a file, and otherwise log stderr/stdout to a file somewhere? The problem I'm having right now is that I'm getting a 500 error instead of 404s when Debug=False. I get 404s as expected when Debug=True. I can't for the life of me figure out what is

Re: Default values/prepopulate fields in ModelAdmin add view

2008-10-24 Thread Delta20
In case anyone else is trying to figure out how to do this, the solution I came up with was to put a dictionary of the values into the request and pass it to the ModelAdmin add_view function def some_view(request, ... ): ... values = { 'title': t, 'author': a } # make QueryDict

Default values/prepopulate fields in ModelAdmin add view

2008-10-23 Thread Delta20
I want to be able to use the standard/auto-generated admin add form, but need to put default values in the fields. Is this possible? Basically I want to do something like this in a view: 1: def some_view(request, ... ): 2: ... 3: values = { 'title': t, 'author': a } 4: admin =

Custom submit buttons on admin form

2008-10-15 Thread Delta20
What's the cleanest way to customize the submit buttons that appear on an admin change_form? If there's a way to override submit_row on change_form, that would be the simplest approach, I think, but I'm very much a django beginner so I would appreciate some guidance. To provide some context,

Re: Template help for new django.contrib.comments

2008-09-22 Thread Delta20
I have the exact same question. I also tried using "object.get_content_object.get_absolute_url" but that didn't work either. On Sep 22, 5:25 pm, macgregor <[EMAIL PROTECTED]> wrote: > I have the new Comments app installed and working and want to modify >

Re: DjangoCon keynote transcript/summary

2008-09-17 Thread Delta20
Thanks Malcolm for giving the background for some of this comments. Taken out of context, that talk was indeed a little bit misleading. Even without knowing the context, I felt that most of his points are not showstoppers for most projects. The good very comfortably outweighs the bad, so much so

Re: DjangoCon keynote transcript/summary

2008-09-16 Thread Delta20
True, it is a little much to transcribe, so I'll briefly summarize his main points for everyone else: - Python sucks, especially significant whitespace (I agree heartily. Only Django keeps me using Python.) - Django could be a lot smarter about scaling the DB (sharding, denormalization, etc) -

DjangoCon keynote transcript/summary

2008-09-16 Thread Delta20
Does anyone know where I can find a transcript, write-up or similar of Cal Henderson's keynote presentation at DjangoCon? Sounds like it was interesting stuff. There is a youtube video here, but it's pretty long: http://uk.youtube.com/watch?v=i6Fr65PFqfk

get_absolute_url gotcha

2008-09-09 Thread Delta20
I want to post this tip here in case this trips up other people: The error message " objects don't have get_absolute_url() methods" does not necessarily mean what it says. The error message is also displayed if there is an error in the the method. If a model has a get_absolute_url method that

Boosting your productivity when debugging Django apps

2008-08-22 Thread Delta20
This question is aimed at those of you who, like me, come from a Java and C++ background and are used to being able to debug things with a debugger - setting breakpoints, stepping through code, evaluating expressions, etc. What do you find to be the most productive approach to debugging Django