Re: ImproperlyConfigured: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1 But I HAVE 1.2.2!

2009-03-15 Thread Malcolm Tredinnick

On Sun, 2009-03-15 at 21:08 -0700, Theme Park Photo, LLC wrote:
> I'm getting this message when trying to start Django (from mod_python)
> 
> 
> (From my apache log)
> 
> [Sun Mar 15 22:07:28 2009] [error] [client 67.188.95.50] PythonHandler
> django.core.handlers.modpython: ImproperlyConfigured: MySQLdb-1.2.1p2
> or newer is required; you have 1.2.1
> 
> 
> BUT! I have 1.2.2 installed, see:
> 
> bash-3.1$ python manage.py shell
> Python 2.4.4 (#1, Oct 23 2006, 13:58:00)
> [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import MySQLdb
> >>> print MySQLdb
>  MySQL_python-1.2.2-py2.4-linux-i686.egg/MySQLdb/__init__.py'>

What does MySQLdb.version_info say? That's what Django is looking at,
not the name of the package.

Also, what version of Django are you using?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ImproperlyConfigured: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1 But I HAVE 1.2.2!

2009-03-15 Thread Theme Park Photo, LLC

I'm getting this message when trying to start Django (from mod_python)


(From my apache log)

[Sun Mar 15 22:07:28 2009] [error] [client 67.188.95.50] PythonHandler
django.core.handlers.modpython: ImproperlyConfigured: MySQLdb-1.2.1p2
or newer is required; you have 1.2.1


BUT! I have 1.2.2 installed, see:

bash-3.1$ python manage.py shell
Python 2.4.4 (#1, Oct 23 2006, 13:58:00)
[GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import MySQLdb
>>> print MySQLdb



There's only one python installed on this machine, so it can't be that
mod_python is picking up a different python...

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Complex Form Issue with saving only 1 of 4 form items

2009-03-15 Thread Malcolm Tredinnick

On Sun, 2009-03-15 at 18:54 -0700, steven.head...@gmail.com wrote:
> Hello,
> I am trying to create a complex form similar to the poll example.

[...]
> This method displays my form correctly, but when I try to save filling
> out only 1 of the 4 Choices, I get a required validation error. Is
> there a way to save only the number of choices I want to save between
> 1 and 4?

You've just reinvented formsets, although, as you notice, there are some
subtleties to it. :-)

Have a read of this:
http://docs.djangoproject.com/en/dev/topics/forms/formsets/

There's also been a number of threads about formsets on this list in the
past couple of weeks, so a bit of searching in the archives might turn
up some help there as well.

Anyway, the answer to your question is "yes", but it would take ages to
go into the details (one of those "if you have to ask, you shouldn't do
it" cases), whereas Django already gives you this functionality.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FormSet max_num and extra

2009-03-15 Thread Kegan Gan

Ah, got it! Many thanks Malcolm.


On Mar 16, 5:58 am, Malcolm Tredinnick 
wrote:
> On Sun, 2009-03-15 at 04:25 -0700, Kegan wrote:
> > I am dealing with formset, and finding the lack of documentation in
> > understanding it. Hope anyone experienced with formset could help.
>
> At some point just opening up the relevant source file is always a good
> solution. It's only Python code and not particularly difficult to
> understand.
>
> Or experiment. Create a formset and vary the parameters you are
> interested in and see how it affects the displayed form.
>
>
>
> > What is the reason to have a "max_num" and "extra" argument when
> > instantiating a form set (using formset_factory)? Can't you just use
> > "max_num" to determine the number of forms in the form set?
>
> The max_num parameter is the number of forms that are populated with
> initial data to display. It means you can pass in, say,  a queryset (for
> modelformsets) without having to make sure it only contains the right
> number of records.
>
> If there are more records in the queryset than max_num, the first
> records are used and the latter ones discarded.
>
> The "extra" parameter is the number of blank forms to display (extra
> forms with no data populated).
>
>
>
> > Also, management_form render "form-TOTAL_FORM", and 'form-
> > INITIAL_FORMS', ... how is this correspond to "max_num" or "extra", or
> > they don't?
>
> The total form count is the total number of forms and the initial form
> count is the number of "initial" forms -- forms populated with initial
> data -- in the form set.
>
> Those values' upper-bounds can be computed from max_num and extra (since
> initial forms won't be greater than max_num) and, thus, total forms
> won't be greater than max_num + extra. But they are only upper bounds.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Complex Form Issue with saving only 1 of 4 form items

2009-03-15 Thread steven.head...@gmail.com

Hello,
I am trying to create a complex form similar to the poll example.
My create method is very similar to the following:

def create(request):
if request.method == 'GET':
pollform = bforms.PollForm()
choiceforms = []
for i in range(4):
choiceforms.append(bforms.ChoiceForm(prefix = 'f%s'%i))
if request.method == 'POST':
pollform = bforms.PollForm(request.POST)
choiceform = bforms.ChoiceForm()
if pollform.is_valid():
poll = pollform.save()
choiceforms = []
for i in range(4):
choiceforms.append(bforms.ChoiceForm(poll=poll, prefix
= 'f%s'%i, data=request.POST))
for form in choiceforms:
if form.is_valid():
form.save()
return HttpResponseRedirect(poll.get_absolute_url())
payload = dict(pollform=pollform, choiceforms=choiceforms)
return render('create.html', payload)

This method displays my form correctly, but when I try to save filling
out only 1 of the 4 Choices, I get a required validation error. Is
there a way to save only the number of choices I want to save between
1 and 4?


Regards,

Steven H.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Memcache unstable under consistent heavy load

2009-03-15 Thread Jacob Kaplan-Moss

On Sun, Mar 15, 2009 at 8:43 PM, meppum  wrote:
> Did you run the script on the same machine as the memcached
> installation or did you do it across the wire?

Both; I can't seem to find any problems.

Again, what's the error you're getting?

Jacob

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ImportError: Could not import settings, but with an EACCES puzzle

2009-03-15 Thread Jim Hickstein

It was SELinux, enabled by default on CentOS 5.2 (apparently).  The man page 
for 
stat(2) didn't mention SELinux, but some web page I stumbled on did.

I started to dig into chcon(1) and all that -- geez, it must be a new century 
-- 
got it to find my application, then django itself, then another python module 
it 
needed (pytz), and then it barfed trying to talk to postgresql on a UNIX-domain 
socket.

So I gave up and disabled SELinux (SELINUX=permissive in /etc/selinux/config). 
I'm on deadline, and the system is not exposed.  Maybe I'll come back to this 
in 
a month or so.

It's also interesting that I could get Apache to get around "mandatory" access 
controls by running it as "sudo /usr/sbin/httpd -X".

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Memcache unstable under consistent heavy load

2009-03-15 Thread Jacob Kaplan-Moss

On Sun, Mar 15, 2009 at 7:42 PM, meppum  wrote:
> I've created a small script that *should* cause this error on any
> machine running memcached. Any thoughts would be appreciated.

Not for me -- the given script completes (quickly) without error on
every memcached installation I've got access to.

What's the error you're getting?

> memcached  -m 8 -c 1024 -v -l 127.0.0.1 -d

Note that you're allocating memcached a whopping 8 MB of RAM. That's
really not very much at all -- 1984 called and wants its hard drive
back.

Jacob

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where do we put our templates?

2009-03-15 Thread Dougal Matthews
Correct, basically as long as Python can access it your all good. Just put
it somewhere that makes sense.
Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/




2009/3/15 Joshua Partogi 

>
> Thanks Doug.
>
> I kinda get the gist now. It seems that template is parsed internally
> by django so it doesn't matter where I put it, which is quite contrary
> to static files like js/css/images.
>
> Kind regards,
>
> On Mar 15, 12:25 am, Dougal Matthews  wrote:
> > You can put them where you want but generally they go inside the
> application
> > folder that uses that template.
> >
> > You may find this an interesting/helpful read;
> http://www.djangobook.com/en/2.0/chapter04/
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Creating KML files for use in Google Maps

2009-03-15 Thread Ariel Mauricio Nunez Gomez
>
> > view
> > 
> > def generateKml(request):
> >
> > locations = Location.objects.all().values('name','lat','longt')
> >
> > result= render_to_response('locations.kml',{
> > 'locations': locations
> > })
> >
> > return HttpResponse(result,mimetype='Content-Type:application/
> > vnd.google-earth.kml+xml')
>


Remember also you could do:

view
===
from django.contrib.gis.shortcuts import render_to_kml

def generateKml(request):
locations = Location.objects.all().values('name','lat','longt')
return render_to_kml('locations.kml', {'locations':locations})

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overriding django admin functionality

2009-03-15 Thread Malcolm Tredinnick

On Sun, 2009-03-15 at 16:06 -0700, Joshua Partogi wrote:
> Thanks Malcolm,
> 
> I'm going to read through the source code and see how I can create a
> new template with my custom authorization. So do you reckon that
> django admin system is already sufficient not to be overridden?

It depends very much on your specifics, however, as I mentioned, both of
the points you mentioned are, as general concepts, already support by
the admin: it supports the concept of users who are authorised to use
the admin and others who aren't and it has the concept of permissions on
a per-model basis, for example. If either of those points are news to
you, you probably should spend a bit of time initially reading the
existing admin documentation and experimenting.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overriding django admin functionality

2009-03-15 Thread Joshua Partogi

Thanks Malcolm,

I'm going to read through the source code and see how I can create a
new template with my custom authorization. So do you reckon that
django admin system is already sufficient not to be overridden?

Best regards,

On Mar 16, 9:58 am, Malcolm Tredinnick 
wrote:
> On Mon, 2009-03-16 at 09:40 +1100, Joshua Partogi wrote:
> > Dear all,
>
> > I need a custom authorization needs for the admin system. I need to
> > define certain users that is allowed to access certain admin
> > functionality. I also need to check whether use has logged in or not.
> > In the end I might be creating the admin from scratch.
>
> > Is there any documentation I can read about this admin system so I can
> > override it or maybe create a new one from scratch?
>
> The source code is the documentation here. There are lots of docstrings
> and comments scattered throughout. django/contrib/admin/sites.py is the
> main entry point for registration. A large portion of the heavy lifting
> is in django/contrib/admin/options.py (e.g. the ModelAdmin class).
>
> We tend to avoid writing anything much more than that at the moment,
> since it would predominantly be repeating the code in English
> (duplication) and there are lots of other higher-impact places where we
> can be spending our time.
>
> However, instead of thinking you'll have to replace the whole thing,
> certainly look at customisations you might be able to make. All of the
> things you described in your initial paragraph can be done *without* any
> customisations (admin permissions and admin already requires
> authentication), for example.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where do we put our templates?

2009-03-15 Thread Joshua Partogi

Thanks Doug.

I kinda get the gist now. It seems that template is parsed internally
by django so it doesn't matter where I put it, which is quite contrary
to static files like js/css/images.

Kind regards,

On Mar 15, 12:25 am, Dougal Matthews  wrote:
> You can put them where you want but generally they go inside the application
> folder that uses that template.
>
> You may find this an interesting/helpful 
> read;http://www.djangobook.com/en/2.0/chapter04/

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overriding django admin functionality

2009-03-15 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 09:40 +1100, Joshua Partogi wrote:
> Dear all,
> 
> I need a custom authorization needs for the admin system. I need to
> define certain users that is allowed to access certain admin
> functionality. I also need to check whether use has logged in or not.
> In the end I might be creating the admin from scratch.
> 
> Is there any documentation I can read about this admin system so I can
> override it or maybe create a new one from scratch?

The source code is the documentation here. There are lots of docstrings
and comments scattered throughout. django/contrib/admin/sites.py is the
main entry point for registration. A large portion of the heavy lifting
is in django/contrib/admin/options.py (e.g. the ModelAdmin class).

We tend to avoid writing anything much more than that at the moment,
since it would predominantly be repeating the code in English
(duplication) and there are lots of other higher-impact places where we
can be spending our time.

However, instead of thinking you'll have to replace the whole thing,
certainly look at customisations you might be able to make. All of the
things you described in your initial paragraph can be done *without* any
customisations (admin permissions and admin already requires
authentication), for example.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Snap and SCT - any reviews?

2009-03-15 Thread Jacob Kaplan-Moss

On Sun, Mar 15, 2009 at 5:40 PM, John Crawford  wrote:
> Anyone? Anyone? Bueller?

That's rude.

Please don't take the amazing work of the volunteers on this board for
granted. Nobody here is required to update your question, and if you
don't get an answer that's just the way it goes. Further, you posted
your on Friday afternoon; expecting to hear back by Sunday ignores the
fact that many of us like to experience that place called "outdoors"
or at least "away from the keyboard" for the weekend.

Jacob

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Creating KML files for use in Google Maps

2009-03-15 Thread Malcolm Tredinnick

On Fri, 2009-02-27 at 05:06 -0800, phoebebright wrote:
> Took me a long long time to work out why the .kml file I created in
> django would parse as valid in Feedburner but googlemaps said it was
> an invalid kml file.  Need to be sending as correct content-type of
> course.

[...]
> view
> 
> def generateKml(request):
> 
> locations = Location.objects.all().values('name','lat','longt')
> 
> result= render_to_response('locations.kml',{
> 'locations': locations
> })
> 
> return HttpResponse(result,mimetype='Content-Type:application/
> vnd.google-earth.kml+xml')

Coming very late to the party here, but it's good to see this written
up. However, (as Eric Florenzano just pointed out to me) the "mimetype"
parameter doesn't look quite right. You don't need to specify the header
name, since Django puts the contents of the mimetype parameter into the
Content-Type header (and gives it the right name). So I suspect this
might be generating slightly bad HTTP headers. Just removing the
"Content-Type:" prefix from that string would fix it.

Thanks for posting your solution, in any case. It's nice to see this
stuff in use and, you're right that the trick is finding and using the
correct MIME type.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: JSON Model Serialization

2009-03-15 Thread Mateusz Wawrzyniak



On Mar 14, 10:14 pm, MartinBorthiry  wrote:
> Hello:
>
>  I'm Trying to serialize a dict which have a list of Model's instance.
> The format that i need is json. Something  like that:
>
>     people = Person.objects.all()

Why don't you use Person.objects.values()?
You will get a list of dicts so there won't be any problems with
serialization.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Snap and SCT - any reviews?

2009-03-15 Thread John Crawford

Anyone? Anyone? Bueller?

John Crawford wrote:
> Hello, I have been looking for Django-based forum-building software,
> and so far, the two best candidates are Snap and SCT. Does anyone have
> any experience with either, and willing to comment on them? Or are
> there other apps that might be better than those? Thanks.
>
> John C>
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Overriding django admin functionality

2009-03-15 Thread Joshua Partogi

Dear all,

I need a custom authorization needs for the admin system. I need to
define certain users that is allowed to access certain admin
functionality. I also need to check whether use has logged in or not.
In the end I might be creating the admin from scratch.

Is there any documentation I can read about this admin system so I can
override it or maybe create a new one from scratch?

Thank you very much in advance

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow me on twitter: http://twitter.com/jpartogi

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



latitude/longitude field type

2009-03-15 Thread Sergio

Hello,

I'm working on field validation for latitude and longitude. I need to
validate them according to the DMS (degree, minutes, seconds) format.
I was wondering if there is already a django field model extension for
this. I know about geodjango, but that is too much for my needs.

Cheers, Sergio
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin filtering on a foreign key is "an unsorted mess" (not my words)

2009-03-15 Thread Eric

Thanks a lot, Daniel! That did the trick.



On Feb 20, 4:55 am, Daniel Roseman 
wrote:
> On Feb 20, 4:32 am, Eric  wrote:
>
>
>
> > Hi, I have an admin filter that filters all entries that have a
> > particular foreign key. Specifically, this foreign key is a "Code"
> > object that contains a "Code #" and a "Description".
>
> > In the admin filter display, it shows all the codes I can filter by,
> > but they are all out of order, i.e.
>
> > Filter by code:
> >     * All
> >     * 3130
> >     * 3340
> >     * 3410
> >     * 5361
> >     * 3370
> >     * 9760
> >     * 1570
> >     * 1090
>
> > This is proving to be a pain for people to navigate. What I'd like is
> > to have this filter list the codes in increasing order. Any
> > suggestions?
>
> > Thanks much!
>
> Define an 'ordering' value in the Meta class for the model your FK is
> pointing to.http://docs.djangoproject.com/en/dev/ref/models/options/#ordering
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FormSet max_num and extra

2009-03-15 Thread Malcolm Tredinnick

On Sun, 2009-03-15 at 04:25 -0700, Kegan wrote:
> I am dealing with formset, and finding the lack of documentation in
> understanding it. Hope anyone experienced with formset could help.

At some point just opening up the relevant source file is always a good
solution. It's only Python code and not particularly difficult to
understand.

Or experiment. Create a formset and vary the parameters you are
interested in and see how it affects the displayed form.

> 
> What is the reason to have a "max_num" and "extra" argument when
> instantiating a form set (using formset_factory)? Can't you just use
> "max_num" to determine the number of forms in the form set?

The max_num parameter is the number of forms that are populated with
initial data to display. It means you can pass in, say,  a queryset (for
modelformsets) without having to make sure it only contains the right
number of records.

If there are more records in the queryset than max_num, the first
records are used and the latter ones discarded.

The "extra" parameter is the number of blank forms to display (extra
forms with no data populated).
> 
> Also, management_form render "form-TOTAL_FORM", and 'form-
> INITIAL_FORMS', ... how is this correspond to "max_num" or "extra", or
> they don't?

The total form count is the total number of forms and the initial form
count is the number of "initial" forms -- forms populated with initial
data -- in the form set.

Those values' upper-bounds can be computed from max_num and extra (since
initial forms won't be greater than max_num) and, thus, total forms
won't be greater than max_num + extra. But they are only upper bounds.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANN: jaqndjan v0.0.1 A 'Template authoring framework' that integrates django templates with jQuery

2009-03-15 Thread molicule

Correcting a Typo: please note the project name on github is jaqndjan

On Mar 15, 1:33 pm, molicule  wrote:
> Hi,
>
> jaqndjan is A 'Template authoring framework' that integrates django
> templates with jQuery
> available at:  http://github.com/molicule/jaqndjan/tree/master
>
> For now you can use djaqndjan to create drop-in django-Form templates
> that have
> sophisticated client-side validation. (it integrates the jquery-
> validation plugin
> fromhttp://docs.jquery.com/Plugins/Validation)
>
> This is an early revision and without a lot of documentation, testing
> etc. I am putting it
> out there to get  comments, feedback and suggestions as well as to
> figure out if there
> are other similar projects underway etc.
>
> Looking forward to your feedback
> S. Sriram
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ANN: djaqndjan v0.0.1 A 'Template authoring framework' that integrates django templates with jQuery

2009-03-15 Thread molicule

Hi,

djaqndjan is A 'Template authoring framework' that integrates django
templates with jQuery
available at:  http://github.com/molicule/jaqndjan/tree/master

For now you can use djaqndjan to create drop-in django-Form templates
that have
sophisticated client-side validation. (it integrates the jquery-
validation plugin
from http://docs.jquery.com/Plugins/Validation )

This is an early revision and without a lot of documentation, testing
etc. I am putting it
out there to get  comments, feedback and suggestions as well as to
figure out if there
are other similar projects underway etc.

Looking forward to your feedback
S. Sriram

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



FIXED: Can't run django on Apache

2009-03-15 Thread Rex



On Mar 14, 7:52 pm, Rex  wrote:
> On Mar 4, 12:47 pm, John Maines  wrote:
>
>
>
> > Hello:
>
> > I've installed Django 1.0 on Ubuntu and am trying to get it to run on
> >Apache.Apacheis installed, working fine, with mod-python also in
> > place. I'm new at everything Linux.
>
> > But when I try to run my app (a test blog),Apachegives an
> > ImportError message (below) I have come across NUMEROUS references to
> > this error message, and the solution usually seems to involve changing
> > the Python Path. But nothing I try seems to work. I've tried using /
> > user/local for a path, /var/www; the path to my app. Nothing works.
> > Any suggestions?
>
> > MOD_PYTHON ERROR
>
> > ProcessId:      9980
> > Interpreter:    'mysite'
>
> > ServerName:     'ubuntu.ubuntu-domain'
> > DocumentRoot:   '/var/www/'
>
> > URI:            '/mysite'
> > Location:       '/'
> > Directory:      None
> > Filename:       '/var/www/mysite'
> > PathInfo:       ''
>
> > Phase:          'PythonHandler'
> > Handler:        'django.core.handlers.modpython'
>
> > Traceback (most recent call last):
>
> [snip]
> > ImportError: Could not import settings 'settings' (Is it on sys.path?
> > Does it have syntax errors?): No module named settings
>
> I'm having the same issue as the OP. Each time I go to mysite.com/
> myapp,Apacheseems to look for a file called /var/www/myapp, instead
> of launching the Django project I attempt to specify in my 
> directive.
>
> I have a project called "mturk". I want to run it on from mysite.com/
> myapp. Based on the answers to the OP's questions, it seems like I
> should be putting something like this in one of my configuration
> files:
>
> 
>         SetHandler python-program
>         PythonHandler django.core.handlers.modpython
>         SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>         PythonOption django.root /home/rex/django/mturk
>         PythonDebug On
>         PythonPath "['/home/rex/django/mturk'] + sys.path"
> 
>
> Some sources say this snippet should go in /etc/apache2/httpd.conf,
> and some sources say it should go in /etc/apache2/sites-enabled/000-
> default. Which should I go with? Also, I read somewhere that I should
> change my DocumentRoot to the path to the Django project, but wouldn't
> that expose my database and my Python source?
>
> Thanks,
>
> Rex

It turns out the problem was my PythonPath directive -- whereas I had
it set to contain the project directory, /home/rex/django/mturk, I
needed to set it to the parent directory, /home/rex/django. It works
now.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: JSON Model Serialization

2009-03-15 Thread bruno desthuilliers

On 15 mar, 18:39, MartinBorthiry  wrote:
(snip)
> Bruno, Thank you for your reply.
> I tried your snipper, but I had the same error.

Uh ?

How did you try it (please provide relevant code) ? This code is used
in production and AFAICT, it JustWork(tm), so if you happened to find
a bug, I'd really like to fix it ASAP.

TIA
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strip empty lines in rendered templates?

2009-03-15 Thread Tim Chase

> This template code:
> 
> 
> {% for entry in entries %}
> {{ entry.title }}
> {% endfor %}
> 
> 
> looks like this when rendered:
> 
> 
> 
> Title 1
> 
> Title 1
> 
> Title 1
> 
> 

While it goes against my aesthetic tastes for making easy-to-read 
templates (I much prefer my templates look like yours), you _can_ 
use the following:

   {% for entry in entries %}
{{ entry.title }}{% endfor %}
   

which gets you the aesthetic output with minimal fuss.

-tim





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Vanity urls: Eg mysite.com//....

2009-03-15 Thread Alex Gaynor
On Sun, Mar 15, 2009 at 2:31 PM, Dougal Matthews  wrote:

> Hi,
> I've used a similar approach once - works fine. Although, you might want to
> sacrifice such a short url for something that is easier to read/understand
> that 'u' and 'g'.
>
> Cheers,
> Dougal
>
> ---
> Dougal Matthews - @d0ugal
> http://www.dougalmatthews.com/
>
>
>
>
> 2009/3/15 ldm999 
>
>
>> I'm using Django Auth and would like to include username in my urls.
>> So, eg, I might have urls like the following:
>>
>> - mysite.com/tom/books/moby-dick
>> - mysite.com/dick/books/moby-dick
>> - mysite.com/harry/books/catch-22
>>
>> To further complicate things, I'd like to support groups too. So that
>> first url param could be a group name (eg seattle-reading-club)
>>
>> So now I'm thinking of using a letter to designate if the url is for a
>> user or a group. Something like:
>>
>> - mysite.com/u/tom/books/moby-dick
>> - mysite.com/g/seattle-reading-group/moby-dick
>>
>> Anyone else done something like this? Any problems with this approach?
>>
>>
>
> >
>
Most people structure their URLs that way since Django makes it nice to have
these pretty urls.  That being said I'd probably write out the full
user/group just because it makes the urls a little more self explanitory and
it's not like it exposes some internal of your app.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Vanity urls: Eg mysite.com//....

2009-03-15 Thread Dougal Matthews
Hi,
I've used a similar approach once - works fine. Although, you might want to
sacrifice such a short url for something that is easier to read/understand
that 'u' and 'g'.

Cheers,
Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/




2009/3/15 ldm999 

>
> I'm using Django Auth and would like to include username in my urls.
> So, eg, I might have urls like the following:
>
> - mysite.com/tom/books/moby-dick
> - mysite.com/dick/books/moby-dick
> - mysite.com/harry/books/catch-22
>
> To further complicate things, I'd like to support groups too. So that
> first url param could be a group name (eg seattle-reading-club)
>
> So now I'm thinking of using a letter to designate if the url is for a
> user or a group. Something like:
>
> - mysite.com/u/tom/books/moby-dick
> - mysite.com/g/seattle-reading-group/moby-dick
>
> Anyone else done something like this? Any problems with this approach?
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strip empty lines in rendered templates?

2009-03-15 Thread Dougal Matthews
Something like this might be able to help you?

http://www.davidcramer.net/code/369/spaceless-html-in-django.html
Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/




2009/3/15 Benjamin Buch 

>
> Hi,
>
> is there a way to tighten up the output that Django renders?
> Especially, remove the empty lines?
>
> This template code:
>
> 
> {% for entry in entries %}
> {{ entry.title }}
> {% endfor %}
> 
>
> looks like this when rendered:
>
> 
>
> Title 1
>
> Title 1
>
> Title 1
>
> 
>
> I stumbled upon this middleware,
> http://code.djangoproject.com/wiki/StripWhitespaceMiddleware,
> but the discussion around it is somewhat dated,
> and even the author states that there are some problems with it.
> http://code.djangoproject.com/wiki/ContributedMiddleware
>
> Is there any other way to handle it?
>
> benjamin
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Strip empty lines in rendered templates?

2009-03-15 Thread Benjamin Buch

Hi,

is there a way to tighten up the output that Django renders?
Especially, remove the empty lines?

This template code:


{% for entry in entries %}
{{ entry.title }}
{% endfor %}


looks like this when rendered:



Title 1

Title 1

Title 1



I stumbled upon this middleware,
http://code.djangoproject.com/wiki/StripWhitespaceMiddleware,
but the discussion around it is somewhat dated,
and even the author states that there are some problems with it.
http://code.djangoproject.com/wiki/ContributedMiddleware

Is there any other way to handle it?

benjamin

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: JSON Model Serialization

2009-03-15 Thread MartinBorthiry



> >  I'm Trying to serialize a dict which have a list of Model's instance.
> > The format that i need is json. Something  like that:
>
> > people = Person.objects.all()
> > res = {'res':0, 'msg':'Ok','data': people}
>
> >   but, i need that result:
> >   {'res':0, 'msg':'Ok','data': [{'id':1,'name':'Sean'},
> >{'id':1,'name':'Steve'}]}
>
> >  When I tried:
> > simplejson.dump(res)
> >  I had this error:
>
> >   [, ] is not JSON
> > serializable
>
> Indeed. It needs a custom, model aware encoder.
>
> >  When I tried:
> > json_serializer = serializers.get_serializer("json")()
> > json_serializer.serialize(object,
> >  ensure_ascii=False)
> >  I had this error:
> > 'str' object has no attribute '_meta'
>
> Django's json serializer takes a queryset as argument.
>
> > please, help
>
> Had the same problem, my solution is here:
>
> http://www.djangosnippets.org/snippets/1374/

Bruno, Thank you for your reply.
I tried your snipper, but I had the same error.
Finally, I solved it using this:

 def api_serialize(objects):
res = []
for el in objects['data'] :
fields = map( lambda f: f.name, el._meta.fields)
values = dict([ (n, getattr( el,n) if not isinstance(getattr
( el,n), Model) else getattr( el,n).__str__() ) for n in
fields])
res.append(values)
objects['data'] = res
return simplejson.dumps(objects, ensure_ascii=False )

Regards
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File handling when not using POST form but service call (base64)

2009-03-15 Thread coulix

Solved using from djang.core.files.base import ContentFile
Thanks to Guðmundur H

On Mar 15, 3:21 pm, coulix  wrote:
> Hi all,
>
> I am using Pyamf to transfer a dynamically generated large image from
> Flex to Django.
> On the Django side i receive the encodedb64 data as a parameter:
>
> My Item model as an imagefield.
> What i have trouble to do is saving the data as the File Django Field.
>
> def save_item(request, uname, data):
>     """ Save a new item """
>     item = Item()
>
>     img = cStringIO.StringIO()
>     img.write(base64.b64decode(data))
>     myFile = File(img)
>
>    item.preview.save('fakename.jpg', myFile, save=False)
>
> That would not work because my File object from StringIO has no mode,
> name etc.
> I also think that using StringIO will load the image data completely
> in memory so i may just give up on the AMF for this particular case
> and use POST.
>
> What do you think ?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Vanity urls: Eg mysite.com//....

2009-03-15 Thread ldm999

I'm using Django Auth and would like to include username in my urls.
So, eg, I might have urls like the following:

- mysite.com/tom/books/moby-dick
- mysite.com/dick/books/moby-dick
- mysite.com/harry/books/catch-22

To further complicate things, I'd like to support groups too. So that
first url param could be a group name (eg seattle-reading-club)

So now I'm thinking of using a letter to designate if the url is for a
user or a group. Something like:

- mysite.com/u/tom/books/moby-dick
- mysite.com/g/seattle-reading-group/moby-dick

Anyone else done something like this? Any problems with this approach?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best way to trap IntegrityError in Django form?

2009-03-15 Thread ldm616

In the end I just did it in the view. Checked for the duplicate before
saving, and sent an error message back to the form if the dupe test
fails. Looks like this. And downside to this approach?

def add_fablist(request):
#
--
fablists = FabList.objects.filter(user=request.user) # Get
fablists for left column
duplicate = False

if request.method == 'POST':
form = FabListForm(data=request.POST)
if form.is_valid():
fablist = form.save(commit=False)
if not FabList.objects.filter(user=request.user,
name=fablist.name): # Check for dupe user/list name combo
fablist.user = request.user
fablist.slug = defaultfilters.slugify(fablist.name) #
Slugify list name
fablist = form.save()
return HttpResponseRedirect('/')
else:
duplicate = True
else:
form = FabListForm()
return render_to_response('fablist_form.html',
{ 'form': form,
  'fablists': fablists,
  'ADD_FABLIST' : True,
  'DUPLICATE'   : duplicate
}, context_instance=RequestContext
(request))

On Mar 8, 3:15 pm, Adam Jenkins  wrote:
> You can override the clean method on the for and have it raise the
> appropriate error for you. I've done the same thing before and came across
> the issue that the form doesn't know the current user. I ended up adding a
> user parameter to the init and passing it when I instantiated the form. Then
> I made my clean_fieldname() method and checked for the record and raised
> ValidationError if it existed.
>
> You can find the docs 
> athttp://docs.djangoproject.com/en/dev/ref/forms/validation/
>
> On Sun, Mar 8, 2009 at 10:39 AM, ldm999  wrote:
>
> > I have a form tied to a List model where User and Name are
> > unique_together.
>
> > What's the best way to trap the IntegrityError if someone tries to
> > create a new List with a User/Name combo that already exists?
>
> > I know I could allow Django forms to do it if I include User in the
> > form, but obviously I need User to be hidden and defaulted to the
> > current user.
>
> > TIA.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django critter helps us code at the speed of light.

2009-03-15 Thread mrts



On Mar 12, 1:24 pm, Nick  wrote:
> On Mar 11, 6:10 pm, Eric Walstad  wrote:
> > Now you can have your pony AND a Django 
> > Critter:http://starship.python.net/~ewalstad/django_critter.html
>
> Excellent!  I think I prefer the Critter to the Pony...

I takes a brave man to identify himself with the grrly Pony, so thumbs
up to everybody who have that much bravado in themselves :)

I don't, therefore I'm all for the critter and my (styled) take is
here: http://mrts-foo.appspot.com/

(Created with Inkscape, but Illustrator is also able to open SVGs).
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Beginner

2009-03-15 Thread TP

I now get this:

ln: creating symbolic link `python/lib/python2.5/site-packages/django/
bin/django-admin.py': File exists


Has that worked?

On Mar 15, 2:59 pm, Alex Gaynor  wrote:
> On Sun, Mar 15, 2009 at 9:57 AM, TP  wrote:
>
> > Thanks for you help.
>
> > I have tried this but im not sure I am doing it correctly...
>
> > What is the command to symlink the files?
>
> > On Mar 15, 2:53 pm, coulix  wrote:
> > > You have to create a link "ln -s" for /usr/bin/django-admin.py
> > > pointing to /usr/lib/python2.5/site-packages/django/bin/django-
> > > admin.py
> > > Or you can do it the long way "python /usr/lib/python2.5/site-packages/
> > > django/bin/django-admin.py startproject foo"
>
> > > On Mar 15, 3:26 pm, TP  wrote:
>
> > > > I have just started to use Django on a Linux machine and when trying
> > > > to create a new problem I get the following error:
>
> > > > django-admin.py: command not found
>
> > > > Any suggestions ?
>
> ln -s  
>
> Is how you do it under Linux/OS X, under windows you can't symlink and need
> to copy it.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Beginner

2009-03-15 Thread TP

I get the same problem that I got when I tried to do it.

ln: creating symbolic link `scs5tdp/lib/python2.5/site-packages/django/
bin/django-admin.py': No such file or directory


On Mar 15, 2:59 pm, Alex Gaynor  wrote:
> On Sun, Mar 15, 2009 at 9:57 AM, TP  wrote:
>
> > Thanks for you help.
>
> > I have tried this but im not sure I am doing it correctly...
>
> > What is the command to symlink the files?
>
> > On Mar 15, 2:53 pm, coulix  wrote:
> > > You have to create a link "ln -s" for /usr/bin/django-admin.py
> > > pointing to /usr/lib/python2.5/site-packages/django/bin/django-
> > > admin.py
> > > Or you can do it the long way "python /usr/lib/python2.5/site-packages/
> > > django/bin/django-admin.py startproject foo"
>
> > > On Mar 15, 3:26 pm, TP  wrote:
>
> > > > I have just started to use Django on a Linux machine and when trying
> > > > to create a new problem I get the following error:
>
> > > > django-admin.py: command not found
>
> > > > Any suggestions ?
>
> ln -s  
>
> Is how you do it under Linux/OS X, under windows you can't symlink and need
> to copy it.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Beginner

2009-03-15 Thread Alex Gaynor
On Sun, Mar 15, 2009 at 9:57 AM, TP  wrote:

>
> Thanks for you help.
>
> I have tried this but im not sure I am doing it correctly...
>
> What is the command to symlink the files?
>
> On Mar 15, 2:53 pm, coulix  wrote:
> > You have to create a link "ln -s" for /usr/bin/django-admin.py
> > pointing to /usr/lib/python2.5/site-packages/django/bin/django-
> > admin.py
> > Or you can do it the long way "python /usr/lib/python2.5/site-packages/
> > django/bin/django-admin.py startproject foo"
> >
> > On Mar 15, 3:26 pm, TP  wrote:
> >
> > > I have just started to use Django on a Linux machine and when trying
> > > to create a new problem I get the following error:
> >
> > > django-admin.py: command not found
> >
> > > Any suggestions ?
> >
>
ln -s  

Is how you do it under Linux/OS X, under windows you can't symlink and need
to copy it.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Beginner

2009-03-15 Thread TP

Thanks for you help.

I have tried this but im not sure I am doing it correctly...

What is the command to symlink the files?

On Mar 15, 2:53 pm, coulix  wrote:
> You have to create a link "ln -s" for /usr/bin/django-admin.py
> pointing to /usr/lib/python2.5/site-packages/django/bin/django-
> admin.py
> Or you can do it the long way "python /usr/lib/python2.5/site-packages/
> django/bin/django-admin.py startproject foo"
>
> On Mar 15, 3:26 pm, TP  wrote:
>
> > I have just started to use Django on a Linux machine and when trying
> > to create a new problem I get the following error:
>
> > django-admin.py: command not found
>
> > Any suggestions ?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Beginner

2009-03-15 Thread coulix

You have to create a link "ln -s" for /usr/bin/django-admin.py
pointing to /usr/lib/python2.5/site-packages/django/bin/django-
admin.py
Or you can do it the long way "python /usr/lib/python2.5/site-packages/
django/bin/django-admin.py startproject foo"


On Mar 15, 3:26 pm, TP  wrote:
> I have just started to use Django on a Linux machine and when trying
> to create a new problem I get the following error:
>
> django-admin.py: command not found
>
> Any suggestions ?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: fastcgi can not send url to my backend server

2009-03-15 Thread Robert Chen
Yes, that's the reason, thanks very much.

I commented out "check-local" because I thought it came with "socket"
configuration. That's the mistake.

Now it woks. Thanks.

Robert.

On Sun, Mar 15, 2009 at 7:45 PM, Ramiro Morales  wrote:

>
> On Sun, Mar 15, 2009 at 8:50 AM, Robert Chen
>  wrote:
> > Hi, all:
> > I used Lighttpd + fastcgi to deploy my Django project. My lighttpd
> > configuration is as following:
> >
> >
> >   fastcgi.server = (
> >   "/ziyoudu.fcgi" => (
> >
> >   "main" => (
> >   "host" => "127.0.0.1",
> >
> >   "port" => 8080,
> >
> > [..]
> >
> > The configuration is the same as that in www.djangoproject.com. But
> lighttpd
> > return 404 when I access http://www.ziyoudu.com/login/
> > I enabled the debug information then and found it seems that the url is
> > translated to a static file path. The debug infomation is:
>
> That's because you aren't really following the documentation
> example, you are missing the "check-local" => "disable"
> directive.
>
> --
> Ramiro Morales
> http://rmorales.net
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model problem, default not propagating to SQL

2009-03-15 Thread Jacob Kaplan-Moss

On Sat, Mar 14, 2009 at 11:56 PM, kpeters  wrote:
> default (active field) does not seem to propagate - see below
> (Postgres 8.3.6 - current Django as of yesterday)
>
> Any ideas?

This is expected behavior: the `default` argument can be things that
can't properly be represented in a database. Consider::

def tomorrow():
return datetime.date.today() + datetime.timedelta(days=1)

pub_date = models.DateField(default=tomorrow)

This creates a `DateField` that defaults to "tomorrow"; that can't
easily be represented in a database.

Jacob

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Beginner

2009-03-15 Thread TP

I have just started to use Django on a Linux machine and when trying
to create a new problem I get the following error:

django-admin.py: command not found



Any suggestions ?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



File handling when not using POST form but service call (base64)

2009-03-15 Thread coulix

Hi all,

I am using Pyamf to transfer a dynamically generated large image from
Flex to Django.
On the Django side i receive the encodedb64 data as a parameter:

My Item model as an imagefield.
What i have trouble to do is saving the data as the File Django Field.

def save_item(request, uname, data):
""" Save a new item """
item = Item()

img = cStringIO.StringIO()
img.write(base64.b64decode(data))
myFile = File(img)

   item.preview.save('fakename.jpg', myFile, save=False)

That would not work because my File object from StringIO has no mode,
name etc.
I also think that using StringIO will load the image data completely
in memory so i may just give up on the AMF for this particular case
and use POST.

What do you think ?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Lookup across relations

2009-03-15 Thread 3xM

Gees... It messed with my link. I'll try again:
http://blackfin.cannedtuna.org/django-testcase.tar.gz
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Lookup across relations

2009-03-15 Thread 3xM

So, now I had the time to create at clean test case. it can be
downloaded here: 

It contains a few views etc. to show the data in the database (in
sqlite3 format, also included in the .tar.gz).

Now, if I go into django's interactive shell (./manage.py shell) and
try out the above mentioned, using Q objects, I still get no results.
Could anybody please help me out, using my testcase? Am I doing
something wrong?

--

Best regards, Mikkel
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: fastcgi can not send url to my backend server

2009-03-15 Thread Ramiro Morales

On Sun, Mar 15, 2009 at 8:50 AM, Robert Chen
 wrote:
> Hi, all:
> I used Lighttpd + fastcgi to deploy my Django project. My lighttpd
> configuration is as following:
>
>
>   fastcgi.server = (
>   "/ziyoudu.fcgi" => (
>
>   "main" => (
>   "host" => "127.0.0.1",
>
>   "port" => 8080,
>
> [..]
>
> The configuration is the same as that in www.djangoproject.com. But lighttpd
> return 404 when I access http://www.ziyoudu.com/login/
> I enabled the debug information then and found it seems that the url is
> translated to a static file path. The debug infomation is:

That's because you aren't really following the documentation
example, you are missing the "check-local" => "disable"
directive.

-- 
Ramiro Morales
http://rmorales.net

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



FormSet max_num and extra

2009-03-15 Thread Kegan

I am dealing with formset, and finding the lack of documentation in
understanding it. Hope anyone experienced with formset could help.

What is the reason to have a "max_num" and "extra" argument when
instantiating a form set (using formset_factory)? Can't you just use
"max_num" to determine the number of forms in the form set?

Also, management_form render "form-TOTAL_FORM", and 'form-
INITIAL_FORMS', ... how is this correspond to "max_num" or "extra", or
they don't?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



fastcgi can not send url to my backend server

2009-03-15 Thread Robert Chen
Hi, all:
I used Lighttpd + fastcgi to deploy my Django project. My lighttpd
configuration is as following:

server.modules  = (
"mod_rewrite",
"mod_redirect",
"mod_alias",
"mod_access",
"mod_status",
"mod_fastcgi",
"mod_accesslog" )

server.document-root= "/var/www/lighttpd-htdocs/"

server.errorlog = "/var/log/lighttpd/error.log"

index-file.names= ( "index.php", "index.html",
"index.htm", "default.htm" )

accesslog.filename  = "/var/log/lighttpd/access.log"

url.access-deny = ( "~", ".inc" )

$HTTP["url"] =~ "\.pdf$" {
  server.range-requests = "disable"
}

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".py" )

server.username= "work"

server.groupname   = "work"

status.status-url  = "/server-status"
status.config-url  = "/server-config"
status.statistics-url = "/server-statistics"

fastcgi.debug = 1

$HTTP["host"] == "www.ziyoudu.com" {
server.document-root = "/home/work/clubhome/web/clubhome"

fastcgi.server = (
"/ziyoudu.fcgi" => (
"main" => (
"host" => "127.0.0.1",
"port" => 8080,
)
),
)

alias.url = (
"/medias/" => "/home/work/clubhome/web/clubhome/medias/"
)

url.rewrite-once = (
"^(/medias.*)$" => "$1",
"^/favicon\.ico$" => "/medias/favicon.ico",
"^/server-status" => "/server-status",
"^/server-config" => "/server-config",
"^/server-statistics" => "/server-statistics",
"^(/.*)$" => "/ziyoudu.fcgi$1",
)
}

The configuration is the same as that in www.djangoproject.com. But lighttpd
return 404 when I access http://www.ziyoudu.com/login/
I enabled the debug information then and found it seems that the url is
translated to a static file path. The debug infomation is:

2009-03-15 16:08:05: (response.c.221) -- splitting Request-URI
2009-03-15 16:08:05: (response.c.222) Request-URI  :  /login/
2009-03-15 16:08:05: (response.c.223) URI-scheme   :  http
2009-03-15 16:08:05: (response.c.224) URI-authority:  www.ziyoudu.com
2009-03-15 16:08:05: (response.c.225) URI-path :  /login/
2009-03-15 16:08:05: (response.c.226) URI-query:
2009-03-15 16:08:05: (response.c.221) -- splitting Request-URI
2009-03-15 16:08:05: (response.c.222) Request-URI  :  /ziyoudu.fcgi/login/
2009-03-15 16:08:05: (response.c.223) URI-scheme   :  http
2009-03-15 16:08:05: (response.c.224) URI-authority:  www.ziyoudu.com
2009-03-15 16:08:05: (response.c.225) URI-path :  /ziyoudu.fcgi/login/
2009-03-15 16:08:05: (response.c.226) URI-query:
2009-03-15 16:08:05: (response.c.276) -- sanatising URI
2009-03-15 16:08:05: (response.c.277) URI-path :  /ziyoudu.fcgi/login/
2009-03-15 16:08:05: (mod_access.c.135) -- mod_access_uri_handler called
2009-03-15 16:08:05: (response.c.391) -- before doc_root
2009-03-15 16:08:05: (response.c.392) Doc-Root :
/home/work/clubhome/web/clubhome
2009-03-15 16:08:05: (response.c.393) Rel-Path : /ziyoudu.fcgi/login/
2009-03-15 16:08:05: (response.c.394) Path :
2009-03-15 16:08:05: (response.c.442) -- after doc_root
2009-03-15 16:08:05: (response.c.443) Doc-Root :
/home/work/clubhome/web/clubhome
2009-03-15 16:08:05: (response.c.444) Rel-Path : /ziyoudu.fcgi/login/
2009-03-15 16:08:05: (response.c.445) Path :
/home/work/clubhome/web/clubhome/ziyoudu.fcgi/login/
2009-03-15 16:08:05: (response.c.462) -- logical -> physical
2009-03-15 16:08:05: (response.c.463) Doc-Root :
/home/work/clubhome/web/clubhome
2009-03-15 16:08:05: (response.c.464) Rel-Path : /ziyoudu.fcgi/login/
2009-03-15 16:08:05: (response.c.465) Path :
/home/work/clubhome/web/clubhome/ziyoudu.fcgi/login/
2009-03-15 16:08:05: (response.c.482) -- handling physical path
2009-03-15 16:08:05: (response.c.483) Path :
/home/work/clubhome/web/clubhome/ziyoudu.fcgi/login/
2009-03-15 16:08:05: (response.c.539) -- file not found
2009-03-15 16:08:05: (response.c.540) Path :
/home/work/clubhome/web/clubhome/ziyoudu.fcgi/login/

I know I must made a mistake somewhere. But I can not found it out. Any
suggestion?

Thanks very much.

Best Regards
Robert.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en