Re: database sqlite3

2009-01-15 Thread mysticalfirebird

I have this error too,
I wonder:
is a python(sqlite3 installation) problem? or a django 1.02 problem?
my ver is 2.6.1

--~--~-~--~~~---~--~~
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 Serialization / Form Validation error

2009-01-15 Thread Alex

I ran into this same problem but the code snippets you guys gave
weren't working. In case anyone is reading this in the future, here is
what you want:

dict([(k, [unicode(e) for e in v]) for k,v in errors.items()])

The above line will give a dictionary of field names mapping to lists
of errors.

HTH

On Dec 17 2008, 1:42 am, Rodrigue  wrote:
> Hi Russell,
>
> I bumped into the same issue today and was glad I found this post.
> However, I found that I had to use unicode() rather than str(),
> which turns your example into:
>
> content = dict((key, [unicode(v) for v in values]) \
>                                         for key, values in
> form.errors.items())
>
> With str() the proxy returns ' object at 0x83878ac>' (i.e. it only puts the name into quotes)
>
> On Oct 19, 6:14 am, "Russell Keith-Magee" 
> wrote:
>
> > On Sun, Oct 19, 2008 at 12:58 AM, justind  wrote:
>
> > > Hello,
>
> > > No one has any ideas?
>
> > Settle down, Tiger. You asked this question on a Friday night. You may
> > need to wait a little more than 18 hours if you want a response.
> > We're all volunteers here, and many of us have professional and family
> > obligations that take priority over answering questions on a mailing
> > list.
>
> > To answer your question - although it may not be immediately obvious
> > to you _why_ this is occurring, the error message you have received
> > does tell you exactly _what_ is occurring.
>
> > Although form.errors appears to be a dictionary containing strings
> > (i.e., a dictionay of lists of strings appear when you print
> > form.errors), it's actually an ErrorDict that contains ValidationError
> > objects. These, in turn, are manipulated in various ways to ensure
> > correct unicode output - and one of those manipulations is the use of
> > proxy objects (django.utils.functional.__proxy__). If you call str()
> > on a proxy object, it will evaluate and return the underlying string,
> > but the object itself isn't a string.
>
> > SimpleJSON (and the Django copy of the SimpleJSON library) only knows
> > how to serialized basic Python types, so it complains when you give it
> > a proxy object. This use of proxy objects in this way was something
> > introduced by the introduction of full unicode support in Django.
> > Jacob's slide predate the introduction of feature, which explains why
> > the example he gave doesn't work out of the box with a more recent
> > Django version.
>
> > However, If you force the rollout of the proxy objects before calling
> > dumps(), SimpleJSON will correctly encode the form errors. Something
> > like:
>
> > >>> simplejson.dumps(dict((key,str(v) for v in values) for key,values in 
> > >>> form.errors.items())
>
> > should do the trick.
>
> > Yours,
> > Russ Magee %-)
>
> > > The code I'm actually using in my view is almost identical to the
> > > validage_contact view from
> > >http://toys.jacobian.org/presentations/2007/oscon/tutorial/(single
> > > slide:http://toys.jacobian.org/presentations/2007/oscon/tutorial/images/dja...)
> > > and I'm using the JsonResponse function from those slides as well.
>
> > > Has something changed since these were published? Is this a bug?
>
> > > On Oct 17, 4:55 pm, "justin.don...@gmail.com"
> > >  wrote:
> > >> Hello,
>
> > >> I'm having a hard time understanding why Django won't let me serialize
> > >> a dictionary of form errors. Can anyone explain why Django throws an
> > >> error if I try to serialize someform.errors, even if I copy it into a
> > >> plain dictionary?
>
> > >> #!/usr/bin/env python
> > >> from django.utils import simplejson
> > >> from project.main.models import SampleForm
>
> > >> test = {}
> > >> simplejson.dumps(test) # works
>
> > >> test = {'key': [u"value"]}
> > >> simplejson.dumps(test) # works
>
> > >> # suppose SampleForms wants a text and url field
> > >> # I just give it a text field to test
> > >> form = SampleForm({"text": "sample text"})
> > >> d = {} # make a new dictionary
> > >> # update d so we're working with a plain dictionary
> > >> d.update(f.errors)
> > >> type(d) # returns dict
>
> > >> # fails: 
> > >> # isnotJSONserializable
> > >> simplejson.dumps(d)

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



LiveSearch

2009-01-15 Thread Praveen

Hi all, how may i apply LiveSearch as Djago official sites do.

So far i have tried.
I have created full-text index for Listing_channels
l=Listing_channels.objects.filter(list_channel__search='Bowling')
its working but i do not want to search for particular table.

some one suggested me to inherit all the table from base table or
apply search query on each table and combine the result. but this is
really awkward.

is there any other alternative way.
--~--~-~--~~~---~--~~
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: How can I process ajax code post encodeURI string ?

2009-01-15 Thread K*K

Resolved with unquote function in urllib

from urllib import unquote

title = unquote(request.POST.get('title'))

On Jan 15, 10:59 am, "K*K"  wrote:
> Hi, All.
>
> I'm using the Ajaxmethod to post some string after encodeURI function
> processed to the Django server, How can I decodeURI in the server
> side ?
>
> Very simple question, But I'm a newbie of Django for process multi-
> language program.
>
> So thank you very much.
--~--~-~--~~~---~--~~
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: Project Scope Thread

2009-01-15 Thread Jurie-Jan Botha

My apologies for the ambiguity of the question. At least you got my
drift.

Thanks for the advice. It gave me a better understanding of how to go
about the problem.

On Jan 16, 4:02 am, Malcolm Tredinnick 
wrote:
> On Thu, 2009-01-15 at 01:12 -0800, Jurie-Jan Botha wrote:
> > I would like to run a thread for an entire Django project. I would
> > like to house the code that starts this thread up inside an
> > application.
>
> Your terminology choices here are going to lead to confusion. Django has
> "applications" (the things you list in the INSTALLED_APPS setting) and
> "projects" (optional; one or more settings files, a root url conf file
> and some applications).
>
> Saying something runs "inside an application" is not really accurate,
> or, at a minimum, is confusing (if you mean some other definition of
> "application").
>
> So let's rephrase this as you would like a thread to run continuously.
>
> The problem is that Django code (and any code that uses the Django
> library) doesn't really have a concept of running continuously. It is
> fed a request, executes some code, generates a response and then might
> stop running. The lifetime of the code is dependent upon the webserver,
> which will never stop and start a new process for every request, but
> will often stop processes now and again for a variety of good reasons.
> Also, multiple processes or threads of execution will be running at once
> (so that the server can handle multiple requests).
>
>
>
> > Currently I placed the code in the '__init__.py' in the root of my
> > Django application, but when I start the server using 'runserver' is
> > seems to run this code twice. So it creates two threads. Any idea how
> > I can prevent this from happening?
>
> Don't do that (see below). There's no guarantee that things are only
> imported once.
>
> > When I start the project as a daemon it seems the thread doesn't run
> > at all!?
>
> > Also, any tips on doing this kind of thing?
>
> Yes. Don't do that.
>
> > I'm a little worried that
> > I might run into some crazy issues when I place this into production.
>
> You're already hitting crazy issues. Any reason to expect they'll
> disappear when you move into production? :-)
>
> If you want something long running, don't have anything Django related
> attempting to manage the lifecycle. You need a long-running daemon
> process. Possibly you might interact with it in a way such that if it's
> not running already, the first request will start it up. You could do
> this by writing some code that knows how to spawn the daemon process and
> also how to check if it's already running. You always use that code to
> contact the daemon and, before anything is sent to the daemon, it checks
> if it's running and, if not, starts it up.
>
> I would probably use a network socket (or a Unix socket) to communicate
> with the daemon in this case, since the socket will be closed if the
> daemon process terminates, giving you a reasonable way to check if it's
> up and running (if you can't connect to the socket, it's probably not
> running).
>
> 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
-~--~~~~--~~--~--~---



Installing Django on shared host

2009-01-15 Thread Chris

Anyone know how to install Django on a GoDaddy (shared) hosting plan
with SSH access?
--~--~-~--~~~---~--~~
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: Problem using cursor.executemany() in manage function

2009-01-15 Thread Malcolm Tredinnick

On Thu, 2009-01-15 at 20:32 -0800, Davepar wrote:
> This is kind of a corner case, but I need to update many of the
> records in a table on a regular basis. I decided to do this with a
> manage command. (This is Django v1.0, btw.) I used something like the
> following:
> 
> cursor = connection.cursor()
> cursor.executemany("UPDATE rf_wxstation SET cache_time = %s, wx_time =
> %s, afc = %s WHERE location_id = %s", updateValues)

Where were you putting this code? It would be nice to either make this
sort of thing work somewhat automatically, or at least document what's
required.

Right now, there isn't quite enough of a problem description to
understand what might be going wrong.

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



Problem using cursor.executemany() in manage function

2009-01-15 Thread Davepar

This is kind of a corner case, but I need to update many of the
records in a table on a regular basis. I decided to do this with a
manage command. (This is Django v1.0, btw.) I used something like the
following:

cursor = connection.cursor()
cursor.executemany("UPDATE rf_wxstation SET cache_time = %s, wx_time =
%s, afc = %s WHERE location_id = %s", updateValues)

The problem is the update was never showing up in the database. No
errors during execution.

I tried using transaction.commit(), but that raised an error until I
added:

@transaction.commit_manually

in front of the function. Then it all started working. Not sure why I
have to explicitly manually handle commits, but I'm just glad it
started working. Hope that helps somebody else.

Dave

--~--~-~--~~~---~--~~
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: reverse() problems (NoReverseMatch)

2009-01-15 Thread Ian Cullinan

That makes sense now, thank you. Another item for my "things that are weird in 
Python" list.

Cheers,

Ian

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of Malcolm Tredinnick
Sent: Friday, 16 January 2009 1:19 PM
To: django-users@googlegroups.com
Subject: RE: reverse() problems (NoReverseMatch)


On Fri, 2009-01-16 at 14:02 +1100, Ian Cullinan wrote:
> Thanks for the explanation, but I still don't understand why it
> doesn't work with function references.
>
> For one,
> http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse says
> "viewname is either the function name (either a function reference, or
> the string version of the name, if you used that form in
> urlpatterns)",

Hmm .. you're right it does say that. Okay, it didn't just work by
accident, then. But it's still the import name problem and that's a
Python issue, hence probably best to avoid it.

>  and the underlying dict for reverse() uses the function references as
> keys wether you call by string or function reference, right? Do get
> the same callable no matter how you import the function or does this
> not tell the whole story:
>
> >>> import facesearch.views
> >>> from facesearch.views import start_search
> >>> facesearch.views.start_search == start_search
> True
>
> You're probably right that using "name=..." is the best solution, but
> it seems inelegant to me - for the case of one urlpattern per view, a
> reference to that view should be a perfectly unambiguous way to
> specify which urlpattern you want.

Should be... possibly. Simply isn't true, though, in Python. If you
import the same module as "foo.bar" in one place and "bar" in another
place (if your Python path permits that), they will be different
objects. Their "names" will be different as well.

So if you can guarantee that everything is always imported via the same
path, including when Django imports it for URLConf purposes, then you're
fine. That's why function references are legal. But it's not always easy
to guarantee or debug that, hence the unambiguous "name" form existing.

Function references in URLConf patterns pre-date reversing, but are very
useful for error checking (you know immediately that you imported the
wrong thing). For reversing purposes they can be fragile. Life's like
that sometimes.

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: importing data into django model

2009-01-15 Thread Malcolm Tredinnick

On Thu, 2009-01-15 at 19:06 -0800, andrew_dunn wrote:
> I realize this is probably a very simple question, but I've been
> trying to figure it out for days and have had no success.
> 
> I've got a data set with about 11,000 lines (CSV). I've written a
> piece of Python code that parses it and defines each field with a
> variable name. What I'd like to do is get this into the database I'm
> using for my Django app.

Every data import situation is different, but the general pattern works
like this:

(1) Read in the data and convert it to a useful (for some value of
"useful") data structure. Almost always, a dictionary is a good data
structure to use here.

(2) Create a model instance or instances from that data. It might be
that there are related models involved, so more than one model is
required, in which case, step (1) might involve creating more than one
dictionary per input record.

(3) Profit.

The reason I'm suggesting using a dictionary as your data structure is
so that you can make the keys match the model field names and then pass
in the dictionary to the class constructor (using "**kwargs" form of
calling). The code might look like this:

for record in input_iterator():
   data_dict = process_entry(record)
   MyModel.object.create(**data)

Maybe process_entry() returns more than one dictionary if you need to
create more than one instance and maybe you need to save instance 1
before using it as a foreign key in instance 2, but that sort of stuff
is just details.

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



importing data into django model

2009-01-15 Thread andrew_dunn

I realize this is probably a very simple question, but I've been
trying to figure it out for days and have had no success.

I've got a data set with about 11,000 lines (CSV). I've written a
piece of Python code that parses it and defines each field with a
variable name. What I'd like to do is get this into the database I'm
using for my Django app.

How in the world do I do this? I know I don't have to enter them in by
hand...

Thanks in advance,
Andrew Dunn
www.dunnreporter.com

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



RE: reverse() problems (NoReverseMatch)

2009-01-15 Thread Malcolm Tredinnick

On Fri, 2009-01-16 at 14:02 +1100, Ian Cullinan wrote:
> Thanks for the explanation, but I still don't understand why it
> doesn't work with function references.
> 
> For one,
> http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse says
> "viewname is either the function name (either a function reference, or
> the string version of the name, if you used that form in
> urlpatterns)",

Hmm .. you're right it does say that. Okay, it didn't just work by
accident, then. But it's still the import name problem and that's a
Python issue, hence probably best to avoid it.

>  and the underlying dict for reverse() uses the function references as
> keys wether you call by string or function reference, right? Do get
> the same callable no matter how you import the function or does this
> not tell the whole story:
> 
> >>> import facesearch.views
> >>> from facesearch.views import start_search
> >>> facesearch.views.start_search == start_search
> True
> 
> You're probably right that using "name=..." is the best solution, but
> it seems inelegant to me - for the case of one urlpattern per view, a
> reference to that view should be a perfectly unambiguous way to
> specify which urlpattern you want. 

Should be... possibly. Simply isn't true, though, in Python. If you
import the same module as "foo.bar" in one place and "bar" in another
place (if your Python path permits that), they will be different
objects. Their "names" will be different as well.

So if you can guarantee that everything is always imported via the same
path, including when Django imports it for URLConf purposes, then you're
fine. That's why function references are legal. But it's not always easy
to guarantee or debug that, hence the unambiguous "name" form existing.

Function references in URLConf patterns pre-date reversing, but are very
useful for error checking (you know immediately that you imported the
wrong thing). For reversing purposes they can be fragile. Life's like
that sometimes.

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



Django sub-sites and email

2009-01-15 Thread joshuajonah

I'm starting a major project as we speak. It's a site where I can
create sub-sites for my clients in subdomains (e.g:
clientsite.mainproject.com). Just like basecamp/tons of other sites.

Many of these sites will have domains pointed at the subdomains on my
main site (e.g: www.clientsite.com -> clientsite.mainproject.com).

I'm looking for a way to deal with mail hosting without having to
setup a hosting container on my server for every domain. That's kind
of the reason I'm using the subsite system. Is there any way to pull
this off without a separate hosting account? Possibly a mail hosting
service i can point the mx records of the domains at?

I know this isn't really a Django specific question, but since the
system is entirely django, I figured I'd ask here first.

Thanks guys,

Joshua
--~--~-~--~~~---~--~~
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: reverse() problems (NoReverseMatch)

2009-01-15 Thread Ian Cullinan

Thanks for the explanation, but I still don't understand why it doesn't work 
with function references.

For one, http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse says 
"viewname is either the function name (either a function reference, or the 
string version of the name, if you used that form in urlpatterns)", and the 
underlying dict for reverse() uses the function references as keys wether you 
call by string or function reference, right? Do get the same callable no matter 
how you import the function or does this not tell the whole story:

>>> import facesearch.views
>>> from facesearch.views import start_search
>>> facesearch.views.start_search == start_search
True

You're probably right that using "name=..." is the best solution, but it seems 
inelegant to me - for the case of one urlpattern per view, a reference to that 
view should be a perfectly unambiguous way to specify which urlpattern you 
want. Though I'm probably missing some piece of the picture and there's an 
implementation detail that screws this up.

Cheers,

Ian

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of Malcolm Tredinnick
Sent: Friday, 16 January 2009 12:25 PM
To: django-users@googlegroups.com
Subject: RE: reverse() problems (NoReverseMatch)

It does work either way, although function references are a bit more
fragile, since the "name" of the function reference varies a bit
depending upon how it's imported.

However, the real problem was in your first message. You wrote:

>>> from django.core.urlresolvers import reverse

>>> from facesearch.views import start_search

>>> reverse(start_search)

The reverse() function expects a string as its first argument. You're
passing a function object. That line kind of only worked by accident
(well, it didn't work at all, but it looked like it did). Pass in a
string and things will go much better.

Of course, then you're more likely to hit the problem with trying to
match the function name exactly as imported, so it's better to use the
"name=..." version of URL patterns as it's more robust and tends to lead
to cleaner code.

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



question about connection.cursor() and transactions

2009-01-15 Thread bob84123

I have an app that uses a few custom SQL calls through
connection.cursor()
as described in 
http://docs.djangoproject.com/en/dev/topics/db/sql/#topics-db-sql.
However they don't display the same transaction semantics as
specified
in 
http://docs.djangoproject.com/en/dev/topics/db/transactions/#topics-db-transactions.

For example, if I have a view that inserts some data using
connection.cursor(),
then throws an exception, the data inserted remains in the database.

I'm not sure if the behaviour I'm observing is a bug, or if I've just
failed to associate
the cursor with the transaction in some way.  If it's something I've
missed, could someone
advise me on how to do that?

For example (views.py):

from django.http import HttpResponse

def test1(request):
  from django.db import connection
  cur = connection.cursor()
# this data is inserted even though the view does not succeed
  cur.execute("insert into table (column) values ('value');")
  raise "This view should not change the database"
  return HttpResponse("hello")

This happens whether or not I explicitly mark the view with
@transaction.commit_on_success.

I'm using postgresql_psycopg2.

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



Re: I'm moving to Oxford

2009-01-15 Thread Bob Gao
Glad to see you

On Thu, Jan 15, 2009 at 12:16 AM, José Moreira wrote:

>
> dont go, run from the white light!
>
> 2009/1/14 Juan Hernandez :
> > yes, we are going to miss you very much ;)
> >
> > So long london!
> >
> > On Wed, Jan 14, 2009 at 10:10 AM, Marc Boivin 
> wrote:
> >>
> >> Glad you let the whole Django community know ;)
> >>
> >>
> >> On 09-01-14, at 08:52, "Will McGugan"  wrote:
> >>
> >> Hi,
> >>
> >> I'm sending this out to everyone in my gmail contacts, because I'm lazy.
> >> Apologies if you don't need to know this.
> >>
> >> I'm moving to Oxford tomorrow (Thursday 15th). Please get in touch if
> you
> >> need my new address. My landline will change, but you can always get me
> on
> >> my mobile.
> >>
> >> I wont have internet access at home from tomorrow, so apologies if
> emails
> >> go unanswered till I get broadband again!
> >>
> >> So long, London!
> >>
> >> Will
> >>
> >> --
> >> Will McGugan
> >> http://www.willmcgugan.com
> >>
> >>
> >>
> >>
> >
> >
> > >
> >
>
>
>
> --
> José Moreira
>
> >
>

--~--~-~--~~~---~--~~
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: advice in model design - principally

2009-01-15 Thread _Sebastian_

Hi Bruno,

thanks for you search hints, maybe mine (database table layout...) was
not the best choice for what I was looking for.
I will give it a go again with your suggestions.

Thx

seb

On Jan 16, 1:29 am, bruno desthuilliers
 wrote:
> On 15 jan, 13:05, _Sebastian_  wrote:
>
> > Hy all,
>
> > I'm trying to replicate a existing project database as a conceptual
> > test.
>
> > I started off with creating a few models and I thought about ways on
> > how I could link and/or organise them. As I'm just starting to learn
> > django and python and my basic database knowledge is restricted to MS
> > products I want to get some basic things right.
>
> > I'm talking not about the technical bits on how to write modules,
> > fields and stuff I am thinking about how to organise tables, the
> > underlying principles and rules.
>
> This is nothing specific to django (or almost, cf below). Google for
> "relational model" and "relational database design",  and "normal
> form". Once you have a normalized data model, there may be a couple
> Django-specific stuff - mostly, Django doesn't (yet) support compound
> primary keys (so you'll have to use a surrogate key), and some
> contribs (like generic) requires an integer primarry key, so better to
> stick to it even if you do have a natural primary key.
>
> > I head a search and came 
> > acrosshttp://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=...
> > which I am reading now but I was wondering if you know a better site
> > to read about this sort of question?
>
> After a very quick look, it seems that the section about design might
> be a good start.
--~--~-~--~~~---~--~~
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: reverse() problems (NoReverseMatch)

2009-01-15 Thread Malcolm Tredinnick

On Fri, 2009-01-16 at 12:46 +1100, Ian Cullinan wrote:
> Actually, it's not the url() function that makes it work, it's specifying the 
> view function by name.
> 
> urlpatterns = patterns('',
> (r'^FaceSearch/search/$', 'facesearch.views.start_search'),
> )
> 
> works,
> 
> from facesearch.views import start_search
> urlpatterns = patterns('',
> (r'^FaceSearch/search/$', start_search),
> )
> 
> doesn't.
> 
> Why doesn't it work when you pass a function reference for the view?
> When you put a string in patterns, reverse() works by sting or
> function reference.
> 
> http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse seems
> to imply that it should work either way. Is this a bug?

It does work either way, although function references are a bit more
fragile, since the "name" of the function reference varies a bit
depending upon how it's imported.

However, the real problem was in your first message. You wrote:

>>> from django.core.urlresolvers import reverse

>>> from facesearch.views import start_search

>>> reverse(start_search)

The reverse() function expects a string as its first argument. You're
passing a function object. That line kind of only worked by accident
(well, it didn't work at all, but it looked like it did). Pass in a
string and things will go much better.

Of course, then you're more likely to hit the problem with trying to
match the function name exactly as imported, so it's better to use the
"name=..." version of URL patterns as it's more robust and tends to lead
to cleaner code.

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: How do I set no minimum number of entries for a formset?

2009-01-15 Thread Malcolm Tredinnick

On Thu, 2009-01-15 at 11:25 -0800, mw wrote:
> Well I can set blank=True for the fields of the Deadline, but that
> doesn't feel quite correct still as now someone could potentially half
> fill out a deadline and have it validate.

Really? Did you try that. Blank means blank, not half-completed. The
form validation code should understand that there is a difference.

> On Jan 15, 1:15 pm, mw  wrote:
> > Hello,
> >
> > First I have two classes setup, Event and Deadline.  Deadline has a
> > foreign key pointing to an Event so that events can have multiple
> > deadlines attached to them.  Event's form is generated through
> > modelform, while I used
> >
> > modelformset_factory(Deadline, max_num=0, extra=1,exclude=('event'))
> >
> > for the deadlines.  I would like there to be one form so a user could
> > just click submit once, with zero or more deadlines and have it be
> > OK.  Unfortunately, submitting zero deadlines with the Event's fields
> > filled out results in the deadlines being marked as not valid.

What did the error say? That there was some problem with the data you
entered, or that at least one entry was required?

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: ManyToManyField in both models

2009-01-15 Thread Malcolm Tredinnick

On Thu, 2009-01-15 at 10:35 -0800, Evgeniy Ivanov (powerfox) wrote:
> Hi list,
> I want to have ManyToMany fields in both models to make django
> generate forms with multiselect for both models.
> Something like this:
> 
> class User(models.Model):
>groups = models.ManyToManyField('Group', related_name='groups')
> class Group(models.Model):
>users = models.ManyToManyField(User, related_name='users')
> 
> First of all without related_name specified this code doesn't work.
> Secondly it will create 2 link/relation tables which can surprise new
> django users.

It's completely logical. You've specified two separate relations here,
not the same relation from both ends.

[...]
> How can I add m2m to both models without using third model with
> foreign keys (or with it, but without extra ID field)? If to be
> sincere it doesn't make much sense, but everything in Django should be
> perfect :)

You only specify the field on one model and it's available at both ends.
This is a design feature so that you *don't* have to write the same
thing twice. So the answer to your question is to specify the ManyToMany
field on one model.

So the solution to your problem is "don't do that". "Perfect" doesn't
mean you can use whatever syntax you like. In Django, each time you
write ManyToManyField, you are specify a new relation between two
models.

You need to go back and look at your original problem. You wanted forms
with multiselect fields for both forms. So the real question is "how do
you do that". I suspect the answer is that you have to manually
construct one of the forms (which you can write a helper function to do
if you need this in a lot of projects, or, if this only happens for one
model, just write a single form class). The other answer is to rethink
your data entry so that this kind of bi-directional multi-select isn't
necessary. It's not a really common UI pattern and you can probably
think of ways to avoid it.

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: Form Wizard, using reverse to pass data to extra_context

2009-01-15 Thread Malcolm Tredinnick

On Thu, 2009-01-15 at 04:13 -0800, coulix wrote:
> Hi,
> 
> I use a formWizard for a signup process:
> 
> url(r'^signup/student/$', SignupStudentWizard([SignupForm,
> StudentForm]),
> {'extra_context':{"type":"student"}}, name='signup_student',),
> 
> Now, used as it is it works fine.
> However in one case i need to pass extra_context data at run_time, to
> display the signup page and a message related to an invitation.
> 
> I tried the following:
> 
> View
> return HttpResponseRedirect(reverse('signup_student', kwargs=
> { 'extra_context':{'message':'woot',} }))
> 
> It fails:
> NoReverseMatch at /account/invite/qsd/
> 
> Reverse for 'signup_student' with arguments '()' and keyword arguments
> '{'extra_context': {'message': 'woot'}}' not found.

Hopefully this wasn't too surprising. Reverse() is designed to construct
URL patterns. The extra_context isn't part of the URL pattern. Different
values of extra_context do not generate different URL patterns, so
there's no way to tell from the string returned by reverse what the
pattern is.
> 
> How would you approach the problem ?

If the URL string has to depend on a particular argument, that argument
has to be part of the URL pattern. That is, when the argument changes,
so must the URL string that is generated. This is a well-known
limitation of Python: it cannot read your mind.

Alternatively, put the extra data into the user's session. Or put the
extra data into the query string portion of the URL. Reverse doesn't
handle query strings (maybe in the future, but certainly not at the
moment), so you could do this:

from django.utils.http import urlencode

def my_view():
   url = "%s?%s" % (reverse(),
   urlencode({"extra_context": ...}))

In this case, the value you use for extra_context has to be something
that can be expressed in a URL string. In your code fragment, you seem
to be hoping that a Python dictionary can be serialised back and forth.
That's probably optimistic (although you might be lucky and have it
work). If you want to pass around Python objects, definitely use the
session, which can pickle things.

Note, also, that the fragment I've written uses
django.utils.http.urlencode, not urllib.urlencode from Python's standard
library. The difference is that Django version handles non-ASCII strings
correctly.

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: Project Scope Thread

2009-01-15 Thread Malcolm Tredinnick

On Thu, 2009-01-15 at 01:12 -0800, Jurie-Jan Botha wrote:
> I would like to run a thread for an entire Django project. I would
> like to house the code that starts this thread up inside an
> application.

Your terminology choices here are going to lead to confusion. Django has
"applications" (the things you list in the INSTALLED_APPS setting) and
"projects" (optional; one or more settings files, a root url conf file
and some applications).

Saying something runs "inside an application" is not really accurate,
or, at a minimum, is confusing (if you mean some other definition of
"application").

So let's rephrase this as you would like a thread to run continuously.

The problem is that Django code (and any code that uses the Django
library) doesn't really have a concept of running continuously. It is
fed a request, executes some code, generates a response and then might
stop running. The lifetime of the code is dependent upon the webserver,
which will never stop and start a new process for every request, but
will often stop processes now and again for a variety of good reasons.
Also, multiple processes or threads of execution will be running at once
(so that the server can handle multiple requests).

> 
> Currently I placed the code in the '__init__.py' in the root of my
> Django application, but when I start the server using 'runserver' is
> seems to run this code twice. So it creates two threads. Any idea how
> I can prevent this from happening?

Don't do that (see below). There's no guarantee that things are only
imported once.

> When I start the project as a daemon it seems the thread doesn't run
> at all!?
> 
> Also, any tips on doing this kind of thing? 

Yes. Don't do that.

> I'm a little worried that
> I might run into some crazy issues when I place this into production.

You're already hitting crazy issues. Any reason to expect they'll
disappear when you move into production? :-)

If you want something long running, don't have anything Django related
attempting to manage the lifecycle. You need a long-running daemon
process. Possibly you might interact with it in a way such that if it's
not running already, the first request will start it up. You could do
this by writing some code that knows how to spawn the daemon process and
also how to check if it's already running. You always use that code to
contact the daemon and, before anything is sent to the daemon, it checks
if it's running and, if not, starts it up.

I would probably use a network socket (or a Unix socket) to communicate
with the daemon in this case, since the socket will be closed if the
daemon process terminates, giving you a reasonable way to check if it's
up and running (if you can't connect to the socket, it's probably not
running).

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



Any libraries to create an online help system in Django or Python?

2009-01-15 Thread alibongo

I admit I know little to nothing about Django and Python, but I've
been charged with creating an online help system to an application
we're writing in Django. I need to have online help features like
Search, Index, Next|Previous page, etc. So something that is displayed
in a new window, and displays context-sensitive help. Rather than
write this in-house, I was wondering if anyone knew of a Python or
Django library that already delivers this type of functionality? I
can't find one in the searching I've done.

Thanks in anticipation,

Alison

--~--~-~--~~~---~--~~
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: reverse() problems (NoReverseMatch)

2009-01-15 Thread Ian Cullinan

Actually, it's not the url() function that makes it work, it's specifying the 
view function by name.

urlpatterns = patterns('',
(r'^FaceSearch/search/$', 'facesearch.views.start_search'),
)

works,

from facesearch.views import start_search
urlpatterns = patterns('',
(r'^FaceSearch/search/$', start_search),
)

doesn't.

Why doesn't it work when you pass a function reference for the view? When you 
put a string in patterns, reverse() works by sting or function reference.

http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse seems to imply 
that it should work either way. Is this a bug?

Cheers,

Ian Cullinan

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of Ian Cullinan
Sent: Friday, 16 January 2009 10:57 AM
To: django-users@googlegroups.com
Subject: RE: reverse() problems (NoReverseMatch)


Using the url() function in patterns made it work (even without the name), 
thanks!

Now I just have to make it work in my storage manager :)

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of Dj Gilcrease
Sent: Friday, 16 January 2009 10:45 AM
To: django-users@googlegroups.com
Subject: Re: reverse() problems (NoReverseMatch)


try

from django.conf.urls.defaults import *

urlpatterns = patterns('',
  url(r'^FaceSearch/search/$', 'facesearch.views.start_search',
name="face-search'),
)


from django.core.urlresolvers import reverse
reverse('face-search')

Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com

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



powered by django + nginx

2009-01-15 Thread mobil

http://youfindr.com/buzz
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to timestamp with MySQL?

2009-01-15 Thread Marc Barranco

Hi there,

I created a model with a date field in order to have a timestamp of
when has been the last modification of the object.

As in the basic tutorial I wrote my model as:
 data = models.DateTimeField ()

Wich should be in SQL:
 "data" timestamp with time zone NOT NULL

(ref: http://docs.djangoproject.com/en/dev/intro/tutorial01/)

However I get this SQL:

CREATE TABLE `projectes_projecte` (
   ()
`data` datetime NOT NULL,
   (...)

where the field data does never auto update.

I've seen (googling) that in MySQL the synatx is different than
"timestamp" but does anyone knows how could I fix it by writing the
django model?

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



Re: Forcing content_types.json to be loaded before any other fixtures

2009-01-15 Thread AndyH



On Jan 14, 2:53 am, Russell Keith-Magee 
wrote:
> On Wed, Jan 14, 2009 at 9:34 AM, Giovannetti, Mark
>
>  wrote:
>
> > Is there a way to force afixtureto be loaded first
> > when running manage.py test?
>
> > I'd like to load a content_types.jsonfixtureimmediately
> > before any other fixtures are loaded.
>
> > This might fix some of the vexing problems with using
> > content_types and tests.
>
> As far as I can make out, this would fix exactly none of the content
> type problems. The problem with content types is that content types
> are dynamically generated, and as a result they are not produced with
> predictable or consistent key values. As long as you serialize all
> your content types in yourfixture, and you haven't added any new
> content types since producing thefixture, you shouldn't have any
> problems deserializing data.
>
> > Anyone know if this is possible?
>
> No, it isn't possible, and it doesn't really make much sense, either.
> Fixtures are all loaded in a single database transaction, so the order
> in which fixtures are loaded doesn't matter.
>
> The only exception to this is if you're using InnoDB tables under
> MySQL, in which case the problem is MySQL's implementation of
> transactions (specifically, InnoDB doesn't allow deferring of
> referential integrity checks to the end of the transaction boundary as
> it should).
>
> Of course, it's entirely possible you've found an new class of problem
> that I wasn't previously aware of, in which case I'd be interested to
> hear exactly what you've done and howfixtureorder fixes the problem.
>

For me, there are issues with tests and content_type fixtures beyond
just their dynamic creation. I need to put together a decent test case
when I have time, but querying a content type via a GenericForeignKey
on another model produces consistently inconsistent and broken
results.

Andy

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



RE: reverse() problems (NoReverseMatch)

2009-01-15 Thread Ian Cullinan

Using the url() function in patterns made it work (even without the name), 
thanks!

Now I just have to make it work in my storage manager :)

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of Dj Gilcrease
Sent: Friday, 16 January 2009 10:45 AM
To: django-users@googlegroups.com
Subject: Re: reverse() problems (NoReverseMatch)


try

from django.conf.urls.defaults import *

urlpatterns = patterns('',
  url(r'^FaceSearch/search/$', 'facesearch.views.start_search',
name="face-search'),
)


from django.core.urlresolvers import reverse
reverse('face-search')

Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com



On Thu, Jan 15, 2009 at 5:13 PM, Ian Cullinan  wrote:
>
> def start_search(request):
>if request.method == 'POST':
>form = SearchForm(request.POST, request.FILES)
>if form.is_valid():
>s = form.save()
>return render_to_response('index.html', {'search': s,})
>else:
>raise Exception("Invalid form")
>else:
>return HttpResponseRedirect('/FaceSearch/')
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
> Behalf Of Dj Gilcrease
> Sent: Friday, 16 January 2009 10:10 AM
> To: django-users@googlegroups.com
> Subject: Re: reverse() problems (NoReverseMatch)
>
>
> whats your start_search function look like
>
> Dj Gilcrease
> OpenRPG Developer
> ~~http://www.openrpg.com
>
>
>
> On Thu, Jan 15, 2009 at 5:00 PM, Ian Cullinan  
> wrote:
>> I'm trying to use django.core.urlresolvers.reverse in the url method of a
>> custom storage manager, but I keep getting NoReverseMatch and I don't know
>> why so I cut everything back to the simplest case I could think of and I'm
>> still not getting anywhere.
>>
>>
>>
>> My urls.py:
>>
>>
>>
>> from django.conf.urls.defaults import *
>>
>> from facesearch.views import start_search
>>
>> urlpatterns = patterns('',
>>
>>   (r'^FaceSearch/search/$', start_search),
>>
>> )
>>
>>
>>
>> Then in the interactive shell I do:
>>
>>
>>
> from django.core.urlresolvers import reverse
>>
> from facesearch.views import start_search
>>
> reverse(start_search)
>>
>> Traceback (most recent call last):
>>
>>   File "", line 1, in 
>>
>>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
>> 254, in reverse
>>
>> *args, **kwargs)))
>>
>>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
>> 243, in reverse
>>
>> "arguments '%s' not found." % (lookup_view, args, kwargs))
>>
>> NoReverseMatch: Reverse for '' with
>> arguments '()' and keyword arguments '{}' not found.
>>
>> Passing the view function by name doesn't work either.
>>
>>
>>
>> What's going on here? Am I doing something rather stupid?
>>
>>
>>
>> Thanks in advance,
>>
>>
>>
>> Ian Cullinan
>>
>> >
>>
>
>
>
> >
>



--~--~-~--~~~---~--~~
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: form for model - with a few changes

2009-01-15 Thread sico

I suppose I want to know if there is anyway to customize the field
output at runtime to add properties like class, disabled etc...

Would rather not use javascript too .

On Jan 16, 1:53 pm, sico  wrote:
> doh!  its one thing being stupid... its another being stupid in front
> of a big crowd of people!
>
> if my field is readonly... it probably doesn't need a dropdown list
> does it??
>
> would still be nice to set date field text box class to vDateField to
> get nice pop-up thingy!
>
> On Jan 16, 1:38 pm, sico  wrote:
>
> > Hi,
>
> > I've inherited a django app - running on 0.96. So far, the people
> > before me have not created any views, and have just used the built-in
> > admin app to modify everything.
>
> > I want to create a view to control adding/editing records for a
> > specific model.
>
> > #So, I create form from the model like:
>
> > if add == True:
> >     myObj = ""
> >     myForm = form_for_model (MyModel)
> > else:
> >     myObj = MyModel.objects.get(pk=myId)
> >     myForm = form_for_instance(myObj)
>
> > form = myForm()   #  this got me at first!!
>
> > # Then I pass this form object to my template using render_to_response
>
> > return render_to_response('mytemplate.html',
> >        {'myId':myId,
> >         'myForm':form,
> >        },
> >        context_instance=RequestContext(request))
>
> > all good so far...
>
> > then, in my template... I thought about using
>
> > myForm.as_table
>
> > but... I want some fields to be disabled if you're editing the record
> > - still want them displayed, just not editable...
>
> > so I tried to display the fields all separately,
>
> > form.fieldname
>
> > that will let me display all the other fields, but to make my field
> > readonly I tried putting it in directly...  > to pass in the model object as well to get the data, but the big
> > kicker is the field is a lookup to a really big table
>
> > surely I'm trying to do this the hard way!!!
>
> > Is there a way to display a form field and specify it to be read-
> > only ???
>
> > Also, would be nice to be able to add class="vDateField" to my
> > datefields so it has the nice pop-up like the admin form
>
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: form for model - with a few changes

2009-01-15 Thread sico

doh!  its one thing being stupid... its another being stupid in front
of a big crowd of people!

if my field is readonly... it probably doesn't need a dropdown list
does it??

would still be nice to set date field text box class to vDateField to
get nice pop-up thingy!

On Jan 16, 1:38 pm, sico  wrote:
> Hi,
>
> I've inherited a django app - running on 0.96. So far, the people
> before me have not created any views, and have just used the built-in
> admin app to modify everything.
>
> I want to create a view to control adding/editing records for a
> specific model.
>
> #So, I create form from the model like:
>
> if add == True:
>     myObj = ""
>     myForm = form_for_model (MyModel)
> else:
>     myObj = MyModel.objects.get(pk=myId)
>     myForm = form_for_instance(myObj)
>
> form = myForm()   #  this got me at first!!
>
> # Then I pass this form object to my template using render_to_response
>
> return render_to_response('mytemplate.html',
>        {'myId':myId,
>         'myForm':form,
>        },
>        context_instance=RequestContext(request))
>
> all good so far...
>
> then, in my template... I thought about using
>
> myForm.as_table
>
> but... I want some fields to be disabled if you're editing the record
> - still want them displayed, just not editable...
>
> so I tried to display the fields all separately,
>
> form.fieldname
>
> that will let me display all the other fields, but to make my field
> readonly I tried putting it in directly...  to pass in the model object as well to get the data, but the big
> kicker is the field is a lookup to a really big table
>
> surely I'm trying to do this the hard way!!!
>
> Is there a way to display a form field and specify it to be read-
> only ???
>
> Also, would be nice to be able to add class="vDateField" to my
> datefields so it has the nice pop-up like the admin form
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Tutorial Part 4 with mod_python

2009-01-15 Thread JCorey

I've gotten to the fourth part of the tutorial in my Apache/mod_python
setup, and I have run into trouble with the reverse() call in the vote
function.  Like the mod_python guide, I set the Apache Location
directive to /mysite.  django.root is also set to /mysite.  But the
reverse() call only comes out to "/polls/1/results".  So I get a 404
and am stuck.  How can I get the /mysite put back into there, properly
(besides just prefixing the string there)?


--~--~-~--~~~---~--~~
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: reverse() problems (NoReverseMatch)

2009-01-15 Thread Dj Gilcrease

try

from django.conf.urls.defaults import *

urlpatterns = patterns('',
  url(r'^FaceSearch/search/$', 'facesearch.views.start_search',
name="face-search'),
)


from django.core.urlresolvers import reverse
reverse('face-search')

Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com



On Thu, Jan 15, 2009 at 5:13 PM, Ian Cullinan  wrote:
>
> def start_search(request):
>if request.method == 'POST':
>form = SearchForm(request.POST, request.FILES)
>if form.is_valid():
>s = form.save()
>return render_to_response('index.html', {'search': s,})
>else:
>raise Exception("Invalid form")
>else:
>return HttpResponseRedirect('/FaceSearch/')
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
> Behalf Of Dj Gilcrease
> Sent: Friday, 16 January 2009 10:10 AM
> To: django-users@googlegroups.com
> Subject: Re: reverse() problems (NoReverseMatch)
>
>
> whats your start_search function look like
>
> Dj Gilcrease
> OpenRPG Developer
> ~~http://www.openrpg.com
>
>
>
> On Thu, Jan 15, 2009 at 5:00 PM, Ian Cullinan  
> wrote:
>> I'm trying to use django.core.urlresolvers.reverse in the url method of a
>> custom storage manager, but I keep getting NoReverseMatch and I don't know
>> why so I cut everything back to the simplest case I could think of and I'm
>> still not getting anywhere.
>>
>>
>>
>> My urls.py:
>>
>>
>>
>> from django.conf.urls.defaults import *
>>
>> from facesearch.views import start_search
>>
>> urlpatterns = patterns('',
>>
>>   (r'^FaceSearch/search/$', start_search),
>>
>> )
>>
>>
>>
>> Then in the interactive shell I do:
>>
>>
>>
> from django.core.urlresolvers import reverse
>>
> from facesearch.views import start_search
>>
> reverse(start_search)
>>
>> Traceback (most recent call last):
>>
>>   File "", line 1, in 
>>
>>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
>> 254, in reverse
>>
>> *args, **kwargs)))
>>
>>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
>> 243, in reverse
>>
>> "arguments '%s' not found." % (lookup_view, args, kwargs))
>>
>> NoReverseMatch: Reverse for '' with
>> arguments '()' and keyword arguments '{}' not found.
>>
>> Passing the view function by name doesn't work either.
>>
>>
>>
>> What's going on here? Am I doing something rather stupid?
>>
>>
>>
>> Thanks in advance,
>>
>>
>>
>> Ian Cullinan
>>
>> >
>>
>
>
>
> >
>

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



form for model - with a few changes

2009-01-15 Thread sico

Hi,

I've inherited a django app - running on 0.96. So far, the people
before me have not created any views, and have just used the built-in
admin app to modify everything.

I want to create a view to control adding/editing records for a
specific model.

#So, I create form from the model like:

if add == True:
myObj = ""
myForm = form_for_model (MyModel)
else:
myObj = MyModel.objects.get(pk=myId)
myForm = form_for_instance(myObj)

form = myForm()   #  this got me at first!!

# Then I pass this form object to my template using render_to_response

return render_to_response('mytemplate.html',
   {'myId':myId,
'myForm':form,
   },
   context_instance=RequestContext(request))


all good so far...

then, in my template... I thought about using

myForm.as_table

but... I want some fields to be disabled if you're editing the record
- still want them displayed, just not editable...

so I tried to display the fields all separately,

form.fieldname

that will let me display all the other fields, but to make my field
readonly I tried putting it in directly... http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: reverse() problems (NoReverseMatch)

2009-01-15 Thread Ian Cullinan

def start_search(request):
if request.method == 'POST':
form = SearchForm(request.POST, request.FILES)
if form.is_valid():
s = form.save()
return render_to_response('index.html', {'search': s,})
else:
raise Exception("Invalid form")
else:
return HttpResponseRedirect('/FaceSearch/')

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of Dj Gilcrease
Sent: Friday, 16 January 2009 10:10 AM
To: django-users@googlegroups.com
Subject: Re: reverse() problems (NoReverseMatch)


whats your start_search function look like

Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com



On Thu, Jan 15, 2009 at 5:00 PM, Ian Cullinan  wrote:
> I'm trying to use django.core.urlresolvers.reverse in the url method of a
> custom storage manager, but I keep getting NoReverseMatch and I don't know
> why so I cut everything back to the simplest case I could think of and I'm
> still not getting anywhere.
>
>
>
> My urls.py:
>
>
>
> from django.conf.urls.defaults import *
>
> from facesearch.views import start_search
>
> urlpatterns = patterns('',
>
>   (r'^FaceSearch/search/$', start_search),
>
> )
>
>
>
> Then in the interactive shell I do:
>
>
>
 from django.core.urlresolvers import reverse
>
 from facesearch.views import start_search
>
 reverse(start_search)
>
> Traceback (most recent call last):
>
>   File "", line 1, in 
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
> 254, in reverse
>
> *args, **kwargs)))
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
> 243, in reverse
>
> "arguments '%s' not found." % (lookup_view, args, kwargs))
>
> NoReverseMatch: Reverse for '' with
> arguments '()' and keyword arguments '{}' not found.
>
> Passing the view function by name doesn't work either.
>
>
>
> What's going on here? Am I doing something rather stupid?
>
>
>
> Thanks in advance,
>
>
>
> Ian Cullinan
>
> >
>



--~--~-~--~~~---~--~~
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: reverse() problems (NoReverseMatch)

2009-01-15 Thread Dj Gilcrease

whats your start_search function look like

Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com



On Thu, Jan 15, 2009 at 5:00 PM, Ian Cullinan  wrote:
> I'm trying to use django.core.urlresolvers.reverse in the url method of a
> custom storage manager, but I keep getting NoReverseMatch and I don't know
> why so I cut everything back to the simplest case I could think of and I'm
> still not getting anywhere.
>
>
>
> My urls.py:
>
>
>
> from django.conf.urls.defaults import *
>
> from facesearch.views import start_search
>
> urlpatterns = patterns('',
>
>   (r'^FaceSearch/search/$', start_search),
>
> )
>
>
>
> Then in the interactive shell I do:
>
>
>
 from django.core.urlresolvers import reverse
>
 from facesearch.views import start_search
>
 reverse(start_search)
>
> Traceback (most recent call last):
>
>   File "", line 1, in 
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
> 254, in reverse
>
> *args, **kwargs)))
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
> 243, in reverse
>
> "arguments '%s' not found." % (lookup_view, args, kwargs))
>
> NoReverseMatch: Reverse for '' with
> arguments '()' and keyword arguments '{}' not found.
>
> Passing the view function by name doesn't work either.
>
>
>
> What's going on here? Am I doing something rather stupid?
>
>
>
> Thanks in advance,
>
>
>
> Ian Cullinan
>
> >
>

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



reverse() problems (NoReverseMatch)

2009-01-15 Thread Ian Cullinan
I'm trying to use django.core.urlresolvers.reverse in the url method of a 
custom storage manager, but I keep getting NoReverseMatch and I don't know why 
so I cut everything back to the simplest case I could think of and I'm still 
not getting anywhere.

My urls.py:

from django.conf.urls.defaults import *
from facesearch.views import start_search
urlpatterns = patterns('',
  (r'^FaceSearch/search/$', start_search),
)

Then in the interactive shell I do:

>>> from django.core.urlresolvers import reverse
>>> from facesearch.views import start_search
>>> reverse(start_search)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 
254, in reverse
*args, **kwargs)))
  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 
243, in reverse
"arguments '%s' not found." % (lookup_view, args, kwargs))
NoReverseMatch: Reverse for '' with 
arguments '()' and keyword arguments '{}' not found.
Passing the view function by name doesn't work either.

What's going on here? Am I doing something rather stupid?

Thanks in advance,

Ian Cullinan

--~--~-~--~~~---~--~~
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: mod_python 3.3.1, Python 2.4.6, Apache 2.2.9 (MacPorts) on Mac OS X 10.5.6 (Leopard)

2009-01-15 Thread Graham Dumpleton



On Jan 16, 1:40 am, peterandall  wrote:
> Hi Graham,
>
> Thanks for the advice, i used mod_wsgi and it worked a treat, no
> issues what so ever. I followed this guide for setting up django and
> everything works well:
>
> http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi

More detailed information in:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

Graham

> On Jan 14, 11:19 pm, Graham Dumpleton 
> wrote:
>
> > Use mod_wsgi instead, it should set up compiler flags correctly even
> > for fussy MacPorts. I can't remember if I rolled those changes into
> > mod_python in subversion trunk. If still want to try mod_python though
> > use:
>
> >   svn cohttps://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk
> > mod_python-trunk
>
> > and use that version.
>
> > For other MacOSX/MacPort issues, see mod_wsgi documentation at:
>
> >  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
>
> > Some of these also affect mod_python.
>
> > With mod_wsgi, even if picks up correct framework, but wrong lib
> > files, you can override it to some degree using WSGIPythonHome
> > directive.
>
> > Anyway, use mod_wsgi if you can as am at point where can't be bothered
> > helping with mod_python problems anymore. ;-)
>
> > Graham
>
> > On Jan 15, 4:52 am, peterandall  wrote:
>
> > > I've also tried doing this:
>
> > > $  cd /System/Library/Frameworks
> > > $  sudo mv Python.framework XXX_Python.framework
>
> > > $  cd  
> > > $  ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/
> > > opt/local/bin/python2.4 --with-max-locks=32
>
> > > Then editing the src/Makefile and updating the LDFLAGS to this:
>
> > > LDFLAGS= -Wl,-F/opt/local/Library/Frameworks -Wl,-framework,Python  -u
> > > _PyMac_Error $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$
> > > (PYTHONFRAMEWORK)   -L/opt/local/lib
>
> > > Then continuing to make and install mod_python
>
> > > $  make
> > > $  sudo make install
> > > $  cd /System/Library/Frameworks
> > > $  sudo mv XXX_Python.framework Python.framework
>
> > > Still no luck, when i run: 'otool -L /opt/local/apache2/modules/
> > > mod_python.so' i get the following:
>
> > >   /opt/local/apache2/modules/mod_python.so:
> > >         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
> > > version 111.1.3)
> > >         /System/Library/Frameworks/Python.framework/Versions/2.5/Python
> > > (compatibility version 2.5.0, current version 2.5.1)
> > >         /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
> > > version 1.0.0)
>
> > > So its still building against the 2.5 version, this is really starting
> > > to confuse me now, i've run out of things to try.
>
> > > Thanks in advance for any help...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Printing elements to template as they happen

2009-01-15 Thread elspiko

Dude!

Thanks so much for that. I'm humbled by you just taking the time to
think about my problem, never mind writing that much code.

I had a feeling it might have to involve threading, but as I've never
used threading before, I didn't want to drive straight in. But I'll
have a play over the weekend, as I'm busy all of tomorrow.

Many thanks again

Rich
--~--~-~--~~~---~--~~
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: Printing elements to template as they happen

2009-01-15 Thread Dj Gilcrease

On Thu, Jan 15, 2009 at 2:05 PM, elspiko  wrote:
>
> Thanks for your reply Bruno, my plan was to use AJAX anyway, as I
> thought this would be the only method, I should have probably
> mentioned this before, I apologise.
>
> In which case I'm still stuck as to how to return the data. Could I
> maybe have an example of how i could do this?


First you need to setup a view that will return the status of the
backup process, then you setup a timer in your javascript to make
calls to that view every 250ms or so, and terminate when it receives
the done command.

psdo-code: http://dpaste.com/109576/ would produce something like;

/path/to/file1.txt ... Backup complete
/path/to/fil2.txt ... Backup complete
.
.
.
/path/to/filen.txt Backup in progress

--~--~-~--~~~---~--~~
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: get_template & nodelist problem

2009-01-15 Thread Greg

> Or just read the code - that's what I did FWIW !-)

Tried that. In fact I'd actually tried the get_nodes_by_type method
and in hindsight I realise it failed for the reason below, but I
didn't realise that at the time.

> > One other slightly tricky thing that I just figured out - when
> > importing your Node you need to import it from django.templatetags,
> > not myproject.myapp.templatetags.
>
> Mmm ??? Why so ? What happens if you don't ?

It returns an empty list, ie doesn't find any matching nodes.


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



Filtering one form field with value from another...

2009-01-15 Thread mediumgrade

Currently, I have a series of models which look something like this:


class make(model.Models):
name = models.CharField()

class model(model.Models):
name = models.CharField()
make = models.ForeignKey(Make)

class claim(models.Model):
make = models.ForeignKey(Make)
model = models.ForeignKey(Model)

In my model form, I would like to dynamically filter the list of
models by the selected make. What is the best way to accomplish this?
Is there a way to do this in ajax so that the field is updated as the
user selects the make?

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



Re: Printing elements to template as they happen

2009-01-15 Thread elspiko

Thanks for your reply Bruno, my plan was to use AJAX anyway, as I
thought this would be the only method, I should have probably
mentioned this before, I apologise.

In which case I'm still stuck as to how to return the data. Could I
maybe have an example of how i could do this?

Thanks

Rich
--~--~-~--~~~---~--~~
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: How to obtain an intermediate ManyToMany object?

2009-01-15 Thread Adam Yee

Maybe try a all(), filter(stuff) or get(thing)?

lightbox.lightboxphotograph_set.all()

Does that yield anything?

On Jan 15, 10:51 am, JonUK  wrote:
> lightbox.lightboxphotograph_set yields:
>
> TypeError: "'RelatedManager' object is not iterable"
>
> :(
--~--~-~--~~~---~--~~
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: Printing elements to template as they happen

2009-01-15 Thread bruno desthuilliers

On 15 jan, 17:11, elspiko  wrote:
> Hi guys,
>
> I'm just wondering if what I want to achieve is possible. What I'm
> doing is creating a file replication application with a django front
> end, and what I'm having trouble with is posting back the files to the
> webpage when the backup of each file is complete.
>
> What I want to be able to do is display the file name to the webpage,
> as they are being backed up. e.g. pseudo code
>
> for file in file_list:
>  backup_file(file)
>  print file
>
> Now I know i can return the entire list once the files have completed,
> but what I'm after is something similar to below:
>
> /path/to/file1.txt - complete
> /path/to/another/file.psd - complete
> ...
> ...
> ...
> Backing up: /path/to/foo/bar.jpg
>
> If this isn't possible then I'll have to live without this, but I'd
> like to be able to do it if it is.

Two possible solutions:

1/ pass your httpResponse object an iterator that will wrap the
effective code and yields appropriate markup for each file. Note that
this means the page won't be fully loaded until all backups are done.

2/ use Ajax to update your page.
--~--~-~--~~~---~--~~
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: get_template & nodelist problem

2009-01-15 Thread bruno desthuilliers



On 15 jan, 21:41, Greg  wrote:
> Great - thanks. I should have come here earlier!

Or just read the code - that's what I did FWIW !-)

> One other slightly tricky thing that I just figured out - when
> importing your Node you need to import it from django.templatetags,
> not myproject.myapp.templatetags.

Mmm ??? Why so ? What happens if you don't ?


--~--~-~--~~~---~--~~
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: get_template & nodelist problem

2009-01-15 Thread Greg

Great - thanks. I should have come here earlier!

One other slightly tricky thing that I just figured out - when
importing your Node you need to import it from django.templatetags,
not myproject.myapp.templatetags. So the following works:

from django.templatetags.myapp_tags import MyAppNode
from django.template.loader import get_template

t = get_template("editable_pages/test.html")
print t.nodelist.get_nodes_by_type(MyAppNode)

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



Tutorial Admin vs User Polls list view

2009-01-15 Thread moiseyo

I'm through  with tutorial , and now after step 4  I'd like  to a make
a few improvements

When  I assign Pool object to 'ADMIN' view  I could see a very nice
interace, with pages, time line sorting   ADD. EDIT DELETE.

The user's simple  views provided in tutorial  does not do  this
finctionality.

Where I can find a sample  how to use  Generic objects  and  make
full POOLS USER interface  like  ADMIN  interface


Thank you


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



Re: How to obtain an intermediate ManyToMany object?

2009-01-15 Thread Andrew Mckay


On 15-Jan-09, at 10:09 AM, JonUK wrote:
> Thanks, but that gives me:
>
> AttributeError: "'Lightbox' object has no attribute 'lightboxes'"

Doh' sorry, reading it again, you've already got the relationship from  
LightboxPhotograph to Lightbox, so thats

lightbox.lightboxphotograph_set

http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

Discusses going following relationships backwards
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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: How do I set no minimum number of entries for a formset?

2009-01-15 Thread mw

Well I can set blank=True for the fields of the Deadline, but that
doesn't feel quite correct still as now someone could potentially half
fill out a deadline and have it validate.

I'm thinking I'm going to have to just do custom validation.  Is that
correct?

On Jan 15, 1:15 pm, mw  wrote:
> Hello,
>
> First I have two classes setup, Event and Deadline.  Deadline has a
> foreign key pointing to an Event so that events can have multiple
> deadlines attached to them.  Event's form is generated through
> modelform, while I used
>
> modelformset_factory(Deadline, max_num=0, extra=1,exclude=('event'))
>
> for the deadlines.  I would like there to be one form so a user could
> just click submit once, with zero or more deadlines and have it be
> OK.  Unfortunately, submitting zero deadlines with the Event's fields
> filled out results in the deadlines being marked as not valid.
>
> How can I set a sorta minimum number of deadlines, i.e. zero, so that
> if a person doesn't have a deadline they could still submit the event?
>
> Thanks in advance for any help,
> mw
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ManyToManyField in both models

2009-01-15 Thread Evgeniy Ivanov (powerfox)

Hi list,
I want to have ManyToMany fields in both models to make django
generate forms with multiselect for both models.
Something like this:

class User(models.Model):
   groups = models.ManyToManyField('Group', related_name='groups')
class Group(models.Model):
   users = models.ManyToManyField(User, related_name='users')

First of all without related_name specified this code doesn't work.
Secondly it will create 2 link/relation tables which can surprise new
django users. But according the documentation it's normal behavior. If
I specify db_table in both tables it will still generate 2 tables,
which will make syncdb failed:

#class taken from http://www.djangosnippets.org/snippets/962/
class ManyToManyField(models.ManyToManyField):
def __init__(self, *args, **kwargs):
source = kwargs.pop('source_db_column', None)
reverse = kwargs.pop('reverse_db_column', None)
if source is not None:
self._m2m_column_name_cache = source
if reverse is not None:
self._m2m_reverse_name_cache = reverse
super(ManyToManyField, self).__init__(*args, **kwargs)

class User(models.Model):
   groups = ManyToManyField('Group', related_name='groups',
source_db_column='USER_ID',
 
reverse_db_column='GROUP_ID',
 
db_table=u'Users_To_Groups')
class Group(models.Model):
   users = ManyToManyField(User, related_name='users',
source_db_column='GROUP_ID',
 
reverse_db_column='USER_ID',
 
db_table=u'Users_To_Groups')
It will generate 2 identical (only fields order differs) tables
Users_To_Groups. And I guess it will work if I create table manually
(since syncdb doesn't touch already created tables). With my patch
from ticket #10037 it will not have extra id field.

Another variant should work: 
http://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany
I will get everything working, but with extra ID column in the
database.
Extra ID is created for single ManyToManyField too:
http://code.djangoproject.com/ticket/10037
I think it's wrong.

How can I add m2m to both models without using third model with
foreign keys (or with it, but without extra ID field)? If to be
sincere it doesn't make much sense, but everything in Django should be
perfect :)


--~--~-~--~~~---~--~~
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: Coda plugin

2009-01-15 Thread Curt

I haven't tried this yet, but it might be what you're looking for:
http://weblog.bignerdranch.com/?p=49

/curt

On Dec 16 2008, 11:43 am, "bax...@gretschpages.com"
 wrote:
> Have I lost my mind, or did I see a django coda plugin recently? Can't
> seem to find it 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
-~--~~~~--~~--~--~---



How do I set no minimum number of entries for a formset?

2009-01-15 Thread mw

Hello,

First I have two classes setup, Event and Deadline.  Deadline has a
foreign key pointing to an Event so that events can have multiple
deadlines attached to them.  Event's form is generated through
modelform, while I used

modelformset_factory(Deadline, max_num=0, extra=1,exclude=('event'))

for the deadlines.  I would like there to be one form so a user could
just click submit once, with zero or more deadlines and have it be
OK.  Unfortunately, submitting zero deadlines with the Event's fields
filled out results in the deadlines being marked as not valid.

How can I set a sorta minimum number of deadlines, i.e. zero, so that
if a person doesn't have a deadline they could still submit the event?


Thanks in advance for any help,
mw




--~--~-~--~~~---~--~~
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: Combining form fields into a single MultiWidget and getting all field data returned

2009-01-15 Thread SnappyDjangoUser

So I am heading down the path of creating a MultiWidget with a Select
drop down list and a radio field displayed side by side.  But the
problem that I am currently encountering into is that my compress
method in the MultiValueField is not being called.  The odd thing is
that if I change the Select field to something other like a
CheckboxInput field the compress method IS called.

Any ideas what is wrong with the code below and why my compress method
is not being called?


# Asset Number Field
UPDATE_CHILDREN_CHOICES = (
('False', 'Update only this device'),
('True', 'Update all children of this device'))

class AssetNumberWidget(forms.MultiWidget):
def __init__(self, attrs=None):
asset_choices = Asset.objects.values_list('idAsset',
'Asset_Number')
widgets = (forms.Select(attrs=attrs, choices=asset_choices),
   forms.RadioSelect(choices=UPDATE_CHILDREN_CHOICES,
renderer=CustomRadioFieldRenderer, attrs=attrs))
super(AssetNumberWidget, self).__init__(widgets, attrs)

def decompress(self, value):
return [value, 'False']

class AssetNumberField(forms.MultiValueField):
default_error_messages = {
'invalid_asset_number': u'Enter a valid asset number.',
'invalid_update_preference': u'Enter a valid selection to
update only this device or to also update all children devices.',
}

def __init__(self, *args, **kwargs):
fields = (
forms.ChoiceField(label='Asset Number'),
forms.ChoiceField(choices=UPDATE_CHILDREN_CHOICES))
widgets = AssetNumberWidget()

if not 'widget' in kwargs:
kwargs['widget'] = AssetNumberWidget()
if not 'initial' in kwargs:
kwargs['initial'] = 'False'
super(AssetNumberField, self).__init__(fields, *args,
**kwargs)

def compress(self, data_list):
if data_list:
if data_list[0] in EMPTY_VALUES:
raise ValidationError(self.error_messages
['invalid_asset_number'])
if data_list[1] in EMPTY_VALUES:
raise ValidationError(self.error_messages
['invalid_update_preference'])
return data_list
return None

On Jan 13, 4:31 pm, SnappyDjangoUser  wrote:
> Hi All,
>
> Is there a way to "link" 2 form fields or use a create a MultiWidget
> consisting of 2 fields so they are logically displayed together?  I
> have a search form which asks the user for a date range to search and
> I am trying to figure out the best way to display them.  The obvious
> option would be to make two separate form fields, a start_date and
> end_date, but I don't like that option. I would much rather have both
> selects show up on the same line, which is not the behavior you get
> with two separate fields.
>
> I am aware of how to do this with a MultiWidget and a MultiValueField,
> but a MultiValueField requires that you compress the data into a
> single value.  I want to return both values, the start_date and
> end_date of the date range, to the view for searching.
>
> Thanks for your input!
>
> -Brian
--~--~-~--~~~---~--~~
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: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey

Well I experimented with your tips Daniel, and put this in my forms
file:

class SurveyForm(forms.ModelForm):

name = forms.CharField(max_length=50, widget=forms.TextInput(attrs=
{'size':'50'}))

class Meta:
model = Survey

And it works. I assume I just add the ones above that I want to change
the defaults on? Much DRYer - ah

Thank You


On Jan 15, 1:38 pm, Peter Bailey  wrote:
> Thanks for the tips Dan, I thought the DRY thing could not be right.
> Not sure I understand tho - I originally made the form with just the
> inner Meta class definition - do you do that and then override things
> that need to change (e.g. where I want to use a longer TextInput
> widget or whatever.
>
> Things worked fine until I changed to the above form definition so
> that I could make mods to the default output.
>
> re "client = forms.ModelChoiceField(User.objects.all())", that is the
> line I mentioned above that I commented out because I suspected it
> too. I tried your change, still not working
>
> Here is the traceback. Thanks Dan and Andrew, listening while I am
> being so verbose, but I wanted to convey as much info as possible. I
> am learning django and python together, and it gets to be pretty
> boggling sometimes, although it is the most fun developing I have had
> in years. I appreciate you taking your time looking at this.
>
> Environment:
>
> Request Method: GET
> Request URL:http://localhost:8000/surveyadd/
> Django Version: 1.1 pre-alpha SVN-9734
> Python Version: 2.5.1
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'generator.surveys']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.doc.XViewMiddleware')
>
> Traceback:
> File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
> in get_response
>   86.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/Users/peterbailey/pywork/generator/../generator/surveys/
> views.py" in surveyadd
>   137.         form = SurveyForm()
> File "/Library/Python/2.5/site-packages/django/forms/models.py" in
> __init__
>   212.             self.instance = opts.model()
>
> Exception Type: TypeError at /surveyadd/
> Exception Value: 'NoneType' object is not callable
>
> Hope that is all the traceback info you need.
>
> Peter
>
> On Jan 15, 1:16 pm, Daniel Roseman 
> wrote:
>
> > On Jan 15, 5:35 pm, Peter Bailey  wrote:
>
> > > I have just recently started using forms. I was avoiding them because
> > > I thought they were not very DRY, but discovered I need them for added
> > > flexibility such as displaying field lengths for example.
>
> > > Anyway, I have created a Form for a Survey object that I use. If I go
> > > to my edit page for a Survey, everything works perfectly. If I go to
> > > do a simple add new (like right out of the docs), I always receive an
> > > error "NoneType' object is not callable". So I am assuming I am trying
> > > to use something not in existence yet, but it seems bizarre to me (but
> > > I am a form noob and hoping I am doing something stupid (at least 1
> > > thing)). Here is my model
>
> > 
>
> > > I tried commenting out the foreign key to the user but that made no
> > > difference. I must be doing something stupid here (obvious hopefully).
>
> > > Can anyone tell me what the problem is?
>
> > > Thanks,
>
> > > Peter
>
> > Why have you repeated all the definitions from the model in your form?
> > As you say, that isn't very DRY, but there's no reason to do it at
> > all.
>
> > It would have been helpful to have posted the full traceback. I
> > suspect your error is coming from this line:
> >         client = forms.ModelChoiceField(User.objects.all())
> > which should be
> >         client = forms.ModelChoiceField(queryset=User.objects.all())
> > However, as i note above, you don't need the line - or any of the
> > field declarations - at all. You do, however, need an inner Meta class
> > which defines the model the form belongs to (Survey).
>
> > --
> > 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: How to obtain an intermediate ManyToMany object?

2009-01-15 Thread JonUK

lightbox.lightboxphotograph_set yields:

TypeError: "'RelatedManager' object is not iterable"

:(
--~--~-~--~~~---~--~~
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: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey

Thanks Andy


On Jan 15, 1:50 pm, Andy Mckay  wrote:
> I don't think you are defining the ModelForm correctly, the whole  
> point is that Django creates the fields for you. If you look at:
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms
>
> This is the key difference between a ModelForm and a normal form:
>
> http://docs.djangoproject.com/en/dev/topics/forms/#form-objects
>
> You'll see there are no field definitions and there is instead a  
> pointer through class Meta: to the model. The form is trying to create  
> the model and failing. A better form for you would be:
>
> class SurveyForm(forms.ModelForm):
>      class Meta:
>          model = Survey
>
> (add in your import statement so it knows what Survey is).
>
> Cheers
> --
>    Andy McKay
>    ClearWind Consulting:www.clearwind.ca
>    Blog:www.agmweb.ca/blog/andy
--~--~-~--~~~---~--~~
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: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Andy Mckay

I don't think you are defining the ModelForm correctly, the whole  
point is that Django creates the fields for you. If you look at:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms

This is the key difference between a ModelForm and a normal form:

http://docs.djangoproject.com/en/dev/topics/forms/#form-objects

You'll see there are no field definitions and there is instead a  
pointer through class Meta: to the model. The form is trying to create  
the model and failing. A better form for you would be:

class SurveyForm(forms.ModelForm):
 class Meta:
 model = Survey

(add in your import statement so it knows what Survey is).

Cheers
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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: Standard way to treat temporary data which must be validated manually (by an admin)

2009-01-15 Thread garagefan

why not have two TextFields for the app, one for the approved content,
and one for the edited and unapproved content?

Write a function that overwrites the content in the approved TextField
with the item in the unapproved TextField and delete the unapproved
TextField and tie that function to a select box.

On Jan 15, 11:17 am, kaskado  wrote:
> Hi,
> not sure the subject said exactly what I want but I tried ;) I'm not a
> web app/django expert so I hope you'll understand our problem.
>
> Let me first describe our system very quickly :
> -On one side we have customers publishing content (text + images)
> -On the other side, consumers, seeing and using this content
>
> When a customer publishes content, we want to approve it before the
> content goes live to Users
>
> Until there... fine ;)
>
> However, when content has already been published, the customer can
> still modify it. When a customer make a modification, we want to
> approve that before the modification goes live.
>
> I wonder how are we supposed to treat that :
>    - Do we store the edited data separately until it is approved ? (we
> want the customer to see his non-approved edited data in his view,
> while the consumer sees the approved data)
>    - Do we use 2 databases, like one would use 2 branch codes with
> release and development..
>
> Help would be much appreciated.
> Regards,
> Jonathan
--~--~-~--~~~---~--~~
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: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey

Thanks for the tips Dan, I thought the DRY thing could not be right.
Not sure I understand tho - I originally made the form with just the
inner Meta class definition - do you do that and then override things
that need to change (e.g. where I want to use a longer TextInput
widget or whatever.

Things worked fine until I changed to the above form definition so
that I could make mods to the default output.

re "client = forms.ModelChoiceField(User.objects.all())", that is the
line I mentioned above that I commented out because I suspected it
too. I tried your change, still not working

Here is the traceback. Thanks Dan and Andrew, listening while I am
being so verbose, but I wanted to convey as much info as possible. I
am learning django and python together, and it gets to be pretty
boggling sometimes, although it is the most fun developing I have had
in years. I appreciate you taking your time looking at this.

Environment:

Request Method: GET
Request URL: http://localhost:8000/surveyadd/
Django Version: 1.1 pre-alpha SVN-9734
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'generator.surveys']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Users/peterbailey/pywork/generator/../generator/surveys/
views.py" in surveyadd
  137. form = SurveyForm()
File "/Library/Python/2.5/site-packages/django/forms/models.py" in
__init__
  212. self.instance = opts.model()

Exception Type: TypeError at /surveyadd/
Exception Value: 'NoneType' object is not callable


Hope that is all the traceback info you need.

Peter





On Jan 15, 1:16 pm, Daniel Roseman 
wrote:
> On Jan 15, 5:35 pm, Peter Bailey  wrote:
>
> > I have just recently started using forms. I was avoiding them because
> > I thought they were not very DRY, but discovered I need them for added
> > flexibility such as displaying field lengths for example.
>
> > Anyway, I have created a Form for a Survey object that I use. If I go
> > to my edit page for a Survey, everything works perfectly. If I go to
> > do a simple add new (like right out of the docs), I always receive an
> > error "NoneType' object is not callable". So I am assuming I am trying
> > to use something not in existence yet, but it seems bizarre to me (but
> > I am a form noob and hoping I am doing something stupid (at least 1
> > thing)). Here is my model
>
> 
>
> > I tried commenting out the foreign key to the user but that made no
> > difference. I must be doing something stupid here (obvious hopefully).
>
> > Can anyone tell me what the problem is?
>
> > Thanks,
>
> > Peter
>
> Why have you repeated all the definitions from the model in your form?
> As you say, that isn't very DRY, but there's no reason to do it at
> all.
>
> It would have been helpful to have posted the full traceback. I
> suspect your error is coming from this line:
>         client = forms.ModelChoiceField(User.objects.all())
> which should be
>         client = forms.ModelChoiceField(queryset=User.objects.all())
> However, as i note above, you don't need the line - or any of the
> field declarations - at all. You do, however, need an inner Meta class
> which defines the model the form belongs to (Survey).
>
> --
> 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: proper way to use S3Storage and Django ImageField

2009-01-15 Thread Aaron

ping?

On Jan 12, 9:53 am, "Aaron Lee"  wrote:
> Hi all and David,
>
> I followed thehttp://code.larlet.fr/doc/django-s3-storage.html
> installation and created a simple model
>
> class Avatar(models.Model):
>     """
>     Avatar model
>     """
>     image = models.ImageField(upload_to="userprofile")
>     user = models.ForeignKey(User)
>
> By using the upload_to="userprofile" (which is also the example given on the
> django-s3-storage.html)
> the path would be something like userprofile/my.jpg
> which would trigger the file storage backend exception
>
> File "/usr/local/src/djtrunk.latest/django/core/files/storage.py", line 81,
> in path
> raise NotImplementedError("This backend doesn't support absolute paths.")
> where name is userprofile/my.jpg
>
> What's the recommended way of using S3 with ImageField?
>
> -Aaron
--~--~-~--~~~---~--~~
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: Check out a new San Francisco music website I have been working on

2009-01-15 Thread Jason Schell
I like the design. Thanks Alex.

-jason

On Thu, Jan 15, 2009 at 1:08 PM, alex kessinger  wrote:

> Hi,
> I have been working on http://loudfarm.com for a long time. If you are
> looking for a better way to find live music events in the bay area this site
> is it. Any feedback is welcome.
>
>
> Thanks,
> Alex Kessinger
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Daniel Roseman

On Jan 15, 5:35 pm, Peter Bailey  wrote:
> I have just recently started using forms. I was avoiding them because
> I thought they were not very DRY, but discovered I need them for added
> flexibility such as displaying field lengths for example.
>
> Anyway, I have created a Form for a Survey object that I use. If I go
> to my edit page for a Survey, everything works perfectly. If I go to
> do a simple add new (like right out of the docs), I always receive an
> error "NoneType' object is not callable". So I am assuming I am trying
> to use something not in existence yet, but it seems bizarre to me (but
> I am a form noob and hoping I am doing something stupid (at least 1
> thing)). Here is my model



> I tried commenting out the foreign key to the user but that made no
> difference. I must be doing something stupid here (obvious hopefully).
>
> Can anyone tell me what the problem is?
>
> Thanks,
>
> Peter

Why have you repeated all the definitions from the model in your form?
As you say, that isn't very DRY, but there's no reason to do it at
all.

It would have been helpful to have posted the full traceback. I
suspect your error is coming from this line:
client = forms.ModelChoiceField(User.objects.all())
which should be
client = forms.ModelChoiceField(queryset=User.objects.all())
However, as i note above, you don't need the line - or any of the
field declarations - at all. You do, however, need an inner Meta class
which defines the model the form belongs to (Survey).

--
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: How to obtain an intermediate ManyToMany object?

2009-01-15 Thread JonUK

Thanks, but that gives me:

AttributeError: "'Lightbox' object has no attribute 'lightboxes'"

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



Check out a new San Francisco music website I have been working on

2009-01-15 Thread alex kessinger
Hi,
I have been working on http://loudfarm.com for a long time. If you are
looking for a better way to find live music events in the bay area this site
is it. Any feedback is welcome.


Thanks,
Alex Kessinger

--~--~-~--~~~---~--~~
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: Pickling a dictionary into a PostgreSQL database?

2009-01-15 Thread Torsten Bronger

Hallöchen!

teth writes:

> [...]
>
> When I try and load the pickled string from the database it gives me
> the following error:
> KeyError at /article/testing123/up/
> '\x00'

I do the same thing, and I remember that I was forced to write
"pickle.loads(str(database_text))" (note the str()).  However, I
don't remember the exception I was confronted with.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de


--~--~-~--~~~---~--~~
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: How to obtain an intermediate ManyToMany object?

2009-01-15 Thread Andrew Mckay


On 15-Jan-09, at 8:49 AM, JonUK wrote:
> how do iterate the LightboxPhotograph objects for a given instance of
> LightBox?

lightbox.lightboxes

should work

http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

Cheers
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Andrew Mckay


On 15-Jan-09, at 9:35 AM, Peter Bailey wrote:
> Anyway, I have created a Form for a Survey object that I use. If I go
> to my edit page for a Survey, everything works perfectly. If I go to
> do a simple add new (like right out of the docs), I always receive an
> error "NoneType' object is not callable".

That's a lot to read through and not too helpful. What might be more  
useful is the traceback (so we now what the error is) and the code  
where the error occurs (which the traceback tells you), presumably  
your view.
--
   Andy McKay
   www.clearwind.ca

--~--~-~--~~~---~--~~
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: Standard way to treat temporary data which must be validated manually (by an admin)

2009-01-15 Thread bruno desthuilliers

On 15 jan, 17:17, kaskado  wrote:
> Hi,
> not sure the subject said exactly what I want but I tried ;) I'm not a
> web app/django expert so I hope you'll understand our problem.
>
> Let me first describe our system very quickly :
> -On one side we have customers publishing content (text + images)
> -On the other side, consumers, seeing and using this content
>
> When a customer publishes content, we want to approve it before the
> content goes live to Users
>
> Until there... fine ;)
>
> However, when content has already been published, the customer can
> still modify it. When a customer make a modification, we want to
> approve that before the modification goes live.
>
> I wonder how are we supposed to treat that :
>    - Do we store the edited data separately until it is approved ? (we
> want the customer to see his non-approved edited data in his view,
> while the consumer sees the approved data)
>    - Do we use 2 databases, like one would use 2 branch codes with
> release and development..
>
Definitively the first, as far as i'm concerned.
--~--~-~--~~~---~--~~
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: Pickling a dictionary into a PostgreSQL database?

2009-01-15 Thread bruno desthuilliers

On 15 jan, 17:17, teth  wrote:
> Hello, I pickled a dictionary and stored it in my database like this:
> article.rating = article.rating + 1
> ratings[request.user.username] = 1
> article.rating_list = pickle.dumps(ratings)
> article.save()
>
> ratings looks like this:
> {'froob': 1, 'alik': 1, 'teth': 1}
>
> When I try and load the pickled string from the database it gives me
> the following error:
> KeyError at /article/testing123/up/
> '\x00'

Perhaps a bit informations would help. Like, what does the line of
code that raises looks like, and what does the field content looks
like ?

> article/testing123 loads the article testing123 from the database and
> the /up/ is to improve the rating of it. The dictionary is to prevent
> users from rating the same article twice by putting their username as
> an index in a dictionary. What am I doing wrong?

As far as I'm concerned, I'd answer that the obvious problem here is
storing a serialized dict into a db field, instead of properly using a
item/user table. But I guess this is not the answer you expect !-)

> (The pickled string
> is stored in a TEXT field)

Isn't pickle a binary format ?

Sorry, not really helpful, I'm afraid.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey

I have just recently started using forms. I was avoiding them because
I thought they were not very DRY, but discovered I need them for added
flexibility such as displaying field lengths for example.

Anyway, I have created a Form for a Survey object that I use. If I go
to my edit page for a Survey, everything works perfectly. If I go to
do a simple add new (like right out of the docs), I always receive an
error "NoneType' object is not callable". So I am assuming I am trying
to use something not in existence yet, but it seems bizarre to me (but
I am a form noob and hoping I am doing something stupid (at least 1
thing)). Here is my model

class Survey(models.Model):
"""Highest level class that defines the attriutes of a survey"""
STATUS_CHOICES = (
('A', 'Active'),
('C', 'Complete'),
('D', 'Development'),
)

TYPE_CHOICES = (
('A', 'Public'),
('B', 'Private'),
)

STATUS_DBS = (
('A', 'MySQL'),
('B', 'MS SQL'),
)

STATUS_OS = (
('A', 'Linux'),
('B', 'OS X'),
('C', 'Unix'),
('D', 'Windows'),
)

STATUS_LANG = (
('A', 'English'),
)

STATUS_ENC = (
('A', 'Autodetect'),
('B', 'Utf8 (UTF-8 unicode)'),
('C', 'ISO Latin 1 (latin1)'),
)


name = models.CharField(max_length=50)
client = models.ForeignKey(User)
gen_source_path = models.CharField(max_length=100)
gen_dest_path = models.CharField(max_length=100)
url = models.CharField(max_length=100, blank=True)
db_type = models.CharField(max_length=1, choices=STATUS_DBS)
db_name = models.CharField(max_length=50)
table_name = models.CharField(max_length=50)
cookie_name = models.CharField(max_length=50)
header_title1 = models.CharField(max_length=50)
header_title2 = models.CharField(max_length=50)
header_title3 = models.CharField(max_length=50)
footer_title1 = models.CharField(max_length=50)
footer_title2 = models.CharField(max_length=50)
status = models.CharField(max_length=1, choices=STATUS_CHOICES)
survey_type = models.CharField(max_length=1, choices=TYPE_CHOICES)
operating_system = models.CharField(max_length=1, choices=STATUS_OS)
language = models.CharField(max_length=1, choices=STATUS_LANG)
encoding = models.CharField(max_length=1, choices=STATUS_ENC)

def __unicode__(self):
return self.name

def client_name(self):
return str(self.client.user)

class Meta:
ordering = ["name"]

and this is the form:

class SurveyForm(forms.ModelForm):

"""Highest level class that defines the attriutes of a survey"""
STATUS_CHOICES = (
('A', 'Active'),
('C', 'Complete'),
('D', 'Development'),
)

TYPE_CHOICES = (
('A', 'Public'),
('B', 'Private'),
)

STATUS_DBS = (
('A', 'MySQL'),
('B', 'MS SQL'),
)

STATUS_OS = (
('A', 'Linux'),
('B', 'OS X'),
('C', 'Unix'),
('D', 'Windows'),
)

STATUS_LANG = (
('A', 'English'),
)

STATUS_ENC = (
('A', 'Autodetect'),
('B', 'Utf8 (UTF-8 unicode)'),
('C', 'ISO Latin 1 (latin1)'),
)

name = forms.CharField(max_length=50, widget=forms.TextInput(attrs=
{'size':'50'}))
client = forms.ModelChoiceField(User.objects.all())
gen_source_path = forms.CharField(max_length=100,
widget=forms.TextInput(attrs={'size':'50'}))
gen_dest_path = forms.CharField(max_length=100 ,widget=forms.TextInput
(attrs={'size':'50'}))
url = forms.CharField(max_length=100, required=False,
widget=forms.TextInput(attrs={'size':'50'}))
db_type = forms.CharField(max_length=1, widget=forms.Select
(choices=STATUS_DBS))
db_name = forms.CharField(max_length=50 ,widget=forms.TextInput(attrs=
{'size':'50'}))
table_name = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
cookie_name = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
header_title1 = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
header_title2 = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
header_title3 = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
footer_title1 = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
footer_title2 = forms.CharField(max_length=50 

Re: Pickling a dictionary into a PostgreSQL database?

2009-01-15 Thread Dj Gilcrease

I would not use a dict like that, just uses more memory, I would
create a ArticleVote models, something like

http://dpaste.com/hold/109437/

I also show how I would use it in the views


Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com



On Thu, Jan 15, 2009 at 9:17 AM, teth  wrote:
>
> Hello, I pickled a dictionary and stored it in my database like this:
> article.rating = article.rating + 1
> ratings[request.user.username] = 1
> article.rating_list = pickle.dumps(ratings)
> article.save()
>
> ratings looks like this:
> {'froob': 1, 'alik': 1, 'teth': 1}
>
> When I try and load the pickled string from the database it gives me
> the following error:
> KeyError at /article/testing123/up/
> '\x00'
>
> article/testing123 loads the article testing123 from the database and
> the /up/ is to improve the rating of it. The dictionary is to prevent
> users from rating the same article twice by putting their username as
> an index in a dictionary. What am I doing wrong? (The pickled string
> is stored in a TEXT field)
>
> >
>

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



How to obtain an intermediate ManyToMany object?

2009-01-15 Thread JonUK

I have this model (bits omitted for brevity):

class Photograph(ImageModel):
title = models.CharField(_('title'), max_length=100, unique=True )

class Lightbox(models.Model):
photographs = models.ManyToManyField('Photograph',
related_name='lightboxes',
through =
'LightboxPhotograph',
symmetrical=False,
verbose_name=_('photographs'),
null=True, blank=True)

class LightboxPhotograph(models.Model):
lightbox = models.ForeignKey( Lightbox )
photograph = models.ForeignKey( Photograph )
order = models.IntegerField( unique=False )

how do iterate the LightboxPhotograph objects for a given instance of
LightBox?

e.g.

for x in lightbox.iterable_LightboxPhotograph_objects

such that: type(x) == LightboxPhotograph

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



Standard way to treat temporary data which must be validated manually (by an admin)

2009-01-15 Thread kaskado

Hi,
not sure the subject said exactly what I want but I tried ;) I'm not a
web app/django expert so I hope you'll understand our problem.

Let me first describe our system very quickly :
-On one side we have customers publishing content (text + images)
-On the other side, consumers, seeing and using this content

When a customer publishes content, we want to approve it before the
content goes live to Users

Until there... fine ;)

However, when content has already been published, the customer can
still modify it. When a customer make a modification, we want to
approve that before the modification goes live.

I wonder how are we supposed to treat that :
   - Do we store the edited data separately until it is approved ? (we
want the customer to see his non-approved edited data in his view,
while the consumer sees the approved data)
   - Do we use 2 databases, like one would use 2 branch codes with
release and development..

Help would be much appreciated.
Regards,
Jonathan

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



Pickling a dictionary into a PostgreSQL database?

2009-01-15 Thread teth

Hello, I pickled a dictionary and stored it in my database like this:
article.rating = article.rating + 1
ratings[request.user.username] = 1
article.rating_list = pickle.dumps(ratings)
article.save()

ratings looks like this:
{'froob': 1, 'alik': 1, 'teth': 1}

When I try and load the pickled string from the database it gives me
the following error:
KeyError at /article/testing123/up/
'\x00'

article/testing123 loads the article testing123 from the database and
the /up/ is to improve the rating of it. The dictionary is to prevent
users from rating the same article twice by putting their username as
an index in a dictionary. What am I doing wrong? (The pickled string
is stored in a TEXT field)

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

2009-01-15 Thread Scott Moonen
Sanrio, this is a known problem.  See open ticket
http://code.djangoproject.com/ticket/4926

  -- Scott

On Thu, Jan 15, 2009 at 11:21 AM,  wrote:

>
> Hi,
>
> I just found out that you can only use one ordering key in the
> ordering. Is this true? If so, what can I do to have ordering on 2
> keys
> instead? (short of overriding the admin, and writing my own custom
> class)
>
> Thanks,
>
> sanrio
>
>
> >
>


-- 
http://scott.andstuff.org/  |  http://truthadorned.org/

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



Admin Ordering

2009-01-15 Thread sanrioyt

Hi,

I just found out that you can only use one ordering key in the
ordering. Is this true? If so, what can I do to have ordering on 2
keys
instead? (short of overriding the admin, and writing my own custom
class)

Thanks,

sanrio


--~--~-~--~~~---~--~~
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: Need URL help

2009-01-15 Thread May

Hello Wai,

Thank you so much for your help.  You are right the view had to be
rewritten.  My problem, however is still at the template.  For some
reason the template code and the URL code aren't coming together
producing the
error message:
commodity() takes exactly 2 arguments (1 given)

Thanks again!

May

On Jan 13, 1:11 pm, Wai Yi Leung  wrote:
> You should rewite the method:
>
> def commodity(request, commodity_id):
>     p = get_object_or_404(Commodity, pk=commodity_id)
>     return render_to_response('fsafety/commodity_detail.html',
> {'commodity': p})
>
> to
>
> def commodity(request):
>     commodity_id = request.POST['commodity'] # this variable comes from
> the form (select value)
>     p = get_object_or_404(Commodity, pk=commodity_id)
>     return render_to_response('fsafety/commodity_detail.html',
> {'commodity': p})
>
> Best regards,
>
> Wai Yi
>
> May schreef:
>
> > Hello All,
>
> > Thank you for the suggestions.  I am getting closer to figuring it
> > out.  Now my error is this:
>
> > commodity() takes exactly 2 arguments (1 given)
>
> > My URL is:
> >     (r'^commodity/$', 'commodity'),
>
> > The Form statement:
> > 
>
> > Thank you!
>
> > May
>
> > On Jan 13, 10:56 am, Wai Yi Leung  wrote:
>
> >> Hi May,
>
> >> Try to debug in shell, this will give you more information.
> >> Lets print the 'p' value after having it set with get_object_or_404 ...
>
> >> And I think you are a bit messing with which method to call. You are
> >> generating the page with the form that contains errors. So lets check
> >> your index() method also.
> >> This method doesn't assign commodity to any variable in the response.
>
> >> Good luck in bughunting.
>
> >> Wai Yi
>
> >> May schreef:
>
> >>> Hello,
>
> >>> I tried the URL and still received this error:
> >>> Page not found (404)
> >>> Request Method:    POST
> >>> Request URL:      http://127.0.0.1:8000/fsafety//commodity_detail/
>
> >>> I think now that the ID is not getting passed to this line:
> >>> 
>
> >>> Thank you for any help you can give.
>
> >>> May
>
> >>> On Jan 13, 10:25 am, Santiago  wrote:
>
>  replace in your url.py:
>
>  (r'^(?P\d+)$/commodity_detail/', 'commodity'),
>
>  by
>
>  (r'^(?P\d+)/commodity_detail/$', 'commodity'),
>
>  this _should_ work
>
>  2009/1/14 May :
>
> > My error is not being able to get the ID passed to the next
> > template.
>
> > The code:
>
> >http://dpaste.com/108580/
>
> > Thank you,
>
> > May
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Printing elements to template as they happen

2009-01-15 Thread elspiko

Hi guys,

I'm just wondering if what I want to achieve is possible. What I'm
doing is creating a file replication application with a django front
end, and what I'm having trouble with is posting back the files to the
webpage when the backup of each file is complete.

What I want to be able to do is display the file name to the webpage,
as they are being backed up. e.g. pseudo code

for file in file_list:
 backup_file(file)
 print file

Now I know i can return the entire list once the files have completed,
but what I'm after is something similar to below:

/path/to/file1.txt - complete
/path/to/another/file.psd - complete
...
...
...
Backing up: /path/to/foo/bar.jpg

If this isn't possible then I'll have to live without this, but I'd
like to be able to do it if it is.


Thanks


Rih
--~--~-~--~~~---~--~~
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 manager natural sort order

2009-01-15 Thread Delta20

Natural sort order is a pretty common requirement - Windows Explorer
and the Mac Finder are both examples of natural sort in action. It's
true there are lots of edge cases, but just handling letters and
digits in a human-reabable way is enough in many cases.

It seems the solution is to add a non-editable sort field to the model
that is a transformed version of the field you wish to sort by, and
use order_by on the sort field.

PS: My apologies for the confusing initial post -- I was editing my
post in a hurry and it got a little messed up.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Question about transaction middleware

2009-01-15 Thread Sebastian Bauer

Hi, i have one simple question, why this middleware leave transaction in 
managed mode? i think this create a little hole to execute queries we 
dont want to execute.

Thanks for answer

--~--~-~--~~~---~--~~
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: mod_python 3.3.1, Python 2.4.6, Apache 2.2.9 (MacPorts) on Mac OS X 10.5.6 (Leopard)

2009-01-15 Thread peterandall

Hi Graham,

Thanks for the advice, i used mod_wsgi and it worked a treat, no
issues what so ever. I followed this guide for setting up django and
everything works well:

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

Thanks again, i've read loads of your posts and you really help a
lot :)

Pete.

On Jan 14, 11:19 pm, Graham Dumpleton 
wrote:
> Use mod_wsgi instead, it should set up compiler flags correctly even
> for fussy MacPorts. I can't remember if I rolled those changes into
> mod_python in subversion trunk. If still want to try mod_python though
> use:
>
>   svn cohttps://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk
> mod_python-trunk
>
> and use that version.
>
> For other MacOSX/MacPort issues, see mod_wsgi documentation at:
>
>  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
>
> Some of these also affect mod_python.
>
> With mod_wsgi, even if picks up correct framework, but wrong lib
> files, you can override it to some degree using WSGIPythonHome
> directive.
>
> Anyway, use mod_wsgi if you can as am at point where can't be bothered
> helping with mod_python problems anymore. ;-)
>
> Graham
>
> On Jan 15, 4:52 am, peterandall  wrote:
>
>
>
> > I've also tried doing this:
>
> > $  cd /System/Library/Frameworks
> > $  sudo mv Python.framework XXX_Python.framework
>
> > $  cd  
> > $  ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/
> > opt/local/bin/python2.4 --with-max-locks=32
>
> > Then editing the src/Makefile and updating the LDFLAGS to this:
>
> > LDFLAGS= -Wl,-F/opt/local/Library/Frameworks -Wl,-framework,Python  -u
> > _PyMac_Error $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$
> > (PYTHONFRAMEWORK)   -L/opt/local/lib
>
> > Then continuing to make and install mod_python
>
> > $  make
> > $  sudo make install
> > $  cd /System/Library/Frameworks
> > $  sudo mv XXX_Python.framework Python.framework
>
> > Still no luck, when i run: 'otool -L /opt/local/apache2/modules/
> > mod_python.so' i get the following:
>
> >   /opt/local/apache2/modules/mod_python.so:
> >         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
> > version 111.1.3)
> >         /System/Library/Frameworks/Python.framework/Versions/2.5/Python
> > (compatibility version 2.5.0, current version 2.5.1)
> >         /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
> > version 1.0.0)
>
> > So its still building against the 2.5 version, this is really starting
> > to confuse me now, i've run out of things to try.
>
> > Thanks in advance for any help...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: advice in model design - principally

2009-01-15 Thread bruno desthuilliers

On 15 jan, 13:05, _Sebastian_  wrote:
> Hy all,
>
> I'm trying to replicate a existing project database as a conceptual
> test.
>
> I started off with creating a few models and I thought about ways on
> how I could link and/or organise them. As I'm just starting to learn
> django and python and my basic database knowledge is restricted to MS
> products I want to get some basic things right.
>
> I'm talking not about the technical bits on how to write modules,
> fields and stuff I am thinking about how to organise tables, the
> underlying principles and rules.

This is nothing specific to django (or almost, cf below). Google for
"relational model" and "relational database design",  and "normal
form". Once you have a normalized data model, there may be a couple
Django-specific stuff - mostly, Django doesn't (yet) support compound
primary keys (so you'll have to use a surrogate key), and some
contribs (like generic) requires an integer primarry key, so better to
stick to it even if you do have a natural primary key.

> I head a search and came across 
> http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=...
> which I am reading now but I was wondering if you know a better site
> to read about this sort of question?

After a very quick look, it seems that the section about design might
be a good start.


--~--~-~--~~~---~--~~
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: how to get a model's field var the field's name in a string?

2009-01-15 Thread bruno desthuilliers

On 15 jan, 09:11, fallhunter  wrote:
> i mean
> i have a model m, and m has a field fd.
> so i can wrote like
>    xx = m.fd
>    m.fd = xxx

I assume you mean "I have a model *instance* m".

> but, when i got a string  s = "fd"
>
> how could i do the same as above?

As usual in Python: use getattr(obj, name) and setattr(obj, name,
value).

> i've tried m.__dict__[s], but it seems read only

Are you sure m is a model instance  here ?


--~--~-~--~~~---~--~~
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: get_template & nodelist problem

2009-01-15 Thread bruno desthuilliers

On 15 jan, 12:02, Greg  wrote:
> I'm building a CMS system in django, and in the admin I need to be
> able to inspect a template to see what nodes it contains.
> (specifically, I'm searching for a custom template tag related to the
> CMS)

> Using
>
> from django.template.loader import get_template
> t = get_template("test.html")
> print t.nodelist
>
> gives me a list of TextNodes etc

IIRC, this is only a list of top-level nodes - nested ones won't
appear in it.

> as expected for basic templates, but
> when I try it on a template that extends another template, all I get
> is the ExtendsNode in my list, ie
>
> []
>
> I'm assuming this is a feature, not a bug, and is due to lazy loading
> or something along those lines — my question is how do I work out what
> nodes the final rendered template will have?

The base Node and NodeList classes both have a get_nodes_by_type
method that
"Return a list of all nodes (within this node and its nodelist) of the
given type".

This method is recursive, which solves the problem mentioned above.
IOW, whether or not a template extends another one, you want :

t = get_template("test.html")
print t.nodelist.get_nodes_by_type(YourNodeTypeHere)


HTH
--~--~-~--~~~---~--~~
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: advice in model design - principally

2009-01-15 Thread Kenneth Gonsalves

On Thursday 15 Jan 2009 6:04:13 pm _Sebastian_ wrote:
> Could you elaborate on what you mean with 'then break them a bit for
> speed'?

well, 3 normal forms is the ideal - but we live in a real world. So after 
normalising the database, it is often found that repeating a field, or adding 
a field that can be calculated from existing fields in a table speeds up 
things enormously without significantly compromising database integrity. So 
we do it. It may not be necessary in a smaller database, but may be needed in 
a bigger one. 

-- 
regards
KG
http://lawgon.livejournal.com

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



Re: advice in model design - principally

2009-01-15 Thread _Sebastian_

Kenneth,

thank you for your reply.

Could you elaborate on what you mean with 'then break them a bit for
speed'?

 - seb

On Jan 15, 11:22 pm, Kenneth Gonsalves  wrote:
> On Thursday 15 Jan 2009 5:35:56 pm _Sebastian_ wrote:
>
> > I head a search and came across
> >http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=...
> >bm.ddi.doc/ddi27.htm
>
> basically you would need to read up on the first three normal forms, try to
> implement them and then break them a bit for speed if needed. Any site that
> describes the normal forms is ok for that - this one seems ok.
>
> --
> regards
> KGhttp://lawgon.livejournal.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: advice in model design - principally

2009-01-15 Thread Kenneth Gonsalves

On Thursday 15 Jan 2009 5:35:56 pm _Sebastian_ wrote:
> I head a search and came across
> http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.i
>bm.ddi.doc/ddi27.htm

basically you would need to read up on the first three normal forms, try to 
implement them and then break them a bit for speed if needed. Any site that 
describes the normal forms is ok for that - this one seems ok.

-- 
regards
KG
http://lawgon.livejournal.com

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



Form Wizard, using reverse to pass data to extra_context

2009-01-15 Thread coulix

Hi,

I use a formWizard for a signup process:

url(r'^signup/student/$', SignupStudentWizard([SignupForm,
StudentForm]),
{'extra_context':{"type":"student"}}, name='signup_student',),

Now, used as it is it works fine.
However in one case i need to pass extra_context data at run_time, to
display the signup page and a message related to an invitation.

I tried the following:

View
return HttpResponseRedirect(reverse('signup_student', kwargs=
{ 'extra_context':{'message':'woot',} }))

It fails:
NoReverseMatch at /account/invite/qsd/

Reverse for 'signup_student' with arguments '()' and keyword arguments
'{'extra_context': {'message': 'woot'}}' not found.

How would you approach the problem ?

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



advice in model design - principally

2009-01-15 Thread _Sebastian_

Hy all,

I'm trying to replicate a existing project database as a conceptual
test.

I started off with creating a few models and I thought about ways on
how I could link and/or organise them. As I'm just starting to learn
django and python and my basic database knowledge is restricted to MS
products I want to get some basic things right.

I'm talking not about the technical bits on how to write modules,
fields and stuff I am thinking about how to organise tables, the
underlying principles and rules.

Is it better to have more tables with fewer rows and link them. Or
habe one large table...

For the purpose of my test the project db will consist of many
datasets for one project each. I would say that 90% of the Columns/
fields could be linked to a project number.
Would that mean they should all be in one table, 100 or more columns?
If not how should I organise them and link the separate tables?
How do I decide what should go into a extra table?
I know that it makes sense to have inn each project reoccurring
selections as a linked table, but what else is there to know?

I head a search and came across
http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.ddi.doc/ddi27.htm
which I am reading now but I was wondering if you know a better site
to read about this sort of question?

Thanks in advance.

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



Aggregates come to Django

2009-01-15 Thread Russell Keith-Magee

Hi all,

For those watching trunk, revision 9742 added aggregate support to
Django. (Yay!)

The short version is that Querysets now have two additional operations
- annotate() and aggregate(). For details on how to use these new
operations, see the documentation:

http://docs.djangoproject.com/en/dev/topics/db/aggregation/

As prior warning - there is one known problem which we are still
tracking down. On Windows, using SQLite and Python 2.5, date and
decimal values can get corrupted. This doesn't affect other versions
of Python (2.4 or 2.6) on Windows, or Python 2.5 on Linux/Mac. I hope
to get these problems cleared up very soon. If you are affected,
either don't update your SVN checkout, or use a different version of
Python (multiple Python versions co-exist fairly easily under
Windows).

I've opened ticket #10031 to track this known problem. If you find any
other issues with aggregates, please open a ticket (or ask on the
mailing list/IRC if you're unsure if the problem is usage or bug).

Lastly - some thank-yous. This commit wouldn't have been possible
without the assistance of many other people.

Nicolas Lara did some excellent work turning a specification into a
working implementation as part of the 2008 Google Summer of Code.
Nicolas - take a bow - you did some excellent work here.

Alex Gaynor provided some excellent assistance debugging and fixing a
number of problems as we neared completion of the project. Thanks
Alex.

Justin Bronn used his GIS-fu to get aggregates working with
contrib.gis. Thanks Justin.

Karen Tracey used her massive personal server farm to provide
cross-platform testing. Thanks Karen.

Ian Kelly helped out testing and fixing aggregates on Oracle. Thanks Ian.

Malcolm Tredinnick did his usual stunning job at reviewing code and
picking holes in designs. Thanks Malcolm.

Thanks also to the many people that contributed ideas during the
design phase, and to those who tested the code as it was developing.
Your efforts may not have ended up in the final design or turned into
a bug report, but thanks for taking the time to look at an
experimental feature.

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



Project Scope Thread

2009-01-15 Thread Jurie-Jan Botha

I would like to run a thread for an entire Django project. I would
like to house the code that starts this thread up inside an
application.

Currently I placed the code in the '__init__.py' in the root of my
Django application, but when I start the server using 'runserver' is
seems to run this code twice. So it creates two threads. Any idea how
I can prevent this from happening?

When I start the project as a daemon it seems the thread doesn't run
at all!?

Also, any tips on doing this kind of thing? I'm a little worried that
I might run into some crazy issues when I place this into production.

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



get_template & nodelist problem

2009-01-15 Thread Greg

I'm building a CMS system in django, and in the admin I need to be
able to inspect a template to see what nodes it contains.
(specifically, I'm searching for a custom template tag related to the
CMS)

Using

from django.template.loader import get_template
t = get_template("test.html")
print t.nodelist

gives me a list of TextNodes etc as expected for basic templates, but
when I try it on a template that extends another template, all I get
is the ExtendsNode in my list, ie

[]

I'm assuming this is a feature, not a bug, and is due to lazy loading
or something along those lines — my question is how do I work out what
nodes the final rendered template will have? I'd like to do this
without having to render the template if possible, as I don't want to
have to fake a RequestContext. I've tried looking in the source code
to no avail - can anyone point me in the right direction?

Thanks,
Greg

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



Project Scope Thread

2009-01-15 Thread Jurie-Jan Botha

I would like to run a thread for an entire Django project. I would
like to house the code that starts this thread up inside an
application.

Currently I placed the code in the '__init__.py' in the root of my
Django application, but when I start the server using 'runserver' is
seems to run this code twice. So it creates two threads. Any idea how
I can prevent this from happening?

When I start the project as a daemon it seems the thread doesn't run
at all!?

Also, any tips on doing this kind of thing? I'm a little worried that
I might run into some crazy issues when I place this into production.

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



how to get a model's field var the field's name in a string?

2009-01-15 Thread fallhunter

i mean
i have a model m, and m has a field fd.
so i can wrote like
   xx = m.fd
   m.fd = xxx

but, when i got a string  s = "fd"

how could i do the same as above?

i've tried m.__dict__[s], but it seems read only

thanks for any help...

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



Re: Re: Mod-Python = Headaches (cannot find my settings file)

2009-01-15 Thread 孙科
 
 SetHandler python-program
 PythonHandler django.core.handlers.modpython
 SetEnv DJANGO_SETTINGS_MODULE caliber.settings
 PythonDebug On
 PythonPath "sys.path + ['C:/projects/']" 
 


2009-01-15 



孙科 



发件人: Malcolm Tredinnick 
发送时间: 2009-01-15  14:24:47 
收件人: django-users 
抄送: 
主题: Re: Mod-Python = Headaches (cannot find my settings file) 
 
On Wed, 2009-01-14 at 20:44 -0800, mclovin wrote:
> Here is my new revised:
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE caliber.settings
> PythonDebug On
> PythonPath "['C:/projects/'] + sys.path"
> 
> 
> still does not work. gives the same error
When you test importing caliber.settings at the command line, with your
Python path set to exactly the above, what happened?
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: How do I manage the order of related objects?

2009-01-15 Thread Beres Botond

The parent object knows about all it's children. Each parent instance
has a 'manager' for the set of children, like
parent_instance.mychildren_set.
More exactly:

activity = Activity.objects.get(id=someid)
activity_parts = activity.activitypart_set.all() # you can use .filter
() etc.

And I'm not sure why you need the order, since they will be already
ordered by primary key (the most recent activity part added will have
highest primary key), and you can just use that.


scelerat wrote:
> I've got a part/collection pairing of objects tables, and I'd like to
> know the best way to manage the order of things inside the table.
>
> Briefly:
>
> class Activity(models.Model):
> # etc...
>
> class ActivityPart(models.Model):
> order   = models.IntegerField("order in parent", default=1)
> activity   = models.ForeignKey( Activity )
> # etc.
>
> What I want to do is, upon creation of an ActivityPart, figure out the
> other parts already pointing to an Activity, and increase the order
> number before saving the part if there are already ones with that
> number. I also want the parent object to know about all its Parts. I'm
> not sure what the best way to do either of these is... it seems like I
> could do some or all of this in the ArrayPart's __init__ method, but
> maybe there's a more Django-ish way?

--~--~-~--~~~---~--~~
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: Dealing with 'date' ranges in template?

2009-01-15 Thread Manfred

Many thank! I didn't know, that I can simply call methods of python
objects inside a template. This make things realy easy!
--
Manfred.
--~--~-~--~~~---~--~~
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: the last line is plone\Python\lib\site-packages\django\db\backends\sqlite3\base.py

2009-01-15 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-01-14, o godz. 23:45, przez Briel:

> All you need is to create the db-file, and then give the name/path to
> it in settings.py


Syncdb will create it for you if not exists.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


--~--~-~--~~~---~--~~
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: User Messages

2009-01-15 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-01-14, o godz. 18:42, przez Tim:

> I am using the messages framework to notify users when another user
> has commented on their profile or on an item they've posted. I was
> pretty excited to see that such an infrastructure was included with
> the authentication system out of the box. However, I was disappointed
> to see that the only way to retrieve messages was via a get _and_
> delete operation, so each get (or reference to "messages" in a
> template) emptied the queue.


Messages are normal model instances, you are not limited to  
get_and_delete_messages(), user.message_set.all() is normal queryset  
so you can retrieve objects without deleting them.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


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