Re: How to call a secure url?

2008-04-20 Thread Peter Rowell

We ran into a problem where users would either a) not be in SSL mode
when they should be, or b) be *in* SSL mode when they shouldn't be. We
solved it with middleware to make sure that we were always in the
correct mode. Note: the page you are on when filling out a form does
not, technically, have to be in SSL for security (only the form action
needs to be), but it makes the customers feel better if they see that
they are on a secure page. Also, you can *not* do a redirect if you
have POST data -- you will lose it.

We always have our forms submit to the same URL that rendered them.
This simplifies things for error handling. If the submission succeeds,
we redirect to a success page (which is *not* in SSL mode).

  HTH,
  Peter
Ps. If this gets mangled by google, let me know and I'll email it to
you.


You need a list in your settings file that has all of the paths that
must be in SSL mode. E.g.

settings.py:

HTTPS_PATHS = [
 '/login/',
 '/subscribe/',
 '/whatever/',
 ]

And add path.to.middleware.file.HttpsMiddleware to your list of
MIDDLEWARE_CLASSES.

In some file:

class HttpsMiddleware:
def process_request(self, request):
try:
path = request.path # Under certain strange conditions
this failed.
except:
return None

host = request.META.get('HTTP_HOST', '')
if path in settings.HTTPS_PATHS:
# path should be https,
if request.is_secure():
# and it is.
return None
# But it's not. Force the issue.
# WARNING: this drops any POST data!!
url = 'https://' + host + request.path
return HttpResponseRedirect(url)
elif request.is_secure():
# It *is* https and it shouldn't be.
url = 'http://' + host + request.path
return HttpResponseRedirect(url)
return None
# process_request
# class HttpsMiddleware

--~--~-~--~~~---~--~~
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: Setting up get_absolute_url with a generic view

2008-04-20 Thread Malcolm Tredinnick


On Sun, 2008-04-20 at 20:16 -0400, Michael wrote:
> your days and months can be one your two digits. So:
> (r'^(?P\d{4})/(?P
> \d{1,2})/(?P\d{1,2})/(?P[a-z0-9-]
> +)/$',
> 
> You can always open up a shell and see the error that is not showing
> up in your template. Use the reverse function. Check out:
> http://www.b-list.org/weblog/2007/sep/06/tips-and-tricks/

Another possible thing to try, if that isn't the solution, is to use the
url() form of specifying URLs and use the "name" parameter. Probably not
the problem, but might be worth trying if you're getting desperate.

It shouldn't be a problem here because you're using a string to specify
the view. However, when a function reference is used to specify the
view, it's often quite tricky to make the name you use in the
get_absolute_url() method match up with the "name" of the function that
Python sees (all the import prefixes have to align, along with a few
planets and constellations). Using the "name" parameter when using
function references is definitely recommended -- to the extent that I
should update the docs to say that -- but, again, I'm not sure it's
going to bite you here. It might, though. I haven't read that code for a
while and might be forgetting something.

Regards,
Malcolm

-- 
I intend to live forever - so far so good. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Post_save signal gets triggered twice

2008-04-20 Thread Malcolm Tredinnick


On Sun, 2008-04-20 at 16:05 -0700, meppum wrote:
> I think I figured out what it is. After finding the post below which
> referenced ticket #3951 it seems it's a known issue.
> 
> The last time the ticket was updated was June of 2007. Am I to
> understand this is not going to be fixed? 

If it wasn't going to be fixed, the ticket would be closed as wontfix.
In fact, that ticket is probably blocking on the signal rewrite that a
couple of people are working on. Then we can try and solve it robustly
(for example, it's possible that signals could register with some kind
of unique id so that duplicate registrations don't take place). There
are a few similar problem in Django (e.g. registering admin classes in
newforms-admin) and a reasonably consistent solution to all of them is a
good goal, too.

Regards,
Malcolm

-- 
Despite the cost of living, have you noticed how popular it remains? 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: 'message_set' causes ProgrammingError while handling Exception

2008-04-20 Thread dallas lynn

I believe this is a postgres thing -- the transaction failed but
postgres didn't rollback, and the message_set.create tries to put a
message in the database.  it's kind of ghetto, but you can also try
manually rolling back postgres when you catch the exception but before
you set the message.


--~--~-~--~~~---~--~~
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 call a secure url?

2008-04-20 Thread Jonas Oberschweiber

As far as I understand it, you need to put the code from the snippet
in its own file and either put that in your project's directory or
somewhere in your python path. Then you have to add the class to
settings.py (there are some existing middlewares, just see how they do
it).

I don't have any experience with this SSL middleware, but the snippet
itself says that you should rather use this:
http://www.djangosnippets.org/snippets/85/

Regards

Jonas

On Mon, Apr 21, 2008 at 3:10 AM, Greg <[EMAIL PROTECTED]> wrote:
>
>  Hello,
>  I have a page on my site where customers can place their order.  This
>  page is secure (https://).  I'm finding that whenever some users click
>  click submit they are presented with a message saying:
>
>  //
>
>  Security alert you are about to be redirected to a connection that is
>  not secure.
>
>  The information you are sending to the current site might be
>  retransmitted to a non secure site.
>
>  Do you wish to continue
>
>  //
>
>  Currently my page that presents the user with their order information
>  and invoice number is not secure.  I was wondering what I need to do
>  to get this page secure.  I was looking around on the web and found
>  this link http://www.djangosnippets.org/snippets/240/ . I added
>  {'SSL':True} to my url but when I do that i get the error:
>
>  TypeError at /cart/success/
>  success() got an unexpected keyword argument 'SSL'
>
>  //
>
>  I've never added Middleware before.  Do I need to add the code from
>  djangosnippet240?
>
>  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: 'message_set' causes ProgrammingError while handling Exception

2008-04-20 Thread Kenneth Gonsalves


On 21-Apr-08, at 6:42 AM, radioflyer wrote:

> I've decided to manually check for uniqueness after form validation
> and before saving, and that seems to work fine for now.
>
> Things like 'unique_for_date' and 'unique_together' seem to work great
> in the admin interface, but in the wild, you have to handle the
> exceptions yourself and I'm not really sure about the best ways to do
> it.

there is a clean method in the form - this is where you do this.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
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: 'message_set' causes ProgrammingError while handling Exception

2008-04-20 Thread radioflyer

Hello Kenneth,
Yes it would. If the user tries to submit a Change that is not unique
on 'student' and 'date' , I want to return them back to the original
page with a message that says "You've already got a change submitted
for that date."

I'm guessing that the programming error has to do with Postgres'
transactions, and that my approach just won't work.
If the exception isn't triggered, my message of "Your request has been
submitted..." shows up on the return page just fine.

I've decided to manually check for uniqueness after form validation
and before saving, and that seems to work fine for now.

Things like 'unique_for_date' and 'unique_together' seem to work great
in the admin interface, but in the wild, you have to handle the
exceptions yourself and I'm not really sure about the best ways to do
it.

Dan J.

On Apr 20, 9:00 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 21-Apr-08, at 12:50 AM, radioflyer wrote:
>
>
>
>
>
> > Hello,
> > I need some help with the code after the IntegrityError exception.
>
> > 
> > s = Student.objects.get(pk=student_id)
>
> > if request.method == 'POST':
> >   form = ChangeForm(request.POST)
> >   if form.is_valid():
> >try:
> >  form.save()
> >  request.user.message_set.create(message="Your request has been
> > submitted...")
> >  return HttpResponseRedirect(reverse(student, args=(s.id,)))
> >except IntegrityError:
> >  request.user.message_set.create(message="Can't do that!")
> >  return HttpResponseRedirect(reverse(student, args=(s.id,)))
> > 
>
> > This code throws:
> > Exception Type: ProgrammingError at /new_change/45/
> > Exception Value: current transaction is aborted, commands ignored
> > until end of transaction block
>
> > Commenting out the 'message create' line, the code runs. If I leave
> > it, Django attempts to insert my message string into the database.
>
> why are you using message_set? Would this not be the set of all
> messages belonging to the particular user?
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
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 call a secure url?

2008-04-20 Thread Greg

Hello,
I have a page on my site where customers can place their order.  This
page is secure (https://).  I'm finding that whenever some users click
click submit they are presented with a message saying:

//

Security alert you are about to be redirected to a connection that is
not secure.

The information you are sending to the current site might be
retransmitted to a non secure site.

Do you wish to continue

//

Currently my page that presents the user with their order information
and invoice number is not secure.  I was wondering what I need to do
to get this page secure.  I was looking around on the web and found
this link http://www.djangosnippets.org/snippets/240/ . I added
{'SSL':True} to my url but when I do that i get the error:

TypeError at /cart/success/
success() got an unexpected keyword argument 'SSL'

//

I've never added Middleware before.  Do I need to add the code from
djangosnippet240?

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: Layout Questions

2008-04-20 Thread Kenneth Gonsalves


On 21-Apr-08, at 3:05 AM, Greg Lindstrom wrote:

> I'll be happy to post some code, but I'd like some direction on how  
> to set up a page.  I would like a header and sidebar.  The footer  
> is optional, but I think it gives a nice, finished look to the page  
> (and it's where I have the "Powered by Django" logo :-).

you are going about it the right way. Problems of overlapping etc are  
actually CSS questions that belong in another forum. As are breaking  
the CSS standards to get it going with IE. Django templates do not  
create html/CSS/javascript - all these you do the same as you would  
do without django

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
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: 'message_set' causes ProgrammingError while handling Exception

2008-04-20 Thread Kenneth Gonsalves


On 21-Apr-08, at 12:50 AM, radioflyer wrote:

>
> Hello,
> I need some help with the code after the IntegrityError exception.
>
> 
> s = Student.objects.get(pk=student_id)
>
> if request.method == 'POST':
>   form = ChangeForm(request.POST)
>   if form.is_valid():
>   try:
> form.save()
> request.user.message_set.create(message="Your request has been
> submitted...")
> return HttpResponseRedirect(reverse(student, args=(s.id,)))
>   except IntegrityError:
> request.user.message_set.create(message="Can't do that!")
> return HttpResponseRedirect(reverse(student, args=(s.id,)))
> 
>
> This code throws:
> Exception Type: ProgrammingError at /new_change/45/
> Exception Value: current transaction is aborted, commands ignored
> until end of transaction block
>
> Commenting out the 'message create' line, the code runs. If I leave
> it, Django attempts to insert my message string into the database.

why are you using message_set? Would this not be the set of all  
messages belonging to the particular user?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
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: Layout Questions

2008-04-20 Thread Michael
Hey Greg;

It's good to see you having fun with setting up your first web app. Laying
out in Django is really great because it let's you work with style and
markup however you like. I generally layout the entire site in HTML and CSS
before I even start working with the django application.

Your block system seems to make sense. A few little tricks that I have
picked up along the way: I put a {% block title %} inside my  tag so
i can easily change the name of the page in my site. Define a block named
extra_head in the  section of your html so for inside pages you can
easily add extra infromation like scripts or extra stylesheets. I also have
found it useful to create a structure in my base that only has a content
section. So my base.html looks like:

header blah
...
{% block content %}

{% endblock content %}
..
footer blah

I then create a base_side_generic.html that puts the sidebar in the content:
{% extends 'base.html' %}
{% block content %}

{% block maincontent %}
{%endblock maincontent %}


{% block sidebar %}
{% endblock sidebar %}

{% endblock content %}

This way you don't always need a sidebar when you have content. It's just a
little trick that might help you out.

That being said, this is a django forum and this is technically really a
HTML/CSS question. Not only does it clutter the list to be answering these
kind of questions, but you also might not get the best answers. Even though
Django works closely with layout, technically the people who monitor this
forum are django-centered, whereas on some of the html forum you can get
some strict HTML answers.

My recommendation is picking up a book called The Zen of CSS Design, it
really helped the way that I build my site's style and I recommend it to
anyone who will listen. It also helps with those pesky float and positioning
problems. Alistapart.com is also a good resource. there are also tons of
forums and mailing lists that you can find that trive on your kinds of
problems.

Good Luck,

Michael

On Sun, Apr 20, 2008 at 5:35 PM, Greg Lindstrom <[EMAIL PROTECTED]>
wrote:

> Hello Everyone-
>
> I to the point of putting together my first Django web app (heck, my first
> real web app).  It's for a gym where my daughter takes gymnastics (level 7,
> thank-you).  This one is mostly static content, but I have created a few
> tables and it's getting me a feel for putting together a site.  There's
> still lots to learn, but it's fun and I'm enjoying myself.  A lot.
>
> When I'm creating my pages, I have a "base" template, base.html, that has
> 4 divisions defined: header, sidebar, maincontent, and footer.  Each of
> these contains a "block" statement.  For example, the header looks something
> line this (dots added to aid formatting...they're not in the real code):
>
> 
> {% block header %}
> Default Header Stuff
> {% endblock %}
> 
>
> I am using the css file to "float" the sidebar to the left, add the
> maincontent and the use css "clear left" on the footer to the look and feel
> of the main page.  I do have a graphic positioned in the upper left corner
> that overlaps the header, sidebar and part of the maincontent.  I gives me
> the look I want at this point but, before I get too far along, I wanted to
> ask if this is the way to set this up?  I have an issue when the content of
> the maincontent section overruns the area specified for it; it runs right
> into the footer (bad).  I also notice that neither the unordered list 
> of the definition list  format correctly in the maincontent section; the
> unordered list lines up right on the left border of the maincontent section
> (as does the definition list).  The unordered list works fine in the
> sidebar, but not in the maincontent.
>
> I'll be happy to post some code, but I'd like some direction on how to set
> up a page.  I would like a header and sidebar.  The footer is optional, but
> I think it gives a nice, finished look to the page (and it's where I have
> the "Powered by Django" logo :-).
>
> Thanks for any help or direction you can provide,
>
> --greg
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Setting up get_absolute_url with a generic view

2008-04-20 Thread Michael
your days and months can be one your two digits. So:
(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P[a-z0-9-]
+)/$',

You can always open up a shell and see the error that is not showing up in
your template. Use the reverse function. Check out:
http://www.b-list.org/weblog/2007/sep/06/tips-and-tricks/

On Sun, Apr 20, 2008 at 3:00 PM, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:

>
> Whoops, sorry, that was bad advice, please ignore!
>
>
> On Apr 20, 2008, at 5:19 AM, Matt wrote:
>
> >
> > I'm trying to get the following get_absolute_url function working in
> > one of my models:
> >
> > 
> >def get_absolute_url(self):
> >return ('django.views.generic.date_based.object_detail', (), {
> >'year': self.start_date.year,
> >'month': self.start_date.month,
> >'day': self.start_date.day,
> >'slug': self.url})
> >get_absolute_url = permalink(get_absolute_url)
> > 
> >
> > the corresponding URL pattern entry looks like this:
> >
> > 
> > (r'^(?P\d{4})/(?P\d{2})/(?P\d{2})/(?P[a-z0-9-]
> > +)/$', 'django.views.generic.date_based.object_detail',
> > dict(info_dict, month_format = "%m", slug_field='url')),
> > 
> >
> > So far, I've only got empty strings returned in the template. Can you
> > see what I'm doing wrong?
> >
> > I'm using latest update from trunk.
> >
> > Many thanks in advance for your help.
> >
> > >
>
>
> >
>

--~--~-~--~~~---~--~~
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: Widgets with an error class

2008-04-20 Thread Juanjo Conti

J. Pablo Fernández escribió:
> No ideas on this?

Hi!

By default they are wrapped in ERROR 
MESSAGE.

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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: Widgets with an error class

2008-04-20 Thread J . Pablo Fernández

No ideas on this?

On Apr 6, 2:38 am, J. Pablo Fernández <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Is there some way to add a class="error" or wrap the inputs in a  class="error"> when the field has a validationerror?
>
> 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
-~--~~~~--~~--~--~---



Layout Questions

2008-04-20 Thread Greg Lindstrom
Hello Everyone-

I to the point of putting together my first Django web app (heck, my first
real web app).  It's for a gym where my daughter takes gymnastics (level 7,
thank-you).  This one is mostly static content, but I have created a few
tables and it's getting me a feel for putting together a site.  There's
still lots to learn, but it's fun and I'm enjoying myself.  A lot.

When I'm creating my pages, I have a "base" template, base.html, that has 4
divisions defined: header, sidebar, maincontent, and footer.  Each of these
contains a "block" statement.  For example, the header looks something line
this (dots added to aid formatting...they're not in the real code):


{% block header %}
Default Header Stuff
{% endblock %}


I am using the css file to "float" the sidebar to the left, add the
maincontent and the use css "clear left" on the footer to the look and feel
of the main page.  I do have a graphic positioned in the upper left corner
that overlaps the header, sidebar and part of the maincontent.  I gives me
the look I want at this point but, before I get too far along, I wanted to
ask if this is the way to set this up?  I have an issue when the content of
the maincontent section overruns the area specified for it; it runs right
into the footer (bad).  I also notice that neither the unordered list 
of the definition list  format correctly in the maincontent section; the
unordered list lines up right on the left border of the maincontent section
(as does the definition list).  The unordered list works fine in the
sidebar, but not in the maincontent.

I'll be happy to post some code, but I'd like some direction on how to set
up a page.  I would like a header and sidebar.  The footer is optional, but
I think it gives a nice, finished look to the page (and it's where I have
the "Powered by Django" logo :-).

Thanks for any help or direction you can provide,

--greg

--~--~-~--~~~---~--~~
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: Can't get ThreadLocals (user in threadlocal storage) working.

2008-04-20 Thread Doug B

Its been a while, but I had problems getting this to work at first
too.  It turned out to be how I was importing the module that
contained thread locals.  I needed to specify the project as well as
the app when doing the import.

I couldn't just do from myapp import mymiddleware, I had to do from
myproject.myapp import mymiddleware.

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



Connect users in models.py to admin site users

2008-04-20 Thread chiefmoamba

Hello,

I have a model in models.py as shown below:

class Tutor(models.Model):
first_name = models.CharField(maxlength=40)
last_name = models.CharField(maxlength=40, core=True)
etc...
etc...

It simply captures fname and lname and adds it to my database. It
works.

However, the 'Tutor' should also be an user on my site, as found in
the Auth section of the admin page. Clearly, I don't ant to replicate
the information, that'd be silly, right?

What I'd like to do is two fold:

1)  Add a field to Auth Users section to show whether a user is a
Tutor or a Student
2) Use a ForeignKey (I guess thats best right) to add the names of the
user to my Tutor Model above.

Can anyone help me with this, please? I don't even know how to find
the Admin Auth Users Model at the moment and try as I might, I can
find nothing on the web to help me solve the issue. Any help is
appreciated!

Thanks,

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



'message_set' causes ProgrammingError while handling Exception

2008-04-20 Thread radioflyer

Hello,
I need some help with the code after the IntegrityError exception.


s = Student.objects.get(pk=student_id)

if request.method == 'POST':
  form = ChangeForm(request.POST)
  if form.is_valid():
try:
  form.save()
  request.user.message_set.create(message="Your request has been
submitted...")
  return HttpResponseRedirect(reverse(student, args=(s.id,)))
except IntegrityError:
  request.user.message_set.create(message="Can't do that!")
  return HttpResponseRedirect(reverse(student, args=(s.id,)))


This code throws:
Exception Type: ProgrammingError at /new_change/45/
Exception Value: current transaction is aborted, commands ignored
until end of transaction block

Commenting out the 'message create' line, the code runs. If I leave
it, Django attempts to insert my message string into the database.

params
[11, "Can't do that!"]
self

sql
'INSERT INTO "auth_message" ("user_id","message") VALUES (11,\'Can
\'\'t do that!\')'

I'm sure I'm just coding this wrong. Anyone help me out?

--~--~-~--~~~---~--~~
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: best practice for creating featured field

2008-04-20 Thread Merrick

Thank you, I had various as errors as you pointed out and as soon as I
implemented your suggestions and reset the database it all works now.

On Apr 20, 8:43 am, Peter Rowell <[EMAIL PROTECTED]> wrote:
> > featured_place = models.ForeignKey(Place, null=true, blank=true)
>
> 1. By any chance are you getting an error like "NameError: name 'true'
> is not defined"? The python keyword is "True", not "true".
>
> 2. If you reference a mode before it is defined, you need to supply a
> string for the referenced model.
>e.g., featured_place = models.ForeignKey('Place', null=True,
> blank=True)
>This only works for forward references to models in the same
> models.py file.
>
> 3. Regarding your error 'null value in column "featured_id" violates
> not-null constraint'.
> You may have added null=True in your ForeignKey declaration, you
> may even have tried to do a ./manage.py syncdb, but that won't affect
> your DB. Once a table exists, django will not ALTER it to match your
> new description. You have two choices:
>  a. Modify your DB directly using whatever tool you use -- command
> line, phpMyAdmin, or whatever.
>  b. Do a ./manage.py reset . WARNING: this will drop the
> tables (and their data) for *all* of the models in the named app, and
> then create them anew with the current definitions.
>
>   HTH,
>   Peter
--~--~-~--~~~---~--~~
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: Setting up get_absolute_url with a generic view

2008-04-20 Thread Eric Abrahamsen

Whoops, sorry, that was bad advice, please ignore!


On Apr 20, 2008, at 5:19 AM, Matt wrote:

>
> I'm trying to get the following get_absolute_url function working in
> one of my models:
>
> 
>def get_absolute_url(self):
>return ('django.views.generic.date_based.object_detail', (), {
>'year': self.start_date.year,
>'month': self.start_date.month,
>'day': self.start_date.day,
>'slug': self.url})
>get_absolute_url = permalink(get_absolute_url)
> 
>
> the corresponding URL pattern entry looks like this:
>
> 
> (r'^(?P\d{4})/(?P\d{2})/(?P\d{2})/(?P[a-z0-9-]
> +)/$', 'django.views.generic.date_based.object_detail',
> dict(info_dict, month_format = "%m", slug_field='url')),
> 
>
> So far, I've only got empty strings returned in the template. Can you
> see what I'm doing wrong?
>
> I'm using latest update from trunk.
>
> Many thanks in advance for your help.
>
> >


--~--~-~--~~~---~--~~
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 page doesn't show calendar popup

2008-04-20 Thread chiefmoamba

Hi,

I had the same problem earlier - 0.96 on Leopard. How do you switch to
trunk?

Thanks,

Ed

On Apr 20, 4:53 pm, sinker <[EMAIL PROTECTED]> wrote:
> Switching to trunk WORKED. Thank you so much!
>
> On Apr 19, 7:42 am, Polat Tuzla <[EMAIL PROTECTED]> wrote:
>
> > I got the same problem with the version 96.1 on Mac.
> > Then switched to trunk and everything went OK.
> > Unfortunately can't tell you why this happened, as I did not bother to
> > investigate the problem further.
> > Just switch to using trunk if that suits you, and you will have the
> > calendar pop ups.
>
> > On Mar 30, 8:39 am, Hoolio <[EMAIL PROTECTED]> wrote:
>
> > > I just installed Django 96.1 on my Mac.  When I follow the tutorial
> > > and get to the Admin page, the calendar pop ups don't show up.  Is
> > > there a problem with the install.  I'm using Leopard.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



questions about Django.db

2008-04-20 Thread 小龙
Just as in table Test:
 name url sizetime
 a   a1   a2  a3
 b   b1   b2  b3

When i get "a" ,how i can get other attrs about a1,a2,a3  while querying?

Thanks a lot   :D
-- 
deSign thE  fuTure
http://www.freeis.cn/

--~--~-~--~~~---~--~~
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: Leopard and Mod_Python.

2008-04-20 Thread Lee Hinde



On Apr 20, 1:32 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Apr 20, 3:54 pm, Lee Hinde <[EMAIL PROTECTED]> wrote:
>
> > This is more venting than anything.
>
> > As a long-time Mac fan boy I'm hugely disappointed at how much trouble
> > it's been to get Apache/MySQL/Mod_Pythyon/django all working together
> > on an Intel Mac running Leopard.
>
> > This 
> > post:http://www.modpython.org/pipermail/mod_python/2008-March/024954.html
> > (which took me all day to find) got me connected.
>
> Don't use mod_python then, use latest mod_wsgi instead which works out
> of the box on MacOS X Leopard no problems.
>
> > And when I finally
> > get Mod_Python working, MySQLdb appears to be borked.
>
> > It appears that one needs 64bit-everything-else (Python, MySQL,
> > MySQLdb) to go with the 64bit httpd Apple has provided.
>
> > My first target installation is going to be on a PPC Mac, so I'm going
> > to put this down for now and get back to being productive.
>
> The mod_wsgi documentation warns you about all the problems with 64
> bit MacOS X. See:
>
>  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
>
> If you can't work out how to build MySQL Python wrappers yourself so
> they are fat, and can't find precompiled binaries either, the mod_wsgi
> documentation tells you how you can force Apache to run as 32 bit so
> it works anyway.
>
> Graham

Thanks Graham. You've been a one man support band on this stuff. Apple
ought to hire you. :-)

 - Lee
--~--~-~--~~~---~--~~
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 page doesn't show calendar popup

2008-04-20 Thread Jon Loyens

Check that the localizations got installed when you installed .96.
This was a problem I had... the installer didn't install the admin
templates or any of the localization files and I had to copy them in
manually.

Jon.

On Apr 20, 10:53 am, sinker <[EMAIL PROTECTED]> wrote:
> Switching to trunk WORKED. Thank you so much!
>
> On Apr 19, 7:42 am, Polat Tuzla <[EMAIL PROTECTED]> wrote:
>
> > I got the same problem with the version 96.1 on Mac.
> > Then switched to trunk and everything went OK.
> > Unfortunately can't tell you why this happened, as I did not bother to
> > investigate the problem further.
> > Just switch to using trunk if that suits you, and you will have the
> > calendar pop ups.
>
> > On Mar 30, 8:39 am, Hoolio <[EMAIL PROTECTED]> wrote:
>
> > > I just installed Django 96.1 on my Mac.  When I follow the tutorial
> > > and get to the Admin page, the calendar pop ups don't show up.  Is
> > > there a problem with the install.  I'm using Leopard.
--~--~-~--~~~---~--~~
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 page doesn't show calendar popup

2008-04-20 Thread sinker

Switching to trunk WORKED. Thank you so much!

On Apr 19, 7:42 am, Polat Tuzla <[EMAIL PROTECTED]> wrote:
> I got the same problem with the version 96.1 on Mac.
> Then switched to trunk and everything went OK.
> Unfortunately can't tell you why this happened, as I did not bother to
> investigate the problem further.
> Just switch to using trunk if that suits you, and you will have the
> calendar pop ups.
>
> On Mar 30, 8:39 am, Hoolio <[EMAIL PROTECTED]> wrote:
>
> > I just installed Django 96.1 on my Mac.  When I follow the tutorial
> > and get to the Admin page, the calendar pop ups don't show up.  Is
> > there a problem with the install.  I'm using Leopard.
--~--~-~--~~~---~--~~
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: best practice for creating featured field

2008-04-20 Thread Peter Rowell

> featured_place = models.ForeignKey(Place, null=true, blank=true)

1. By any chance are you getting an error like "NameError: name 'true'
is not defined"? The python keyword is "True", not "true".

2. If you reference a mode before it is defined, you need to supply a
string for the referenced model.
   e.g., featured_place = models.ForeignKey('Place', null=True,
blank=True)
   This only works for forward references to models in the same
models.py file.

3. Regarding your error 'null value in column "featured_id" violates
not-null constraint'.
You may have added null=True in your ForeignKey declaration, you
may even have tried to do a ./manage.py syncdb, but that won't affect
your DB. Once a table exists, django will not ALTER it to match your
new description. You have two choices:
 a. Modify your DB directly using whatever tool you use -- command
line, phpMyAdmin, or whatever.
 b. Do a ./manage.py reset . WARNING: this will drop the
tables (and their data) for *all* of the models in the named app, and
then create them anew with the current definitions.

  HTH,
  Peter
--~--~-~--~~~---~--~~
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 page doesn't show calendar popup

2008-04-20 Thread Juanjo Conti

sinker escribió:
> I checked it out on every browser I have installed on my machine
> (incl. Firefox) ... no calendar on any of them. I'll try switching to
> trunk.
> 

I had no this problem in 0.96 running firefox on Ubuntu.

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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 page doesn't show calendar popup

2008-04-20 Thread sinker

I checked it out on every browser I have installed on my machine
(incl. Firefox) ... no calendar on any of them. I'll try switching to
trunk.

Thanks to everyone!

On Apr 19, 10:39 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I believe this was a Safari issue that was fixed at some point post-.
> 96.1(if you guys aren't using safari feel free to post again).
>
> On Apr 19, 2:42 pm, Polat Tuzla <[EMAIL PROTECTED]> wrote:
>
> > I got the same problem with the version 96.1 on Mac.
> > Then switched to trunk and everything went OK.
> > Unfortunately can't tell you why this happened, as I did not bother to
> > investigate the problem further.
> > Just switch to using trunk if that suits you, and you will have the
> >calendarpop ups.
>
> > On Mar 30, 8:39 am, Hoolio <[EMAIL PROTECTED]> wrote:
>
> > > I just installed Django 96.1 on my Mac.  When I follow the tutorial
> > > and get to theAdminpage, thecalendarpop ups don't show up.  Is
> > > there a problem with the install.  I'm using Leopard.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



obfuscating form fields in templates and admin

2008-04-20 Thread Jon Loyens

Hi all,

I'm working on an application where a user has an a special number
assigned to them.  This account number must be editable both by the
user and in admin.  I want the number to be obfuscated in the form
when it is initially displayed but then when overwritten by a customer
service rep (in admin) or a user (in the public gui) un obfuscated
data is displayed.

This problem I'm working on is extremely similar to when a site only
shows you the last four digits of the credit card you have on file
with them and replaces the first 12 digits with *'s.  Then you can
enter a new credit number and it overwrite the stars and submit a new
number.

The key here is that I have to do this for both admin and templates.
I guess what I'd really like to do is inject some sort of class that
when this string is retrieved for display in a form, it displays a
special string.

Thanks for your ideas in advance,

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



Can't get ThreadLocals (user in threadlocal storage) working.

2008-04-20 Thread Hilbert Schraal

Hi All,

I've followed the CookBook (http://code.djangoproject.com/wiki/
CookBookThreadlocalsAndUser) to have the user available in my model. I
have added the ThreadLocals class to my code and added it to the
middleware class setting. It gets called en sets values that look
valid.

However, when I call the get_current_user() method, it always returns
None. I tried this using 'manage.py runserver' and using mod_python.

I use Django 0.96.1 on Ubuntu Hardy (Python 2.5.2) and Debian (Python
2.4.4). Here's my settings.py (I replaced the project name with XXX).

Anyone got a clue?
Thanks,
Hilbert

# Django settings for XXX project.
import logging


#--
#
# Below are the settings that most likely change per
environment   #
#--
#

#DEBUG needs to be 'False' on environments other than development
# NOTE: with DEBUG = True, some settings are overridden ot the bottom
of this file.
DEBUG = True
TEMPLATE_DEBUG = DEBUG

# logging configuratie
LOG_LEVEL = logging.DEBUG
LOG_FILE = '/tmp/XXX.log'

DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = XXX # Or path to database file if using
sqlite3.
DATABASE_USER = XXX # Not used with sqlite3.
DATABASE_PASSWORD = XXX # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

# location of the cache. Needs to be an absolute path
CACHE_BACKEND = 'file:///tmp/django_cache'

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/home/schraal/XXX-media/'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"/home/schraal/XXX/cms/templates",
)

#--
#
# DO NOT CHANGE THE SETTINGS BELOW HERE, UNLESS YOU KNOW WHAT YOU'RE
DOING #
#--
#

CACHE_MIDDLEWARE_SECONDS = 300
CACHE_MIDDLEWARE_KEY_PREFIX = 'XXX'
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

ADMINS = (
# ('Your Name', '[EMAIL PROTECTED]'),
)

MANAGERS = ADMINS

# Local time zone for this installation. Choices can be found here:
# 
http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
# although not all variations may be possible on all operating
systems.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'Europe/Amsterdam'

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'nl'

DATETIME_FORMAT = 'd-m-Y H:i'

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

APPEND_SLASH = True

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com;
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/;, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '[EMAIL PROTECTED]@d(5w+m)kpcjffne(pvb+#6w2s_pz*5)b%$f'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.middleware.cache.CacheMiddleware',
'XXX.cms.middleware.session.ThreadLocals',
)

ROOT_URLCONF = 'rvucms.urls'

INSTALLED_APPS = (
'XXX.cms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'XXX.upload'
)

logging.basicConfig(level=LOG_LEVEL,
format='%(asctime)s %(levelname)s %(message)s',
  

Re: Setting up get_absolute_url with a generic view

2008-04-20 Thread Eric Abrahamsen

Matt,

You're using get_absolute_url to return an actual view – it's only  
meant to return a string representing the the URL for that model  
instance. The generic view information goes in your URL config file  
only, and get_absolute_url should return a URL that is matched by one  
of the regular expressions in the config. So in your case, it should  
look like this:

def get_absolute_url(self):
 return "/%s/%s/%s/%s/" % (self.year, self.month, self.day,  
self.slug)

That ought to produce a URL that will trigger the date-based object  
detail below.

http://www.djangoproject.com/documentation/model-api/#get-absolute-url

Hope that helps,
Eric


On Apr 20, 2008, at 5:19 AM, Matt wrote:

>
> I'm trying to get the following get_absolute_url function working in
> one of my models:
>
> 
>def get_absolute_url(self):
>return ('django.views.generic.date_based.object_detail', (), {
>'year': self.start_date.year,
>'month': self.start_date.month,
>'day': self.start_date.day,
>'slug': self.url})
>get_absolute_url = permalink(get_absolute_url)
> 
>
> the corresponding URL pattern entry looks like this:
>
> 
> (r'^(?P\d{4})/(?P\d{2})/(?P\d{2})/(?P[a-z0-9-]
> +)/$', 'django.views.generic.date_based.object_detail',
> dict(info_dict, month_format = "%m", slug_field='url')),
> 
>
> So far, I've only got empty strings returned in the template. Can you
> see what I'm doing wrong?
>
> I'm using latest update from trunk.
>
> Many thanks in advance for your help.
>
> >


--~--~-~--~~~---~--~~
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: DateTimeField calendar not showing

2008-04-20 Thread chiefmoamba

Yes - sorry. In the admin. Thanks. Ed

On Apr 20, 1:59 pm, Juanjo Conti <[EMAIL PROTECTED]> wrote:
> chiefmoamba escribió:
>
> > Hi All,
>
> > For some reason my DateTimeField is not showing a calendar next to the
> > 'DateTime' box in my view. My code from models.py is below. Can anyone
> > offer me any suggestions? I am using 0.96.
>
> You mean in the admin or in any other place?
>
> Juanjo
> --
> mi blog:http://www.juanjoconti.com.ar
--~--~-~--~~~---~--~~
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: Custom form field overrides model attributes?

2008-04-20 Thread Berco Beute

Thanks, Phil! That works perfectly.

The only thing that feels awkward about Django's models is that the
attributes feel like a mixture of stuff that belongs to the view and
stuff that belongs to the model (blank=True, null=True anybody?). But
that's about the only small complaint I have about Django.

After returning to Django now I remember again what was so cool about
it: the community around it. :)

Thanks, everyone!
2B

PS: I'm using this widget: http://www.djangosnippets.org/snippets/391/

On Apr 20, 12:19 pm, "Phil Davis" <[EMAIL PROTECTED]> wrote:
> On 20/04/2008, Berco Beute <[EMAIL PROTECTED]> wrote:
> If you only want to change the widget type for a field you can just
> modify the form
> after creating it or do it in the __init__ method. This has the
> benefit of not having
> to repeat the label/required information in 2 places (model and form):
>
> #forms.py
>class EventForm(forms.ModelForm):
>
>   def __init__(self, *args, **kwargs):
>   super(EventForm, , self).__init__(*args, **kwargs)
>   self.fields['endDate'].widget = DateTimeWidget()
>
>  class Meta:
>   model = Event
>
> --
> Phil Davis
--~--~-~--~~~---~--~~
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 use ImageField to save images to dynamic path

2008-04-20 Thread PENPEN

I defined such a model:

class Thing(models.Model):
photo = models.ImageField(
upload_to='images/', blank=True, null=True)

Here is the form for this model:
class ThingForm(ModelForm):
class Meta:
model = Thing

Now it could handle the image upload request and save images to
MEDIA_ROOT/images/ directory.

My question is how to change the upload_to value dynamicly in the
view. For example, I can get the user name in the view level, and I
want to save the image to that user's directory, e.g. 'avatar/
username/'.

--~--~-~--~~~---~--~~
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: Custom form field overrides model attributes?

2008-04-20 Thread Juanjo Conti

Berco Beute escribió:
> Using: Latest from trunk
> 
> I'm using a custom widget for datetimefields:
> 

BTW, which one are you using? The one that wrappers jscalendar?

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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: DateTimeField calendar not showing

2008-04-20 Thread Juanjo Conti

chiefmoamba escribió:
> Hi All,
> 
> For some reason my DateTimeField is not showing a calendar next to the
> 'DateTime' box in my view. My code from models.py is below. Can anyone
> offer me any suggestions? I am using 0.96.

You mean in the admin or in any other place?

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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: Question with querysets and foreignkey relationships

2008-04-20 Thread Julien

Ok, I see. After some mucking around, I managed to make it work like
this:

orgs = Organisation.objects.filter(blabla=something)
values = orgs.values('country')
country_id_list = [value['country'] for value in values]
num_countries = Country.objects.filter(id__in=country_id_list).count()


Looks a bit hackish but it works and is fairly fast.

Regards,

Julien

On Apr 20, 9:11 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-04-20 at 03:32 -0700, Julien wrote:
> > Hi,
>
> > Here's my code:
>
> > class Country(models.Model):
> > 
>
> > class Organisation(models.Model):
> > country = models.ForeignKey(Country, db_index=True)
> > 
>
> > Then, in a views, I select a number of organisations:
>
> > orgs = Organisation.objects.filter(blabla=something)
>
> > Now, I'd like to get the number of countries concerned by those
> > organisations I've selected. How is that possible?
>
> You cannot do it with a single queryset. At the SQL level this type of
> query requires a "GROUP BY" construction and querysets don't do that.
> Aggregate support (which includes counting related things) is something
> that is being worked on, but it's still a way off.
>
> For now, the solution is either to use custom SQL, or do one count()
> queryset for each oragnisation.
>
> Regards,
> Malcolm
>
> --
> I just got lost in thought. It was unfamiliar 
> territory.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Setting up get_absolute_url with a generic view

2008-04-20 Thread Matt

I'm trying to get the following get_absolute_url function working in
one of my models:


def get_absolute_url(self):
return ('django.views.generic.date_based.object_detail', (), {
'year': self.start_date.year,
'month': self.start_date.month,
'day': self.start_date.day,
'slug': self.url})
get_absolute_url = permalink(get_absolute_url)


the corresponding URL pattern entry looks like this:


(r'^(?P\d{4})/(?P\d{2})/(?P\d{2})/(?P[a-z0-9-]
+)/$', 'django.views.generic.date_based.object_detail',
dict(info_dict, month_format = "%m", slug_field='url')),


So far, I've only got empty strings returned in the template. Can you
see what I'm doing wrong?

I'm using latest update from trunk.

Many thanks in advance for your help.

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



DateTimeField calendar not showing

2008-04-20 Thread chiefmoamba

Hi All,

For some reason my DateTimeField is not showing a calendar next to the
'DateTime' box in my view. My code from models.py is below. Can anyone
offer me any suggestions? I am using 0.96.

Thanks,

Ed


from django.db import models

class Course(models.Model):
course = models.CharField(maxlength=100, core=True)
start_date = models.DateTimeField()
end_date = models.DateTimeField()

def __str__(self):
return self.course

class Admin:
list_display = ('course', 'start_date', 'end_date', )
list_filter = ('course',)
ordering = ('-course',)
search_fields = ('course',)
--~--~-~--~~~---~--~~
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: post_save Signal Trouble

2008-04-20 Thread Malcolm Tredinnick


On Sun, 2008-04-20 at 03:49 -0700, Alex Koshelev wrote:
> No, in python each module evaluates one time - at import process.

Your answer depends upon the condition that things are only imported
once, which isn't true if __import__() is used (it acts like reload()).
Since Django uses __import__ in a few places, it's possible for model
files to be imported more than once.

Regards,
Malcolm

-- 
A clear conscience is usually the sign of a bad memory. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Question with querysets and foreignkey relationships

2008-04-20 Thread Malcolm Tredinnick


On Sun, 2008-04-20 at 03:32 -0700, Julien wrote:
> Hi,
> 
> Here's my code:
> 
> class Country(models.Model):
> 
> 
> class Organisation(models.Model):
> country = models.ForeignKey(Country, db_index=True)
> 
> 
> 
> Then, in a views, I select a number of organisations:
> 
> orgs = Organisation.objects.filter(blabla=something)
> 
> Now, I'd like to get the number of countries concerned by those
> organisations I've selected. How is that possible?

You cannot do it with a single queryset. At the SQL level this type of
query requires a "GROUP BY" construction and querysets don't do that.
Aggregate support (which includes counting related things) is something
that is being worked on, but it's still a way off.

For now, the solution is either to use custom SQL, or do one count()
queryset for each oragnisation.

Regards,
Malcolm

-- 
I just got lost in thought. It was unfamiliar territory. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: post_save Signal Trouble

2008-04-20 Thread Alex Koshelev

No, in python each module evaluates one time - at import process.

On Feb 29, 12:18 am, itodd <[EMAIL PROTECTED]> wrote:
> Ok,
>
> I've figured out models.py was being evaluated multiple times. Where
> should I put my dispatcher code to ensure this doesn't happen?
>
> Thanks,
>
> Todd
>
> On Feb 28, 3:02 pm, itodd <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to implement simple auditing in my project. I've 
> > seenhttp://code.djangoproject.com/wiki/AuditTrailbutit does not work
> > with my models.
>
> > I connect me _post_save function to signals.post_save in hopes of it
> > being dispatched once. The code below takes a snapshot of the model
> > and saves it. For some reason django is emitting the post_savesignal
> >twiceand therefor firing my _post_save functiontwicewhich I
> > obviously do not want. Can anyone help me trouble shoot this?
>
> > I'm using django r7174.
>
> > I've mitigated this example down to the following:
>
> > # models.py
> > class Company(models.Model):
> > history = generic.GenericRelation('Audit')
> > name = models.CharField(max_length=64)
>
> > class Audit(models.Model):
> > TYPES = (
> > ('C','Create'),
> > ('U','Update'),
> > ('D','Delete')
> > )
>
> > content_type = models.ForeignKey(ContentType)
> > object_id = models.PositiveIntegerField()
> > user = models.ForeignKey(User)
> > object = models.TextField()
> > type = models.CharField(max_length=1,choices=TYPES)
> > created = models.DateTimeField(auto_now_add=True)
>
> > def __unicode__(self):
> > return self.get_type_display()
>
> > def _post_save(sender,instance,created):
> > if(hasattr(instance,'history')):
> > print sender # Print the sender
> > instance.history.create(\
> > user=User.objects.get(id=1),\
> > type=created and 'C' or 'U',\
> > object=simplejson.dumps(instance.__dict__)
> > )
>
> > dispatcher.connect(_post_save,signal=signals.post_save)
>
> > # shell>>> from common.models import Company
> > >>> c=Company(name="My Company")
> > >>> c.save()
>
> > 
> > 
>
> > Any suggestions would help. I'm banging my head on the desk with this
> > one.
>
> > Thanks,
>
> > Todd
--~--~-~--~~~---~--~~
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: Apache processes locked when using locmem cache

2008-04-20 Thread Graham Dumpleton



On Apr 20, 3:51 am, yish <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am having a problem with Apache (prefork),mod_python, Django (trunk-
> version 6410) and python 2.5.1. I am currently testing my site with 5
> apache processes and haven't yet set up memcached (on the list but had
> some issue with some of my cache keys not being valid for memcached).
>
> Every couple days I will find all my apache processes have locked up.
> I finally investigated a bit deeper this morning and after gdb-ing
> into each process, they were all stuck with an identical python stack
> trace. Now I am assuming that each process has arrived at the same
> state independent of each other (given prefork MPM) which would seem
> to indicate that this problem is quite rampant.  Has anyone seen this
> before?  Separately does anyone know if there is a way in apache/mod_pythonto 
> detect and kill these processes stuck in this way?

There is no way to auto detect and kill off these processes if using
mod_python and Apache.

If however you use mod_wsgi in daemon mode, its ability to detect
deadlocked Python processes may work depending on the original cause.
If its deadlock detection mechanism doesn't help, then you could use
the inactivity-timeout option for the daemon process to force a
process restart when there is no detected input/output by active
requests, or no new requests. So, even if the deadlock isn't due to a
dodgy Python C extension where multithreading is present, the
inactivity timeout mechanism should help to kill of a stuck process.

Graham

> I am only using the cache for some model level pre-calculations and
> not for page or template caching.  Also I took a quick look at the
> locmem cache code and was a little concerned about locking within 
> set->_cull->delete where both set and delete try to acquire the same lock.
>
> Haven't put too much thought into it yet since threading issues always
> drive me a little batty.
>
> Here is a sample of the relevant python corresponing gdb stack traces
>
> Thanks, Yishai
>
> /usr/local/lib/python2.5/threading.py (216): wait
> /usr/local/lib/python2.5/threading.py (216): wait
> /usr/local/lib/python2.5/threading.py (292): acquire
> /usr/local/lib/python2.5/threading.py (292): acquire
> /home/yish/lib/python2.5/django/utils/synch.py (69): writer_enters
> /home/yish/lib/python2.5/django/core/cache/backends/locmem.py (69):
> delete
> /home/yish/lib/python2.5/django/core/cache/backends/simple.py (55):
> _cull
> /home/yish/lib/python2.5/django/core/cache/backends/simple.py (64):
> set
> /home/yish/lib/python2.5/django/core/cache/backends/simple.py (39):
> set
> /home/yish/lib/python2.5/django/core/cache/backends/locmem.py (48):
> set
> /home/yish/lib/python2.5/django/core/cache/backends/locmem.py (48):
> set
> /home/yish/webapps/django/branches/main/djangotest/goodrec/models.py
> (857): get_entity_brief
>
> #0  0x0013d7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
> #1  0x00442c1f in [EMAIL PROTECTED] () from /lib/tls/libpthread.so.0
> #2  0x00d3f483 in PyThread_acquire_lock (lock=0x966e1a0, waitflag=1)
> at Python/thread_pthread.h:334
> #3  0x00d43dbb in lock_PyThread_acquire_lock (self=0xfffc,
> args=0xb7ee802c) at ./Modules/threadmodule.c:46
> #4  0x00ccbb7a in PyCFunction_Call (func=0xb7679dec, arg=0xb7ee802c,
> kw=0x0) at Objects/methodobject.c:108
> #5  0x00d14ce0 in PyEval_EvalFrameEx (f=0x95a0324, throwflag=0) at
> Python/ceval.c:3564
> #6  0x00d15ead in PyEval_EvalCodeEx (co=0xb7c5f698,
> globals=0xb7be5604, locals=0x0, args=0x9425cf8, argcount=1,
> kws=0x9425cfc, kwcount=0, defs=0xb7bec9d8,
>     defcount=1, closure=0x0) at Python/ceval.c:2831
> #7  0x00d13ec4 in PyEval_EvalFrameEx (f=0x9425bb4, throwflag=0) at
> Python/ceval.c:3659
> #8  0x00d15ead in PyEval_EvalCodeEx (co=0xb7c5f890,
> globals=0xb7be5604, locals=0x0, args=0x9426428, argcount=1,
> kws=0x942642c, kwcount=0, defs=0xb7beca78,
>     defcount=1, closure=0x0) at Python/ceval.c:2831
> #9  0x00d13ec4 in PyEval_EvalFrameEx (f=0x94262ec, throwflag=0) at
> Python/ceval.c:3659
> #10 0x00d157c8 in PyEval_EvalFrameEx (f=0x94b6514, throwflag=0) at
> Python/ceval.c:3650
> #11 0x00d157c8 in PyEval_EvalFrameEx (f=0x963fbec, throwflag=0) at
> Python/ceval.c:3650
> #12 0x00d157c8 in PyEval_EvalFrameEx (f=0x9426454, throwflag=0) at
> Python/ceval.c:3650
> #13 0x00d15ead in PyEval_EvalCodeEx (co=0xb7aa4ec0,
> globals=0xb7aaaf0c, locals=0x0, args=0x94262ac, argcount=4,
> kws=0x94262bc, kwcount=0, defs=0xb7ab0598,
>     defcount=1, closure=0x0) at Python/ceval.c:2831
> #14 0x00d13ec4 in PyEval_EvalFrameEx (f=0x9426164, throwflag=0) at
> Python/ceval.c:3659
> #15 0x00d15ead in PyEval_EvalCodeEx (co=0xb7aa4020,
> globals=0xb7aaad74, locals=0x0, args=0x94c1b0c, argcount=3,
> kws=0x94c1b18, kwcount=0, defs=0xb7ab06d8,
>     defcount=1, closure=0x0) at Python/ceval.c:2831
> #16 0x00d13ec4 in PyEval_EvalFrameEx (f=0x94c19b4, throwflag=0) at
> Python/ceval.c:3659
> #17 0x00d157c8 in PyEval_EvalFrameEx (f=0x94c0c14, throwflag=0) 

Question with querysets and foreignkey relationships

2008-04-20 Thread Julien

Hi,

Here's my code:

class Country(models.Model):


class Organisation(models.Model):
country = models.ForeignKey(Country, db_index=True)



Then, in a views, I select a number of organisations:

orgs = Organisation.objects.filter(blabla=something)

Now, I'd like to get the number of countries concerned by those
organisations I've selected. How is that possible?

Although the following code is wrong, is there a similar easy way to
achieve that?

country_count = orgs.country_set.all().distinct().count()

Thanks a lot!

Julien
--~--~-~--~~~---~--~~
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: Custom form field overrides model attributes?

2008-04-20 Thread Phil Davis

On 20/04/2008, Berco Beute <[EMAIL PROTECTED]> wrote:
>
>  Using: Latest from trunk
>
>  I'm using a custom widget for datetimefields:
>
>  ==
>  #models.py
>  class Event(models.Model):
> endDateTime = models.DateTimeField('Finish', blank=True,
>  null=True)
>
>
>  #forms.py
>  class EventForm(forms.ModelForm):
> endDateTime = forms.DateTimeField(widget=DateTimeWidget)
>
> class Meta:
> model = Event
>
>  ==
>
>  But somehow the 'endDateTime' field is still required when rendering
>  the form and the label is 'endDateTime' instead of 'Finish'. Resetting
>  the app, syncing the db etc. doesn't help.
>
>  Any suggestions?

If you only want to change the widget type for a field you can just
modify the form
after creating it or do it in the __init__ method. This has the
benefit of not having
to repeat the label/required information in 2 places (model and form):


#forms.py
   class EventForm(forms.ModelForm):

  def __init__(self, *args, **kwargs):
  super(EventForm, , self).__init__(*args, **kwargs)
  self.fields['endDate'].widget = DateTimeWidget()

 class Meta:
  model = Event


-- 
Phil Davis

--~--~-~--~~~---~--~~
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: Custom form field overrides model attributes?

2008-04-20 Thread Malcolm Tredinnick


On Sun, 2008-04-20 at 02:20 -0700, Berco Beute wrote:
> Using: Latest from trunk
> 
> I'm using a custom widget for datetimefields:
> 
> ==
> #models.py
> class Event(models.Model):
> endDateTime = models.DateTimeField('Finish', blank=True,
> null=True)
> 
> 
> #forms.py
> class EventForm(forms.ModelForm):
> endDateTime = forms.DateTimeField(widget=DateTimeWidget)
> 
> class Meta:
> model = Event
> 
> ==
> 
> But somehow the 'endDateTime' field is still required when rendering
> the form

All form fields default to required=True and you haven't changed that in
your EventForm. You need to pass required=False to the form field if you
don't want it to be required.

>  and the label is 'endDateTime' instead of 'Finish'.

That's also expected. You have replaced the default form field with one
of your own. On your replacement field, you haven't specified a label,
so it uses the attribute name as the label. The new 'endDateTime' field
you have specified in the form completely replaces any default form
field that Django might otherwise have generated from your model for
that field. It doesn't merge the two in some undefined manner. If you
want it to have a custom label, you'll need to specify that on the form
field.

Regards,
Malcolm

-- 
Save the whales. Collect the whole set. 
http://www.pointy-stick.com/blog/


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



Custom form field overrides model attributes?

2008-04-20 Thread Berco Beute

Using: Latest from trunk

I'm using a custom widget for datetimefields:

==
#models.py
class Event(models.Model):
endDateTime = models.DateTimeField('Finish', blank=True,
null=True)


#forms.py
class EventForm(forms.ModelForm):
endDateTime = forms.DateTimeField(widget=DateTimeWidget)

class Meta:
model = Event

==

But somehow the 'endDateTime' field is still required when rendering
the form and the label is 'endDateTime' instead of 'Finish'. Resetting
the app, syncing the db etc. doesn't help.

Any suggestions?

2B
--~--~-~--~~~---~--~~
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: Sending emails with special characters

2008-04-20 Thread Julien

Thanks Malcolm, I opted for the Django solution and it worked indeed.
Here's the new code:

from django.conf import settings
from django.core.mail import EmailMultiAlternatives, SMTPConnection

smtp_server='XXX'  # Only because I want to use different
settings than the default ones
smtp_user='X'
smtp_pass='X'


def html_mail(subject, recipient, html_contents, text_contents,
sender=settings.DEFAULT_FROM_EMAIL, recipient_name='', sender_name='',
charset=None):
from_email, to = named(sender, sender_name), named(recipient,
recipient_name)
msg = EmailMultiAlternatives(subject, text_contents, from_email,
[to])
msg.content_subtype = "html"  # Main content is now text/html
msg.attach_alternative(html_contents, "text/html")

connection = SMTPConnection(host=smtp_server, username=smtp_user,
password=smtp_pass)
connection.send_messages([msg])


def named(mail,name):
   if name: return '%s <%s>' % (name,mail)
   return mail



Cheers,

Julien


On Apr 19, 6:17 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2008-04-19 at 00:43 -0700, Julien wrote:
> > Thanks for the hints.
>
> > I'm maintaining the code done by another developer:
>
> [... snipped ...]
>
>
>
> > As you see, after your comments I added the force_unicode function
> > call, but it didn't fix the problem. I tried to look into Django code
> > but I got a bit lost. Can you easily spot the issue in the code above.
>
> Unfortunately, robustly sending email is a fairly tricky process and the
> only effective way I've found to debug it is by carefully reading the
> error messages and reading through tracebacks to work out where
> unexpected data comes from. You are in the best position to see which
> piece of input data is raising the problem and where that problem is
> coming from.
>
> Your code looks roughly correct, but comparing it to Django's version
> you seem to have just forced everything to Unicode, without noticing
> that when we create the mail headers, we carefully encode things to
> UTF-8.
>
> Since your method is very similar to the existing Django code, I'd
> really be tempted to rewrite it in that format. Create an EmailMessage
> for each message, call attach() on that to add the HTML version (passing
> in the MIME type) and then call send_messages on an SMTPConnection()
> should work. It will be slightly more efficient that your version, too
> (only making one network connection for all the messages).
>
> If you don't want to go that path, just proceed slowly, reading the
> tracebacks and tracing where the data comes from. It can be slightly
> fiddly, but you'll get there eventually.
>
> Malcolm
>
> --
> If at first you don't succeed, destroy all evidence that you 
> tried.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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: Need help loading template

2008-04-20 Thread spirit

I think you can write it like
(r‘^([\w-]+)/(\d{4})/(\d+)/(\d+)/(?P\d+)/$’,
find_seminar_occurrence),
it should be OK.

On 4月20日, 上午10时31分, Brandon Taylor <[EMAIL PROTECTED]> wrote:
> Changing my urls.py to this:
>
> from django.conf.urls.defaults import *
> from rdk.training.views import *
>
> urlpatterns = patterns('',
>(r'^$', list_seminars),
>(r'^([\w-]+)/(\d{4})/(\d{1,2})/(\d{1,2})/(?P
> \d+)/$', find_seminar_occurrence),
> )
>
> fixed the problem. I simply added a caret to the beginning of the
> second pattern. Hope this helps someone else.
>
> Brandon
>
> On Apr 19, 8:24 am, Brandon Taylor <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
>
> > In my urls.py, I'm matching: a slug from a foreign key / the year /
> > month / day / pk of the record as such:
>
> > from django.conf.urls.defaults import *
> > from rdk.training.views import *
>
> > urlpatterns = patterns('',
> >(r'^$', list_seminars),
> >(r'[-\w]+/d{4}/d+/d+/(?Pd+)/$',
> > find_seminar_occurrence),
> > )
>
> > #In views.py
>
> > def find_seminar_occurrence(request, id):
> > seminars = Seminar.objects.exclude(pk=id).order_by('title')
> > occurrence = Occurrence.objects.get(pk=id)
> > return render_to_response('seminar_detail.html', locals())
>
> > The problem is that the template that Django is looking for is the
> > primary key + .html: 3.html, 1.html, etc. What did I do wrong?
>
> > TIA,
> > Brandon
--~--~-~--~~~---~--~~
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: Leopard and Mod_Python.

2008-04-20 Thread Graham Dumpleton



On Apr 20, 3:54 pm, Lee Hinde <[EMAIL PROTECTED]> wrote:
> This is more venting than anything.
>
> As a long-time Mac fan boy I'm hugely disappointed at how much trouble
> it's been to get Apache/MySQL/Mod_Pythyon/django all working together
> on an Intel Mac running Leopard.
>
> This post:http://www.modpython.org/pipermail/mod_python/2008-March/024954.html
> (which took me all day to find) got me connected.

Don't use mod_python then, use latest mod_wsgi instead which works out
of the box on MacOS X Leopard no problems.

> And when I finally
> get Mod_Python working, MySQLdb appears to be borked.
>
> It appears that one needs 64bit-everything-else (Python, MySQL,
> MySQLdb) to go with the 64bit httpd Apple has provided.
>
> My first target installation is going to be on a PPC Mac, so I'm going
> to put this down for now and get back to being productive.

The mod_wsgi documentation warns you about all the problems with 64
bit MacOS X. See:

  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX

If you can't work out how to build MySQL Python wrappers yourself so
they are fat, and can't find precompiled binaries either, the mod_wsgi
documentation tells you how you can force Apache to run as 32 bit so
it works anyway.

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



Is psyco project alive?

2008-04-20 Thread bcurtu

Is psyco active and alive? Is it compatible with django? What about
Pypy? Anyone using any of these jit engines to run Django?
--~--~-~--~~~---~--~~
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 overwrite the hyperlink of objects in change list template of django admin?

2008-04-20 Thread Leon

I had worked out my way.

The hyperlink for a specifc object in admin interface is actually
hardcoded in contrib.admin.views.main.py, line 766:
def url_for_result(self, result):
return "%s/" % quote(getattr(result, self.pk_attname))

so what I did, is to overwrite this method of the given changelist
object. Here is the details. Hope it could be some help to other
people.
1. Define a new tag:

from django.contrib.admin.templatetags.admin_list import result_list
from types import MethodType
from django.template import Library
register = Library()

def url_for_result_new(link_format):
return lambda self, result: link_format % getattr(result,
self.pk_attname)
# This function is a template tag for use in an overridden
change_list.html template.
def result_list_with_link(cl, link_format):
url_for_result_link = url_for_result_new(link_format)
setattr(cl, 'url_for_result', MethodType(url_for_result_link, cl))
return result_list(cl)
result_list_with_link = register.inclusion_tag("admin/
change_list_results.html")(result_list_with_link)

2. Copy the template/admin/change_list.html to template/admin/
//change_list.html. Here the the  is
the one that you want to overwrite its object change hyperlink

3.Edit the template/admin///change_list.html.
Change this line:
{% block result_list %}{% result_list cl %}{% endblock %}

to:
{% load  %>
{% block result_list %}{% result_list_with_link cl "//%s/"
%}{% endblock %}

here the "%s" will be filled with object pk


On Apr 15, 12:17 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-04-14 at 20:50 -0700, Leon wrote:
> > Great. I'll wait for the newforms-admin branch integration.
>
> > Is there any document about this newforms-admin?
>
> Django's wiki and documentation and things really are very
> search-engine-friendly. :-)
>
> http://www.google.com/search?q=django+newforms-admin
>
> The wiki page is probably the right place to 
> start:http://code.djangoproject.com/wiki/NewformsAdminBranch
>
> Regards,
> Malcolm
>
> --
> Honk if you love peace and quiet.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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 do designers create content

2008-04-20 Thread Kenneth Gonsalves


On 20-Apr-08, at 12:16 PM, James Bennett wrote:

> On Sun, Apr 20, 2008 at 1:33 AM, lee <[EMAIL PROTECTED]> wrote:
>>  designers. Do the designers use text base editting like ultraedit or
>>  or graphics based software like dreamweaver? Most of the artist I  
>> know
>>  don't do much coding and are into photoshop, illustrator and
>>  dreamweaver.
>
> Most of the designers I've worked with mock things up in Photoshop,
> then bust out TextMate to do the HTML and CSS.

I know a couple of guys who use Gimp and Inkscape - amazing he work  
they turn out

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
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 do designers create content

2008-04-20 Thread James Bennett

On Sun, Apr 20, 2008 at 1:33 AM, lee <[EMAIL PROTECTED]> wrote:
>  designers. Do the designers use text base editting like ultraedit or
>  or graphics based software like dreamweaver? Most of the artist I know
>  don't do much coding and are into photoshop, illustrator and
>  dreamweaver.

Most of the designers I've worked with mock things up in Photoshop,
then bust out TextMate to do the HTML and CSS.


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



Re: how do designers create content

2008-04-20 Thread Kenneth Gonsalves


On 20-Apr-08, at 12:03 PM, lee wrote:

>  Do the designers use text base editting like ultraedit or
> or graphics based software like dreamweaver? Most of the artist I know
> don't do much coding and are into photoshop, illustrator and
> dreamweaver. On sites like lawrence.com where there are lots of
> content developers do they create pages in web forms, or editors or
> graphic packages?

django graphic designers design just like regular graphic designers

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
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 do designers create content

2008-04-20 Thread lee

I am new to django, but I think it is really cool. I have used other
web dev systems before like zope/plone and php. I am a little new to
the template type system of django and I was wondering how most web
designer create therir content when there are seperate programmers and
designers. Do the designers use text base editting like ultraedit or
or graphics based software like dreamweaver? Most of the artist I know
don't do much coding and are into photoshop, illustrator and
dreamweaver. On sites like lawrence.com where there are lots of
content developers do they create pages in web forms, or editors or
graphic packages?


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