Re: prepopulate_from

2008-08-18 Thread Jorge Vargas

On Mon, Aug 11, 2008 at 1:26 AM, Donn <[EMAIL PROTECTED]> wrote:
>
> On Monday, 11 August 2008 08:56:13 Oleg Oltar wrote:
>> I want to use text stored in field title to generate slugs.
> In the svn (> 0.96) you have to use ModelAdmin like this:
>
> clas Toon(models.Model):
>  title = models.CharField(max_length=50)
>  slug = models.SlugField(db_index=True,unique=True)
>
> class ToonAdmin(admin.ModelAdmin):
>  prepopulated_fields = {"slug": ("title",)} #sluggify the title field
>
> admin.site.register(Toon, ToonAdmin)
>
Since we are in the topic is there a less verbose way of doing this? I
have several objects (4 so far) that all share the same slug/title
pattern. which translates into 5 classes and 10 properties. could it
be a good idea to subclass Slug providing the defaults I want?

> HTH,
> \d
>
> >
>

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

2008-08-18 Thread Greg Detre

Many thanks! This was really timely and helpful. In case someone's
googling, I'm 99% sure that the book Oleg is referring to is Practical
Django Projects by James Bennett.

It's mostly excellent, but I haven't been so far found anywhere on the
Apress site that has a) a list of errata b) code snippets from the
book to download.

Thanks again, Donn.

g

On Aug 11, 3:26 am, Donn <[EMAIL PROTECTED]> wrote:
> On Monday, 11 August 2008 08:56:13 Oleg Oltar wrote:> I want to use text 
> stored in field title to generate slugs.
>
> In the svn (> 0.96) you have to use ModelAdmin like this:
>
> clas Toon(models.Model):
>   title = models.CharField(max_length=50)
>   slug = models.SlugField(db_index=True,unique=True)
>
> class ToonAdmin(admin.ModelAdmin):
>   prepopulated_fields = {"slug": ("title",)} #sluggify the title field
>
> admin.site.register(Toon, ToonAdmin)
>
> HTH,
> \d

--~--~-~--~~~---~--~~
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: InlineModelAdmin min_num ?

2008-08-18 Thread Peter of the Norse

Perhaps you’re thinking of `extra`?

On Aug 13, 2008, at 9:24 PM, mike wrote:

> InlineModelAdmin has max_num , shouldn't it have a min_num or am I
> missing something?
>
> Thanks,
> -Mike

-- 
Peter of the Norse


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



manager select_related()

2008-08-18 Thread saeb


Sorry to ask a stupid question, but following is my basic model
structure. I want to create a custom manager for a class which has a
foreignKey to another class. And to call that manager function in list
display to display all the related properties.  Am I doing it right? I
don't see any associated fields when I execute the following in shell.
Please help me with this issue, Thanks.



class privateAcctManager(models.Manager):
def show_acct(self):
return super(privateAcctManager,
self).get_query_set().select_related()

class privateAcct(models.Model):
id = models.ForeignKey(Acct)
obj = privateAcctManager()

def  all_acct(self):
   return self.obj.show_acct()

 class Meta:
   db_table= 'private_acct'

class PublicAcct(models.Model):
id = models.ForeignKey(Acct)
 class Meta:
   db_table= 'public_acct'

class Account(models.Model):
   name = models.TextField()
   balance = models.decimalfield()

class PrivateAcctAdmin(admin.modelAdmin):
list_display =( id, all_acct.name , all_acct.balance)



--~--~-~--~~~---~--~~
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: PIL 1.1.6, jpeg decoder error, going insane...

2008-08-18 Thread farastray

I had the same issue with Fedora 8, but for some reason the changes
you suggest didn't work for me.. However, I did find an obscure thread
where the Fredrik Lundh suggested trying yum install python-imaging,
and this solved all my problems!

Cheers,

Christian

On Jun 26, 7:01 am, sparky <[EMAIL PROTECTED]> wrote:
> Evert,
>
> Thank you for your help, I REALLY appreciate anyone giving me their
> time, like this. I have fixed it. The issue was to do with the library
> path and the way that Linux (Fedora Core 3) runs and is
> configured.I've been running a Linux dedicated server for a while but
> had no previous experience of Linux - quite a learning curve.
>
> PIL was not finding the libjpeg in /usr/local/lib, so I added it to /
> etc/ld.so.conf (a common Fedora gotcha apparently), ran ldconfig (to
> rebuild the library cache), re-ran PIL setup.py, and Bob's yer uncle!
>
> I had tried the JPEG_ROOT thing before, but obviously not got it
> right.
>
> Thanks again.
>
> If you ever get to DJUGL (Django Users, London), I'll buy you a beer!
>
> mjj
--~--~-~--~~~---~--~~
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: ImageField save issues (IOError: [Errno 37] No locks available)

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 17:23 -0700, wnielson wrote:
> For what its worth, I did manage a work around on the NFS side.  In /
> etc/export you need to have the `no_subtree_check` option enabled.
> Apparently this has mild security implications (as stated in man
> exports), but it does allow the locking to work properly.

I've opened #8043 anyway, since not everybody is going to have the
ability to reconfigure the NFS mount options. A big, hulking sysadmin
may be standing between them and the config file, for example. Which
makes this a bit of a showstopper in that case. Fortunately, it looks
like it's ultimately solvable.

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



Re: ImageField save issues (IOError: [Errno 37] No locks available)

2008-08-18 Thread wnielson

For what its worth, I did manage a work around on the NFS side.  In /
etc/export you need to have the `no_subtree_check` option enabled.
Apparently this has mild security implications (as stated in man
exports), but it does allow the locking to work properly.

Thanks for the insight Malcolm.

Cheers,
Wes

On Aug 19, 12:48 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-08-18 at 16:42 -0700, wnielson wrote:
> > Thanks for the quick response.  Yes, I did do some searching and ran
> > across the post about NFS (and yes I am using an NFS mount).  However,
> > I can solve the problem by bypassing the `save` method like so:
>
> > from django.core.files import File
>
> > f = open('my_filename.jpg', 'w')
> > myfile = File(f)
> > myfile.write(image.read())
> > sm.image = myfile
>
> > I suppose this method works because it bypasses the `save` method's
> > use of the lock.
>
> Precisely. Which makes it subject to race conditions and lots of
> problems because of that.
>
> You could also avoid the problem by not saving your file at all. Both
> options are just symptom patching, rather than a solution to the
> problem. :-)
>
> Looks like we need to switch from flock-based locking to fcntl-based
> locking where available. *sigh*. I'll take care of opening a ticket for
> this.
>
> 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
-~--~~~~--~~--~--~---



Re: ImageField save issues (IOError: [Errno 37] No locks available)

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 16:42 -0700, wnielson wrote:
> Thanks for the quick response.  Yes, I did do some searching and ran
> across the post about NFS (and yes I am using an NFS mount).  However,
> I can solve the problem by bypassing the `save` method like so:
> 
> from django.core.files import File
> 
> f = open('my_filename.jpg', 'w')
> myfile = File(f)
> myfile.write(image.read())
> sm.image = myfile
> 
> I suppose this method works because it bypasses the `save` method's
> use of the lock.

Precisely. Which makes it subject to race conditions and lots of
problems because of that.

You could also avoid the problem by not saving your file at all. Both
options are just symptom patching, rather than a solution to the
problem. :-)

Looks like we need to switch from flock-based locking to fcntl-based
locking where available. *sigh*. I'll take care of opening a ticket for
this.

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



Re: ImageField save issues (IOError: [Errno 37] No locks available)

2008-08-18 Thread wnielson

Thanks for the quick response.  Yes, I did do some searching and ran
across the post about NFS (and yes I am using an NFS mount).  However,
I can solve the problem by bypassing the `save` method like so:

from django.core.files import File

f = open('my_filename.jpg', 'w')
myfile = File(f)
myfile.write(image.read())
sm.image = myfile

I suppose this method works because it bypasses the `save` method's
use of the lock.

On Aug 19, 12:16 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-08-18 at 16:05 -0700, wnielson wrote:
> > I've been running into an issue while trying to upgrade my code to use
> > Django's new file handling system.  When I try to use the `save`
> > method of a `ImageField` instance, I get an `IOError: [Errno 37] No
> > locks available`.  The file gets created but nothing is ever written
> > to it.  Here is a basic example that illustrates the issue I keep
> > running into.
>
> We need some more details about your particular setup. Are you trying to
> save to an NFS mounted filesystem? A bit of searching on Google for that
> error message (which hopefully you also did before posting to the
> mailing list, right?) shows that it's possible there.
>
> If you're not using an NFS_mounted system as the destination, what sort
> of OS and filesystem are you trying to save to? Do things change if you
> target the file saves to somewhere else that is more or less guaranteed
> to be locally mounted (e.g. /tmp on a Unix system)?
>
> 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
-~--~~~~--~~--~--~---



Re: ImageField save issues (IOError: [Errno 37] No locks available)

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 16:05 -0700, wnielson wrote:
> I've been running into an issue while trying to upgrade my code to use
> Django's new file handling system.  When I try to use the `save`
> method of a `ImageField` instance, I get an `IOError: [Errno 37] No
> locks available`.  The file gets created but nothing is ever written
> to it.  Here is a basic example that illustrates the issue I keep
> running into.

We need some more details about your particular setup. Are you trying to
save to an NFS mounted filesystem? A bit of searching on Google for that
error message (which hopefully you also did before posting to the
mailing list, right?) shows that it's possible there.

If you're not using an NFS_mounted system as the destination, what sort
of OS and filesystem are you trying to save to? Do things change if you
target the file saves to somewhere else that is more or less guaranteed
to be locally mounted (e.g. /tmp on a Unix system)?

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



Re: ifequal doesn't evaluate expressions

2008-08-18 Thread zdmytriv

> However the implementation of such a
> tag would be unlikely to need much patching in the future

"... patching in the future"

No comments...

> so Malcolm's
> advice about implementing it yourself would be acceptable, I'd have thought.

No comments...

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



ImageField save issues (IOError: [Errno 37] No locks available)

2008-08-18 Thread wnielson

I've been running into an issue while trying to upgrade my code to use
Django's new file handling system.  When I try to use the `save`
method of a `ImageField` instance, I get an `IOError: [Errno 37] No
locks available`.  The file gets created but nothing is ever written
to it.  Here is a basic example that illustrates the issue I keep
running into.

from django.db import models
from urllib import urlopen

class SomeModel(models.Model):
image = models.ImageField(upload_to='some_dir', blank=True,
null=True)


sm = SomeModel()
image = urlopen('http://ecx.images-amazon.com/images/I/
51pnPEb8STL._SS500_.jpg')
sm.image.save('my_filename.jpg', image, save=False)


Does anyone have any advice?

Thanks in advance,
Wes
--~--~-~--~~~---~--~~
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: ifequal doesn't evaluate expressions

2008-08-18 Thread Steve Holden

zdmytriv wrote:
> 2 Steve:
>
>   
>> That's no way to endear yourself to the Django community. The
>> development team has some pretty good brains.
>> 
>
> I agree, I was too aggressive, sorry about that. Just can't believe
> that bug like this can be on this level.
>   
I'd argue that it isn't a bug, it's a feature there by design.
> What about ifless? Is it going to be implemented in 1.0 also?
>   
>> I very much doubt it.
>> 
>
> It doesn't look like... I hope...
>
>   
No, Django's in feature freeze now. However the implementation of such a 
tag would be unlikely to need much patching in the future, so Malcolm's 
advice about implementing it yourself would be acceptable, I'd have thought.


regards
 Steve



--~--~-~--~~~---~--~~
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: ifequal doesn't evaluate expressions

2008-08-18 Thread zdmytriv

> That's one good reason why it's not needed in core. If you need it and
> you understand the trade-offs and consequences, you can implement it
> immediately with no break in the flow. Django's supported third-party
> template tags since day 1 (and even earlier). :-)

It's always bad idea to extend somebodies tool because when you wanted
to update current version with latest you can be in trouble. Latest
doesn't always support previous.
i.e. Django 1.0 uses Variable class to process variable from template
but 0.96 uses plain function resolve_variable() which is deprecated in
1.0.

Zinovii
--~--~-~--~~~---~--~~
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: How to set can_delete to TabularInline

2008-08-18 Thread Marinho Brandao

ok, found here:

http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L755

2008/8/18 Marinho Brandao <[EMAIL PROTECTED]>:
> Hi all,
>
> (talking about Admin)
>
> somebody knows how to set a can_delete=True to a TabularInline-based class?
>
> looking into the code, I see the inline formsets are created in
> ModeAdmin.add_view and ModeAdmin.change_view, and not found a way to
> do that with no hack into them to set can_delete
>
> thanks :)
>
> --
> Marinho Brandão (José Mário)
> http://marinho.webdoisonline.com/
>



-- 
Marinho Brandão (José Mário)
http://marinho.webdoisonline.com/

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



How to set can_delete to TabularInline

2008-08-18 Thread Marinho Brandao

Hi all,

(talking about Admin)

somebody knows how to set a can_delete=True to a TabularInline-based class?

looking into the code, I see the inline formsets are created in
ModeAdmin.add_view and ModeAdmin.change_view, and not found a way to
do that with no hack into them to set can_delete

thanks :)

-- 
Marinho Brandão (José Mário)
http://marinho.webdoisonline.com/

--~--~-~--~~~---~--~~
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: ifequal doesn't evaluate expressions

2008-08-18 Thread zdmytriv

2 Steve:

> That's no way to endear yourself to the Django community. The
> development team has some pretty good brains.

I agree, I was too aggressive, sorry about that. Just can't believe
that bug like this can be on this level.

> > What about ifless? Is it going to be implemented in 1.0 also?
>
> I very much doubt it.

It doesn't look like... I hope...

Zinovii
--~--~-~--~~~---~--~~
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: ifequal doesn't evaluate expressions

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 13:37 -0700, zdmytriv wrote:
> 2 Malcolm:
> 
> > It makes a lot of sense when you think about what they can apply to.
> > Equality is a natural operation for all sorts of object types. The
> "less
> > than" comparison only applies to things that have a natural
> ordering.
> > The first set is much larger than the second.
> > A normal use for "ifequal" is testing string values for equality.
> not so
> > much for doing mathematical comparisons.

[...]
> You still can compare them and python is not going to complain and
> more you can compare even objectA < 1...

I used the word "natural" in my original post for a reason. You can
certainly compare these objects, but it's not particularly sensible. We
already have enough problems with people comparing visually similar, but
actually unlike, objects and having equality fail. Introducing ordering
operations would lead to further confusion.

> I still can't get why not to implement ifless. It's like 3 min of
> coding.

That's one good reason why it's not needed in core. If you need it and
you understand the trade-offs and consequences, you can implement it
immediately with no break in the flow. Django's supported third-party
template tags since day 1 (and even earlier). :-)

Anyway, it's all a moot point. Feature freeze is in place. Let's move
onwards to 1.0.

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



Re: ifequal doesn't evaluate expressions

2008-08-18 Thread zdmytriv

2 Malcolm:

> It makes a lot of sense when you think about what they can apply to.
> Equality is a natural operation for all sorts of object types. The "less
> than" comparison only applies to things that have a natural ordering.
> The first set is much larger than the second.
> A normal use for "ifequal" is testing string values for equality. not so
> much for doing mathematical comparisons.

I'm disagree. ifequal at the end goes to python level of equality. So
1. a = 1, b = 1.0
2. a = 1, b = "1"

ifequal 1 1.0  # True
ifequal 1 "1"  # False

So looks like dynamic typecasting works.

For example:

class ClassA(object):
   pass

class ClassB(object):
   pass

objectA = ClassA()
objectB = ClassB()

if objectA < objectB:
print "A < B"
else:
print "A > B"

You still can compare them and python is not going to complain and
more you can compare even objectA < 1...

If you dig deeper into realization level, into django/template/
defaulttags.py:

class IfEqualNode(Node):
...
def render(self, context):
...
if (self.negate and val1 != val2) or (not self.negate and val1
== val2):
return self.nodelist_true.render(context)
...

So comparison is nothing but python == and !=.

I still can't get why not to implement ifless. It's like 3 min of
coding.

Zinovii
--~--~-~--~~~---~--~~
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: inline model with FilePathField

2008-08-18 Thread tosh


On Aug 18, 2:09 pm, tosh <[EMAIL PROTECTED]> wrote:
> maybe i'm missing something obvious but it seems that if i have an
> inline model that uses the FilePathField a new object is added on
> every save.
>
> simple example
>
> models:
> class Video(models.Model):
> title = models.CharField()
> filepath = models.FilePathField(path="/path")
>
> class Story(models.Model):
> title = models.CharField()
> video = models.ForeignKey(Video)
>
> admin:
> class VideoInline(admin.TabularInline):
> model = Video
>
> class StoryAdmin(admin.ModelAdmin):
> inlines = [VideoInline, ]
>
> in this case every time you add or edit a Story, A video is added
> regardless?


i just read my own message and realized i never actually asked my
question, even though it's implied. How can i stop this behavior?
before newforms i could specify a field as core and so the inline
would not be saved but since newforms has been merged core no longer
exists.
--~--~-~--~~~---~--~~
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: lighttpd +fastcgi

2008-08-18 Thread Gonzalo Almeida

wow that was easy,
thanks you very much malcolm

Gon



-- 
Linux user #466939

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



FormWizard Problems

2008-08-18 Thread ocgstyles

I'm experiencing some strange behavior with the Form Wizard.  During
testing, sometimes I'll get to the last step, click Finish, and I'll
get another form with no fields and finish button turns back into a
next button.

Its set up like this:

# urls.py
(r'^application/$', MyWizard([Appl1, Appl2, DummyForm, DummyForm])),

I use DummyForms (class DummyForm(forms.Form): pass) as a place holder
because I know I will have 4 steps.  During the process_step function,
I want to insert the correct forms.  The form that displays for step3,
depends on a value selected in step2.  A value in step3, determines
which field gets inserted for step 4.  I see some examples out there
where people use form_list.append(NewForm) to add steps.  I chose not
to do this because I am display an indicator that states which step
you are on; I don't want the total number of steps to change.

So the process_step logic looks like this:

# forms.py
def process_step(self, request, form, step):
  # cleaned_data at this point apparently contains a unicode string
value, rather than a python data type - annoying.
  if form.__class__.__name__ == 'Appl2' and
form.__dict__.has_key('cleaned_data'):
if form.cleaned_data['test_value_1'] == 'True':
  self.form_list[2] = Appl3_yes
else
  self.form_list[2] = Appl3_no

  if form.__class__.__name__ == 'Appl3' and
form.__dict__.has_key('cleaned_data'):
if form.cleaned_data['test_value_2'] == 'True':
  self.form_list[3] = Appl4_yes
else
  self.form_list[3] = Appl4_no


First off, am I using the "process_step" function properly?  In my
case, does the fact that this function gets called after each submit
for every completed step?  For example:

Step 0
Step 0, 1
Step 0, 1, 2
Step 0, 1, 2, 3

I have a feeling I'm just screwing up something elementary, because I
have another form that works just like this one, only difference being
that I only do 1 form substitution, rather than 2.

Any ideas?

Keith

--~--~-~--~~~---~--~~
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: ImportError: cannot import name parse_lookup

2008-08-18 Thread Nicolas Couture

Using django-tagging r133 fixed the problem.

Thank you!

On Aug 18, 3:54 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-08-18 at 12:33 -0700,NicolasCouturewrote:
> > [...]
> >     signals.post_save.connect(self._save, cls, True)
> > AttributeError: 'object' object has no attribute 'connect'
>
> > I am using django r7966.
>
> > Would anyone be able to provide more input as to why this is breaking?
>
> Because you're using the latest version of django-tagging, which has
> been updated to support the latest version of Django (currently at
> r8434). That includes some changes that are backwards-incompatible. So
> you need a slightly older checkout of Django tagging.
>
> 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
-~--~~~~--~~--~--~---



Re: lighttpd +fastcgi

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 16:47 -0300, Gonzalo Almeida wrote:
> hello,
> I have a problem with lighttpd + fastcgi,
> I used have the newforms-admin branch and everything worked fine.
> but when I started using the trunk version, the problems appeared.
> when I access http://localhost/admin/, I try to loggin in the admin.
> and it redirect me to http://localhost/mysite.fcgi/admin/
> and this appear in the browser :
> 
> Page not found (404)
> Request Method:   POST
> Request URL:  http://localhost/mysite.fcgi/mysite.fcgi/admin/
> (the mysite.fcgi is repeated)

Refer to
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined

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



Re: ImportError: cannot import name parse_lookup

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 12:33 -0700, Nicolas Couture wrote:
> [...]

> signals.post_save.connect(self._save, cls, True)
> AttributeError: 'object' object has no attribute 'connect'
> 
> I am using django r7966.
> 
> Would anyone be able to provide more input as to why this is breaking?

Because you're using the latest version of django-tagging, which has
been updated to support the latest version of Django (currently at
r8434). That includes some changes that are backwards-incompatible. So
you need a slightly older checkout of Django tagging.

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



Workflow Building with NewForms, ModelForm

2008-08-18 Thread DoctorMO

Hello All,

This is just a quick FYI to state what I'm currently working on and
see if anyone has anything to add or good ideas (or even criticisms)

Since django can do model forms which reflect a models fields and save
the created object appropriately. I'm researching the possibility of
creating some structures to manage workflows which would ultimately be
a collection of model forms which would save inter-referencing models.

The functionality it needs to do is, pass data from each step and save
when the process is complete (not before); be able to model process
level data entry so you could specify interesting relationships.

I don't know what will come out of my work, but I'm hoping to build
something useful for organisational software.

Best Regards, Martin Owens
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



lighttpd +fastcgi

2008-08-18 Thread Gonzalo Almeida

hello,
I have a problem with lighttpd + fastcgi,
I used have the newforms-admin branch and everything worked fine.
but when I started using the trunk version, the problems appeared.
when I access http://localhost/admin/, I try to loggin in the admin.
and it redirect me to http://localhost/mysite.fcgi/admin/
and this appear in the browser :

Page not found (404)
Request Method: POST
Request URL:http://localhost/mysite.fcgi/mysite.fcgi/admin/
(the mysite.fcgi is repeated)

also APPEND_SLASH  is not working.
I looked every where to solve the problem but I didn't find anything.
the problems only appear with lighttpd + fastcgi. with apache and
mod_python works fine

Does anyone know what is going on?

thanks in advance

ps: sorry my English is not so good


-- 
Linux user #466939

--~--~-~--~~~---~--~~
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: ImportError: cannot import name parse_lookup

2008-08-18 Thread Nicolas Couture

On Jul 21, 2:25 pm, Fernando Rodríguez <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm implementing the coltrane blog app in "Practical Django Projects"
> and when I try to syncdb I get this error and traceback.
>
> I'm using version 0.97 downloaded from svn.
>
> Any ideas? O:-)
>
> PS Here's the traceback:
>
> Traceback (most recent call last):
>   File "./manage", line 11, in 
>     execute_manager(settings)
>   File
> "/usr/lib/python2.5/site-packages/django/core/management/__init__.py",
> line 301, in execute_manager
>     utility.execute()
>   File
> "/usr/lib/python2.5/site-packages/django/core/management/__init__.py",
> line 248, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/usr/lib/python2.5/site-packages/django/core/management/base.py", line
> 77, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File
> "/usr/lib/python2.5/site-packages/django/core/management/base.py", line
> 91, in execute
>     output = self.handle(*args, **options)
>   File
> "/usr/lib/python2.5/site-packages/django/core/management/base.py", line
> 173, in handle
>     return self.handle_noargs(**options)
>   File
> "/usr/lib/python2.5/site-packages/django/core/management/commands/shell.py", 
> line 18, in handle_noargs
>     loaded_models = get_models()
>   File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 136, in get_models
>     self._populate()
>   File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 57, in _populate
>     self.load_app(app_name, True)
>   File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 72, in load_app
>     mod = __import__(app_name, {}, {}, ['models'])
>   File "/home/fernando/django/elis/models.py", line 6, in 
>     from tagging.fields import TagField
>   File "/home/fernando/django/tagging/fields.py", line 10, in 
>     from tagging.models import Tag
>   File "/home/fernando/django/tagging/models.py", line 9, in 
>     from tagging.managers import TagManager, TaggedItemManager
>   File "/home/fernando/django/tagging/managers.py", line 6, in 
>     from django.db.models.query import QuerySet, parse_lookup
> ImportError: cannot import name parse_lookup

I am seeing the same exception using tagging-0.2.1 while reading
Practical Django Projects:

[EMAIL PROTECTED]:~/dev/django/cms$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 301, in execute_manager
utility.execute()
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 248, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 77, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 90, in execute
self.validate()
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 117, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 128, in get_app_errors
self._populate()
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "/home/remote/dev/django/coltrane/models.py", line 7, in

from tagging.fields import TagField
  File "/usr/lib/python2.5/site-packages/tagging/fields.py", line 10,
in 
from tagging.models import Tag
  File "/usr/lib/python2.5/site-packages/tagging/models.py", line 9,
in 
from tagging.managers import TagManager, TaggedItemManager
  File "/usr/lib/python2.5/site-packages/tagging/managers.py", line 6,
in 
from django.db.models.query import QuerySet, parse_lookup
ImportError: cannot import name parse_lookup

Using the tagging from trunk (r145):

[EMAIL PROTECTED]:~/dev/django/cms$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 301, in execute_manager
utility.execute()
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 248, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 77, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 90, in execute

inline model with FilePathField

2008-08-18 Thread tosh

maybe i'm missing something obvious but it seems that if i have an
inline model that uses the FilePathField a new object is added on
every save.

simple example

models:
class Video(models.Model):
title = models.CharField()
filepath = models.FilePathField(path="/path")

class Story(models.Model):
title = models.CharField()
video = models.ForeignKey(Video)

admin:
class VideoInline(admin.TabularInline):
model = Video

class StoryAdmin(admin.ModelAdmin):
inlines = [VideoInline, ]


in this case every time you add or edit a Story, A video is added
regardless?
--~--~-~--~~~---~--~~
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: Trouble with regex

2008-08-18 Thread Fernando Rodríguez

El lun, 18-08-2008 a las 13:10 -0500, Malcolm Tredinnick escribió:

> It looks like you might be making an assumption that the patterns are
> concatenated. This isn't correct.
> 
> The patterns in resume_templates.urls will be applied to the suffixes of
> the URLs matching resumes (after the first matched portion is removed).
> It's not the case that the reg-exp patterns are joined together and then
> applied as a single thing. Django first matches /resumes/, sees that it
> matches and then passes control to the next piece of the resolver
> (resume_templates.urls).

Thanks Malcolm, now I got it.



--~--~-~--~~~---~--~~
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: Trouble with regex

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 20:04 +0200, Fernando Rodríguez wrote:
> El lun, 18-08-2008 a las 12:49 -0500, Norman Harman escribió:
> 
> > 
> > I'm fairly certain the space indicates an urls came from an "include". 
> > The spaces are not really part of regex.
> 
> OK
> 
> 
> > 
> > In latter case career would be word
> > 
> > 
> > Your urls should be like this:
> >(r'^(?P[-\w]+)/$', career_list),
> >(r'^jss/(?P[-\w]+)/$', jss_list),
> 
> I don't understand this part. Since the patterns in the app urls.py will
> become a suffix of the pattern in the project's urls.py 

It looks like you might be making an assumption that the patterns are
concatenated. This isn't correct.

The patterns in resume_templates.urls will be applied to the suffixes of
the URLs matching resumes (after the first matched portion is removed).
It's not the case that the reg-exp patterns are joined together and then
applied as a single thing. Django first matches /resumes/, sees that it
matches and then passes control to the next piece of the resolver
(resume_templates.urls).

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



Re: Trouble with regex

2008-08-18 Thread Fernando Rodríguez

El lun, 18-08-2008 a las 10:35 -0700, Rajesh Dhawan escribió:

> 
> You need to remove replace /jss/ there with jss/:
> 
> (r'jss/(?P[-\w]+)/$', jss_list),
> 

Ouch! O:-)



--~--~-~--~~~---~--~~
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: Trouble with regex

2008-08-18 Thread Fernando Rodríguez

El lun, 18-08-2008 a las 12:49 -0500, Norman Harman escribió:

> 
> I'm fairly certain the space indicates an urls came from an "include". 
> The spaces are not really part of regex.

OK


> 
> In latter case career would be word
> 
> 
> Your urls should be like this:
>(r'^(?P[-\w]+)/$', career_list),
>(r'^jss/(?P[-\w]+)/$', jss_list),

I don't understand this part. Since the patterns in the app urls.py will
become a suffix of the pattern in the project's urls.py 
(r'^resumes/', include('agbo.resume_templates.urls')),

why shoudl they need the start of line meta char? :-?

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?hl=en
-~--~~~~--~~--~--~---



Re: Trouble with regex

2008-08-18 Thread Norman Harman

Fernando Rodríguez wrote:
> Hi,
> 
> I have the following regexes on my django app urls.py:
> 
> urlpatterns = patterns('',
>
># List of all resumes for a given Career
>(r'(?P[-\w]+)/$', career_list),
>
># List of all resumes for a given jss
>(r'/jss/(?P[-\w]+)/$', jss_list),
>)
> 
> On my django project I have:
> 
> urlpatterns = patterns('',
> # Access to the resume templates
> (r'^resumes/', include('agbo.resume_templates.urls')),
> )
> 
> Whenever I try to call the second view (jss_list) with a url such as
> localhost:8000/resumes/jss/no-experience/ I get into trouble.
> 
> Instead of calling the second, django calls the first one and the group
> "career" contains "no-experience".  It looks like the "/jss/" is being
> ignored, but I don't know why. :-?
> 
> 
> If I try a url that doesn't exist, I get some interesting information:
> 
> -- Page not Found error 
> Using the URLconf defined in resume_templates_biz.urls, Django tried
> these URL patterns, in this order: 
> 
>  1. ^admin/doc/
>  2. ^admin/(.*)
>  3. ^resumes/ (?P[-\w]+)/$
>  4. ^resumes/ /jss/(?P[-\w]+)/$
> 
> The current URL, resumes/, didn't match any of these.
> ---
> 
> The url patterns 3 and 4 have a space  between "^resumes/" and the rest.
> I have no idead where that space is coming from or if it's the cause of
> the error mentioned above.

I'm fairly certain the space indicates an urls came from an "include". 
The spaces are not really part of regex.

One problem is the jss regex should not start with / since your resumes 
ends with one.

Another problem is your regex's don't include ^ match start of text. 
Without you t run into problems with regex doing partial match at end of 
string. Just like you are having your example.

Since you omit the match start your 1st urls matches:
   /resumes/jss/no-experience/
and
   /resumes/anything/at/all/ending_with_a_word_and_a_slash/word/

In latter case career would be word


Your urls should be like this:
   (r'^(?P[-\w]+)/$', career_list),
   (r'^jss/(?P[-\w]+)/$', jss_list),


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
It's August!  Keep your cool with the Statesman.  Check out our hot
deals in print and online for back-to-school savings and more!

--~--~-~--~~~---~--~~
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: how to display date nicely

2008-08-18 Thread Rajesh Dhawan



On Aug 18, 7:20 am, Will Rocisky <[EMAIL PROTECTED]> wrote:
> actually I have to do it in views, not template
> I need some pure python code

Django's default filters are written in pure Python ;)

You can just call the django.template.defaultfilters.date() method
directly in your view -- just pass it the date instance and the format
string as arguments. The format string would use the same pattern as
you would when using the date filter in a template.

-RD
--~--~-~--~~~---~--~~
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: Trouble with regex

2008-08-18 Thread Rajesh Dhawan

Hi Fernando,

> I have the following regexes on my django app urls.py:
>
> urlpatterns = patterns('',
>
># List of all resumes for a given Career
>(r'(?P[-\w]+)/$', career_list),
>
># List of all resumes for a given jss
>(r'/jss/(?P[-\w]+)/$', jss_list),
>)

You need to remove replace /jss/ there with jss/:

(r'jss/(?P[-\w]+)/$', jss_list),

-Rajesh D

--~--~-~--~~~---~--~~
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: dynamic creation of model with geodjango ?

2008-08-18 Thread springmeyer

Guillame,

Absolutely. GeoDjango can be used to read new or existing geographic
datasources from dozens of formats. GeoDjango provides a ctypes
interface to the foundational GDAL/OGR library, which is the open
source industry standard for format translation. Look for the utility
called `orginspect`.

While the GeoDjango documentation is still being worked on, the
Docstrings are excellent.  To see how ogrinspect works you'll need to
do nothing but (a sample project and shapefile can be downloaded from
http://code.google.com/p/geodjango-basic-apps/wiki/GeographicAdminQuickStart):

>>> from django.contrib.gis.utils import ogrinspect
>>> help(ogrinspect)


Help on function ogrinspect in module
django.contrib.gis.utils.ogrinspect:

ogrinspect(*args, **kwargs)
Given a data source (either a string or a DataSource object) and a
string
model name this function will generate a GeoDjango model.

Usage:

>>> from django.contrib.gis.utils import ogrinspect
>>> ogrinspect('/path/to/shapefile.shp','NewModel')

...will print model definition to stout

or put this in a python script and use to redirect the output to a
new
model like:

$ python generate_model.py > myapp/models.py

# generate_model.py
from django.contrib.gis.utils import ogrinspect
shp_file = 'data/mapping_hacks/world_borders.shp'
model_name = 'WorldBorders'

print ogrinspect(shp_file, model_name, multi_geom=True, srid=4326,
 geom_name='shapes', blank=True)
:

Cheers,

Dane


On Aug 13, 12:39 am, guillaume <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I'm pretty glad to see that GeoDjango has joined the main trunk. As it
> is a great tool for managing geographic data, I am wondering if it is
> possible to create a new model dynamically. Imagine you want to add a
> new geographic data source to your app, how can it be done ?
>
> Regards,
>
> Guillaume
--~--~-~--~~~---~--~~
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: modelforms: getting field object in clean_ method

2008-08-18 Thread Steve Holden

Aljosa Mohorovic wrote:
> On Aug 18, 5:13 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>> "2 or more fields" is a signal that the clean() method on the form is
>> the right place to do this. At that point, all the fields will have
>> individually passed their validation (i.e. they will be of the right
>> type) and any fields which didn't pass will not be in self.cleaned_data.
> 
> i can find examples of clean() method and "raise
> forms.ValidationError('error msg')" but none on how to bind error with
> field.
> what i would like to do in clean method is raise field validation
> error(after PROBLEM part):
> def clean(self):
>   if custom_validation() == False:
> raise forms.ValidationError('custom validation failed')
> 
> # raise validation error for field_1 and field_2
> # PROBLEM: don't know how to raise validation errors on fields
> raise forms.ValidationError('field_1 error msg') on field_1
> raise forms.ValidationError('field_2 error msg') on field_2
> 
>   return self.cleaned_data
> 
http://www.djangosnippets.org/snippets/337/

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--~--~-~--~~~---~--~~
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: Serving static content using Apache

2008-08-18 Thread Steve Holden

djandrow wrote:
> Managed to get it working, thanks everyone.
> 
> I guess the problem was CSS was missing from locationMatch
> --~--~-~--~~~---~--~~

Good news. For what it's worth, when I am serving static content I tend 
to set whole directories to be served statically rather than limit it to 
specific extensions by matching. So in my config files I tend to use 
stuff like

 
 SetHandler None
 

 
 SetHandler None
 

and everything from those areas gets served statically. I only have 
multiple directories because the original design didn't conveniently 
lump everything under /static/.

YMMV, of course, but it's a thought.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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



Trouble with regex

2008-08-18 Thread Fernando Rodríguez

Hi,

I have the following regexes on my django app urls.py:

urlpatterns = patterns('',
   
   # List of all resumes for a given Career
   (r'(?P[-\w]+)/$', career_list),
   
   # List of all resumes for a given jss
   (r'/jss/(?P[-\w]+)/$', jss_list),
   )

On my django project I have:

urlpatterns = patterns('',
# Access to the resume templates
(r'^resumes/', include('agbo.resume_templates.urls')),
)

Whenever I try to call the second view (jss_list) with a url such as
localhost:8000/resumes/jss/no-experience/ I get into trouble.

Instead of calling the second, django calls the first one and the group
"career" contains "no-experience".  It looks like the "/jss/" is being
ignored, but I don't know why. :-?


If I try a url that doesn't exist, I get some interesting information:

-- Page not Found error 
Using the URLconf defined in resume_templates_biz.urls, Django tried
these URL patterns, in this order: 

 1. ^admin/doc/
 2. ^admin/(.*)
 3. ^resumes/ (?P[-\w]+)/$
 4. ^resumes/ /jss/(?P[-\w]+)/$

The current URL, resumes/, didn't match any of these.
---

The url patterns 3 and 4 have a space  between "^resumes/" and the rest.
I have no idead where that space is coming from or if it's the cause of
the error mentioned above.

Any help would be greatly appreciated.

Fernando





--~--~-~--~~~---~--~~
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: modelforms: getting field object in clean_ method

2008-08-18 Thread Aljosa Mohorovic

On Aug 18, 5:13 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> "2 or more fields" is a signal that the clean() method on the form is
> the right place to do this. At that point, all the fields will have
> individually passed their validation (i.e. they will be of the right
> type) and any fields which didn't pass will not be in self.cleaned_data.

i can find examples of clean() method and "raise
forms.ValidationError('error msg')" but none on how to bind error with
field.
what i would like to do in clean method is raise field validation
error(after PROBLEM part):
def clean(self):
  if custom_validation() == False:
raise forms.ValidationError('custom validation failed')

# raise validation error for field_1 and field_2
# PROBLEM: don't know how to raise validation errors on fields
raise forms.ValidationError('field_1 error msg') on field_1
raise forms.ValidationError('field_2 error msg') on field_2

  return self.cleaned_data

Aljosa
--~--~-~--~~~---~--~~
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 and set encryption in Model Forms

2008-08-18 Thread simong

On Aug 11, 1:42 am, jonknee <[EMAIL PROTECTED]> wrote:
> On Aug 10, 11:29 am, simong <[EMAIL PROTECTED]> wrote:
>
> > The code executes correctly and writes the record to the database but
> > doesn't encrypt the credit card number.
>
> You're not following the snippet you linked to, the view code you
> posted shows that you're writing ccno directly. The example you linked
> to writes to the property. It might be easier to do in a custom save()
> method because the ModelForm one is automatically writing the ccno
> value.
>
> And in any event, you may want to rethink about saving credit card
> numbers at all. Especially like this where it's attached to an order.
> It's a big liability for little payoff (just save the info you get
> back from the payment gateway and you can do stuff like refunds and
> most support subscriptions). PCI compliance isn't easy and if you slip
> up you can easily lose the ability to accept credit cards and that
> will most likely devastate your business.

Finally got back to looking at this, thanks both for the tip.

I agree that it's not a good idea to save credit card numbers even
when encrypted but the client isn't using a payment gateway, just
their shop card machine so it's a way of transmitting the number so
that they can process it by hand.

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



I posted a new template tag for forever-caching resources...

2008-08-18 Thread Jon Brisbin

...at djangosnippets:

http://www.djangosnippets.org/snippets/991/

I wanted to be able to use the forever-caching capability of Google  
Web Toolkit with my own resources, so I wrote this template tag to  
handle any resource. If the file you want cacheable is a JS or CSS  
file, it will (optionally) use YUI compressor to compress the file  
first.

It creates a copy of your original file called "LONGMD5SUM.cache.(js| 
css|png|gif|etc...)". You have to set it up separately, but to get the  
effect of forever-caching, configure your webserver to cache resources  
conforming to that name. Different webservers do it differently, of  
course (I use lighttpd), so that's left as an exercise to the reader.

In DEBUG mode, the minification and copying is turned off so you don't  
get a proliferation of files as you develop.

I'm not entirely happy with the way I handle relative vs. absolute  
paths. It's hard to get a scheme that will work in cacheable and non- 
cacheable mode using the same pathname. I settled on setting  
DOCUMENT_ROOT in settings.py to my real document root (one step above  
MEDIA_ROOT) and using "/media/css/my.css" etc... in the "src" and  
"href" attributes in the template. I have to strip the leading "/" off  
to make os.path.join work right, but I have to put it *back* after I  
strip out DOCUMENT_ROOT and send it as a path to the browser. I think  
there's a better way to handle this and I'd be interested in hearing  
how to do that.

I hope you find this useful. Comments are welcome!

Thanks!

Jon Brisbin
http://jbrisbin.com




--~--~-~--~~~---~--~~
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: Model relationships

2008-08-18 Thread [EMAIL PROTECTED]

Thanks for your reply Malcolm. I'll take a look at related fields.
--~--~-~--~~~---~--~~
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: modelforms: getting field object in clean_ method

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 08:05 -0700, Aljosa Mohorovic wrote:
> i currently use self.instance but i'm not sure if i can do that since
> i didn't find an example using it in docs.

There are a few parts of model forms that aren't (re-)documented in the
docs. Reading the code and docstrings is a good way to look at what's
possible there. From having a quick read of the code, self.instance
looks like the right thing.

> also, i'm looking for clean method example where i can raise
> validation errors for 2 or more fields based on single validation.

"2 or more fields" is a signal that the clean() method on the form is
the right place to do this. At that point, all the fields will have
individually passed their validation (i.e. they will be of the right
type) and any fields which didn't pass will not be in self.cleaned_data.

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



Re: Model relationships

2008-08-18 Thread Malcolm Tredinnick


On Mon, 2008-08-18 at 05:36 -0700, [EMAIL PROTECTED] wrote:
> Incase my question wasn't clear enough, as I had trouble describing
> it ...
> 
> Can a different model access the manytomany table that django makes ?

No, but you're probably thinking about this on the wrong level. Think
about it in terms of models: once you have a Task instance, you can
easily work out which users have been assigned to it (because any models
that are related can access each other).

So, ignore the database tables and look at how to access related fields.
This is described in the db-api documentation, as well as in the Django
tutorial (polls and choices in the tutorial are related by a ForeignKey
and the syntax is basically identical for ManyToManyFields).

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



Re: modelforms: getting field object in clean_ method

2008-08-18 Thread Aljosa Mohorovic

i currently use self.instance but i'm not sure if i can do that since
i didn't find an example using it in docs.
also, i'm looking for clean method example where i can raise
validation errors for 2 or more fields based on single validation.
something like:
if custom_validation() == False:
  # raise validation error for field_1 and field_2

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



modelforms: getting field object in clean_ method

2008-08-18 Thread Aljosa Mohorovic

if i have a MainModel:

class MainModel(models.Model):
  [...]
  mymodel = models.ForeignKey(MyModel)

and MainModelForm:

class MainModelForm(forms.ModelForm):
  def clean_somefield(self):
# here i need to get mymodel for current form to validate
something

somewhere in views i have:

mainmodel_instance = MainModel(mymodel=mymodel_instance)
form = MainModelForm(request.POST, instance=mainmodel_instance)

what can i do to get mymodel instance in clen_ methods?

Aljosa Mohorovic
--~--~-~--~~~---~--~~
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: Generic Views and ModelAdmin: too much code?

2008-08-18 Thread fabio natali

Dear Ivan, your help is priceless, thanks!

Ivan Sagalaev wrote:
[...]
> In models.py you can get rid of repeating "Manufacturer" two extra times 
> by doing:
> 
>  class Manufacturer(models.Model):
>  name = models.CharField(max_length=30)
>  address = models.CharField(max_length=50)
> 
>  admin.site.register(Manufacturer, admin.ModelAdmin)

> Also you can register admins for all models in a loop:

Done, it works great.

> > Isn't there sort of a wildcard or shortcut to catch all those
> > cases at once?
> 
> You can make one yourself through some python-fu:
> 
>  (r'(?P\w+)/?$', model_view(list_detail.object_list)),
>  (r'^(?P\w+)/(?P\d+)/?$', 
> model_view(list_detail.object_detail)),
>  (r'^(?P\w+)/create/?$', model_view(create_object)),
>  (r'^(?P\w+)/update/(?P\d+)/?$', 
> model_view(update_object)),
> 
> "Model_view" here is a decorator that would take model name from 
> argument and turn it into a respective queryset:
> 
>  # mapping from lowercased names of models to models
>  from django.db.models import Model
>  import models
>  model_classes = dict(
>  (i.__class__.__name__.lower(), i)
>  for i in dir(models)
>  if isinstance(i, Model)
>  )
> 
>  def model_view(func):
>  def wrapper(request, *args, **kwargs):
>  model = kwargs.pop('model')
>  kwargs['queryset'] = model_classes[model].objects.all()
>  return func(request, *args, **kwargs)
>  return wrapper

This is the urls.py I created: http://dpaste.com/72138/
It doesn't work though: I get a
KeyError at /manufacturer
u'manufacturer'
when accessing http://localhost:8000/manufacturer
(manufacturer being one of my model)

Thank you very much for any further help,
Fabio.

-- 
fabio natali
http://poisson.phc.unipi.it/~natali

--~--~-~--~~~---~--~~
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: looping around lists

2008-08-18 Thread Tim Chase

> This problem's kinda hard to explain, but I'll try my best. I've got a
> list variable : notes_list which looks like: {'note 1', 'note2' etc..}
> 
> I'm using this variable within a forloop and I want it to cycle based
> on the number of loop (notes_list.0 for the first loop, notes_list.1
> for the second time it loops).
> 
> I tried using the following code:
> 
> {{notes_list.forloop.counter0}}
> 
> but that didn't work. Any ideas on how to solve this problem?

If I understand what you're trying to do, you want to pair one 
list ("List A", which you're iterating over in your loop) with 
items in a 2nd list ("List B", your notes_list above) so you're 
trying something like


   view:

   render_to_response('foo.html', {
 'lista': lista,
 'listb': notes_list
 })


   template:

   {% for item in lista %}
{{ item }}
{{ listb.forloop.counter0 }} 
   {% endfor %}


If this is the case, it sounds like you want to use the Python 
"zip()" call to pair up the items:

new view:

   render_to-response('foo.html', {
 'pairs': zip(lista, notes_list)
 })

0.96 and earlier version template:
   {% for pair in pairs %}
{{ pair.0 }}
{{ pair.1 }}
   {% endfor %}

development version template:
   {% for itema, itemb in pairs %}
 {{ itema }}
 {{ itemb }}
   {% endfor %}

Hope this helps,

-tim





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



looping around lists

2008-08-18 Thread iceanfire

Hey,

This problem's kinda hard to explain, but I'll try my best. I've got a
list variable : notes_list which looks like: {'note 1', 'note2' etc..}

I'm using this variable within a forloop and I want it to cycle based
on the number of loop (notes_list.0 for the first loop, notes_list.1
for the second time it loops).

I tried using the following code:

{{notes_list.forloop.counter0}}

but that didn't work. Any ideas on how to solve this problem?


--~--~-~--~~~---~--~~
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: ManyToManyField contains

2008-08-18 Thread [EMAIL PROTECTED]

It is returning a queryset. Check your code to make sure you're not
converting  it to a list or anything and check your models/managers to
make sure you're not overriding stuff there.

In the future, you can do this:

MyUser = User.objects.get(username='thisUsername')
theQuery = Class.objects.filter(users__id=myUser.id)

And you can use that like any other filter, so you could do __id__in,
__username__contains, etc.
--~--~-~--~~~---~--~~
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: Model relationships

2008-08-18 Thread [EMAIL PROTECTED]

Incase my question wasn't clear enough, as I had trouble describing
it ...

Can a different model access the manytomany table that django makes ?
--~--~-~--~~~---~--~~
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: ManyToManyField contains

2008-08-18 Thread Robert

Ah yes, I know this. For some reason, however, user.class_set.all()
doesn't seem to be returning a queryset (I need to be using a queryset
so I can feed it into a modelChoiceField). Is there any way that I can
turn class_set.all() into a queryset?

On Aug 18, 6:14 am, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> I seem to keep making this mistake, even though I know better.
>
> contains only works for strings. In other words, it checks to see if a
> string field contains the substring you provide. You want to use the
> reverse relationship from the user, rather than a query:
>
> myUser = User.objects.get(username='thisUsername')
> classes = myUser.class_set.all()
>
> Todd
>
> On Sun, Aug 17, 2008 at 8:11 PM, Robert <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
> > I'm trying to query a ManyToManyField to see whether or not it
> > contains a specific type of object.
> > My query is as follows:
> > MyUser = User.objects.get(username='thisUsername')
> > theQuery = Class.objects.filter(users__contains=myUser)
>
> > but when I try to run that, i get the following error:Related Field
> > has invalid lookup: contains
> > Any thoughts?
> > Thank you so much, any help is greatly appreciated.
> > -Robert
--~--~-~--~~~---~--~~
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: how to display date nicely

2008-08-18 Thread James Bennett

2008/8/18 Will Rocisky <[EMAIL PROTECTED]>:
> actually I have to do it in views, not template
> I need some pure python code

All Python datetime objects support the 'strftime' method, which is
what you want to use. Consult Python's documentation for the full
details.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



BooleanField and RadioSelect

2008-08-18 Thread Pong

Hi,

I try to use BooleanField with RadioSelect widget to get input option
like this:

Publish article: (o) Yes, publish now
   ( ) No, save changes and publish later

I specify my BooleanField like this:

CHOICES = ((True, "Yes, publish now"), (False, ("No, save changes and
publish later"))
publish = BooleanField(widget=RadioSelect(choices=choices))

Do I have to use ChoiceField? I'm creating the form directly from
model, and model has BooleanField so I don't know if ChoiceField is
going to work at all.
--~--~-~--~~~---~--~~
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: how to display date nicely

2008-08-18 Thread Will Rocisky

actually I have to do it in views, not template
I need some pure python code

On Aug 18, 5:14 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Wiadomość napisana w dniu 2008-08-18, o godz. 13:08, przez Will Rocisky:
>
> > I have a datetime object '2008-15-06 11:12:13'
> > I want to display it like 'June 6, 2008 at 11:12'
>
> You have to format it using strftime() or in template using built-in  
> "date" filter. Seehttp://www.djangoproject.com/documentation/templates/#date
> --
> We read Knuth so you don't have to. - Tim Peters
>
> Jarek Zgoda
> [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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: 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 down the page -- like inline only without a parent.
>
> I'd like to edit only certain fields from the model in that 'mass change'
> screen -- I guess this is a job for the fields list.
>
> (It's a menu model and I'd like to change the ordering number of links as well
> as titles -- without having to click back and forth from list to detail).
>
> How do I create a second entry in the home page of admin for a model and then
> alter the change list in the way described?
>
> Or is this a job for a custom form, off a link unrelated to /admin ?
>
> \d
--~--~-~--~~~---~--~~
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: how to display date nicely

2008-08-18 Thread Dmitry Dzhus

Will Rocisky wrote:

> I have a datetime object '2008-15-06 11:12:13'
> I want to display it like 'June 6, 2008 at 11:12'

{{ some_datevalue_object|date:"F j, Y at H:i" }}
-- 
Happy Hacking.

http://sphinx.net.ru
む


--~--~-~--~~~---~--~~
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: how to display date nicely

2008-08-18 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-08-18, o godz. 13:08, przez Will Rocisky:

> I have a datetime object '2008-15-06 11:12:13'
> I want to display it like 'June 6, 2008 at 11:12'


You have to format it using strftime() or in template using built-in  
"date" filter. See http://www.djangoproject.com/documentation/templates/#date
-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda
[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: how to display date nicely

2008-08-18 Thread Daniel Roseman

On Aug 18, 12:08 pm, Will Rocisky <[EMAIL PROTECTED]> wrote:
> I have a datetime object '2008-15-06 11:12:13'
> I want to display it like 'June 6, 2008 at 11:12'

http://www.djangoproject.com/documentation/templates/#date

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



how to display date nicely

2008-08-18 Thread Will Rocisky

I have a datetime object '2008-15-06 11:12:13'
I want to display it like 'June 6, 2008 at 11:12'



--~--~-~--~~~---~--~~
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: Serving static content using Apache

2008-08-18 Thread djandrow

Managed to get it working, thanks everyone.

I guess the problem was CSS was missing from locationMatch
--~--~-~--~~~---~--~~
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: Serving static content using Apache

2008-08-18 Thread djandrow

I've added this,

 #css has been added to the end
SetHandler None


but still no luck, however if i look at the pages statically on the
server rather than having apache serve them the CSS is used so now I
know that the CSS works and i guess its in the right place, although
the relative and absolute address are the same, but if thats the case
it should work anyway.

Does anybody have any ideas?

Andrew
--~--~-~--~~~---~--~~
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: ManyToManyField contains

2008-08-18 Thread Todd O'Bryan

I seem to keep making this mistake, even though I know better.

contains only works for strings. In other words, it checks to see if a
string field contains the substring you provide. You want to use the
reverse relationship from the user, rather than a query:

myUser = User.objects.get(username='thisUsername')
classes = myUser.class_set.all()

Todd

On Sun, Aug 17, 2008 at 8:11 PM, Robert <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> I'm trying to query a ManyToManyField to see whether or not it
> contains a specific type of object.
> My query is as follows:
> MyUser = User.objects.get(username='thisUsername')
> theQuery = Class.objects.filter(users__contains=myUser)
>
> but when I try to run that, i get the following error:Related Field
> has invalid lookup: contains
> Any thoughts?
> Thank you so much, any help is greatly appreciated.
> -Robert
> >
>

--~--~-~--~~~---~--~~
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: Admin mass change screen

2008-08-18 Thread Donn

On Monday, 18 August 2008 09:39:12 Matthias Kestenholz wrote:
> But maybe I've got something for you if you want to reorder
> items using a drag-n-drop interface.
Thanks for that. I will go and look when I have a chance.

\d

--~--~-~--~~~---~--~~
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: Customizing the error page

2008-08-18 Thread Gregor Müllegger

The django-command-extensions manipulate the debug page to add an
interactive console.
They provide a new management command for that: "runserver_plus"

Maybe you can get some know-how from them:
http://code.google.com/p/django-command-extensions/source/browse/trunk/django_extensions/management/commands/runserver_plus.py

On Aug 17, 5:54 pm, "Chris Moffitt" <[EMAIL PROTECTED]> wrote:
> Does anyone know the best practice for customizing the default Django error
> page? The simplest thing I'd like to do is include a version number for
> other software components (just like Django does now) so that it makes it
> easier for us to troubleshoot issues with Satchmo. Has anyone done this in a
> simple way without hacking Django?
>
> Thanks,
> Chris
--~--~-~--~~~---~--~~
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: Admin mass change screen

2008-08-18 Thread Matthias Kestenholz

Hi,

I don't know about the mass change screen, haven't thought too much about
that yet. But maybe I've got something for you if you want to reorder
items using
a drag-n-drop interface.

On Sun, Aug 17, 2008 at 8:38 PM, varikin <[EMAIL PROTECTED]> wrote:
>
> I am looking to do something very similar.  I have a Pictures model
> that has an order.  I am planning on using jquery sort to reorder them
> by dragging them on the change list. I will let you know how it works
> for me.
>

I've already implemented something like this. Your model needs to have a field
named 'sortkey' (best if it is of type IntegerField(default=0)) and you need to
add the reorder_link templatetag to your the object-tools block of your
admin/change_list.html template.

The relevant files are here:





I hope that helps.

Matthias

--~--~-~--~~~---~--~~
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: Admin mass change screen

2008-08-18 Thread Donn

On Sunday, 17 August 2008 20:38:06 varikin wrote:
> I am planning on using jquery sort to reorder them
> by dragging them on the change list.
Cool, if you get that right, I'd like to hear about it!

\d

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