How do I pass along an extra parameter to a view?

2008-10-05 Thread Theme Park Photo, LLC

I'm just getting started in Django and I'm stuck.

I have defined in settings a variable called STATIC_ROOT that contains
the root URL where static assets are served. In development it's
something like static.example.com.local and in production it would be
static.example.com

How do I pass this along to views that are implemented in in Django
contrib?

The documentation seems to imply you can do this:

urlpatterns = patterns('',
(r'^foo/$', views.foobar_view, {'template_name':
'template1.html'}),
)

but when I try it with code like this

...
(r'accounts/login/$', 'django.contrib.auth.views.login' ,
{'staticroot' : settings.STATIC_ROOT}),
   ...

 I get this error:

login() got an unexpected keyword argument 'staticroot'

Is there any way to pass more dictionary values to
django.contrib.auth.views.login?


--~--~-~--~~~---~--~~
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: Name of button pressed not in request.POST

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 07:40 -0700, ydjango wrote:
> I have more than one input submit button and want to know which one
> was clicked.
> Request.POST does not have that information for some reason.

So you mean you have the same problem you had when you first posted this
message less than one day earlier? Please wait a little while for people
who might have the time to answer your question. Remember that everybody
posting on this list is doing so as a volunteer.

> 
> Using django 1.0 svn
> 
> I would appreciate if you can point me to right resource.
> This is should be something very simple that I am missing.
> 
> 
> On Oct 4, 11:44 am, ydjango <[EMAIL PROTECTED]> wrote:
> > I do not see the name of submit button in request.POST. it has all
> > other form fields
> >
> >  if request.POST.has_key('save'):
> >  does not work too

That's exactly how it should be done. There must be something special or
slightly wrong about the way you've constructed your form or your view.
Perhaps you could construct a very small example (a form with only one
buttone and the corresponding view function) that doesn't work and paste
it in full -- it should only be a dozen lines or so total. Then we might
be able to see what you're doing wrong.

Based on the information you have provided so far, this should work.

Have you looked at what keys *are* being submitted in request.POST?
Maybe that will provide a clue.

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



adding date to template

2008-10-05 Thread KillaBee

I have been trying to add date to my template, but for the life of me
have not.

I have a field in the MYSQL db, and In my models class but when I put
the text box it doesn't post to the db.  No field does. And the
calendar does show anything to debug.

{{ poll.question }}Time Sheet



{% if error_message %}{{ error_message }}{%
endif %}





{% for day in headers %}

{{ day|date:"D"|slice:":2" }}

{% endfor %}



{% for week in calendar %}



{% for day in week %}

{% if
day.event %}{{ day.day|
date:"j" }}{% else %}{{ day.day|date:"j" }}{% endif %}

{% endfor %}



{% endfor %}





  {% for choice in poll.choice_set.all %}

  

  Worked

  

  Fedtime

  

  

  

  

  

{% endfor %}









  {{ choice.choice }}



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



Django directory

2008-10-05 Thread Felipe Sodré Silva
Hi.

I've made a django installation a few months ago, but now I forgot where the
installation directory is (that is, the directory where I can edit Admin
template files and other contrib files).

Is there an easy way to discover where it is? I'm using MacOS X

Thanks !

Felipe

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



disable help_text

2008-10-05 Thread Lars Stavholm

Hi All,

does anyone know of a way to turn off (disable/replace)
the rather long help text message for ManyToManyField's,
starting with "Hold down..."?

Any input appreciated
/Lars


--~--~-~--~~~---~--~~
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: perplexing form issue

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 20:21 -0700, Bobby Roberts wrote:
> Hi group.  I have  form on the right side of my website.  It's a
> simple site consisting of a single template and utlizes flat pages.
> Now i can create content just fine and that is all working.  The issue
> is that the form is not showing up when I view the site.  I'm assuming
> that it is because something is awry with the urls or views.  I think
> i've narrowed it down to the following question.
> 
> How can I specify that the form show and work on each page in the
> website? I've tried the following in my urls.py file:
> 
> (r'/$', 'myForm'),
> 
> 
> where myForm is my view

Django only processes one view per request, so that particular pattern
says that if the request is for "/" (only!), the myForm view should be
called. And that is all.

If you want to form to be included in each and every template, then you
can either use a context processor, or you could put it in a common
function that each of your views call at the end. I tend to do the
latter fairly regularly, since there's a bunch of stuff I do in each
(well, most) views. So rather than calling render_to_response(), I call
finalise_view_processing() -- my own function -- that does all the final
common stuff and then calls render_to_response with the modified 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
-~--~~~~--~~--~--~---



perplexing form issue

2008-10-05 Thread Bobby Roberts

Hi group.  I have  form on the right side of my website.  It's a
simple site consisting of a single template and utlizes flat pages.
Now i can create content just fine and that is all working.  The issue
is that the form is not showing up when I view the site.  I'm assuming
that it is because something is awry with the urls or views.  I think
i've narrowed it down to the following question.

How can I specify that the form show and work on each page in the
website? I've tried the following in my urls.py file:

(r'/$', 'myForm'),


where myForm is my view


what am I missing?
--~--~-~--~~~---~--~~
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: installing tiny mce for flatpages

2008-10-05 Thread Bobby Roberts

> So you did this 
> part?http://code.djangoproject.com/wiki/AddWYSIWYGEditor#UsingTinyMCEwithf...
>
> Do you have MEDIA_URL and MEDIA_ROOT setup correctly in settings.py?
> Are you using the development server? Do you have that setup to server
> static content?

yeah see my previous post.  This is on a live server not a dev.  I've
got an admin.py file setup per the django doc and have /static setup
as an application to serve static content.  MEDIA_URL is setup
correctly and is serving static content.
--~--~-~--~~~---~--~~
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: installing tiny mce for flatpages

2008-10-05 Thread Brian Neal

On Oct 5, 9:35 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> > Did you see this:
>
> >http://code.djangoproject.com/wiki/AddWYSIWYGEditor
>
> yeah i saw that and tried to follow it.  Here's what i did:
>
> 1.  d/l tinymce
> 2.  uploaded to /static/admin/js/tiny_mce   (i have static setup as an
> app to serve static files)
> 3.  I created a textarea.js file as instructed an put it in that dir
> 4.  I created the admin.py file in /www/myproject
>
> i'm using newforms in the admin

So you did this part?
http://code.djangoproject.com/wiki/AddWYSIWYGEditor#UsingTinyMCEwithflatpagesnewforms

Do you have MEDIA_URL and MEDIA_ROOT setup correctly in settings.py?
Are you using the development server? Do you have that setup to server
static content?
--~--~-~--~~~---~--~~
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: installing tiny mce for flatpages

2008-10-05 Thread Bobby Roberts

> Did you see this:
>
> http://code.djangoproject.com/wiki/AddWYSIWYGEditor

yeah i saw that and tried to follow it.  Here's what i did:

1.  d/l tinymce
2.  uploaded to /static/admin/js/tiny_mce   (i have static setup as an
app to serve static files)
3.  I created a textarea.js file as instructed an put it in that dir
4.  I created the admin.py file in /www/myproject


i'm using newforms in the admin
--~--~-~--~~~---~--~~
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: installing tiny mce for flatpages

2008-10-05 Thread Brian Neal

On Oct 4, 3:34 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> hi group.  I need some help getting tinymce installed for flatpages in
> admin.  I'm serving static content from an application called /static/
> with tinymce located in /static/js/tiny_mce/.  I have read the docs on
> creating an admin.py file and have done that as well but it's not
> showing the richtext box... just the textarea.  Is there anyone out
> there that can help?

Did you see this:

http://code.djangoproject.com/wiki/AddWYSIWYGEditor

?

Regards,
BN
--~--~-~--~~~---~--~~
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: a NameError happened when using Meta option 'unique_together'

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 06:42 -0700, Matrixer wrote:
> hi, when I was trying to use the Meta option 'unique_together' in my
> Membership model below, a NameError happened, I don't know what the
> problem is, I am using django 1.0 and sqlite3
> 
> regards,
> Matrixer
> 
> ---
> class Membership(models.Model):
> person = models.ForeignKey('Person')
> group = models.ForeignKey('Group')
> 
> class Meta:
> unique_together('person', 'group')

This would be a function call to a function called unique_together
(which doesn't exist). You've left out an equals (=) character.

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: Questions about HttpResponseRedirect and reverse

2008-10-05 Thread Steve Holden
Malcolm Tredinnick wrote:
> On Fri, 2008-10-03 at 13:29 -0400, Steve Holden wrote:
>   
>> Alexis Bellido wrote:
>> 
>>> Cool, thanks for the confirmation. I'm still devouring all the
>>> documentation, a couple of books and practicing a lot on Django :)
>>>   
>>>   
>> One of the things I find tricksiest about learning new Django code is
>> that the connections between the URLs and the views can often turn out
>> to be a maze of twisty little passages, all alike. It's difficult (for
>> me, anyway - maybe there's some obvious technique I have overlooked) to
>> trace which pieces of code and which URLs are associated.
>> 
>
> Hmm... this is getting off-topic a bit for this thread, but can you
> elaborate a bit more on what you mean here? I can't say this was
> something that every seemed tricky to me with Django, but I know
> different people learn and think differently, so it would be interesting
> to hear where there hidden shoals might be.
>
> It feels like it should be as simple as being a reg-exp pattern that
> captures some parameters and calls a view passing in those parameters
> and possible some extra ones. You can also give each pattern a name.
>
> I'm not mocking here. I'd like to hear how this can be hard so that I
> can at least experiment with some alternative explanations in the future
> when talking to people.
I'll do my best to explain, but it's a little difficult to "go back and
do it again" once the issues are past. It may be that I am complaining
about the specific apps I have dealt with rather than Django generally.
Or it may just be that there's something fundamental I've overlooked. I
accept that you aren't mocking, but I know you will appreciate that it's
difficult to confess ignorance at this apparently fundamental level when
you've been working with the web for some while.

I have just spent some time looking at how I can add user profiles to a
test site, and decided this would best be done by adding the
django-registration and django-profiles apps to it. Getting the code in
was relatively easy -- about the only thing I had to do was fix up a
newforms import. However, since I couldn't find much generic advice on
gluing these bits and pieces together I am quite prepared to accept that
it may just be because I've botched the job.

I think from memory the most difficult issue was with the named URLs, as
there is no definitive mapping between the textual names, the URL
components and the names. (I realize that the names have been made close
to the names of the views they map to, but knowing where to find them
does require some familiarity with the code).

Further, common URL prefixes don't necessarily map to views in the same
module (though this could be my misconfiguration). I have attached (to
avoid wrapping issues) a text file showing the various URLconfs that are
(or should be) configured into my application. It's ended up as a bit of
a dog's breakfast, having been patched together in a less-than-optimal way.

What I was hoping for was to be able to generate some clear state
transition diagram showing the sequences of URLs that particular actions
like registering a new user, adding a profile and editing it, and so on
would go through, along with the templates I would have to prepare and
the available contexts for each template. So I suppose it's not really
the individual mappings I find troublesome as much as the overall task
flow. *Is* this just me?

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

BASE SITE

(r'^$', homepage),
(r'^(students/.*)/$', stdpage),
(r'^(py)/$', stdpage),
(r'^(py/.*)/$', stdpage),
(r'^(partners)/', stdpage),
(r'^(partners/.*)/$', stdpage),
(r'^(review/.*)$', stdpage),
(r'^(opensource)/$', stdpage),
(r'^(projects)/$', stdpage),
(r'^(thankyou)/$', stdpage),
(r'^(family)/$', stdpage),
(r'^(training)/$', stdpage),
(r'^(about)/$', stdpage),
(r'^(search)/$', stdpage),
(r'^registration/', include("registration.urls")),
(r'^grp/', include('grp.urls')),
(r'^(contact)', include('contact.urls')),
url(r'^accounts/register/$',
registration.views.register,
{"profile_callback": hwprofile.models.create_profile},
name='registration_register'),
# Non-overridden register package
(r'^accounts/', include('registration.urls')),
(r'^accounts/profile/', 'hwprofile.views.postlogin'),
(r'^accounts/password/reset/complete/$', 
django.contrib.auth.views.password_reset_complete, {}, 
'password_reset_complete'),
(r'^accounts/password/reset/confirm/(?P.+)/(?P\d)/$', 

Re: Keyword arguments with spaces and the url tag

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 18:09 -0700, Alexis Bellido wrote:
> Hi, I'm reading the docs and was testing named url patterns, I have
> something like this in my URLConf:
> 
> url(r'^search/(?P.*)$', 'books.views.search',
> name='search_page'),
> 
> And the view is defined like this:
> 
> def search(request, words):
> 
> Now I'd like to print a link to the search page with certain words
> from a template and used the url tag like this:
> 
> {% url search_page words="someword" %}
> 
> When viewing on the browser I get something like '/search/someword',
> which is good.
> 
> My question is how do I pass more than one word in the 'words'
> parameter?
> 
> If I do this:
> 
> {% url search_page words="someword otherword" %}
> 
> I get this error:
> 
> TemplateSyntaxError at (my page name here)
> 
> Could not parse the remainder: '"someword' from '"someword
> 
> Can the url tag handle parameters with spaces? If so, how?

That's probably just a bug. Please open a ticket for it. It probably
falls into one of a couple of other tickets about slightly more robust
parameter passing in template tags that are slowly being worked on, but
make a new ticket for it so that we remember to test this case.

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



Keyword arguments with spaces and the url tag

2008-10-05 Thread Alexis Bellido

Hi, I'm reading the docs and was testing named url patterns, I have
something like this in my URLConf:

url(r'^search/(?P.*)$', 'books.views.search',
name='search_page'),

And the view is defined like this:

def search(request, words):

Now I'd like to print a link to the search page with certain words
from a template and used the url tag like this:

{% url search_page words="someword" %}

When viewing on the browser I get something like '/search/someword',
which is good.

My question is how do I pass more than one word in the 'words'
parameter?

If I do this:

{% url search_page words="someword otherword" %}

I get this error:

TemplateSyntaxError at (my page name here)

Could not parse the remainder: '"someword' from '"someword

Can the url tag handle parameters with spaces? If so, how?

Or maybe I'm missing the whole point and I should do this is a
different way?

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: Questions about HttpResponseRedirect and reverse

2008-10-05 Thread Alexis Bellido

Cool, now it's completely clear.

Thanks a lot 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: Admin UI: How to auto select selectbox items via URL?

2008-10-05 Thread Russell Keith-Magee

On Mon, Oct 6, 2008 at 7:06 AM, Dana <[EMAIL PROTECTED]> wrote:
>
> On Sep 18, 2:16 pm, Dana <[EMAIL PROTECTED]> wrote:
>> Im confused as to why I cannot select items above 9 and if this issue
>> is fixed in Django 1.0? Could someone test it on 1.0 and let me know?
>> Also, if you know how to get around this for 0.96, I'd love to hear
>> it. This is a Javascript related issue.

> Anyone have anything to say about this problem?

My first reaction (and one of the reasons that nobody responded the
first time you asked) is "Have you tried it?". If you want to know if
a bug has been fixed in v1.0, the easiest way to check is to try. If
your existing application large enough that you don't want to port it,
it doesn't take much to knock out a quick test application. Asking
someone else to do your testing is a little bit presumptuous.

However - that said - the behaviour you are talking about (passing in
data in the URL which is used by the form) has nothing to do with
Javascript - it's entirely part of the way Django admin handles forms.
I'm not aware of any problems with v1.0 that match the one you
describe. If you can provide a simple failing test case, open a ticket
and there is a chance someone will look at the problem.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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: Questions about HttpResponseRedirect and reverse

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 16:03 -0700, Alexis Bellido wrote:
> After some more reading and testing I'll try to answer myself, if any
> of you could confirm if I'm on the right track please let me know and
> please correct me if I'm not using the right terminology as well:
> 
> First, in my URLConf I have a url pattern like:
> 
> (r'^search/$', 'books.views.search', {}, 'search_page'),
> 
> I'm using a name url pattern here: 'search_page', that's the fourth
> parameter and I've included an empty dictionary as third parameter,
> can I just omit it?

If you just omit it, the fourth parameter will then become the third
parameter and there will be no fourth parameter. That isn't what you
want. The best way to do this in "short form" is to use the url(...)
style of url patterns. To wit:

url(r'^search/$', 'books.views.search', name='search_page'),

There's no real difference between this and the tuple form (internally,
Django converts the tuple form into a url(...) form), but the above
version is a proper Python function call, so you can use keyword
arguments. The fourth argument is called "name", so you can specify it
without needing to give the third argument.

> 
> Then at the revelant place in my view function I have:
> 
> return HttpResponseRedirect(reverse('search_page'))
> 
> It works for me, am I doing it correctly?

That is indeed correct. If you had any arguments in the search pattern,
say,

url(r'^search2/(\d+)/$', 'books.view.search',
name='search_page2'),

you could write

reverse('search_page2', args=[42])

to reverse that call. The reverse() call takes "args" and "kwargs"
parameters and the former should be a list or a tuple (the kwargs
parameters would be a dictionary). You must call them "args" and
"kwargs" and not use positional parameters, since, for historical
reasons, the second argument of reverse() is something else that you
don't use here.

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: Admin UI: How to auto select selectbox items via URL?

2008-10-05 Thread Dana

Anyone have anything to say about this problem?

On Sep 18, 2:16 pm, Dana <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Wondering why the Django admin Multiple Select box widget (in Django
> 0.96, not sure if 1.0 is different), only allows you to pass in single
> digit values via the URL. Basically, if I have a multiple select box
> on a popup form and Id like to pass in a value to the url like so:
>
>     example.com/admin/my/model/path/1/?stories=25
>
> It will not select ... in the select box,
> but it will if I pass it a one digit value like so:
>
>     example.com/admin/my/model/path/1/?stories=2
>
> Which will select ... as expected.
>
> Im confused as to why I cannot select items above 9 and if this issue
> is fixed in Django 1.0? Could someone test it on 1.0 and let me know?
> Also, if you know how to get around this for 0.96, I'd love to hear
> it. This is a Javascript related issue.
>
> Cheers,
> Dana
--~--~-~--~~~---~--~~
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: Questions about HttpResponseRedirect and reverse

2008-10-05 Thread Alexis Bellido

After some more reading and testing I'll try to answer myself, if any
of you could confirm if I'm on the right track please let me know and
please correct me if I'm not using the right terminology as well:

First, in my URLConf I have a url pattern like:

(r'^search/$', 'books.views.search', {}, 'search_page'),

I'm using a name url pattern here: 'search_page', that's the fourth
parameter and I've included an empty dictionary as third parameter,
can I just omit it?

Then at the revelant place in my view function I have:

return HttpResponseRedirect(reverse('search_page'))

It works for me, am I doing it correctly?
--~--~-~--~~~---~--~~
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: No FlatPage matches the given query.

2008-10-05 Thread John Allen

Have you looked at these notes on how to get the Practical Django
Projects examples to work:
http://blog.haydon.id.au/2008/08/notes-on-practical-django-projects.html
?

--~--~-~--~~~---~--~~
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: Questions about HttpResponseRedirect and reverse

2008-10-05 Thread Alexis Bellido

Hey, Malcolm, maybe an example could help. I'm reading the forms
documentation at http://docs.djangoproject.com/en/dev//topics/forms/
and I see this code as part of the view function for a contact form:

def contact(request):
if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST
data
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
return HttpResponseRedirect('/thanks/') # Redirect after
POST
else:
form = ContactForm() # An unbound form

return render_to_response('contact.html', {
'form': form,
})

I'd like to know the best way to use this line:

return HttpResponseRedirect('/thanks/') # Redirect after POST

that's a redirect to an absolute, hard-coded, url: /thanks. I guess
that's not too portable, for example if I want to test at
http://development-server.com/subdirectory before going to
http://production-server.com/.

How should I setup my URLConf and use HttpResposeRedirect and reverse
in my view to be able to move my code independently of the domain or
directory structure?

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



No FlatPage matches the given query.

2008-10-05 Thread Matt

Hello,

I am running through the Practical Django projects book. I've gotten
to the point where I am trying to view an entry detail, but the error
that I am getting is: No FlatPage matches the given query

Here's my urls.py:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^cardie/', include('cardie.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^blog/(?P\d{4})/(?P\w{3})/(?P\d{2})/(P?[-
\w]+)/$', 'coltrane.views.entry_detail'),
(r'^blog/$', 'coltrane.views.entries_index'),
(r'^admin/(.*)', admin.site.root),
(r'',include('django.contrib.flatpages.urls')),
)

Here's the url that I am trying to view:

http://127.0.0.1:8000/blog/2008/oct/05/test/

Everything looks okay to me. Any ideas? Thanks in advance!

--~--~-~--~~~---~--~~
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: Where to put initializing code

2008-10-05 Thread Arnaud Delobelle

On Oct 5, 7:12 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Arnaud Delobelle wrote:
> > Hi Django users,
>
> > I have a project made of several app and I am adding a 'search' app
> > which provides searching facilities across all apps.  Each app whose
> > content can be searched needs to register with the search app with
> > code such as:
>
> > def search_genf(request, search_terms):
> >     # generate weighed results
>
> > from project.search import register
> > register('Category name', search_genf)
>
> > My question is: how should I make an app register?
[...]
> > What, in your opinion, would be a good way to go about doing this?
>
> You might want to look at the code for admin.autodiscover(), which scans
> the various apps for an admin model. You could do something similar for
> your search functionality. It's doing pretty much what you already do,
> though.

I'll have a look there, thanks.

--
Arnaud


--~--~-~--~~~---~--~~
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: a NameError happened when using Meta option 'unique_together' in model

2008-10-05 Thread Karen Tracey
On Sun, Oct 5, 2008 at 9:47 AM, Matrixer <[EMAIL PROTECTED]> wrote:

>
> hi, when I was trying to use the Meta option 'unique_together' in my
> Membership model below, a NameError happened, I don't know what the
> problem is, I am using django 1.0 and sqlite3
>
> regards,
> Matrixer
>
> ---
> class Membership(models.Model):
>person = models.ForeignKey('Person')
>group = models.ForeignKey('Group')
>
>class Meta:
>unique_together('person', 'group')
>
> ---
>unique_together('person', 'group')
> NameError: name 'unique_together' is not defined
>

You've coded it as a method call and there is no such method.  You want it
to be an assignment:

http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together

Karen

--~--~-~--~~~---~--~~
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: django cms outside of django

2008-10-05 Thread chiggsy

> By "outside of Django" I'm guessing you mean "outside of a web environment"

Yes, that is what i meant.

>
> Yes, you can use Django components separately. At work we use Django's
> ORM for management scripts such as print accounting.
>
> I've set up a standalone Django template-- no views, models, or urls. It
> was more like a traditionaly CGI script.


That sounds promising.  I really wanted to use the ./manage.py
inspectdb tool in particular to turn this foreign db into python for
me.  Is it at all possible to share your template?




--~--~-~--~~~---~--~~
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: mptt + contrib.comments?

2008-10-05 Thread Chris Stromberger
This article is a great resource as well--explains all you need to know very
nicely I think (I especially like the trick of finding number of descendants
(so number of comments associated with an item) just from inspecting the
values for "right" and "left"--single row query).  I found this a while back
and had started rolling my own, then I discovered Django (so have started
"porting" my site to Django), then I discovered the mptt app and thought I
could just drop it in.  Has not been that easy (probably in large part due
to my Django-newbie status).
http://www.sitepoint.com/article/hierarchical-data-database/2/

Keep us posted on your system.  Would like to see it.

On Sat, Oct 4, 2008 at 11:02 AM, Jonathan Nelson <[EMAIL PROTECTED]>wrote:

>
> I'm actually rolling my own threaded comments system using an MPTT
> algorithm.  Contrib.comments and the django-mptt aren't a really good
> fit for what I need.
>
> It's taken me a while to get my head around the concept of traversing
> the tree using the comment.left and comment.right values, but after
> you understand it, it really seems to work well.
>
> I'll try and put some code up on Google code when I get mine
> finished.
>
> I've found this article to be very helpful:
> http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
>
> And, I've found this book to be invaluable:
>
> http://www.amazon.com/Hierarchies-Smarties-Kaufmann-Management-Systems/dp/1558609202/ref=sr_1_5?ie=UTF8=books=1223136111=8-5
>
> J.
>
>
>
>
> On Oct 1, 2:10 pm, "Chris Stromberger" <[EMAIL PROTECTED]>
> wrote:
> > If I can get something working, I'll share!  Still fiddling around with
> it.
> >
> > On Wed, Oct 1, 2008 at 2:48 PM, john Moylan <[EMAIL PROTECTED]> wrote:
> > > Hi Chris,
> >
> > > I'd love to see your finished code - if you can/want to share?
> >
> > > J
> >
> > > 2008/9/30 Chris Stromberger <[EMAIL PROTECTED]>
> >
> > > OK, nevermind on the admin page issue.  Was being caused
> > >> by TEMPLATE_STRING_IF_INVALID being set to something other than ''.
> > >> Would still love to see an example of contrib.comments + mptt!
> >
> > >> Thanks,
> > >> Chris
> >
> > >> On Tue, Sep 30, 2008 at 4:25 PM, Chris Stromberger <
> > >> [EMAIL PROTECTED]> wrote:
> >
> > >>> One specific issue I am having is that the admin screen for the
> Comment
> > >>> model is not "synched up" with the data.  The admin list screen has a
> table
> > >>> of field names, and the columns do not match the data--the data is
> shifted.
> > >>>  So for example, the "Is public" column is displaying the IP address.
>  Etc.
> > >>>  Any ideas on what would cause this?  Mptt adds some fields to your
> model
> > >>> dynamically, so wondering if this is somehow related.
> > >>> Any tips appreciated.
> >
> > >>> Thanks,
> > >>> Chris
> >
> > >>> On Tue, Sep 30, 2008 at 2:31 PM, Chris Stromberger <
> > >>> [EMAIL PROTECTED]> wrote:
> >
> >  I'm trying to use mptt with contrib.commments and am not having much
> >  luck.  Basically would like to allow nested comments.  Pretty new to
> Django,
> >  so that is contributing to the problem.  Would love to see a simple
> >  example/summary of what needs to change in contrib.comments to
> incorporate
> >  mptt.
> >  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: django cms outside of django

2008-10-05 Thread Jeff Anderson
chiggsy wrote:
> What steps are needed to use the django cms outside of django.  I have
> a database , that i want to manipulate.  it's just a db.  I dont want
> to learn SQLAlchemy for this , today. I just want to goof around with
> it, run some queries, etc.  is this possible?
>   
By "outside of Django" I'm guessing you mean "outside of a web environment"

Yes, you can use Django components separately. At work we use Django's
ORM for management scripts such as print accounting.

I've set up a standalone Django template-- no views, models, or urls. It
was more like a traditionaly CGI script.

You just need to import the appropriate Django libs in your Python
script, and you are good to go.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: select_related()

2008-10-05 Thread johnny

Ok, for example, I can pass in
Modelname.objects.select_related().all() for the queryset, obj's_Id
for the object_id.  And the 'object' in the generic view will actually
be calling a .get(id=obj's_Id) on that lazy, select_related queryset?
thanks for the reply,
Johnny

On Oct 5, 3:18 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-10-05 at 03:32 -0700, johnny wrote:
> > Hi,
> >   I'm wondering if select_related() is used for the object_detail
> > generic view.  If not, shouldn't it be since it's more efficient?
> > Also, is select_related only useful on a .get() method?
>
> It's entirely up to you, when creating your queryset, whether to use
> select_related() or not. It is certainly not something anything like a
> generic view should always put in place, since it can impact performance
> in a negative way if you aren't using all the related fields it
> retrieves (which can be a lot if your model has lots of linkages to
> other models or itself).
>
> select_related() can be used on any queryset, not just when using a
> get() call.
>
> 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: Where to put initializing code

2008-10-05 Thread Steve Holden

Arnaud Delobelle wrote:
> Hi Django users,
>
> I have a project made of several app and I am adding a 'search' app
> which provides searching facilities across all apps.  Each app whose
> content can be searched needs to register with the search app with
> code such as:
>
> def search_genf(request, search_terms):
> # generate weighed results
>
> from project.search import register
> register('Category name', search_genf)
>
> My question is: how should I make an app register?
>
> At the moment, I am putting the registering code in app/__init__.py,
> which is automatically run when the server starts, but I don't know if
> this is a good idea.  My other idea was to add a 'search.py' file to
> each searchable app, and have code such as this is search/
> __init__.py :
>
> for app in settings.INSTALLED_APP:
> # if app has file search.py, import it and register its search
> function(s)
>
> However, I feel like I am not doing it right.
> What, in your opinion, would be a good way to go about doing this?
>   
You might want to look at the code for admin.autodiscover(), which scans
the various apps for an admin model. You could do something similar for
your search functionality. It's doing pretty much what you already do,
though.

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



Where to put initializing code

2008-10-05 Thread Arnaud Delobelle

Hi Django users,

I have a project made of several app and I am adding a 'search' app
which provides searching facilities across all apps.  Each app whose
content can be searched needs to register with the search app with
code such as:

def search_genf(request, search_terms):
# generate weighed results

from project.search import register
register('Category name', search_genf)

My question is: how should I make an app register?

At the moment, I am putting the registering code in app/__init__.py,
which is automatically run when the server starts, but I don't know if
this is a good idea.  My other idea was to add a 'search.py' file to
each searchable app, and have code such as this is search/
__init__.py :

for app in settings.INSTALLED_APP:
# if app has file search.py, import it and register its search
function(s)

However, I feel like I am not doing it right.
What, in your opinion, would be a good way to go about doing this?

--
Arnaud
--~--~-~--~~~---~--~~
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: Flatpages, get_absolute_url() and ABSOLUTE_URL_OVERRIDES

2008-10-05 Thread bruno desthuilliers

On 5 oct, 11:30, Erik Allik <[EMAIL PROTECTED]> wrote:
>
> what if I did the from django.core.urlresolvers import reverse part in
> the function itself that gets called?
>
> def my_flatpage_url(o):
>from django.core.urlresolvers import reverse
>return '%s%s' % (reverse('my-site-index'), o.url)
>
> ABSOLUTE_URL_OVERRIDES = {
>'flatpages.flatpage': my_flatpage_url,
>
> }


Well, instead of a direct cycle dependancy, you'd have an indirect
one. You'd still have a cyclic dependancy anyway.

> That wouldn't introduce a chicken-and-egg problem, would it?

It would just the same.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



django cms outside of django

2008-10-05 Thread chiggsy

What steps are needed to use the django cms outside of django.  I have
a database , that i want to manipulate.  it's just a db.  I dont want
to learn SQLAlchemy for this , today. I just want to goof around with
it, run some queries, etc.  is this possible?
--~--~-~--~~~---~--~~
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: Name of button pressed not in request.POST

2008-10-05 Thread bruno desthuilliers

On 5 oct, 16:40, ydjango <[EMAIL PROTECTED]> wrote:
> I have more than one input submit button and want to know which one
> was clicked.
> Request.POST does not have that information for some reason.
>
> Using django 1.0 svn
>
> I would appreciate if you can point me to right resource.
> This is should be something very simple that I am missing.

Probably - but I have no cue about what's causing your problem.


I just did a quick test and it worked just fine. Here's the test:

# yadda/view.py
 from django.shortcuts import render_to_response

def form(request):
context = dict(post=dict(), results=list())

if request.POST:
for k in request.POST:
context['post'][k] = request.POST[k]

for name in ('save', 'id_save', 'Save', 'cancel', 'id_cancel',
'Cancel'):
context['results'].append(
"request.POST.has_key('%s') == %s" % (name,
request.POST.has_key(name))
)

return render_to_response('yadda/form.html', context)

# templates/yadda/form.html
{% if results %}

{% for r in results %}
{{ r }}
{% endfor %}

{% endif %}

{% if post %}
{{ post|default:"???" }}
{% else %}
no post
{% endif %}










# urls.py
from django.conf.urls.defaults import *
from yadda.views import form

urlpatterns = patterns('',
url(r'^form/$', form),
)

Try running this in your project...


--~--~-~--~~~---~--~~
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: Flatpages, get_absolute_url() and ABSOLUTE_URL_OVERRIDES

2008-10-05 Thread John Allen

Small postscript to the above:

On 21 August, Jannis Leidel (http://jannisleidel.com/)  posted that he
was using something like Erik's code:

from django.core.urlresolvers import reverse
ABSOLUTE_URL_OVERRIDES = {
'coltrane.entry': lambda o: reverse('coltrane_entry_detail',
kwargs={
'year':
o.pub_date.strftime('%Y'),
'month':
o.pub_date.strftime('%m'),
'slug': o.slug }),
}

and a few days later he added "UPDATE: Seems like Django 1.0 broke
this. Trying to figure out why.. ", which nicely demonstrates
Malcolm's warning not to do this.


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



Hierarchy on foreign key

2008-10-05 Thread Ramashish Baranwal

Hi,

On admin change list, I want to group objects based on a foreign key.
Is there a way to generate a hierarchy based on foreign/m2m key
instead of date?

Consider the following example-

class Book(models.Model):
# ...
publisher = models.ForeignKey(Publisher)

On Book's admin page, I want the books to be arranged by their
publishers. This may be helpful when I have a large number of books in
the database. How can one do this, preferably in a generic way?

Thanks,
Ram

--~--~-~--~~~---~--~~
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: forms.BooleanField

2008-10-05 Thread James Bennett

On Sun, Oct 5, 2008 at 11:07 AM, globophobe <[EMAIL PROTECTED]> wrote:
> I encountered this when I upgraded from my recent copy of 0.97 django
> to 1.0-final. Why does MyForm not validate when instantiated as m =
> MyForm({'bfield':'False'})?

Because the field doesn't have "required=False"; all form fields are
required by default unless you say otherwise. A BooleanField
translates into a checkbox, and the only way to "require" a value for
a checkbox is to require it to be checked (i.e., to have a value which
evaluates true); any false value, or the absence of a value, will
fail.

This has been the documented behavior for a long time, though
occasional bugs would cause it not to actually work that way.

(also, there have been several long discussions about this behavior
leading up to it being finalized as it currently works, so if you'd
like to take up an argument against it you probably want to start by
finding them in the archive)


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



forms.BooleanField

2008-10-05 Thread globophobe

I encountered this when I upgraded from my recent copy of 0.97 django
to 1.0-final. Why does MyForm not validate when instantiated as m =
MyForm({'bfield':'False'})?

In [27]: class MyForm(forms.Form):
   bfield = forms.BooleanField()
   :
   :

In [28]: m = MyForm({'bfield':'False'})

In [29]: m.is_valid()
Out[29]: False

In [30]: m = MyForm({'bfield':'True'})

In [31]: m.is_valid()
Out[31]: True
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



a NameError happened when using Meta option 'unique_together'

2008-10-05 Thread Matrixer

hi, when I was trying to use the Meta option 'unique_together' in my
Membership model below, a NameError happened, I don't know what the
problem is, I am using django 1.0 and sqlite3

regards,
Matrixer

---
class Membership(models.Model):
person = models.ForeignKey('Person')
group = models.ForeignKey('Group')

class Meta:
unique_together('person', 'group')

--~--~-~--~~~---~--~~
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: Name of button pressed not in request.POST

2008-10-05 Thread ydjango

I have more than one input submit button and want to know which one
was clicked.
Request.POST does not have that information for some reason.

Using django 1.0 svn

I would appreciate if you can point me to right resource.
This is should be something very simple that I am missing.


On Oct 4, 11:44 am, ydjango <[EMAIL PROTECTED]> wrote:
> I do not see the name of submit button in request.POST. it has all
> other form fields
>
>  if request.POST.has_key('save'):
>      does not work too
>
> Where can I find which button was pressed.
>
> 
> various fields...
>  
> other input buttons
> 
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



a NameError happened when using Meta option 'unique_together' in model

2008-10-05 Thread Matrixer

hi, when I was trying to use the Meta option 'unique_together' in my
Membership model below, a NameError happened, I don't know what the
problem is, I am using django 1.0 and sqlite3

regards,
Matrixer

---
class Membership(models.Model):
person = models.ForeignKey('Person')
group = models.ForeignKey('Group')

class Meta:
unique_together('person', 'group')

---
unique_together('person', 'group')
NameError: name 'unique_together' is not defined
--~--~-~--~~~---~--~~
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: Flatpages, get_absolute_url() and ABSOLUTE_URL_OVERRIDES

2008-10-05 Thread John Allen

Malcolm,
Thanks, your explanation is clear for me and I certainly don't need to
live dangerously - the conventional usage of ABSOLUTE_URL_OVERRIDES
works fine for me. I was only trying to satisfy my curiosity about
using reverse() because I've read a number of posts from James Bennett
and others suggesting that using reverse() is generally a good thing
to do.
John

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



select_related()

2008-10-05 Thread johnny

Hi,
  I'm wondering if select_related() is used for the object_detail
generic view.  If not, shouldn't it be since it's more efficient?
Also, is select_related only useful on a .get() method?
thanks.
Johnny
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django / Postgresql problem

2008-10-05 Thread Anderson Santos
Hello, everyone

I am getting a strange "permission denied" error on database server running
my site.

I am trying to send bulk mail to a huge list, it was working fine few days
ago but now it's dropping connections everytime. I had postgresql log
configured just few days ago and it's full of  "unexpected EOF on client
connection" and when sending the mailing as a standalone app I get the
following error " File
"/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py", line
1608, in execute_sql
  cursor.execute(sql, params)
psycopg2.OperationalError: could not send data to server: Permission denied"

But in general it is OK, it sends the first emails but it just dies that way
at some point when doing a random query (not in a specif query). Sometimes
after 15 minutes execution, sometimes after 1 hour and half. I don't know if
I am missing something. Most of things I have to send are cached, but it
does some queries on database during the process to get user details and
stuff like that.

The website navigation is fine, I don't get any server error while
navigating, but it seems raising "unexpected EOF on client connection"
everytime.

But even tho, I can't understand that unexpect EOF on my postgresql log. The
server is just fine, accepting 250 connections and using much less then
that, apache has between 15 process alive (it's prefork) so it's not
resources and there are two servers (app+db) with a crossover connection so
I doubt it's a connection problem.

I don't know if it's a database misconfiguration, psycopg2 bug (I am using
the version 2.0.7) or anything else I am missing. I also don't know how
django deals with connection, if it's one per query, on per request and now,
using it standalone, if it is by program so it makes even harder to me to
figure out.

Any help will be appreciate.

--~--~-~--~~~---~--~~
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: Flatpages, get_absolute_url() and ABSOLUTE_URL_OVERRIDES

2008-10-05 Thread Erik Allik

Malcolm,

what if I did the from django.core.urlresolvers import reverse part in  
the function itself that gets called?

def my_flatpage_url(o):
   from django.core.urlresolvers import reverse
   return '%s%s' % (reverse('my-site-index'), o.url)

ABSOLUTE_URL_OVERRIDES = {
   'flatpages.flatpage': my_flatpage_url,
}

That wouldn't introduce a chicken-and-egg problem, would it?

Erik

On 05.10.2008, at 11:39, Malcolm Tredinnick wrote:

>
>
> On Sun, 2008-10-05 at 00:50 -0700, John Allen wrote:
>> Erik, Malcolm,
>>
>> Thanks for two very interesting answers - but which one is correct?
>> Malcolm, you are saying, in effect, that the code in Erik's post can
>> never work in the settings file?
>
> Even if it does work by accident, it would not be at all stable. You
> cannot use anything from Django in settings file. If you do and it  
> works
> because of some accidental reason and then later breaks, you get to  
> keep
> all the pieces and you can't complain.
>
> 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: Flatpages, get_absolute_url() and ABSOLUTE_URL_OVERRIDES

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 12:30 +0300, Erik Allik wrote:
> Malcolm,
> 
> what if I did the from django.core.urlresolvers import reverse part in  
> the function itself that gets called?
> 
> def my_flatpage_url(o):
>from django.core.urlresolvers import reverse
>return '%s%s' % (reverse('my-site-index'), o.url)
> 
> ABSOLUTE_URL_OVERRIDES = {
>'flatpages.flatpage': my_flatpage_url,
> }
> 
> That wouldn't introduce a chicken-and-egg problem, would it?

*sigh* As I mentioned earlier, if it works by accident now, then that's
fine, but don't come crying if it stops working in the future because we
happen to change when we evaluate ABSOLUTE_URL_OVERRIDES to somewhat
earlier than you expected or something. It's simply far too
time-consuming, fiddly and generally counter-productive to try and play
games with which parts of Django you can use in settings. Don't do that.

It seems like people are determined to do dangerous things just because
they can. That's fine. This is professional computer science and we're
all adults. But using ABSOLUTE_URL_OVERRIDES in a way that requires
access to your URL configuration would suggest to me that you're abusing
the notion and should probably come up with an alternate solution in any
case.

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: select_related()

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 03:32 -0700, johnny wrote:
> Hi,
>   I'm wondering if select_related() is used for the object_detail
> generic view.  If not, shouldn't it be since it's more efficient?
> Also, is select_related only useful on a .get() method?

It's entirely up to you, when creating your queryset, whether to use
select_related() or not. It is certainly not something anything like a
generic view should always put in place, since it can impact performance
in a negative way if you aren't using all the related fields it
retrieves (which can be a lot if your model has lots of linkages to
other models or itself).

select_related() can be used on any queryset, not just when using a
get() call.

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



Editing user profile in admin interface

2008-10-05 Thread Felipe Sodré Silva
Hi. I've followed these steps to create a profile model to my users:
http://www.djangobook.com/en/1.0/chapter12/#cn222

However, I'm still not able to add nor edit the profile information in the
admin interface. Is there any further step to take in order to be able to do
it?

Thank you!
Felipe

--~--~-~--~~~---~--~~
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: Recursive relationship - two models, same table

2008-10-05 Thread AndyB

Well the admin *already* does lots of things it 'was never intended to
do'.

Why have devs gone to all the effort of adding extra customization
hooks if extending the admin was such a fools errand? :)

To my mind the more versatile the admin gets the better it is for
Django.

Yes - there is a point you reach where it would be quicker to write
your own views but it's rather hard to see where that point is until
you've tried pushing the boundries of what the admin can do.

regards,

AndyB

On Oct 4, 9:48 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Will Temperley wrote:
> > Hi All
>
> > I have a load of Institutions, some with departments, some not. So I
> > created a model that can represent this simple hierarchy. See models
> > at the bottom.
>
> >  Fine, but a bit confusing for users, plus if the user just wants to
> > deal with Institutions alone in the admin, they're faced with
> > institutions and departments.  I'm relying heavily on the admin app in
> > my project btw.
>
> > So, I've tried having two models - InstitutionDepartment and
> > Institution that have the same table but different managers- (see
> > below). Institution doesn't use the "parent" foreign key.  (Btw I
> > haven't used inheritance here cos copy and paste is quick and dirty.)
>
> > I also have an Address model and JobPosition model that depend on
> > "institution_department_id", therefore to make this work, I'll need
> > two Address models with the same table?
>
> > I've tried this and it works, it's just v messy! Is there a better way
> > to do this??
> > >From my point of view it would just be much easier to have multiple
> > ModelAdmin classes use a single Model, but I can't do this can I?
>
> > Cheers
>
> > Will T
>
> > class InstitutionDepartment(models.Model):
> >     TYPE_CHOICES = (
> >         ('I', 'Institution'),
> >         ('D', 'Department'),
> >     )
> >     institution_department_id = models.AutoField(primary_key=True)
> >     name = models.CharField(max_length=200)
> >     acronym = models.CharField(max_length=10,  null=True, blank=True)
> >     type = models.CharField(max_length=1,  choices=TYPE_CHOICES)
> >     parent = models.ForeignKey('self',  null=True,  blank=True)
> >     def __unicode__(self):
> >         if self.parent:
> >             return ' | '.join([self.parent.name,  self.name, ])
> >         else:
> >             return self.name
> >     class Meta:
> >         db_table = 'institution_department'
> >         ordering = ['parent__name', 'name', ]
>
> > class Institution(models.Model):
> >     TYPE_CHOICES = (
> >         ('I', 'Institution'),
> >         ('D', 'Department'),
> >     )
> >     institution_department_id = models.AutoField(primary_key=True)
> >     name = models.CharField(max_length=200)
> >     acronym = models.CharField(max_length=10,  null=True, blank=True)
> >     objects = InstitutionManager()
> >     type = models.CharField(max_length=1,  choices=TYPE_CHOICES)
> >     def __unicode__(self):
> >             return self.name
> >     class Meta:
> >         db_table = 'institution_department'
>
> > class StreetAddress1(StreetAddressAbstract):
> >     institution_department =
> > models.OneToOneField(InstitutionDepartment)
> >     class Meta(StreetAddressAbstract.Meta):
> >         pass
>
> > class StreetAddress2(StreetAddressAbstract):
> >     institution_department = models.OneToOneField(Institution)
> >     class Meta(StreetAddressAbstract.Meta):
> >         pass
>
> I could be wrong (it's happened before :-) but it seems to me that many
> time the contortions people go through to make the admin interface do
> what they want actually end up taking more time than writing the
> necessary customized views.
>
> Sorry if this isn't helpful, but I have seen many cases where people ask
> "how do I make the admin interface do (something it was never intended
> to)". Django allows you to build custom views with custom templates so
> easily it seems a shame to have to mangle the admin system to manage
> contorted models just to avoid writing a little custom code.
>
> regards
>  Steve
>
> 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: Flatpages, get_absolute_url() and ABSOLUTE_URL_OVERRIDES

2008-10-05 Thread free won
in Js, "document.URL" has the same function as   get_ab_url().


-- 
真正的杰出,不是妙用规则的错层,而是极致的偏执于信念

--~--~-~--~~~---~--~~
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: Flatpages, get_absolute_url() and ABSOLUTE_URL_OVERRIDES

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 00:50 -0700, John Allen wrote:
> Erik, Malcolm,
> 
> Thanks for two very interesting answers - but which one is correct?
> Malcolm, you are saying, in effect, that the code in Erik's post can
> never work in the settings file?

Even if it does work by accident, it would not be at all stable. You
cannot use anything from Django in settings file. If you do and it works
because of some accidental reason and then later breaks, you get to keep
all the pieces and you can't complain.

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: Editing user profile in admin interface

2008-10-05 Thread Malcolm Tredinnick


On Sun, 2008-10-05 at 00:45 -0700, Felipe Sodré Silva wrote:
> I'm sorry, what I am actually able to add and edit profiles, but I'd
> like it to be added at the time of user registration (as if it was
> part of the User model, and not only after creating the new user in
> separate).

Well, that's not the way user profiles are handled in the admin. They
are really just normal related classes. The only way they are special is
that there's a special get_profile() method on the User model.

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: Flatpages, get_absolute_url() and ABSOLUTE_URL_OVERRIDES

2008-10-05 Thread John Allen

Erik, Malcolm,

Thanks for two very interesting answers - but which one is correct?
Malcolm, you are saying, in effect, that the code in Erik's post can
never work in the settings file?

John
--~--~-~--~~~---~--~~
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: Editing user profile in admin interface

2008-10-05 Thread Felipe Sodré Silva
I'm sorry, what I am actually able to add and edit profiles, but I'd like it
to be added at the time of user registration (as if it was part of the User
model, and not only after creating the new user in separate).

Thanks

Felipe

On Sun, Oct 5, 2008 at 12:43 AM, Felipe Sodré Silva <[EMAIL PROTECTED]>wrote:

> Hi. I've followed these steps to create a profile model to my users:
> http://www.djangobook.com/en/1.0/chapter12/#cn222
>
> However, I'm still not able to add nor edit the profile information in the
> admin interface. Is there any further step to take in order to be able to do
> it?
>
> Thank you!
> Felipe
>

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