Re: Extending User model after magic-removal

2006-06-11 Thread Marcin Kaszynski

Luke Plant <[EMAIL PROTECTED]> writes:
> This is actually quite interesting.  You would need to alter your
> patch a bit so that it works for models with 'app_label' defined --
> the "model_module.__name__.split('.')[-2]" logic should exist in
> only one place.

Good point.  Another problem I ran into is that circular dependencies
caused by models imported in the patch function result in somewhat
confusing error messages.  I have yet to find a way to fix this.

On the bright side, I already found another use for the patch:

def patch_flatpage(name, bases, attrs):
attrs['Admin'].js = ('tiny_mce/tiny_mce.js',
 'tiny_mce/textareas.js')
return attrs

MODEL_PATCHES = {'flatpages.FlatPage': patch_flatpage}

:)

> Other than that it seems quite good -- maybe you should create a
> ticket.

That I will, I posted it here first to get some feedback and a chance
to fix any problems before I submit a patch.  Thanks for your
comments!

-mk

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Using DB module(s) in another app (twisted)

2006-06-11 Thread Jos Yule

Hey, i'm developing both a website and real-time network application,
and i'm using django for the website bits and twisted for the real-time
app (multiplayer games). I'd like to share the some of the DB info
between the two applications, and am wondering what the easiest way to
do this would be? It would be great if i could just import the DB stuff
into my Twisted app, and be able to us it as i do in the django app.

Any suggestions?

Thanks!


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Strange problems in 0.91

2006-06-11 Thread Andrew Degtiariov

Hi there!.
I have looked to migrate my project from 0.91 to MRT, b/c expecting
some problem with template and manipulator classes inheritances. E.g.
for example, template "add" extends "base", and template "edit"
extends "add"; if we  visit first an URL which matched to
myapps.views.add function (with returns render_to_response('add',
base_context) and second visit an URL which matched to
myapps.views.edit functions which returns render_to_response('edit',
base_context), we will see page as if myapps.views.edit returns
render_to_response('add', base_context) (but code executed from
myapps.views.edit, I hae check). Restarting server and visiting "Edit"
URL again, will display "Edit" page ok. If I change "Edit" template to
be extended "base" (copy needed html code from "Add" template and add
"Edit" specific code), then problem disappeared.

Same problem with manipulator class inheritances:
Manipulator "Add"  inherited from "Manipulator" and introduced
validator isSomeFieldValid. Manipulator "Edit"  inherited from "Add"
and redefined validator isSomeFieldValid.
First visit the "Add" page (not even user click submit button in form).
Second visit the "Edit" page, fill the fields and click submit. User
will see error from Add.isSomeFieldValid (with my trying to debug
problem Edit.isSomeFieldValid does not raise any exception. Its look
like django lanched Edit.isSomeFieldValid and next
Add.isSomeFieldValid. Problem solved by removing inheritance "Edit"
from "Add" and moving common code to third party module wich used in
both "Add" and "Edit".

Probem exists with djando-admin.py runserver and with FastCGI mode under apache.

So for avoiding these problems I have looked to migrate to MRT.
Anybody know is construction
  Entry.objects.filter(
headline__startswith='What').exclude(
pub_date__gte=datetime.now()).filter(
pub_date__gte=datetime(2005, 1, 1))

translated to a single SQL query with WHERE clause? E.g. to something like
SELECT * FROM table_name WHERE headline LIKE 'What%' AND NOT pud_date
>= '2006-06-11 19:08:17' AND pub_date >= '2005-01-01 00:00:00'.
Or all filtering provided at application level?

-- 
Andrew Degtiariov
DA-RIPE

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Subclassing in Trunk

2006-06-11 Thread gabor

Malcolm Tredinnick wrote:
> On Fri, 2006-06-09 at 13:25 +0200, Gábor Farkas wrote:
>> Malcolm Tredinnick wrote:
>>> On Wed, 2006-06-07 at 11:34 +0100, David Reynolds wrote:
 Hi,

 I seem to remember reading either on the mailing list or IRC channel  
 that sub-classing doesn't work at the moment, is that correct? It  
 seems to work to some extent but I can't recreate the behaviour that  
 replaces_model='modelname' used to do. Is this going to be readded,  
 or a better way of doing it added and what sort of timescales are on  
 this?
>>> So nobody's pointed out that this was discussed here within the last
>>> couple of weeks. The latest status is this:
>>> http://groups.google.com/group/django-users/browse_frm/thread/827c7ba291a319e0/c9038b1e540deec4#c9038b1e540deec4
>>>
>>> It's not part of Summer of Code or anything, but it is being worked on.
>>>
>> hi Malcolm,
>>
>> great to hear that things are progressing also there...
>>
>> if i may ask... are you doing it with table-joins?
> 
> Yes.
> 
>> if yes... won't be there a performance penalty every time i want to 
>> access a field defined in the parent model?
> 
< snip />
> I am choosing to do things
> in the most natural (to me) fashion initially and trust the database to
> do its bit and only then, if it turns out to be unacceptable, should
> somebody look at where trade-offs can be made.

i'm fine with this approach, thanks a lot for the explanation.

gabor

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: calendar for blog app?

2006-06-11 Thread yml

Hello,

Have you already looked at the date_based archive:
  - 'django.views.generic.date_based.archive_month'
You can find the documentation there:
http://www.djangoproject.com/documentation/generic_views/#django-views-generic-date-based-archive-month
I hope that will help you


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Custom templates and inline editing

2006-06-11 Thread [EMAIL PROTECTED]

How can I display the form fields for an object that should be edited
inline in a custom template?

I'm passing a FormWrapper to my template, but I'm just not sure how to
display forms for inline objects or if it's even possible at this time.

Thanks.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



get_FIELD_display() doesn't work inside an instance of the model itself

2006-06-11 Thread Rudolph

Hi,

When I use get_FIELD_display() within a model method, I get the value
itself instead of the "human readable value". Also when you render a
Template inside a model method and you put something like {{
self.get_FOO_display }} in your template it has the same problem.

Does anybody experience this problem? If so, I'll file a ticket.

Rudolph


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: get_FIELD_display() doesn't work inside an instance of the model itself

2006-06-11 Thread Rudolph

Hi,

I tried to repeat the problem in a small model to publish here. Somehow
the problem doesn't show up. I'll try to isolate the problem and if
necessary post a message here.

Rudolph


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: get_FIELD_display() doesn't work inside an instance of the model itself

2006-06-11 Thread Rudolph

Hi,

I found the real problem and filed a ticket:
http://code.djangoproject.com/ticket/2136

Rudolph


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



m2m with 'self', limit_choice_to for excluding self

2006-06-11 Thread Ramiro Morales

Hello fellow Django users,

I have a model with a m2m relationship to self (think tickets that
optionally depend on one
or more tickets) and I want the the UI of the admin app add/change
pages to exclude the
item itself from the possible choices of tickets the user can select
it to depend on.

dependencies = models.ManyToManyField('self', symmetrical=False,
related_name='blocked_items', verbose_name=_('Depends on'), null=True,
blank=True)

I'm trying to use limit_choices_to for that, but I can' t find a way
to express what I want;
there is not __ne field lookup expression in Django. I can't use the
exclude(**kwargs) method because the limit_choices_to only accepts
dictionaries of the
form {: , ...} or Q objects.

Trying to use a handful of variations with the (undocumented?) QNot
object type don' t
work either, the model validation stops with these kind of errors

both
limit_choices_to=QNot=(id_exact=self.id)
limit_choices_to=QNot=(pk=self.id)
give

File ".../models.py", line 36, in Item
dependencies = models.ManyToManyField('self', symmetrical=False,
related_name='blocked_items', verbose_name=_('Depends on'), null=True,
blank=True, limit_choices_to=QNot(id__exact=self.id))
NameError: name 'self' is not defined

limit_choices_to=QNot=(id__exact=id) gives

 File ".../models.py", line 36, in Item
dependencies = models.ManyToManyField('self', symmetrical=False,
related_name='blocked_items', verbose_name=_('Depends on'), null=True,
blank=True, limit_choices_to=QNot(id__exact=id))
TypeError: __init__() got an unexpected keyword argument 'id__exact'

limit_choices_to=QNot=(pk=id) gives

File ".../models.py", line 36, in Item
dependencies = models.ManyToManyField('self', symmetrical=False,
related_name='blocked_items', verbose_name=_('Depends on'), null=True,
blank=True, limit_choices_to=QNot(pk=id))
TypeError: __init__() got an unexpected keyword argument 'pk'

ideas?

TIA

-- 
 Ramiro Morales

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---