Re: Changing field error messages

2008-09-22 Thread Donn

On Tuesday, 23 September 2008 08:47:10 Daniel Roseman wrote:
> self.validate_unique()
Ah! That's the magic.
Thanks.

\d

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



Re: Changing field error messages

2008-09-22 Thread Daniel Roseman

On Sep 22, 9:59 am, Donn <[EMAIL PROTECTED]> wrote:
> Hi,
> I would like to change the 'already exists' message when one adds a record
> that duplicates a unique one in the table.
> Nearest I can tell, the fields.error_messages do not offer a way to alter that
> message.
>
> Here's my basic code:
>
> class AAForm( ModelForm ):
>         def __init__(self,*args,**kwargs):
>                 super(AAForm, self).__init__(*args,**kwargs)
>                 self.fields['fullname'].error_messages = {
>                         'required':'Be there no name?',
>                         'already_exists':'blah' #<-- this one is a dud
>                         }
>         class Meta:
>                 model = AuthorArtist
> \d

No, apparently not. There's a ticket in for this (#8913) but in the
meantime maybe you could define a clean() method and catch and re-
raise the ValidationError there.

class AAForm(ModelForm):
 ... blah 

def clean(self):
try:
self.validate_unique()
except ValidationError:
raise ValidationError('Hey guys, this one's already
there!')
return self.cleaned_data

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



Re: ModelChoiceField with Unique Results

2008-09-22 Thread Daniel Roseman

On Sep 22, 10:58 pm, BobZ <[EMAIL PROTECTED]> wrote:
> Thanks dmorozov, that worked fine in the sense that it returned only
> unique years in a select box, but it still didn't order them properly
> (getting non-duplicate years as 1961, 1931, 2000, 1975, 1995, etc.).
>
> Somehow the order_by section of  "set([(obj.year, obj.year) for obj in
> Vehicle.objects.all().order_by('-year')]) " isn't performing its
> function.
>
> Any ideas?
>
> Thanks again!
>

To be honest, dmorozov's solution sounds like overkill for what you
need. Try something like this:

class SearchForm(forms.ModelForm):
year = forms.ModelChoiceField(queryset=Vehicle.objects.order_by('-
year').distinct())

You'll need to be sure Vehicle has a __unicode__ method for this to
work.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Changing field error messages

2008-09-22 Thread Donn

bump...

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



'next' value in comment post/preview

2008-09-22 Thread Eric Abrahamsen

Somewhat pursuant to this thread:
http://groups.google.com/group/django-users/browse_thread/thread/a0c468f0c81bb197#

a hidden 'next' field in the comment post form doesn't get carried  
over to the comment preview view. It seems like if you're going to  
have a manual 'next' value possible in the comment post, you'd also  
want that value accessible in the preview view. Currently the only  
context variables getting passed to comment_preview.html are the  
comment text, and the form data (which ignores the 'next' field), and  
as far as I know that's not enough to reconstruct the redirect URL I'm  
after (comment.content_object.get_absolute_url). If that's right, I'll  
submit a patch that passes the next value to comment_preview.html.

Thanks,
Eric

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



Re: MooTools

2008-09-22 Thread Xenocide001

wow thanks i didn-t know that. imma check out Pinax too..  thanx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: update or add object?

2008-09-22 Thread John M

Dang, I knew there was something there!  Thanks R. Gorman :)

On Sep 22, 6:10 pm, "R. Gorman" <[EMAIL PROTECTED]> wrote:
> get_or_create
>
> http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-cre...
>
> R.
>
> On Sep 22, 7:55 pm, John M <[EMAIL PROTECTED]> wrote:
>
> > Is there a method I can call in a view that given a key, it checks to
> > see if that object exists and if it does returns that object, or if it
> > doesn't, adds it to the DB and returns the new key?
>
> > I could have sworn there was a shortcut for this.
>
> > Thanks
>
> > John
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Postgresql 'missing FROM-clause entry in subquery for table' error on lookup that spans relationships

2008-09-22 Thread Malcolm Tredinnick


On Mon, 2008-09-22 at 18:22 -0700, cfobel wrote:
> Hello,
> 
> I'm encountering an error when performing a lookup that spans
> relationships.  The query is as follows:
> 
> myitems =
> MyItem.objects_all.exclude(user__somemodel__created__gte=(datetime.now()
> - timedelta(days=3)))
> 
> With the following (stripped) models:
> 
> class MyItem(models.Model):
> user = models.ForeignKey(user, unique=True)
> 
> class SomeModel(models.Model):
> created = models.DateTimeField('Date created',
> default=datetime.now)
> user = models.ForeignKey(User)

This is a pretty good test case, but the looks of it. The only thing
missing is the custom manager (since you're calling MyItem.objects_all,
not MyItem.objects) and that possibly affects something, too.

In any case, any time we're generating invalid SQL instead of raising
some other error (or doing the right thing for valid code -- and the
above looks valid at first glance), it's a bug.

Could you please open a ticket for this so that I remember to look at it
(assign it to "mtredinnick" straight away, if you like).

> 
> The error I get is:
> 
> Traceback (most recent call last):
>   
>   File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
> line 179, in _result_iter
> self._fill_cache()
>   File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
> line 612, in _fill_cache
> self._result_cache.append(self._iter.next())
>   File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
> line 269, in iterator
> for row in self.query.results_iter():
>   File "/usr/lib/python2.5/site-packages/django/db/models/sql/
> query.py", line 206, in results_iter
> for rows in self.execute_sql(MULTI):
>   File "/usr/lib/python2.5/site-packages/django/db/models/sql/
> query.py", line 1723, in execute_sql
> cursor.execute(sql, params)
>   File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
> line 19, in execute
> return self.cursor.execute(sql, params)
> psycopg2.ProgrammingError: missing FROM-clause entry in subquery for
> table "u1"
> LINE 1: ..._myitem" U0 INNER JOIN "notes_note" U2 ON (U1."id" = ...
>  
> ^
> 
> To debug the issue, I looked at the SQL generated by the 'myitems'
> queryset above.  The generated SQL is:
> 
> SELECT "users_myitem"."id", "users_myitem"."user_id"
> FROM "users_myitem"
> WHERE NOT (
>   "users_myitem"."user_id" IN (
> SELECT U2."user_id"
> FROM "users_myitem" U0
> INNER JOIN "myapp_somemodel" U2 ON (U1."id" = U2."user_id")
> WHERE U2."created" >= 2008-09-19 19:57:43.111687
>   )
> )
> 
> It looks like the table "users_myitem" is being improperly labeled as
> 'U0',

Well, not really. The users_myitem table in the main query and
users_myitem in the subquery are different instances of the table, so it
has to have an alias. The main table from the outer query is always
going to end up being "U0" in an inner query like this (since it's the
first in a list of names and the number is the index in the list).

>  and then is referred to as 'U1' on the next line. 

The interesting bit is what happened to U1. I have a suspicion this
might be related to another optimisation that isn't working reliably,
but which I thought wasn't harming anything (just generating less than
optimal code): we shouldn't really need U0 in the above query, since we
can just test against the thing it's joining to.

There's definitely something going wrong here. Again, we shouldn't ever
be sending malformed SQL to the database. That's always a Django bug. I
can't drop everything right this minute to look at it, but if you open a
ticket I'll certainly take a look, since SQL bugs are something I take
very personally.

Regards,
Malcolm



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



Postgresql 'missing FROM-clause entry in subquery for table' error on lookup that spans relationships

2008-09-22 Thread cfobel

Hello,

I'm encountering an error when performing a lookup that spans
relationships.  The query is as follows:

myitems =
MyItem.objects_all.exclude(user__somemodel__created__gte=(datetime.now()
- timedelta(days=3)))

With the following (stripped) models:

class MyItem(models.Model):
user = models.ForeignKey(user, unique=True)

class SomeModel(models.Model):
created = models.DateTimeField('Date created',
default=datetime.now)
user = models.ForeignKey(User)

The error I get is:

Traceback (most recent call last):
  
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 179, in _result_iter
self._fill_cache()
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 612, in _fill_cache
self._result_cache.append(self._iter.next())
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 269, in iterator
for row in self.query.results_iter():
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/
query.py", line 206, in results_iter
for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/
query.py", line 1723, in execute_sql
cursor.execute(sql, params)
  File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: missing FROM-clause entry in subquery for
table "u1"
LINE 1: ..._myitem" U0 INNER JOIN "notes_note" U2 ON (U1."id" = ...
 
^

To debug the issue, I looked at the SQL generated by the 'myitems'
queryset above.  The generated SQL is:

SELECT "users_myitem"."id", "users_myitem"."user_id"
FROM "users_myitem"
WHERE NOT (
  "users_myitem"."user_id" IN (
SELECT U2."user_id"
FROM "users_myitem" U0
INNER JOIN "myapp_somemodel" U2 ON (U1."id" = U2."user_id")
WHERE U2."created" >= 2008-09-19 19:57:43.111687
  )
)

It looks like the table "users_myitem" is being improperly labeled as
'U0', and then is referred to as 'U1' on the next line.  If I correct
this issue and run the SQL command manually, I get the expected
records returned.  The corrected SQL is as follows:

SELECT "users_myitem"."id", "users_myitem"."user_id"
FROM "users_myitem"
WHERE NOT (
  "users_myitem"."user_id" IN (
SELECT U2."user_id"
FROM "users_myitem" U1
INNER JOIN "myapp_somemodel" U2 ON (U1."id" = U2."user_id")
WHERE U2."created" >= '2008-09-19 19:51:43.151089'
  )
)

Am I doing something wrong?  Is this a bug?

Any help would be greatly appreciated.

Thanks,
Christian

PS - I'm really enjoying 1.0!

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



Re: Accessing Settings from Flatpages

2008-09-22 Thread Chris

On Sep 22, 8:59 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Chris wrote:
> > I have various global values, like SITE_NAME, defined in my
> > settings.py. How would you make settings available inside Flatpage
> > templates? For non-flatpages, I'm currently importing settings in my
> > view and explicitly passing it in render_to_response(). Do Flatpages
> > allow you to specify what data gets passed to them, aside from the db
> > page data?
>
> The simplest way would be to define a template context processor. See
>
> http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context...
>
> for some hints.

Thanks, adding a context processor worked perfectly.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelChoiceField - remove empty-value

2008-09-22 Thread Brian Neal

On Sep 5, 11:19 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-09-05 at 03:11 -0700, mwebs wrote:
> > Hello,
>
> > I use amodelchoicefieldand want to remove the entry that represents
> > "no item selected"(--), because in my
> > scenario I will only allow to select between existing entries.
>
> Specify adefaultvalue for the field (one of the choices). Then that
> will be shown as the initially selected option.

I could not find a way to specify a default value.

> The empty choice isn't there because it's a valid option. It's actually
> a useful user-interface feature. If somebody submitted a form without
> making a choice, it would be invalid because the empty "" choice is
> not valid. It's there because you didn't specify adefaultvalue and
> Django doesn't make a choice ofdefaultinitial value for you. The user
> has not yet made a selection, so they must choose one of the options
> explicitly. If they just hit "submit" without making a choice, Django is
> careful to ensure they don't accidentally end up selecting whichever
> option Django displayed first.
>
> Regards,
> Malcolm

Sounds reasonable. However I am using a RadioSelect widget in my "rite-
of-passage" first Django poll app. It looks very weird to see this on
a form (please forgive the crude ASCII art):

Vote Now:
* 
* Yes
* No
[Submit]

However I looked at the django source code and found that you can set
empty_label to None to get rid of that first choice. Here is how I did
it in my form class:

from django import forms
from gpp.polls.models import Choice

class VoteForm(forms.Form):
   """Form for voting in a poll."""
   options = forms.ModelChoiceField(queryset = Choice.objects.none(),
widget = forms.RadioSelect)

   def __init__(self, poll_id):
  super(VoteForm, self).__init__()
  self.fields['options'].queryset =
Choice.objects.filter(poll=poll_id)
  self.fields['options'].empty_label = None

I hope this helps someone!

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



Re: update or add object?

2008-09-22 Thread R. Gorman

get_or_create

http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-create-kwargs

R.

On Sep 22, 7:55 pm, John M <[EMAIL PROTECTED]> wrote:
> Is there a method I can call in a view that given a key, it checks to
> see if that object exists and if it does returns that object, or if it
> doesn't, adds it to the DB and returns the new key?
>
> I could have sworn there was a shortcut for this.
>
> Thanks
>
> John
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Accessing Settings from Flatpages

2008-09-22 Thread Steve Holden

Chris wrote:
> I have various global values, like SITE_NAME, defined in my
> settings.py. How would you make settings available inside Flatpage
> templates? For non-flatpages, I'm currently importing settings in my
> view and explicitly passing it in render_to_response(). Do Flatpages
> allow you to specify what data gets passed to them, aside from the db
> page data?
The simplest way would be to define a template context processor. See

http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/

for some hints.

regards
 Steve


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



Re: OS path in python

2008-09-22 Thread Bobby Roberts

> import os
> os.environ['SERVER_NAME']
>
> See how that goes.

I get:
KeyError: 'SERVER_NAME'

So i'm assuming we aren'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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Accessing Settings from Flatpages

2008-09-22 Thread Chris

I have various global values, like SITE_NAME, defined in my
settings.py. How would you make settings available inside Flatpage
templates? For non-flatpages, I'm currently importing settings in my
view and explicitly passing it in render_to_response(). Do Flatpages
allow you to specify what data gets passed to them, aside from the db
page data?

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



Re: OS path in python

2008-09-22 Thread gaz

On Sep 23, 10:01 am, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> I need to find the x part of the path which is the domain name
> (whatever.com, ie).  I'm thinking that the only way to do this is to
> get the current URL being viewed but I can't figure that out.

Assuming you are using Python CGI, you could check the HTTP
environment variables... see http://hoohoo.ncsa.uiuc.edu/cgi/env.html
for a good reference.

import os
os.environ['SERVER_NAME']

See how that goes.

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



Re: OS path in python

2008-09-22 Thread Bobby Roberts



On Sep 22, 6:11 pm, Erik Allik <[EMAIL PROTECTED]> wrote:
> Shouldn't that be os.path.abspath(os.path.dirname(__file__)) instead  
> just in case the .py file is executed with a relative path?
>
> And Bobby, I would instead use the Sites framework to compute the URL  
> of the site, not rely on a local folder name.
>

Hi all -

let me clarify things.  this is a straight python platform at the
moment.  We plan on moving it to django but for now we just have
python running on an in-house framework.

there is a point in the code where i need to write a file... let's
call it "myfile.txt".  The directory i'm writing to most likely will
not have any existing files inside.  Therefore the dirname function
won't work because I have no file to base it off of.

the only known in this situation is the file should be written to

home/sites/x/library where x is the domain name which also
happens to be dynamic.

I need to find the x part of the path which is the domain name
(whatever.com, ie).  I'm thinking that the only way to do this is to
get the current URL being viewed but I can't figure that out.  I think
it has to be with os or urllib but I can't seem to find the answer.
any help is greatly appreciated.



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



update or add object?

2008-09-22 Thread John M

Is there a method I can call in a view that given a key, it checks to
see if that object exists and if it does returns that object, or if it
doesn't, adds it to the DB and returns the new key?

I could have sworn there was a shortcut for this.

Thanks

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



docutils extra

2008-09-22 Thread aleray

Hey,

I installed docutils svn version and I couldn't get the documention
working (was in the python path) until I found I needed to register in
my pythonpath the "extra" directory in the docutils package. Docutils
team apparently moved in that directory some libraries needed for
django documention (I read somthing about license issues, but can't
find the quote anymore). Anyway, it could be nice to write it
somewhere on django documentation website.

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



Re: Impact of a CustomManager on the RelatedManager

2008-09-22 Thread gaz

Thanks Bruno,

I'd already tried that - I noticed that with or without the
use_for_related_field being set on the Custom Manager the effect was
the same - ie. the RelatedManager fires off it's own code without
actually using the MyCurrentSiteManager instance that is already
associated with the Model Class.

At the moment my solution has been to do:

  def _get_conferences(self):
return Conference.objects.filter(venue=self)
  conferences = property(_get_conferences)

I'm not sure this is the best way, but I am basing that on my reading
at 
http://docs.djangoproject.com/en/dev/topics/db/managers/#adding-extra-manager-methods
and http://docs.djangoproject.com/en/dev/topics/db/models/#model-methods

Any advice on as to whether or not this is the best way to get the
solution I am after appreciated!

Gary

On Sep 22, 10:01 pm, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> On 22 sep, 01:49, gaz <[EMAIL PROTECTED]> wrote:
> (snip)> I have overloaded the default manager in my model to use a slight
> > variant of the CurrentSiteManager, shown below.
>
> (snip)
> > What I am seeing is that the following queries work and present only
> > the objects which are on the site (Venue) or objects which are related
> > to a Venue on the site (Conference):
>
> > Venue.objects.all()
> > Conference.objects.all()
>
> > However, if I try to get the related objects of a Venue object, I get
> > an error as below:
>
> (snip)
>
> I might be wrong (only had a very cursory glance at your code), but
> I'd say you want to have a look at this:
>  http://docs.djangoproject.com/en/dev/topics/db/managers/#using-manage...
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to simulate recursive inlines in admin?

2008-09-22 Thread David Durham, Jr.

2008/9/22 Steve Holden <[EMAIL PROTECTED]>:
> This all seems rather ambitious for the admin. Isn't it supposed to be a
> simple application, and aren't those kind of functions supposed to be
> implemented by other views? There's no point trying to make the admin
> all things to all people - that would just complicate it so much as to
> make it unusable by anyone other than a guru.

I'm not writing this SessionWizard thing specifically for the admin,
though I wouldn't necessarily rule it out.  The point of it is to walk
ordinary, non-DB savvy, users through the creation of multiple
entities without these users having to know specifically the
relationships between entities (a programmer worries about that).  For
instance, creating a complete questionaire with the current admin
would involve, creating a questionaire, then creating questions and
answers and associating the questions with the questionaire and the
answers with the questions (basically select the same things
repeatedly from drop-downs).  This is resolved if you allow arbitrary
nesting of inlines and know how to map the relationships without the
user having to repeated select the same things from drop-downs, but it
could lead to one really long form.  Taking a multiple forms/requests
approach allows people to 1- pick up where they left off (say a
machine crashes or they just want save and pick up where they left off
and 2- quickly navigate to specific parts of the workflow in order to
add, change or remove or whatever.

I'm still a django newb, though, so please correct me if I stated
anything incorrectly.

Thanks,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



suscribe

2008-09-22 Thread Ovnicraft
-- 
[b]question = (to) ? be : !be; .[/b]

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



Re: How to simulate recursive inlines in admin?

2008-09-22 Thread Steve Holden

David Durham, Jr. wrote:
> On Mon, Sep 22, 2008 at 4:05 PM, Petar Marić <[EMAIL PROTECTED]> wrote:
>   
>> I'm using the admin app for creating Questionnaires and I'd like to let users
>> edit questions and answers in the same form. AFAIK recursive inlines aren't
>> supported in Django (a hard problem by itself) so the only other way I could
>> think of is to inject a TextArea form field inside of the QuestionInline and
>> then do the processing of it manually. Answers would then be separated by
>> newlines and the positions would be determined by the order of lines in the
>> TextArea.
>>
>> The problem is I don't know how to inject the TextArea in the inline. I tried
>> many things from simple to complex - and the otherwise excellent 
>> documentation
>> doesn't give much help.
>> 
>
> Another approach is to go with some kind of wizard-like very simple
> workflow where you start off creating a questionaire, then you add
> questions and answers.  I have a working "session wizard"  that
> handles some of the boiler plate with this kind of thing.  It's not
> "done" yet, but it is working.  Here's a link to the django snippets
> entry:
>
>http://www.djangosnippets.org/snippets/1078/
>
> I have code that dynamically manipulates the "form_list" associated
> with the wizard so that I can, for instance, display buttons like
> 'save and add question' and then add a question form to the list of
> forms.   I also display navigation links to each form or step in the
> wizard (which in your case would be a tree-like structure -- actually
> maybe wizard in the right word for this thing ...).  Let me know if
> this interests you at all, and I'd be glad to say more about it.
>
>   
This all seems rather ambitious for the admin. Isn't it supposed to be a
simple application, and aren't those kind of functions supposed to be
implemented by other views? There's no point trying to make the admin
all things to all people - that would just complicate it so much as to
make it unusable by anyone other than a guru.

regards
 Steve


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



What's the best way to handle different login requirements

2008-09-22 Thread catsclaw

Hi all --

   I'm having trouble figuring out how to properly design this in
Django.  I'm using the Django user system.

   I've got an application I'm writing that allows people to browse an
SVN repository in Django.  In order to do this, I need to hang on to
their username and password so I can hand it off to the SVN site
whenever they hit the backend.  I *really* don't want to store it in
the database, so what I'm doing is creating my own login form that
stores it in their session.  That works fine.

   However, my main application *also* needs to check when users log
in, to see if they've filled in some profile data before they can
access the site.  I don't want to put this check in my subapp (since
it's separate from the main site) but I'm not sure how else to put
things.

   In short, is there some recommended way I can have my code override
the built-in login system, so different applications can have
different things run on significant events (like login, user creation,
etc?)

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



Re: OS path in python

2008-09-22 Thread Erik Allik

Shouldn't that be os.path.abspath(os.path.dirname(__file__)) instead  
just in case the .py file is executed with a relative path?

And Bobby, I would instead use the Sites framework to compute the URL  
of the site, not rely on a local folder name.

Erik

On 23.09.2008, at 0:51, Plamen Dragozov wrote:

>
> From inside a python module:
> os.path.dirname(__file__)
>
> Best,
> Plamen Dragozov
>
> Bobby Roberts wrote:
>>
>> On Sep 22, 5:05 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>>
>>> os.path.dirname()
>>>
>>
>>
>> Thanks.  The main problem is that i have to dynamically get the url
>> i'm at so i can pass to that function ( Python returns that i'm
>> missing 1 argument and I don't know how to dynamically pass that in.)
>>>
>>
>
>
> >


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



Updates not working

2008-09-22 Thread Adam Findley

So I have a pretty simple case here in a view:

event = Event.Objects.get(id='23')
event.end_date = datetime.now()
event.save()

It should just work right?

When looking at the queries, the UPDATE command has all of the keys
quoted, but not the values.  This causes the query to fail.

For some reason this fails in the view, but doesn't fail in the
shell... I'm at such a loss here.  Any ideas here?

Adam

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



Re: Install version .90 help

2008-09-22 Thread KillaBee



On Sep 19, 8:18 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-09-19 at 09:48 -0700, KillaBee wrote:
>
> > On Sep 19, 9:18 am, KillaBee <[EMAIL PROTECTED]>
> > wrote:
> > > On Sep 18, 8:34 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > On Thu, 2008-09-18 at 15:13 -0700, Carol wrote:
> > > > > As far as I can see, django-admin.py doesn't have a subcommand called
> > > > > init.
>
> > > > It did in 0.90, We're talking about something release in mid-November,
> > > > 2005: things have changed a little since then. :-)
>
> > > > Regards,
> > > > Malcolm
>
> > > I am using an old .90 program that has been a pain to recode to 1.0.
> > > I s there a guide on django's website I ca look at?
> > > I used the same settings as I did before, in 1.0 that worked.  There
> > > is not a manage.py but there is a management.py with a init.  When I
> > > did python management.py and any command nothing happened, so I am
> > > thinking that the settings might be wrong, or the location was not in
> > > python.
>
> > > MANAGERS = ADMINS
>
> > > DATABASE_ENGINE = 'mysql'
> > > DATABASE_NAME = 'timesheets'
> > > DATABASE_USER = 'bryant'
> > > DATABASE_PASSWORD = ''
> > > DATABASE_HOST = '10.0.0.20'
> > > DATABASE_PORT = '3306'
>
> > > Does Django .90 automaticlly put projects in python?
>
> [...]
>
>
>
> > I see *args, **kwargs2 , so I am thinking it is a db problem with the
> > username and password, but I can log in with I.  Do I need a number in
> > my user name on .90?
>
> In my original post, I said that it could be something like the database
> port number. You apparently didn't check that. The database port number
> in the settings file you posted is a string, not an integer. That's
> almost certainly the problem. You will not be able to simply use a 1.0
> settings file with 0.90. There are lots of differences, some large and
> some small. Basically, everything on the BackwardsIncompatibleChanges
> page in the wiki (and the older version of that page that is linked from
> the top).
>
> Regards,
> Malcolm`

I did check the pages but did not find anything like the errors.
I took out the host and port, but I still get the error.
I looked at the connections.py and mysql.py.
In the connections.py there is a way to make a db connection because
of this error:
File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line
176, in __init__
super(Connection, self).__init__(*args, **kwargs2)
host '10.0.0.20'
user 'bryant'
db 'timesheets'
port '3306'
this gave me a format error.

I looked at the mysql.py because of this error:
File "/usr/lib/python2.5/site-packages/Django-0.90-py2.5.egg/django/
core/db/backends/mysql.py", line 67, in cursor
self.connection = Database.connect(**kwargs)
and the if is:
if DATABASE_PORT:
kwargs['port'] = DATABASE_PORT
self.connection = Database.connect(**kwargs)

is there a middleware that might help connect?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelChoiceField with Unique Results

2008-09-22 Thread BobZ

Thanks dmorozov, that worked fine in the sense that it returned only
unique years in a select box, but it still didn't order them properly
(getting non-duplicate years as 1961, 1931, 2000, 1975, 1995, etc.).

Somehow the order_by section of  "set([(obj.year, obj.year) for obj in
Vehicle.objects.all().order_by('-year')]) " isn't performing its
function.

Any ideas?

Thanks again!

On Sep 22, 1:39 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> You can try something like this:
>
> class SearchForm(forms.ModelForm):
>     year = forms.ChoiceField()
>
>     def __init__(self, *args, **kwargs):
>         super(SearchForm, self) .__init__(*args, **kwargs)
>
>         self.fields['year'].choices = \
>             set([(obj.year, obj.year) for obj in \
>             Vehicle.objects.all().order_by('-year')])
>
>     class Meta:
>         model = Vehicle
>
> On Sep 22, 8:17 pm, BobZ <[EMAIL PROTECTED]> wrote:
>
> > What I'm trying to do seems relatively simple, but I have yet to find
> > a proper solution for it.
>
> > I'm trying to query a list of years from a database of registered
> > vehicles in my county and display them in a drop-down select menu in a
> > form.
>
> > Since the registered vehicles database has many  cars of the same
> > year,  I need to make those results from the query display in a unique
> > (no duplicate 2007 options for example), descending order when the
> > select menu is clicked.
>
> > Here's what I've been using so far in my forms.py file:
> > #class SearchForm(forms.ModelForm):
> > #    year = forms.ModelChoiceField
> > #    class Meta:
> > #        model = Vehicle
>
> > This only gives me an empty text field.
> > I'm fairly new to Django, so any help would be greatly appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Dictionary Issue in Django Template (Beginner)

2008-09-22 Thread [EMAIL PROTECTED]

Hi,
The following are a few lines from my Django template which i cannot
get to work..

{% for machine in web %}
  {% for status_message in  status.machine %}
  {{status_message}} 
  {% endfor %}
{% endfor %}

web [list()] - is a list of machines..
status [dict()] - is a dictionary of lists.
  So, if I do something like status.intel2, it would return a
list.
status_message - is something i am using to traverse through the
list.


In the above code, if I hard code something like status.intel4.. my
code works perfectly fine..and a list is returned, which i can
traverse through using the second for loop//
But, I want to be able to do this dynamically, using the machine name
from the web list..
So, i want to be able to do something like status.machine..

Can someone please help me out!!

Thanks,
Venkatesh H

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



Re: OS path in python

2008-09-22 Thread Plamen Dragozov

 From inside a python module:
os.path.dirname(__file__)

Best,
Plamen Dragozov

Bobby Roberts wrote:
>
> On Sep 22, 5:05 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>   
>> os.path.dirname()
>> 
>
>
> Thanks.  The main problem is that i have to dynamically get the url
> i'm at so i can pass to that function ( Python returns that i'm
> missing 1 argument and I don't know how to dynamically pass that in.)
> >
>   


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



Re: Template help for new django.contrib.comments

2008-09-22 Thread macgregor

Think I may have just figured it out

comment.content_object.get_absolute_url works for me.


On Sep 22, 2:37 pm, Delta20 <[EMAIL PROTECTED]> wrote:
> I have the exact same question. I also tried using
> "object.get_content_object.get_absolute_url" but that didn't work
> either.
>
> On Sep 22, 5:25 pm, macgregor <[EMAIL PROTECTED]> wrote:
>
> > I have the new Comments app installed and working and want to modify
> > django/contrib/comments/templates/comments/posted.html to include a
> > link to the content object that a comment gets added to.
>
> > For example: If someone posts a comment on a blog entry, the comment
> > gets added and then the user is redirected to /comments/posted?c=X
> > where X is the comment id. How can I get a URL to the blog entry that
> > this comment belongs to?
>
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to simulate recursive inlines in admin?

2008-09-22 Thread David Durham, Jr.
On Mon, Sep 22, 2008 at 4:05 PM, Petar Marić <[EMAIL PROTECTED]> wrote:
> I'm using the admin app for creating Questionnaires and I'd like to let users
> edit questions and answers in the same form. AFAIK recursive inlines aren't
> supported in Django (a hard problem by itself) so the only other way I could
> think of is to inject a TextArea form field inside of the QuestionInline and
> then do the processing of it manually. Answers would then be separated by
> newlines and the positions would be determined by the order of lines in the
> TextArea.
>
> The problem is I don't know how to inject the TextArea in the inline. I tried
> many things from simple to complex - and the otherwise excellent documentation
> doesn't give much help.

Another approach is to go with some kind of wizard-like very simple
workflow where you start off creating a questionaire, then you add
questions and answers.  I have a working "session wizard"  that
handles some of the boiler plate with this kind of thing.  It's not
"done" yet, but it is working.  Here's a link to the django snippets
entry:

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

I have code that dynamically manipulates the "form_list" associated
with the wizard so that I can, for instance, display buttons like
'save and add question' and then add a question form to the list of
forms.   I also display navigation links to each form or step in the
wizard (which in your case would be a tree-like structure -- actually
maybe wizard in the right word for this thing ...).  Let me know if
this interests you at all, and I'd be glad to say more about it.


- 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MooTools

2008-09-22 Thread Erik Allik

You should consider Pinax at http://pinaxproject.com/. Cloud27.com is  
powered by Pinax. It's a community site platform you can customize to  
your needs.

Erik

On 22.09.2008, at 22:14, Xenocide001 wrote:

>
> i was wondering how to make django project along with Mootools, the
> project itself it-s nothing now (no code just a doodle in my notebook
> and an idea)..
> i-ve seen a lot of django powered comunnity sites.. and i was looking
> for making one.. i know a bit of javascript.. and mootools
> so i like some libraries of mootools and iwould like to implemment
> them on my community project powered by django..
> i'm sorryabout my english but i speak spanish...
>
> >


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



Re: Template help for new django.contrib.comments

2008-09-22 Thread Delta20

I have the exact same question. I also tried using
"object.get_content_object.get_absolute_url" but that didn't work
either.


On Sep 22, 5:25 pm, macgregor <[EMAIL PROTECTED]> wrote:
> I have the new Comments app installed and working and want to modify
> django/contrib/comments/templates/comments/posted.html to include a
> link to the content object that a comment gets added to.
>
> For example: If someone posts a comment on a blog entry, the comment
> gets added and then the user is redirected to /comments/posted?c=X
> where X is the comment id. How can I get a URL to the blog entry that
> this comment belongs to?
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Template help for new django.contrib.comments

2008-09-22 Thread macgregor

I have the new Comments app installed and working and want to modify
django/contrib/comments/templates/comments/posted.html to include a
link to the content object that a comment gets added to.

For example: If someone posts a comment on a blog entry, the comment
gets added and then the user is redirected to /comments/posted?c=X
where X is the comment id. How can I get a URL to the blog entry that
this comment belongs to?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Passing in a value from a url

2008-09-22 Thread djandrow

Thanks Karen, it works fine now.

regards,

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



Re: OS path in python

2008-09-22 Thread Bobby Roberts



On Sep 22, 5:05 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> os.path.dirname()


Thanks.  The main problem is that i have to dynamically get the url
i'm at so i can pass to that function ( Python returns that i'm
missing 1 argument and I don't know how to dynamically pass that in.)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to obtain the difference between two related querysets?

2008-09-22 Thread Ben Butler-Cole

On Aug 14, 8:57 pm, DrakerNet2 <[EMAIL PROTECTED]> wrote:
> How do I obtain thedifferencebetweenQueryset1 and 2 (i.e. how do I
> obtain all records fromQueryset1 that do not appear inQueryset2?

I've been trying to work this out as well. I have an answer, but not
one that I'm very happy with.

To retrieve a list of all the books *not* in a library I can write:

>>> books = Book.objects.exclude(pk__in=library.books.values('pk').query)

It seems a shame to have to specify the primary key here and I don't
like poking around inside the implementation to get at the query
attribute. I was hoping for something a little cleaner like:

>>> books = Book.objects.all() - library.books.all()

Am I missing something?

Thanks
Ben

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



Re: OS path in python

2008-09-22 Thread Jarek Zgoda

os.path.dirname()

Wiadomość napisana w dniu 2008-09-22, o godz. 22:51, przez Bobby  
Roberts:

>
> i've got a setup like most people where i have directory structure
> such as:
>
> home/sites/xxx/whatever
>
>
> where xxx is the domain name
>
> If I have a file sitting in the "whatever" directory, how can i find
> the domain name under which the file resides?
>
>
>
> Thanks for helping a noob.
> >

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

Jarek Zgoda, R&D, Redefine
[EMAIL PROTECTED]


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



How to simulate recursive inlines in admin?

2008-09-22 Thread Petar Marić
Hi everybody,

I'm creating a Django based web application for my Master thesis and I've got
a hard problem. This is my model (greatly simplified):

class Questionnaire(models.Model):
title = models.CharField()
description = models.TextField()
created_by = models.ForeignKey(User, editable=False)

class Question(models.Model):
title = models.CharField()
questionnaire = models.ForeignKey(Questionnaire)
position = PositionField(unique_for_field='questionnaire')

class Answer(models.Model):
title = models.CharField()
question = models.ForeignKey(Question)
position = PositionField(unique_for_field='question')

I'm using the admin app for creating Questionnaires and I'd like to let users
edit questions and answers in the same form. AFAIK recursive inlines aren't
supported in Django (a hard problem by itself) so the only other way I could
think of is to inject a TextArea form field inside of the QuestionInline and
then do the processing of it manually. Answers would then be separated by
newlines and the positions would be determined by the order of lines in the
TextArea.

The problem is I don't know how to inject the TextArea in the inline. I tried
many things from simple to complex - and the otherwise excellent documentation
doesn't give much help.

Thanks,
-- 
Petar Marić
*e-mail: [EMAIL PROTECTED]
*mobile: +381 (64) 6122467

*icq: 224720322
*jabber: [EMAIL PROTECTED]
*web: http://www.petarmaric.com/

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



OS path in python

2008-09-22 Thread Bobby Roberts

i've got a setup like most people where i have directory structure
such as:

home/sites/xxx/whatever


where xxx is the domain name

If I have a file sitting in the "whatever" directory, how can i find
the domain name under which the file resides?



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



Re: Abstract Superclass and Foreign Keys

2008-09-22 Thread Peter Bailey

Well a good session with my db made it apparent why this looked like
it was working in Admin but not my other code - I had a join table
pointing to the item superclasses, and thus their names showed up - OK
- I feel even sillier now!

So, I am proceeding with the generic keys/relations and so far am not
sure that the Admin is creating my supertype class properly when I
create a subtype. Can anyone tell me if it should, or whether I need
to hook the code and do something manually when I am creating these
through the Admin.

Sorry to keep bothering everyone.

Peter



On Sep 22, 12:34 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> Malcolm, (or any other knowledgeable soul), I have been experimenting
> with bothabstractclasses and GenericForeignKeys and Relations to
> solve my issues, and I still have some problems and questions. There
> are not a lot of examples of those, and what I really need is for this
> all to work properly in the admin so I can add a page and in the page
> inline be able to add any sub-classed "Item". Can you tell me if that
> type of functionality is supported in Admin yet with generic keys?
>
> Also, I discovered my issue above when I was writing some backend code
> to generate pages from the data collected in the Admin. Theforeignkeyissue 
> then became apparent. One thing I am trying to wrap my head
> around however is that when using my original model as above, the
> Admin app handled everything correctly. I was able to add several
> different item sub-types individually and attach them to pages without
> problem, and everything seemed to work fine and things also seemed
> correct in the database, So I guess I completely see the logic of why
> a generickeywould be required, but the Admin seems to work with what
> I gave it correctly - I know it has a lot of magic, but I keep going
> back and thinking if the Admin can work properly with this, there must
> be a way that I can too. Very frustrating. Thoughts anyone (maybe I am
> losing it :-) .
>
> Thanks again,
>
> Peter
>
> On Sep 16, 9:37 am, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > Thanks for the responses. There are a number of subclasses and I won't
> > know the specifics initially. I'll check out the GenericForeighnKey.
> > Sounds like it is what I want.
>
> > Thanks again,
>
> > Peter
>
> > On Sep 16, 8:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Mon, 2008-09-15 at 18:10 -0700, Peter Bailey wrote:
> > > > Hi all. I have a set of classes (web page items like radios,
> > > > checkboxes, etc.) They are built on asuperclass- Item.  I need a
> > > > join table to link them to specific pages in which I also store a
> > > > position (PageItem) . Here is a snippet:
>
> > > > #
> > > > ---
> > > >  ---
> > > > # will use this for subclassing into our item subtypes
> > > > #
> > > > ---
> > > >  ---
>
> > > > class Item(models.Model):
> > > >    name = models.CharField(max_length=30)
>
> > > >    def __unicode__(self):
> > > >        return self.name
>
> > > >    class Meta:
> > > >        abstract= True
>
> > > > #
> > > > ---
> > > >  ---
>
> > > > class Page(models.Model):
> > > >    website = models.ForeignKey(Website)
> > > >    position = models.IntegerField()
> > > >    file_name = models.CharField(max_length=50)
> > > >    h1_title = models.CharField(max_length=50)
>
> > > >    def __unicode__(self):
> > > >            return self.file_name
>
> > > >    class Meta:
> > > >        ordering = ["file_name"]
>
> > > > #
> > > > ---
> > > >  ---
>
> > > > class PageItem(models.Model):
> > > >    page = models.ForeignKey(Page, editable=False)
> > > >    item = models.ForeignKey(Item) # WANT THIS TO POINT TO SPECIFIC
> > > > SUBCLASS ITEM
> > > >    position = models.IntegerField()
>
> > > >    def name(self):
> > > >            return str(self.item.name)
>
> > > >    class Meta:
> > > >            ordering = ['position']
>
> > > > #
> > > > ---
> > > >  ---
>
> > > > class RadioBoxType(Item):
> > > >    """A Radio Button object with its specific attributes"""
> > > >        . etc.
>
> > > > My problem is that I want the item/page relationship in the join table
> > > > PageItem, so I can track the position. I realize that I can't have a
> > > > fk to anabstractclass though and obviously want it to point to the
> > > > subclassed object.
>
> > > So point it at the subclass you want it to point at.
>
> > > If you mean, however, that you want it to point to one of a number of
> > > possible subclasses, depending on the instance, then that isn't a
> > > ForeignKey (a ForeignKey points to one particular model). What you're
> >

Re: function import errors model import in other file

2008-09-22 Thread Gerard Petersen

Norman,

Seems so simple when you point it out .. :-)I know what happens, but it still 
seems fuzzy. This means I can not place anything anywhere even though I needed 
the stuff where I imported it. I think I'll draw some schematics to get a 
clearer view on what goes where.

Thanx a lot!!

Regards,

Gerard.

Norman Harman wrote:
> Gerard Petersen wrote:
>> Hi All,
>>
>> I'm trying to import a function. When adding this statement I get a Model 
>> import error in a completely different place, not even related. I've added 
>> the files from my app directory and their import statements below. 
>>
>> Are there any unauthorized imports being done?
>> Do I need to specify more exact since it's a deviating filename?
>> Do I need to add the deviating filenames (myforms.py, myfunctions.py) to 
>> settings.py or _init__.py?
>>
>> I'm completely lost. Thanx a lot!
>>
>> Regards,
>>
>> Gerard.
>>
>>
>> ## __init__.py
>> empty!
>>
>> ## urls.py
>> from django.conf.urls.defaults import *
>> from django.contrib import admin
>> from django.conf import settings
>>
>> ## views.py
>> from django.shortcuts import render_to_response, get_object_or_404
>> from django.conf.urls.defaults import *
>> from django.http import Http404, HttpResponseRedirect, HttpResponse
>> from django.core.urlresolvers import reverse
>> from models import *
>> from myforms import *
>> from myfunctions import *
>> from datetime import datetime
>>
>> ## models.py
>> from django.db import models
>> from django.contrib import admin
>> from statemachine import Machine
>> import datetime
>>
>> ## myforms.py
>> from models import *
>> from django.forms import *
>>
>> ## statemachine.py
>> from django.db import models
>> from django.utils.functional import curry
>> from myfunctions import current_date << Adding this one
>>
>> ## myfunctions.py
>> from django.db import models
>> from models import MetaData  << Breaks this one
>> from datetime import datetime, timedelta
>> from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_DOWN
>>
>> With this >> ImportError: cannot import name MetaData
>>
>> Full trace: http://paste.pocoo.org/show/85970/
>>
>>
>> Thanx again!
>>
>>
> It looks like you have made a circular import:
> 
>statemachine imports myfunctions which imports models which imports 
> statemachine == doh!
> 
> Don't do that.
> 
> 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: MySQL case sensitivity

2008-09-22 Thread tcp

Karen,

Thank you for the detailed answer. Currently I am following the Sams
Django in 24 Hours book. The example there gives an uppercase folder
name.

>From your response I can see that it would be good practice to stick
to lowercase folders (I will follow that path).

I found that support uppercase folder names could be supported with
MySQL on Windows by switching MySQL to use lower_case_table_names = 0
(like Unix default) in my.ini. I agree with you that changing the
Django core code doesn't seem to be a good idea and appreciate your
advise.

Best Regards,
Tom

On Sep 22, 3:39 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 22, 2008 at 2:29 PM, tcp <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Getting started.
>
> > I've got a MySQL database running on Windows (MySQL on Windows is not
> > case sensitive)
>
> > I create a model called People which has a Class called Person.
>
> Your terminology is confusing here. I think you are saying you have a Django
> application (i.e. directory containing models.py, etc.) named 'People' with
> a Django model named Person.  It is a little odd to have an uppercase letter
> in your directory name, and that is what is causing the problem.
>
>
>
> > I sync the database and it creates a table "people_person"
>
> Django actually creates a table named 'People_person'.  Django lowercases
> the part of the name that comes from your model's class name, but not the
> part that comes from your application directory name.  The lowercasing of
> 'people' is coming from MySQL, as described here:
>
> http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
>
> assuming you are using the default setting of 1 for lower_case_table_names
> on Windows.
>
>
>
> > If I immediately run syncdb again, it errors out with:
>
> > Creating table People_person
> > Traceback (most recent call last):
> >  File "manage.py", line 11, in 
> > .
> > .
> > .
> >    raise errorclass, errorvalue
> > _mysql_exceptions.OperationalError: (1050, "Table 'people_person'
> > already exists
> > ")
>
> > Notice that it doesn't think that People_person exists because it is
> > using a case sensitive search in Python and then it attempts to create
> > the table which FAILS in the case insensitive Windows MySQL.
>
> On a syncdb, Django retrieves the existing table names from the DB.  It gets
> back 'people_person', which does not match the table it wants to create,
> which is 'People_person', so it tries to create 'People_person'.  However
> MySQL lowercases the entire thing and now it matches an exising table so the
> create fails.
>
> > I'm looking at a book that advises setting uses_case_insensitive_name
> > = True in the django/db/backends/__init__py filebut this doesn't
> > seem to work.
>
> I have no idea what book you are referring to here nor what that setting is
> supposed to affect.  However, if a book recommends changing the Django
> source to fix a problem like this I'd be a bit leery of following any of its
> advice.  In general Django accomodates various databases and platforms
> without requiring any fiddling with the source.  Unless you are sure you
> understand all the issues and have come to the conclusion through your own
> research that for some reason Django out of the box doesn't work properly
> for your environment (in which ase I'd hope you'd bring it up as an issue to
> be addressed by the Django developers), it's a bad idea to be changing
> things in the Django code.
>
> > This seems like a bug to me in the MySQL implementation. Can someone
> > suggest the best way to work around this problem or to set the db case
> > insensitivity
>
> You could --
>
> 1. set lower_case_table_names to 0 on your MySQL implementation.  That way
> MySQL won't gratuitiously lowercase the names that Django passes to it.  If
> you are concerned about the scary-sounding warning about corrupt indexes
> that can result from this being set to 0 if you then also access the tables
> with a different lettercase, you could instead:
>
> 2 - specify an all-lowercase db_table name in the Meta class of your Person
> model.  See the docs 
> here:http://docs.djangoproject.com/en/dev/ref/models/options/#db-table.  Or:
>
> 3 - avoid using uppercase letters in your Djano application names.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MySQL case sensitivity

2008-09-22 Thread Karen Tracey
On Mon, Sep 22, 2008 at 2:29 PM, tcp <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> Getting started.
>
> I've got a MySQL database running on Windows (MySQL on Windows is not
> case sensitive)
>
> I create a model called People which has a Class called Person.
>

Your terminology is confusing here. I think you are saying you have a Django
application (i.e. directory containing models.py, etc.) named 'People' with
a Django model named Person.  It is a little odd to have an uppercase letter
in your directory name, and that is what is causing the problem.


>
> I sync the database and it creates a table "people_person"
>

Django actually creates a table named 'People_person'.  Django lowercases
the part of the name that comes from your model's class name, but not the
part that comes from your application directory name.  The lowercasing of
'people' is coming from MySQL, as described here:

http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

assuming you are using the default setting of 1 for lower_case_table_names
on Windows.


> If I immediately run syncdb again, it errors out with:
>
> Creating table People_person
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
> .
> .
> .
>raise errorclass, errorvalue
> _mysql_exceptions.OperationalError: (1050, "Table 'people_person'
> already exists
> ")
>
>
> Notice that it doesn't think that People_person exists because it is
> using a case sensitive search in Python and then it attempts to create
> the table which FAILS in the case insensitive Windows MySQL.
>

On a syncdb, Django retrieves the existing table names from the DB.  It gets
back 'people_person', which does not match the table it wants to create,
which is 'People_person', so it tries to create 'People_person'.  However
MySQL lowercases the entire thing and now it matches an exising table so the
create fails.


> I'm looking at a book that advises setting uses_case_insensitive_name
> = True in the django/db/backends/__init__py filebut this doesn't
> seem to work.
>

I have no idea what book you are referring to here nor what that setting is
supposed to affect.  However, if a book recommends changing the Django
source to fix a problem like this I'd be a bit leery of following any of its
advice.  In general Django accomodates various databases and platforms
without requiring any fiddling with the source.  Unless you are sure you
understand all the issues and have come to the conclusion through your own
research that for some reason Django out of the box doesn't work properly
for your environment (in which ase I'd hope you'd bring it up as an issue to
be addressed by the Django developers), it's a bad idea to be changing
things in the Django code.


> This seems like a bug to me in the MySQL implementation. Can someone
> suggest the best way to work around this problem or to set the db case
> insensitivity
>

You could --

1. set lower_case_table_names to 0 on your MySQL implementation.  That way
MySQL won't gratuitiously lowercase the names that Django passes to it.  If
you are concerned about the scary-sounding warning about corrupt indexes
that can result from this being set to 0 if you then also access the tables
with a different lettercase, you could instead:

2 - specify an all-lowercase db_table name in the Meta class of your Person
model.  See the docs here:
http://docs.djangoproject.com/en/dev/ref/models/options/#db-table.  Or:

3 - avoid using uppercase letters in your Djano application names.

Karen

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



Re: MooTools

2008-09-22 Thread Horst Gutmann

Django itself doesn't really care what JavaScript library you want to
use. Simply include it in your templates and use it like you would any
other static file :-) In this regard it doesn't really matter if you
want to use MooTools, jQuery, YUI, Prototype or whatever other JS
library you want to use :-)

-- Horst

On Mon, Sep 22, 2008 at 9:14 PM, Xenocide001 <[EMAIL PROTECTED]> wrote:
> i was wondering how to make django project along with Mootools, the
> project itself it-s nothing now (no code just a doodle in my notebook
> and an idea)..
> i-ve seen a lot of django powered comunnity sites.. and i was looking
> for making one.. i know a bit of javascript.. and mootools
> so i like some libraries of mootools and iwould like to implemment
> them on my community project powered by django..
> i'm sorryabout my english but i speak spanish...
>
> >
>

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



MooTools

2008-09-22 Thread Xenocide001

i was wondering how to make django project along with Mootools, the
project itself it-s nothing now (no code just a doodle in my notebook
and an idea)..
i-ve seen a lot of django powered comunnity sites.. and i was looking
for making one.. i know a bit of javascript.. and mootools
so i like some libraries of mootools and iwould like to implemment
them on my community project powered by django..
i'm sorryabout my english but i speak spanish...

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



Re: ModelChoiceField with Unique Results

2008-09-22 Thread [EMAIL PROTECTED]

You can try something like this:

class SearchForm(forms.ModelForm):
year = forms.ChoiceField()

def __init__(self, *args, **kwargs):
super(SearchForm, self) .__init__(*args, **kwargs)

self.fields['year'].choices = \
set([(obj.year, obj.year) for obj in \
Vehicle.objects.all().order_by('-year')])

class Meta:
model = Vehicle


On Sep 22, 8:17 pm, BobZ <[EMAIL PROTECTED]> wrote:
> What I'm trying to do seems relatively simple, but I have yet to find
> a proper solution for it.
>
> I'm trying to query a list of years from a database of registered
> vehicles in my county and display them in a drop-down select menu in a
> form.
>
> Since the registered vehicles database has many  cars of the same
> year,  I need to make those results from the query display in a unique
> (no duplicate 2007 options for example), descending order when the
> select menu is clicked.
>
> Here's what I've been using so far in my forms.py file:
> #class SearchForm(forms.ModelForm):
> #    year = forms.ModelChoiceField
> #    class Meta:
> #        model = Vehicle
>
> This only gives me an empty text field.
> I'm fairly new to Django, so any help would be greatly appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelChoiceField with Unique Results

2008-09-22 Thread [EMAIL PROTECTED]

You can try something like this:

class SearchForm(forms.ModelForm):
year = forms.ChoiceField()

def __init__(self, *args, **kwargs):
super(SearchForm, self) .__init__(*args, **kwargs)

self.fields['year'].choices = \
set([(obj.year, obj.year) for obj in \
Vehicle.objects.all().order_by('-year')])

class Meta:
model = Vehicle


On Sep 22, 8:17 pm, BobZ <[EMAIL PROTECTED]> wrote:
> What I'm trying to do seems relatively simple, but I have yet to find
> a proper solution for it.
>
> I'm trying to query a list of years from a database of registered
> vehicles in my county and display them in a drop-down select menu in a
> form.
>
> Since the registered vehicles database has many  cars of the same
> year,  I need to make those results from the query display in a unique
> (no duplicate 2007 options for example), descending order when the
> select menu is clicked.
>
> Here's what I've been using so far in my forms.py file:
> #class SearchForm(forms.ModelForm):
> #    year = forms.ModelChoiceField
> #    class Meta:
> #        model = Vehicle
>
> This only gives me an empty text field.
> I'm fairly new to Django, so any help would be greatly appreciated.

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



Re: MySQL case sensitivity

2008-09-22 Thread Juan Hernandez
I've got a MySQL database running on Windows (MySQL on Windows is not
> case sensitive)


That does not depends on the OS, depends on the Charset established in the
DB. Check the charset being used at the DB and then run syncdb again

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



MySQL case sensitivity

2008-09-22 Thread tcp

Hi,

Getting started.

I've got a MySQL database running on Windows (MySQL on Windows is not
case sensitive)

I create a model called People which has a Class called Person.

I sync the database and it creates a table "people_person"

If I immediately run syncdb again, it errors out with:

Creating table People_person
Traceback (most recent call last):
  File "manage.py", line 11, in 
.
.
.
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1050, "Table 'people_person'
already exists
")


Notice that it doesn't think that People_person exists because it is
using a case sensitive search in Python and then it attempts to create
the table which FAILS in the case insensitive Windows MySQL.

I'm looking at a book that advises setting uses_case_insensitive_name
= True in the django/db/backends/__init__py filebut this doesn't
seem to work.

This seems like a bug to me in the MySQL implementation. Can someone
suggest the best way to work around this problem or to set the db case
insensitivity

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



Re: function import errors model import in other file

2008-09-22 Thread Norman Harman

Gerard Petersen wrote:
> Hi All,
> 
> I'm trying to import a function. When adding this statement I get a Model 
> import error in a completely different place, not even related. I've added 
> the files from my app directory and their import statements below. 
> 
> Are there any unauthorized imports being done?
> Do I need to specify more exact since it's a deviating filename?
> Do I need to add the deviating filenames (myforms.py, myfunctions.py) to 
> settings.py or _init__.py?
> 
> I'm completely lost. Thanx a lot!
> 
> Regards,
> 
> Gerard.
> 
> 
> ## __init__.py
> empty!
> 
> ## urls.py
> from django.conf.urls.defaults import *
> from django.contrib import admin
> from django.conf import settings
> 
> ## views.py
> from django.shortcuts import render_to_response, get_object_or_404
> from django.conf.urls.defaults import *
> from django.http import Http404, HttpResponseRedirect, HttpResponse
> from django.core.urlresolvers import reverse
> from models import *
> from myforms import *
> from myfunctions import *
> from datetime import datetime
> 
> ## models.py
> from django.db import models
> from django.contrib import admin
> from statemachine import Machine
> import datetime
> 
> ## myforms.py
> from models import *
> from django.forms import *
> 
> ## statemachine.py
> from django.db import models
> from django.utils.functional import curry
> from myfunctions import current_date  << Adding this one
> 
> ## myfunctions.py
> from django.db import models
> from models import MetaData   << Breaks this one
> from datetime import datetime, timedelta
> from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_DOWN
> 
> With this >> ImportError: cannot import name MetaData
> 
> Full trace: http://paste.pocoo.org/show/85970/
> 
> 
> Thanx again!
> 
> 
It looks like you have made a circular import:

   statemachine imports myfunctions which imports models which imports 
statemachine == doh!

Don't do that.


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the sidelines and huddle up with the Statesman all season long
for complete high school, college and pro coverage in print and online!

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



Re: djangoamf doesn't work with models with ImageField

2008-09-22 Thread euglena

I'm now using django 1.0 and djangoamf 0.6. Maybe this djangoamf
version is conflicted to the new django version? Has anyone tried the
two together?
This error occurs whenever I try to return a queryset with a
"ImangeField".

This is the whole traceback:

Traceback (most recent call last):
  File "D:\Programe Files\python\Lib\site-packages\django\core\servers
\basehttp.
py", line 277, in run
self.result = application(self.environ, self.start_response)
  File "D:\Programe Files\python\Lib\site-packages\django\core\servers
\basehttp.
py", line 634, in __call__
return self.application(environ, start_response)
  File "D:\Programe Files\python\Lib\site-packages\django\core\handlers
\wsgi.py"
, line 239, in __call__
response = self.get_response(request)
  File "D:\Programe Files\python\Lib\site-packages\django\core\handlers
\base.py"
, line 67, in get_response
response = middleware_method(request)
  File "D:\Programe Files\python\Lib\site-packages\amf\django
\middleware\__init_
_.py", line 107, in process_request
response_data = amf.write(response_message)
  File "D:\Programe Files\python\lib\site-packages\amf\__init__.py",
line 188, i
n write
return amf3.write(message)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
483, in wr
ite
_write_bodies(message.bodies, output)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
459, in _w
rite_bodies
write_data(body.data, content, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
290, in wr
ite_data
_write_data(d, output, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
279, in _w
rite_data
func(d, output, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
393, in wr
ite_array
_write_data(elem, output, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
279, in _w
rite_data
func(d, output, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
443, in wr
ite_object
_write_data(value, output, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
279, in _w
rite_data
func(d, output, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
443, in wr
ite_object
_write_data(value, output, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
279, in _w
rite_data
func(d, output, context)
  File "D:\Programe Files\python\Lib\site-packages\amf\amf3.py", line
418, in wr
ite_object
key = context.get_object_reference_index(d)
  File "D:\Programe Files\python\lib\site-packages\amf\__init__.py",
line 126, i
n get_object_reference_index
return self._obj_refs.index(obj)
  File "D:\Programe Files\python\Lib\site-packages\django\db\models
\fields\__ini
t__.py", line 102, in __cmp__
return cmp(self.creation_counter, other.creation_counter)
AttributeError: 'list' object has no attribute 'creation_counter'

On Sep 19, 10:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Sep 19, 2008 at 6:39 AM, euglena <[EMAIL PROTECTED]> wrote:
>
> > anyone there?
>
> > On Sep 13, 11:49 am, euglena <[EMAIL PROTECTED]> wrote:
> > > Hi everybody,
> > > I have a model like this:
> > > class Product(models.Model):
> > >     ...
> > >     icon = models.ImageField(upload_to='icons/', blank=True)
> > >     ...
>
> > > And I want my dangoamf to get a list of this model's objects. I always
> > > get an AttributeError: 'list' object has no attribute 'creation
> > > +counter' if I don't comment out this icon Field.
>
> > > Has anyone encountered this situation?
> > > Forgive my poor English...
>
> I don't know anything about djangoamf so can't help you directly.  I suggest
> you might want to provide more information, such as versions of Django &
> djangoamf you are using, and a pointer to a full traceback on dpaste.com of
> the error.  Apparently with the limited information you provided so far
> nobody reading recognized a problem they have encountered or could help
> with.  More information might help.
>
> Karen- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANN: Updated Django Cheat Sheet

2008-09-22 Thread Andrew Durdin

We've updated the cheat sheet to correct two typos:

 - The "default_if_none" filter is now correctly spelt  (thanks to
Aaron C. de Bruyn for pointing it out).

 - The "ForeignKey" model field is now correctly named  (thanks to
Nikos Delibaltadakis for pointing it out).

Grab it from http://www.mercurytide.co.uk/whitepapers/django-cheat-sheet/

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



function import errors model import in other file

2008-09-22 Thread Gerard Petersen

Hi All,

I'm trying to import a function. When adding this statement I get a Model 
import error in a completely different place, not even related. I've added the 
files from my app directory and their import statements below. 

Are there any unauthorized imports being done?
Do I need to specify more exact since it's a deviating filename?
Do I need to add the deviating filenames (myforms.py, myfunctions.py) to 
settings.py or _init__.py?

I'm completely lost. Thanx a lot!

Regards,

Gerard.


## __init__.py
empty!

## urls.py
from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings

## views.py
from django.shortcuts import render_to_response, get_object_or_404
from django.conf.urls.defaults import *
from django.http import Http404, HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from models import *
from myforms import *
from myfunctions import *
from datetime import datetime

## models.py
from django.db import models
from django.contrib import admin
from statemachine import Machine
import datetime

## myforms.py
from models import *
from django.forms import *

## statemachine.py
from django.db import models
from django.utils.functional import curry
from myfunctions import current_date<< Adding this one

## myfunctions.py
from django.db import models
from models import MetaData << Breaks this one
from datetime import datetime, timedelta
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_DOWN

With this >> ImportError: cannot import name MetaData

Full trace: http://paste.pocoo.org/show/85970/


Thanx again!


-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: Custom tags and "extends"

2008-09-22 Thread Karish

In short, the question is:

How does a custom tag in a parent template access the nodes of the
derived template in its render() function?

Thanks!

On Sep 22, 8:21 am, Karish <[EMAIL PROTECTED]> wrote:
> I wrote a very simple custom tag, called oneline, which stips all
> newline characters from whatever is inside it.
>
> I want to use it in a base template like this (base.txt):
> {% load text %}{% oneline %}
> {% block body %}{% endblock %}
> {% endoneline %}
>
> In the derived template (derived.txt) I just do:
>
> {% extends 'mail/base.subject' %}
> {% block body %}
> a
> b
> c
> {% endblock %}
>
> But this doesn't work. The oneline tag that I wrote doesn't actually
> see the node of the block within the render function.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Change text box to a drop down box in the admin interface?

2008-09-22 Thread Karen Tracey
On Mon, Sep 22, 2008 at 12:49 PM, Jason <[EMAIL PROTECTED]> wrote:

>
> Thanks for the reply Karen.
>
> With that being said I would still like to know just how easy or hard
> it is to switch something like this around. In real terms its only a
> minor change. Can this be achieved with a few lines in my admin.py
> file or would I have to do this another way?
>

It's easy enough to override the form used by Admin, and then its just a
matter of creating the form to meet your specifications.  Given a model
defined as:

class Category(models.Model):
title = models.CharField(max_length=40)
parent = models.CharField(max_length=40, null=True, blank=True)

You could put this in your admin.py:

class MyCategoryForm(forms.ModelForm):
parent = forms.ChoiceField(required=False)
class Meta:
model = Category
def __init__(self, *args, **kwargs):
super(MyCategoryForm, self).__init__(*args, **kwargs)
self.fields['parent'].choices = [('', '-')]
self.fields['parent'].choices.extend([(c.title, c.title) for c in
Category.objects.all()])

class CategoryAdmin(admin.ModelAdmin):
form = MyCategoryForm
class Meta:
model = Category

admin.site.register(Category, CategoryAdmin)



which I think would give what you ask for.

Karen

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



Re: MySQLdb + AMD64

2008-09-22 Thread TheIvIaxx

I understand this isnt a django specific question, but i figured
someone out there might have tried starting a django project with
mysql on an AMD64 platform.  If so, how did they accomplish it.

On Sep 8, 7:19 pm, Martin Diers <[EMAIL PROTECTED]> wrote:
> Perhaps you should direct this to a MySQL list somewhere? This in not  
> a Django question.
>
> On Sep 6, 2008, at 2:43 PM, TheIvIaxx wrote:
>
>
>
> > After searching around for a bit for a build of MySQLdb, i have found
> > that i will probably need to build the module for AMD64 on windows.
> > Is there a guide or something that shows what needs to be done to
> > build a module for a certain architecture?
>
> > Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: _get_next_or_previous_ usage

2008-09-22 Thread Rafael Beccar Barca

On Sun, Sep 21, 2008 at 9:46 PM, Rafael Beccar Barca
<[EMAIL PROTECTED]> wrote:
> On Sun, Sep 21, 2008 at 9:23 PM, Malcolm Tredinnick
> <[EMAIL PROTECTED]> wrote:
>>
>>
>> On Sun, 2008-09-21 at 17:36 -0300, Rafael Beccar Barca wrote:
>>> Hi,
>>>
>>> I didn't find documentation for _get_next_or_previous_by_FIELD and
>>> _get_next_or_previous_in_order
>>
>> The fact that they start with underscores and aren't documented in the
>> Model API is a big that they are internal methods, not intended to be
>> used by any user-level code.
>>
>>> What parameters should I pass when calling them from shell ?
>>>
>>> How should I use them on my templates ?
>>
>> You shouldn't use them directly. What is the problem you are actually
>> trying to solve?
>
> I was trying to implement previous and next buttons and I found this tutorial:
>
> http://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First_App#Tweak_the_links_and_tags
>
> where teach a very interesting way of implement them for date fields
> but I need to use them for a class that doesn't have any date time
> fields but is ordered by an integer field.
>
> Then, I used ipython to check what methods were available for the
> object and got curious about _get_next_or_previous_by_FIELD and
> _get_next_or_previous_in_order
>
> But I think I would change my question to a clearer one: How can I
> easily implement next and previous buttons in my template for a class
> that does not have any date fields?
>
> I'm not expecting a full explanation, just some tips so I can start
> investigating myself.

Well, I just solved the problem by writing the logic on the view and
passing "next" and "previous" variables in the context.

However, I still wonder if get_next_in_order and get_previous_in_order
(defined in db/models/base.py) are django built-ins for doing this. I
tried to use them but I just don't get how they work. But I will let
that for further investigation somewhere in the future.

Thanks anyway.

Regards,
Rafael

>
> Regards,
> Rafael
>
>>
>> Regards,
>> Malcolm
>>
>>
>>
>> >>
>>
>

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



Re: Querysets and includes

2008-09-22 Thread Norman Harman

Charles Choiniere wrote:
> On Mon, Sep 22, 2008 at 10:46 AM, Norman Harman <[EMAIL PROTECTED] 
> > wrote:
> 
> 
> nek4life wrote:
>  > How would I go about getting a queryset into an include?  Say I
> have a
>  > blog and I have a page for the post detail.  On the sidebar I would
>  > like to have the blog categories dynamically built or have recent
>  > articles, or recent comments, etc...  What would be the best approach
>  > to build these "widgets" for use on multiple pages?  Any help
> would be
>  > much appreciated.  Thanks.
> 
> Custom Template Tags?
> 
> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags
> 
> 
> --
> Norman J. Harman Jr.
> Senior Web Specialist, Austin American-Statesman
> 
> ___
> Get off the sidelines and huddle up with the Statesman all season long
> for complete high school, college and pro coverage in print and online!
> 
> 
> 
> I was looking at that and found the inclusions tags and that looks like 
> what I need, however I'm a little unsure about where to put this 
> function.  Would I put this in the model I want to pull the data from? 
>  I haven't extended the templating system before so I'm a wee bit confused. 

http://docs.djangoproject.com/en/dev/topics/templates/#custom-libraries-and-template-inheritance

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags

"The app should contain a templatetags directory, at the same level as 
models.py, views.py, etc. If this doesn’t already exist, create it - 
don’t forget the __init__.py file to ensure the directory is treated as 
a Python package.

Your custom tags and filters will live in a module inside the 
templatetags directory. The name of the module file is the name you’ll 
use to load the tags later, so be careful to pick a name that won’t 
clash with custom tags and filters in another app."

Saying all that, depending on what you're actually doing, putting the 
actual "logic" into a method on a model that the template tag calls (as 
opposed to putting the logic in the template tag itself) might make 
sense.  In other instances it might not.

Very general rule:

   If it's doing display/formating type stuff put it in the template tag.

   If it's doing db stuff, calculations based on model fields, proly 
should be in the model.

This is a core of OO & MVC.  each layer/object should do it's thing and 
not get involved in what other layers/objects are doing.


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the sidelines and huddle up with the Statesman all season long
for complete high school, college and pro coverage in print and online!

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



Re: Change text box to a drop down box in the admin interface?

2008-09-22 Thread Jason

Thanks for the reply Karen.

With that being said I would still like to know just how easy or hard
it is to switch something like this around. In real terms its only a
minor change. Can this be achieved with a few lines in my admin.py
file or would I have to do this another way?



On Sep 22, 5:04 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 22, 2008 at 11:51 AM, Jason <[EMAIL PROTECTED]> wrote:
>
> > Could someone help with this?
>
> > The admin panel is automatically generating my model. This is my
> > model.
>
> > title = models.CharField(...)
> > parent = models.CharField(..., null = True)
>
> > The admin panel is currently displaying 2 text input boxes.
>
> > What I want to display is a single text input box for the title field
> > and a dropdown box containing "" and an array of  titles as the parent
> > field.
>
> > To make it clearer.
>
> > Title : # Text Input Box
> > Parent: # Dropdown containing category titles.
>
> > The question is how do I do this. I am new to Django and have waded
> > through the ModelAdmin documentation but just can't get this going.
>
> > Any ideas on how I can achieve this?
>
> It rather sounds like a better fit for what you want to achieve is for your
> 'parent' field to be a ForeigKey to self instead of an independent
> CharField.  Assuming your model's __unicode__ function returns the 'title'
> field you'll get exactly what you are looking for in the admin interface
> without any special customization.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Abstract Superclass and Foreign Keys

2008-09-22 Thread Peter Bailey

Malcolm, (or any other knowledgeable soul), I have been experimenting
with both abstract classes and Generic Foreign Keys and Relations to
solve my issues, and I still have some problems and questions. There
are not a lot of examples of those, and what I really need is for this
all to work properly in the admin so I can add a page and in the page
inline be able to add any sub-classed "Item". Can you tell me if that
type of functionality is supported in Admin yet with generic keys?

Also, I discovered my issue above when I was writing some backend code
to generate pages from the data collected in the Admin. The foreign
key issue then became apparent. One thing I am trying to wrap my head
around however is that when using my original model as above, the
Admin app handled everything correctly. I was able to add several
different item sub-types individually and attach them to pages without
problem, and everything seemed to work fine and things also seemed
correct in the database, So I guess I completely see the logic of why
a generic key would be required, but the Admin seems to work with what
I gave it correctly - I know it has a lot of magic, but I keep going
back and thinking if the Admin can work properly with this, there must
be a way that I can too. Very frustrating. Thoughts anyone (maybe I am
losing it :-) .

Thanks again,

Peter


On Sep 16, 9:37 am, Peter Bailey <[EMAIL PROTECTED]> wrote:
> Thanks for the responses. There are a number of subclasses and I won't
> know the specifics initially. I'll check out the GenericForeighnKey.
> Sounds like it is what I want.
>
> Thanks again,
>
> Peter
>
> On Sep 16, 8:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Mon, 2008-09-15 at 18:10 -0700, Peter Bailey wrote:
> > > Hi all. I have a set of classes (web page items like radios,
> > > checkboxes, etc.) They are built on asuperclass- Item.  I need a
> > > join table to link them to specific pages in which I also store a
> > > position (PageItem) . Here is a snippet:
>
> > > #
> > > ---
> > >  ---
> > > # will use this for subclassing into our item subtypes
> > > #
> > > ---
> > >  ---
>
> > > class Item(models.Model):
> > >    name = models.CharField(max_length=30)
>
> > >    def __unicode__(self):
> > >        return self.name
>
> > >    class Meta:
> > >        abstract = True
>
> > > #
> > > ---
> > >  ---
>
> > > class Page(models.Model):
> > >    website = models.ForeignKey(Website)
> > >    position = models.IntegerField()
> > >    file_name = models.CharField(max_length=50)
> > >    h1_title = models.CharField(max_length=50)
>
> > >    def __unicode__(self):
> > >            return self.file_name
>
> > >    class Meta:
> > >        ordering = ["file_name"]
>
> > > #
> > > ---
> > >  ---
>
> > > class PageItem(models.Model):
> > >    page = models.ForeignKey(Page, editable=False)
> > >    item = models.ForeignKey(Item) # WANT THIS TO POINT TO SPECIFIC
> > > SUBCLASS ITEM
> > >    position = models.IntegerField()
>
> > >    def name(self):
> > >            return str(self.item.name)
>
> > >    class Meta:
> > >            ordering = ['position']
>
> > > #
> > > ---
> > >  ---
>
> > > class RadioBoxType(Item):
> > >    """A Radio Button object with its specific attributes"""
> > >        . etc.
>
> > > My problem is that I want the item/page relationship in the join table
> > > PageItem, so I can track the position. I realize that I can't have a
> > > fk to an abstract class though and obviously want it to point to the
> > > subclassed object.
>
> > So point it at the subclass you want it to point at.
>
> > If you mean, however, that you want it to point to one of a number of
> > possible subclasses, depending on the instance, then that isn't a
> > ForeignKey (a ForeignKey points to one particular model). What you're
> > modelling in that case is best done with the GenericForeignKey, since
> > that encodes both the content type (i.e. the model type) of the target
> > as well as the primarykeyvalue.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ModelChoiceField with Unique Results

2008-09-22 Thread BobZ

What I'm trying to do seems relatively simple, but I have yet to find
a proper solution for it.

I'm trying to query a list of years from a database of registered
vehicles in my county and display them in a drop-down select menu in a
form.

Since the registered vehicles database has many  cars of the same
year,  I need to make those results from the query display in a unique
(no duplicate 2007 options for example), descending order when the
select menu is clicked.

Here's what I've been using so far in my forms.py file:
#class SearchForm(forms.ModelForm):
#year = forms.ModelChoiceField
#class Meta:
#model = Vehicle

This only gives me an empty text field.
I'm fairly new to Django, so any help would be greatly appreciated.

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



Re: View error in tutorial 3 (URLCONF)

2008-09-22 Thread Karen Tracey
On Mon, Sep 22, 2008 at 11:52 AM, Caisys <[EMAIL PROTECTED]> wrote:

>
> Hi,
> I am following the tutorials on django website. My problem is that
> when i create url conf for views that do not exist, the admin site
> ceases to work.
> Mysite\urls.py includes:
> (r'^admin/(.*)', admin.site.root),
> (r'^polls/', include('mysite.polls.urls')),
> Mysite\Polls\urls.py includes:
> urlpatterns = patterns('mysite.polls.views',
>(r'^$', 'index'),
>(r'^(?P\d+)/$', 'detail'),
>(r'^(?P\d+)/results/$', 'results'),
>(r'^(?P\d+)/vote/$', 'vote'),
>
> )
>
> The thing is results & votes views do not exist yet, so I can
> understand if they generate an error, but why does a reequest to http:\
> \127.0.0.1:8000\admin generate an error :  'module' object has no
> attribute 'vote'
> ???
> Thanks
>
>
Admin uses reverse url lookups to generate links on the admin pages.
Reverse lookups require that all your urlpatters be valid, since it scans
through them all.  Therefore it's best not to include not-yet-implemented
stuff in your urlpatters, just comment them out until you really do
implement the functions.

Karen

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



Re: Change text box to a drop down box in the admin interface?

2008-09-22 Thread Karen Tracey
On Mon, Sep 22, 2008 at 11:51 AM, Jason <[EMAIL PROTECTED]> wrote:

>
> Could someone help with this?
>
> The admin panel is automatically generating my model. This is my
> model.
>
> title = models.CharField(...)
> parent = models.CharField(..., null = True)
>
> The admin panel is currently displaying 2 text input boxes.
>
> What I want to display is a single text input box for the title field
> and a dropdown box containing "" and an array of  titles as the parent
> field.
>
> To make it clearer.
>
> Title : # Text Input Box
> Parent: # Dropdown containing category titles.
>
> The question is how do I do this. I am new to Django and have waded
> through the ModelAdmin documentation but just can't get this going.
>
> Any ideas on how I can achieve this?
>

It rather sounds like a better fit for what you want to achieve is for your
'parent' field to be a ForeigKey to self instead of an independent
CharField.  Assuming your model's __unicode__ function returns the 'title'
field you'll get exactly what you are looking for in the admin interface
without any special customization.

Karen

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



View error in tutorial 3 (URLCONF)

2008-09-22 Thread Caisys

Hi,
I am following the tutorials on django website. My problem is that
when i create url conf for views that do not exist, the admin site
ceases to work.
Mysite\urls.py includes:
(r'^admin/(.*)', admin.site.root),
(r'^polls/', include('mysite.polls.urls')),
Mysite\Polls\urls.py includes:
urlpatterns = patterns('mysite.polls.views',
(r'^$', 'index'),
(r'^(?P\d+)/$', 'detail'),
(r'^(?P\d+)/results/$', 'results'),
(r'^(?P\d+)/vote/$', 'vote'),

)

The thing is results & votes views do not exist yet, so I can
understand if they generate an error, but why does a reequest to http:\
\127.0.0.1:8000\admin generate an error :  'module' object has no
attribute 'vote'
???
Thanks

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



Change text box to a drop down box in the admin interface?

2008-09-22 Thread Jason

Could someone help with this?

The admin panel is automatically generating my model. This is my
model.

title = models.CharField(...)
parent = models.CharField(..., null = True)

The admin panel is currently displaying 2 text input boxes.

What I want to display is a single text input box for the title field
and a dropdown box containing "" and an array of  titles as the parent
field.

To make it clearer.

Title : # Text Input Box
Parent: # Dropdown containing category titles.

The question is how do I do this. I am new to Django and have waded
through the ModelAdmin documentation but just can't get this going.

Any ideas on how I can achieve this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to?: My micro-isv website, django style

2008-09-22 Thread mamcxyz

Ok, I'm doing a new version of a system I made to take orders in
mobile device and I'm working now for reach the global market
(latinamerica, USA & maybe some of europa).

My current website is not very informative. I wanna have a decent ISV
website & plan do it all with django. I'm looking in the best way to:

- Have docs
- Register users
- Minimal paypal integration
- Newsletters
- Multi-language (spanish - english only)

I'm hunting for ready-to-go options to get this. The documentation
part is the most tricky for me. I wanna be able to do something like
the django docs ;). I think a wiki is the way to go, but wonder what
is the best option, where best is:

- In django, or easy to integrate
- A decent editor (not wanna do raw markdown anymore!)
- Writer friendly
- Multilanguage

Also, any idea in how make a community? A important part of this
system is the ability to give to anyone to build a integrator (in
python) to any crm/erp in the market. I need do a kind of "integrator
catalog".

I don't know if put a forum, or look for a more simple & light way to
manage request and stuff like that...

I'm a lonely wolf so I like the simplest way... if possible.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm, one form, two models

2008-09-22 Thread Joseph Kocherhans

On Mon, Sep 22, 2008 at 8:57 AM, diN0bot <[EMAIL PROTECTED]> wrote:
>
> Seems like Joseph's problem is typical for User/Profile work.
>
> Initially I used the same inheritance model as he does. Working with a
> single form in the view and template is a win for code re-use and
> simplicity.
>
> I looked into formsets but haven't gotten it to work with multiple
> model types. It seems like I should be able to show the User form with
> the Profile inlined, right?

No. Formsets are designed to work with instances of a single model
type. Inline formsets are closer to what you want, but really, that
adds a lot more complication that just writing 2 forms would. Even if
you *do* use an inline formset, you're still going to have to render
both the form and the formset.

> My solution is to create a class that generalizes working with
> multiple model forms. Or rather, it abstract the multiple form
> handling and printing behind a Form interface so that the view and
> template don't know the difference. It'd be nice to make more use of
> formsets or provided code since I feel like I've reinvented the wheel.

You aren't reinventing the wheel. There isn't code in Django to do
what you're trying to do. If you really feel like you need to write
some sort of wrapper for this, I'd suggest keeping the case you deal
with down to a simple situation: 1 child object with a OneToOneField
or a ForeignKey to a parent object.

Joseph

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



Re: Django + Active Directory + Firebird DB ???

2008-09-22 Thread mamcxyz

Also, depending in your situation, you can use a "master" database and
use remote views to consolidate the diferents databases and code just
like was a single one. This is a feature on Sql Server and I think is
sure that exist for postgress.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is possible this hack for the admin? Get user & current item in the save

2008-09-22 Thread mamcxyz

Any idea in how do this?

How catch the request on the save method?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom tags and "extends"

2008-09-22 Thread Karish

I wrote a very simple custom tag, called oneline, which stips all
newline characters from whatever is inside it.

I want to use it in a base template like this (base.txt):
{% load text %}{% oneline %}
{% block body %}{% endblock %}
{% endoneline %}

In the derived template (derived.txt) I just do:

{% extends 'mail/base.subject' %}
{% block body %}
a
b
c
{% endblock %}

But this doesn't work. The oneline tag that I wrote doesn't actually
see the node of the block within the render function.

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



Re: Authentication: user_passes_test() - issue

2008-09-22 Thread R. Gorman

I'm not 100% sure I understand your question, but I believe you're
asking how to pass the model object to the view that will verify if
the request was made by a certain user.  If so, you should look at
using the url template tags (http://docs.djangoproject.com/en/dev/ref/
templates/builtins/#url).  With this you can pass arguments to a view,
in your case 'model'.

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



Re: ordering results of a queryset by foreign fields

2008-09-22 Thread Rajesh Dhawan


> Thank you too, Karen, for your help.
> In fact i am using the 0.96 and the problem is that i can't upgrade to
> the 1.0 right now because the project i'm working on started months
> ago and we are near the end date.. we can't rewrite the application to
> be compatible with the 1.0 in such a few time..
>
> Just to be straight: is there a way to make this work also on 0.96?
> because otherwise we will tell the client that this feature isn't
> going to work and we will take our time to update the code... but
> obviously this is the last solution (we'd prefer not to miss the end
> date) and i'm trying very hard to make it work anyway..

You have several options:

1. Migrate your app to Django 1.0. The downside is that this will take
you some time to implement and test.

2. Denormalize some of your ordering related data. For example, add an
author surname column to your Version table. I know you said you don't
want to change the table structure. But adding this column is not such
a big deal if you must have the ordering working by your deadline. If
you go this route, you will need:

a. a one-time script that populates the author surname for all your
existing version rows.

b. a small change to your Version.save() method to populate the author
surname field every time a new Version instance is created.

Then you can directly order by that field without having to follow a 4-
level deep relation.

This approach will work if your Django app is the only way to create
and update your data because you are then able to ensure that the
surname field is always in sync.

See more on denormalization below, if you're interested (or if you
think that this is bad DB design practice :) :

http://highscalability.com/scaling-secret-2-denormalizing-your-way-speed-and-profit

-Rajesh D

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



Re: Querysets and includes

2008-09-22 Thread Charles Choiniere
On Mon, Sep 22, 2008 at 10:46 AM, Norman Harman <[EMAIL PROTECTED]>wrote:

>
> nek4life wrote:
> > How would I go about getting a queryset into an include?  Say I have a
> > blog and I have a page for the post detail.  On the sidebar I would
> > like to have the blog categories dynamically built or have recent
> > articles, or recent comments, etc...  What would be the best approach
> > to build these "widgets" for use on multiple pages?  Any help would be
> > much appreciated.  Thanks.
>
> Custom Template Tags?
>
> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags
>
>
> --
> Norman J. Harman Jr.
> Senior Web Specialist, Austin American-Statesman
> ___
> Get off the sidelines and huddle up with the Statesman all season long
> for complete high school, college and pro coverage in print and online!
>
> >
>
I was looking at that and found the inclusions tags and that looks like what
I need, however I'm a little unsure about where to put this function.  Would
I put this in the model I want to pull the data from?  I haven't extended
the templating system before so I'm a wee bit confused.

-- 
Charles Choiniere

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



Re: Model/admin page problem

2008-09-22 Thread tsmets

Correct 
I, of course, added after synching and it looked everything was fine
Tx,

\T,



On Sep 22, 3:29 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 22, 2008 at 9:10 AM, tsmets <[EMAIL PROTECTED]> wrote:
> > I am running 1.0 on sqlite3 and I keep on getting
> > [snip]
> > TemplateSyntaxError at /admin/
>
> > Caught an exception while rendering: no such table: django_admin_log
>
> > [snip]
> > What is wrong in my set up ... ?
>
> It seems you did not have  'django.contrib.admin' listed in your
> INSTALLED_APPS when you ran syncdb.  So, check what you have in
> INSTALLED_APPS.  If it does not include 'django.contrib.admin', add it.  You
> need to re-run syncdb with 'django.contrib.admin' listed in INSTALLED_APPS
> in order to get the tables admin uses created in the db.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Querysets and includes

2008-09-22 Thread Norman Harman

nek4life wrote:
> How would I go about getting a queryset into an include?  Say I have a
> blog and I have a page for the post detail.  On the sidebar I would
> like to have the blog categories dynamically built or have recent
> articles, or recent comments, etc...  What would be the best approach
> to build these "widgets" for use on multiple pages?  Any help would be
> much appreciated.  Thanks.

Custom Template Tags? 
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the sidelines and huddle up with the Statesman all season long
for complete high school, college and pro coverage in print and online!

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



Re: ordering results of a queryset by foreign fields

2008-09-22 Thread Vokial

Mmmmh both of you made it clear: i've got to upgrade to django 1.0...

Again thank you for your help, i'll see what i can do about that.

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



Re: ordering results of a queryset by foreign fields

2008-09-22 Thread Vokial

Thank you too, Karen, for your help.
In fact i am using the 0.96 and the problem is that i can't upgrade to
the 1.0 right now because the project i'm working on started months
ago and we are near the end date.. we can't rewrite the application to
be compatible with the 1.0 in such a few time..

Just to be straight: is there a way to make this work also on 0.96?
because otherwise we will tell the client that this feature isn't
going to work and we will take our time to update the code... but
obviously this is the last solution (we'd prefer not to miss the end
date) and i'm trying very hard to make it work anyway..






On 22 Set, 16:19, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 22, 2008 at 10:04 AM, Vokial <[EMAIL PROTECTED]> wrote:
>
> > Thank you for the answer.
>
> > I already read the page you linked me (the django documentation is
> > becoming my second home :) ) and i tried what you said but i got this
> > error:
> > OperationalError at /search/1/
> > (1054, "Unknown column
> > 'images_version.shoot__subject__photographer__surname' in 'order
> > clause'")
>
> > [snip]
>
> What version of Django are you using?  Anything prior to when the
> queryset-refactor branch was merged to trunk was notoriously fragile about
> ordering on related fields. If you are trying to use 0.96 for this, you
> probably need to upgrade to 1.0.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Querysets and includes

2008-09-22 Thread nek4life

How would I go about getting a queryset into an include?  Say I have a
blog and I have a page for the post detail.  On the sidebar I would
like to have the blog categories dynamically built or have recent
articles, or recent comments, etc...  What would be the best approach
to build these "widgets" for use on multiple pages?  Any help would be
much appreciated.  Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ordering results of a queryset by foreign fields

2008-09-22 Thread Rajesh Dhawan



On Sep 22, 10:04 am, Vokial <[EMAIL PROTECTED]> wrote:
> Thank you for the answer.
>
> I already read the page you linked me (the django documentation is
> becoming my second home :) ) and i tried what you said but i got this
> error:
> OperationalError at /search/1/
> (1054, "Unknown column
> 'images_version.shoot__subject__photographer__surname' in 'order
> clause'")

You are using Django 1.0, right? That order_by call won't work with
0.96.

You may have to add a select_related() clause to the query like this:
Version.objects.select_related().order_by('shoot__subject__photographer__surname')

Also, it helps people follow the stream of discussions better if you
don't top post your responses (people can't tell what part you are
responding to.)

>
> Ok let's be more precise in the explanation (i tried to be as simple
> as i could but maybe i left out something important, sorry).
>
> The application is a search engine for a very big (i mean VERY big)
> database of images. The actual image files are stored in the Version
> table.. the other 2 tables are just there to sort the images (every
> table has about 20 attributes, like size in pixel, size in cm, date,
> camera settings and so on).
> The search fields are divided into 2 groups: "filter(**filter)" for
> Version attributes and "filtersubj(**filter)" for Subject attributes.
> Filters are defined by various request.session['field'] coming from
> the template form. If the user leaves out a field, it's left out from
> the filter.
>
> Starting from the search part (i hope it keeps the indentation.. ):
>
> version_id = []
> subjects = Subject.objects.filter(**filtersubj)
> subjs = Subject.objects.filter(Q(title__icontains=(str(text))) |
> Q(caption__icontains=(str(text
> for subj in subjs:
>shoots = Shoot.objects.filter(subject =
> subj.id).filter(description__icontains=(str(text))).filter(**filtershoot)
>for shoot in shoots:
>   vers =
> Version.objects.filter(shoot=shoot.id).filter(description__icontains=(str(t­ext)))
>   for version in vers:
>  version_id.append(version.id)
> version = Version.objects.filter(id__in = version_id).filter(**filter)
>
> Up to now i can get the various versions filtered. Now i need to add
> some ordering options: by image size, by author surname and a couple
> of other cases.
>
> The ordering options are chosen by the user from a form and are linked
> in a series of if-else, like:
> if size:
>   **order by size**
> else:
>   if author:
> **order by author**
> 
>
> I tried the select_related option but it can't get the Author table
> since it's outside the actual app...

It should not matter that the Author table is in a different app.

It would help if you included the queries that you tried.


> i can get up to
> subject_photographer.id.. i tried also to use this photographer.id to
> create a list of authors, appending every single author it can find in
> the list and then i tried to filter the subject by this list, to get
> the shoot starting from the subject and then the version from the
> shoot..but at this point i still can't order the results by surname :(
>
> I think it might be easier than it looks but i'm really stuck and i
> can't see a solution..

You really want to make sure you are on Django 1.0.

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



Re: ordering results of a queryset by foreign fields

2008-09-22 Thread Karen Tracey
On Mon, Sep 22, 2008 at 10:04 AM, Vokial <[EMAIL PROTECTED]> wrote:

>
> Thank you for the answer.
>
> I already read the page you linked me (the django documentation is
> becoming my second home :) ) and i tried what you said but i got this
> error:
> OperationalError at /search/1/
> (1054, "Unknown column
> 'images_version.shoot__subject__photographer__surname' in 'order
> clause'")
>
> [snip]

What version of Django are you using?  Anything prior to when the
queryset-refactor branch was merged to trunk was notoriously fragile about
ordering on related fields. If you are trying to use 0.96 for this, you
probably need to upgrade to 1.0.

Karen

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



Re: ordering results of a queryset by foreign fields

2008-09-22 Thread Vokial

Thank you for the answer.

I already read the page you linked me (the django documentation is
becoming my second home :) ) and i tried what you said but i got this
error:
OperationalError at /search/1/
(1054, "Unknown column
'images_version.shoot__subject__photographer__surname' in 'order
clause'")

Ok let's be more precise in the explanation (i tried to be as simple
as i could but maybe i left out something important, sorry).

The application is a search engine for a very big (i mean VERY big)
database of images. The actual image files are stored in the Version
table.. the other 2 tables are just there to sort the images (every
table has about 20 attributes, like size in pixel, size in cm, date,
camera settings and so on).
The search fields are divided into 2 groups: "filter(**filter)" for
Version attributes and "filtersubj(**filter)" for Subject attributes.
Filters are defined by various request.session['field'] coming from
the template form. If the user leaves out a field, it's left out from
the filter.

Starting from the search part (i hope it keeps the indentation.. ):

version_id = []
subjects = Subject.objects.filter(**filtersubj)
subjs = Subject.objects.filter(Q(title__icontains=(str(text))) |
Q(caption__icontains=(str(text
for subj in subjs:
   shoots = Shoot.objects.filter(subject =
subj.id).filter(description__icontains=(str(text))).filter(**filtershoot)
   for shoot in shoots:
  vers =
Version.objects.filter(shoot=shoot.id).filter(description__icontains=(str(text)))
  for version in vers:
 version_id.append(version.id)
version = Version.objects.filter(id__in = version_id).filter(**filter)

Up to now i can get the various versions filtered. Now i need to add
some ordering options: by image size, by author surname and a couple
of other cases.

The ordering options are chosen by the user from a form and are linked
in a series of if-else, like:
if size:
  **order by size**
else:
  if author:
**order by author**


I tried the select_related option but it can't get the Author table
since it's outside the actual app... i can get up to
subject_photographer.id.. i tried also to use this photographer.id to
create a list of authors, appending every single author it can find in
the list and then i tried to filter the subject by this list, to get
the shoot starting from the subject and then the version from the
shoot..but at this point i still can't order the results by surname :(

I think it might be easier than it looks but i'm really stuck and i
can't see a solution..

:(




On 22 Set, 15:36, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > I can't order the results of a queryset by a field in a related
> > table..
>
> Have you 
> seen:http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-f...
>
>
>
> > I have this set of applications (they are far more complex, i'm
> > cutting out all the unnecessary parts):
>
> > images app:
> > class Subject(models.Model):
> > photographer = models.ForeignKey(Author)
> > [... a lot more stuff..]
>
> > class Shoot(models.Model):
> > subject = models.ForeignKey(Subject)
> > [... again a lot more stuff..]
>
> > class Version(models.Model):
> > shoot = models.ForeignKey(Shoot)
> > [...yet even more stuff.. ]
>
> > lists app:
> > class Author(models.Model):
> > name = models.CharField(max_length=50)
> > surname = models.CharField(max_length=50)
>
> > So basically the relation goes like: version <- shoot <- subject ->
> > author
>
> > Ok.. i need to order the results of a Version.objects.all() query by
> > author surname... with no success.. can someone help me to write the
> > correct syntax to do this?
>
> You didn't mention what you've tried so far that didn't work for you.
> Have you tried the following?
>
> Version.objects.all().order_by('shoot__subject__photographer__surname')
>
> -Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm, one form, two models

2008-09-22 Thread diN0bot

Seems like Joseph's problem is typical for User/Profile work.

Initially I used the same inheritance model as he does. Working with a
single form in the view and template is a win for code re-use and
simplicity.

I looked into formsets but haven't gotten it to work with multiple
model types. It seems like I should be able to show the User form with
the Profile inlined, right?

My solution is to create a class that generalizes working with
multiple model forms. Or rather, it abstract the multiple form
handling and printing behind a Form interface so that the view and
template don't know the difference. It'd be nice to make more use of
formsets or provided code since I feel like I've reinvented the wheel.

diN0.

On Sep 10, 11:48 am, "Joseph Kocherhans" <[EMAIL PROTECTED]>
wrote:
> On Wed, Sep 10, 2008 at 6:59 AM, Michel Thadeu Sabchuk
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > Hi guys,
>
> > What is the best way to work with 2 models on the same forms? Suppose
> > I have the following case:
>
> > class Profile(models.Models):
> >    user = models.ForeignKey(User)
> >    some_data = models.CharField()
>
> > How can I add a profile and a user on the same form using ModelForm? I
> > used to do:
>
> > class ProfileForm(models.ModelForm):
> >    class Meta:
> >        model = Profile
> >    first_name = models.CharField()
> >    last_name = models.CharField()
> >    email = models.EmailField()
>
> Use 2 separate ModelForms. One for each model. If the 2 models happen
> to have overlapping field names, you can use the 'prefix' argument to
> the form to avoid name collisions.
>
> One bit to be wary of is calling form.is_valid() in your view. If you
> have something like this:
>
> if user_form.is_valid() and profile_form.is_valid():
>     # save stuff
>
> and user_form.is_valid is False, profile_form.is_valid() won't be
> called. I usually write a function called all_valid(list_of_forms)
> that calls is_valid() on each form and returns False if any of them
> fail.
>
> Joseph
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ordering results of a queryset by foreign fields

2008-09-22 Thread Rajesh Dhawan

Hi,

> I can't order the results of a queryset by a field in a related
> table..

Have you seen:
http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields


> I have this set of applications (they are far more complex, i'm
> cutting out all the unnecessary parts):
>
> images app:
> class Subject(models.Model):
> photographer = models.ForeignKey(Author)
> [... a lot more stuff..]
>
> class Shoot(models.Model):
> subject = models.ForeignKey(Subject)
> [... again a lot more stuff..]
>
> class Version(models.Model):
> shoot = models.ForeignKey(Shoot)
> [...yet even more stuff.. ]
>
> lists app:
> class Author(models.Model):
> name = models.CharField(max_length=50)
> surname = models.CharField(max_length=50)
>
> So basically the relation goes like: version <- shoot <- subject ->
> author
>
> Ok.. i need to order the results of a Version.objects.all() query by
> author surname... with no success.. can someone help me to write the
> correct syntax to do this?

You didn't mention what you've tried so far that didn't work for you.
Have you tried the following?

Version.objects.all().order_by('shoot__subject__photographer__surname')

-Rajesh D

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



Re: Model/admin page problem

2008-09-22 Thread Karen Tracey
On Mon, Sep 22, 2008 at 9:10 AM, tsmets <[EMAIL PROTECTED]> wrote:

> I am running 1.0 on sqlite3 and I keep on getting
> [snip]
> TemplateSyntaxError at /admin/
>
> Caught an exception while rendering: no such table: django_admin_log
>
> [snip]
> What is wrong in my set up ... ?
>

It seems you did not have  'django.contrib.admin' listed in your
INSTALLED_APPS when you ran syncdb.  So, check what you have in
INSTALLED_APPS.  If it does not include 'django.contrib.admin', add it.  You
need to re-run syncdb with 'django.contrib.admin' listed in INSTALLED_APPS
in order to get the tables admin uses created in the db.

Karen

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



Re: Model/admin page problem

2008-09-22 Thread tsmets



I am running 1.0 on sqlite3 and I keep on getting
[snip]
TemplateSyntaxError at /admin/

Caught an exception while rendering: no such table: django_admin_log

Original Traceback (most recent call last):
  File "C:\Python25\lib\site-packages\django\template\debug.py", line
71, in render_node
result = node.render(context)
  File "C:\Python25\Lib\site-packages\django\template\defaulttags.py",
line 244, in render
if (value and not ifnot) or (ifnot and not value):
  File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
185, in __nonzero__
iter(self).next()
  File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
179, in _result_iter
self._fill_cache()
  File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
612, in _fill_cache
self._result_cache.append(self._iter.next())
  File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
269, in iterator
for row in self.query.results_iter():
  File "C:\Python25\Lib\site-packages\django\db\models\sql\query.py",
line 206, in results_iter
for rows in self.execute_sql(MULTI):
  File "C:\Python25\Lib\site-packages\django\db\models\sql\query.py",
line 1700, in execute_sql
cursor.execute(sql, params)
  File "C:\Python25\Lib\site-packages\django\db\backends\util.py",
line 19, in execute
return self.cursor.execute(sql, params)
  File "C:\Python25\Lib\site-packages\django\db\backends
\sqlite3\base.py", line 167, in execute
return Database.Cursor.execute(self, query, params)
OperationalError: no such table: django_admin_log

Request Method: GET
Request URL:http://localhost:8000/admin/
Exception Type: TemplateSyntaxError
Exception Value:

Caught an exception while rendering: no such table: django_admin_log

Original Traceback (most recent call last):
  File "C:\Python25\lib\site-packages\django\template\debug.py", line
71, in render_node
result = node.render(context)
  File "C:\Python25\Lib\site-packages\django\template\defaulttags.py",
line 244, in render
if (value and not ifnot) or (ifnot and not value):
  File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
185, in __nonzero__
iter(self).next()
  File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
179, in _result_iter
self._fill_cache()
  File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
612, in _fill_cache
self._result_cache.append(self._iter.next())
  File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
269, in iterator
for row in self.query.results_iter():
  File "C:\Python25\Lib\site-packages\django\db\models\sql\query.py",
line 206, in results_iter
for rows in self.execute_sql(MULTI):
  File "C:\Python25\Lib\site-packages\django\db\models\sql\query.py",
line 1700, in execute_sql
cursor.execute(sql, params)
  File "C:\Python25\Lib\site-packages\django\db\backends\util.py",
line 19, in execute
return self.cursor.execute(sql, params)
  File "C:\Python25\Lib\site-packages\django\db\backends
\sqlite3\base.py", line 167, in execute
return Database.Cursor.execute(self, query, params)
OperationalError: no such table: django_admin_log

Exception Location: C:\Python25\lib\site-packages\django\template
\debug.py in render_node, line 81
Python Executable:  C:\Python25\python.exe
Python Version: 2.5.2
Python Path:['C:\\Projects\\mwb\\tools\\django_test', 'C:\
\Python25', 'C:\\Program Files\\IBM\\WebSphere MQ\\bin', 'C:\\Python25\
\python25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\
\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25\
\lib\\site-packages']
Server time:Mon, 22 Sep 2008 14:57:53 +0200
[/snip]

This seems consistent with the logs

C:\Projects\tools\django_test>python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have
any superusers defined.
Would you like to create one now? (yes/no): yes
Username: tsmets
E-mail address: [EMAIL PROTECTED]
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model



What is wrong in my set up ... ?


\T,


















On Jul 31, 7:49 pm, Martin Diers <[EMAIL PROTECTED]> wrote:
> Hello Alaric, welcome aboard!
>
> You are currently running Django 0.96.
>
> There have been a massive number of changes to Django since then, not  
> the least of which is an entirely new Admin system which separates the  
> Admin configuration from the model, and a refactoring of the Queryset  
> system.
>
> I would strongly suggest you upgrade to the SVN version, or,  
> alternately, wait for 1.0beta1 which is due out next week sometime.
>
> On Jul 31, 2008, at 12:21 PM, Alaric Haag wrote:
>
>
>
> > Hello all
>
> > This i

ordering results of a queryset by foreign fields

2008-09-22 Thread Vokial

Hi!

I can't order the results of a queryset by a field in a related
table..

I have this set of applications (they are far more complex, i'm
cutting out all the unnecessary parts):

images app:
class Subject(models.Model):
photographer = models.ForeignKey(Author)
[... a lot more stuff..]

class Shoot(models.Model):
subject = models.ForeignKey(Subject)
[... again a lot more stuff..]

class Version(models.Model):
shoot = models.ForeignKey(Shoot)
[...yet even more stuff.. ]


lists app:
class Author(models.Model):
name = models.CharField(max_length=50)
surname = models.CharField(max_length=50)

So basically the relation goes like: version <- shoot <- subject ->
author

Ok.. i need to order the results of a Version.objects.all() query by
author surname... with no success.. can someone help me to write the
correct syntax to do this?

Bear in mind that the table structure is fixed, i can't change it
because i'm working for a client who asked specifically this
structure.

I did some research in this group but i couldn't find the answer.. can
anyone please help me writing the correct syntax for the queryset?

Thank you in advance!

-Vokial-

PS. sorry for any grammar errors, i'm not english (as you might have
guessed :P )

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



Re: Django + Active Directory + Firebird DB ???

2008-09-22 Thread Bubblegum

Hi Erik,

Thank you a lot for your reply. I looked more deeply into Django +
LDAP + Active Directory connectivity and it looks that an
authentication/authorization is viable and can be achieved. Here is
the link for potential solution: http://www.djangosnippets.org/snippets/501/

Thnks a lot for links toward multiple-DB connectivity. I will
definitely investigate. Of course I may have further things to be
cleared out for me regarding the topic, so I may return with further
question later this week.

Again, thanks a lot.

Sincerely,
stefan

On Sep 22, 11:21 am, Erik Allik <[EMAIL PROTECTED]> wrote:
> Hi and welcome to Django!
>
> On 22.09.2008, at 11:39, Bubblegum wrote:
>
> > I am searching for a solution to following problem. I was asked to
> > write a simple web UI for particular organization, who uses M$ Active
> > Directory for authentication/authorization purposes. Moreover their
> > DBs are Firebird/Interbase exclusively. They have plenty of em on
> > multiple hosts... The web UI I am about to write will gradually take
> > over all the databases and their systems.
>
> > I was left freedom to pick own environment for the task. So I opted
> > for a Linux box and Python. I want to avoid using PHP if possible. But
> > I am not sure if with Django I am on a right track, so I am looking
> > for an advice while I dig too deep finding I went wrong direction.
>
> What are your functional/feature/performance etc. requirements? Not  
> that I'm an expert on this but someone more experienced can help you  
> if you provide more information.
>
> > First I want to use company's Active Directory to do authentication/
> > authorization. I know that I can interact with Active Directory over
> > Python's LDAP module. I am not sure if I can force Django to use
> > Active Directory instead of default DB authentication/authorization. I
> > am sure I will have to write a module for that. I just want to know if
> > it is possible and maybe some entry point for the start.
>
> There's really lots of articles and material to be found on the  
> internet about Django and LDAP authentication. Writing a custom  
> authentication backend for Django is not difficult. Lots of people  
> need to authenticate against LDAP so I'm sure you'll find existing  
> working code for ya.
>
> > Second issue is with the RDBMS they use. It is Firebird/Interbase with
> > several databases on several hosts. So far I found that there is a
> > Firebird database connector for Django. So I assume that I will be
> > able to use Models and other cool Django's DB stuff with Firebird as
> > well. What I am concerned is that as far as I understand Django is
> > commited to single mutually exclusive relationship to just one
> > database. I need to know whether I can tell Django that there are
> > different hosts and different databases in a real world and that a
> > little bit of promiscuity won't hurt. Especially when the
> > authentication/authorization will be done through different means and
> > not through the DB.
>
> The multiple database support thing comes up a lot lately. There are  
> plans to implement this in Django as the lower level of the ORM  
> already supports multiple databases. Django still lacks a friendly  
> multi-DB API but I think you can still connect to multiple databases  
> for now using the the somewhat raw approach and wait for Django 1.1  
> (or when the multi-db branch has been created).
>
> http://code.djangoproject.com/wiki/MultipleDatabaseSupport
>
> A recent discussion (that's still going on I think) about multiple  
> database support which I believe will give you clues about how to use  
> multiple databases right 
> now:http://groups.google.com/group/django-developers/browse_thread/thread...
>
> Erik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Authentication: user_passes_test() - issue

2008-09-22 Thread mwebs

Hi,

I my scenario users can only edit some model if thy are also the
authors.
With the permission_required_decorator this is not possible.

So what about the user_passes_test-decorator.
I want to do something like this:

def user_can_edit(user, model):
   if user.is_authenticated and user == model.author:
  return True
   else:
 return False

So the problem is, how do I pass the model? Is there a
way to this, or do I have to write my own decorator?

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



Authentication: user_passes_test() - issue

2008-09-22 Thread mwebs

Hi,

I my scenario users can only edit some model if thy are also the
authors.
With the permission_required_decorator this is not possible.

So what about the user_passes_test-decorator.
I want to do something like this:

def user_can_edit(user, model):
   if user.is_authenticated and user == model.author:
  return True
   else:
 return False

So the problem is, how do I pass the model? Is there a
way to this, or do I have to write my own decorator?

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



Re: Impact of a CustomManager on the RelatedManager

2008-09-22 Thread bruno desthuilliers

On 22 sep, 01:49, gaz <[EMAIL PROTECTED]> wrote:
(snip)
> I have overloaded the default manager in my model to use a slight
> variant of the CurrentSiteManager, shown below.
>
(snip)
> What I am seeing is that the following queries work and present only
> the objects which are on the site (Venue) or objects which are related
> to a Venue on the site (Conference):
>
> Venue.objects.all()
> Conference.objects.all()
>
> However, if I try to get the related objects of a Venue object, I get
> an error as below:
>
(snip)

I might be wrong (only had a very cursory glance at your code), but
I'd say you want to have a look at this:
 
http://docs.djangoproject.com/en/dev/topics/db/managers/#using-managers-for-related-object-access

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django -- very very basic query !

2008-09-22 Thread bruno desthuilliers

On 21 sep, 16:20, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I am basically c/c++/Unix dev, and knowing little python stuff. And
> little bit about xhtml.
> I just wanted to know to learn/develop site using Django, Do i have to
> master of Python, Xhtml , Javascript ?

Well... (x)html is kind of necessary to write even static web pages,
and that whatever the language / technology used, writting server-side
web applications requires at least some basic understanding of the
http protocol.

wrt/ Python, since Django is a Python framework, I fail to see how you
could effectively use the latter without learning the former.

Now note that 'learning' doesn't necessarily imply 'mastering' !-)


> What kind of stuff, i can do using Django ?

Hem... Developping server-side web applications ?-)


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



Re: Cookie problem

2008-09-22 Thread M.Ganesh

plungerman wrote:
> On Sep 19, 11:40 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
>   
>> Getting the following error message when I try to access the admin page
>> of my spanking new django 1.0 installation :
>> "Looks like your browser isn't configured to accept cookies. Please
>> enable cookies, reload this page, and try again."
>> 
>
> are you using a login form that is not using the
> django.contrib.auth.auth_views.login view for GET?  that is, you have
> a form that might be, say, part of your sidebar navigation and that
> form uses that a URI like /accounts/login/ as the action of a "post"
> form, which has as its view  django.contrib.auth.auth_views.login.  if
> that is the case, then you would be seeing the error you described
> above.  we have a couple of clients that wanted a login form on all
> pages in the header.  the action of the form is /accounts/login/ and
> the form would be replaced by user links like change password, update
> info, etc.  the form did not work at first and we saw the same error
> about cookies, which is because that view tries set a test cookie and
> if the test cookie is not present, then upon POST, the form returns
> the cookie error.  the only solution i found was to comment out the
> test cookie portion of the django source, which IMO is not necessary
> and sort of a relic from a time when folks would actually turn off
> cookies for privacy reasons.
>
>   
>> Other information :
>> 1. django 0.96 working well in the same laptop and browser. My
>> production site continues to run
>> 2. Using Firefox 3 on Linux Mint OS (an Ubuntu derivative)
>> 3. In Firefox preferences both 'Accept cookies from sites' and 'Accept
>> third-party cookies' options are enabled
>> 4. My google search brought-up Changeset 8509, but that's t
>> technical for me to comprehend
>> Thanks for the help in advance
>>
>> Regards Ganesh
>> 
Hi plungerman,


Thanks for your mail. I am not trying to do anything complicated (yet). 
I just setup Django 1.0, not even created any models. I just wanted to 
see the admin page before porting my models from the 0.96 installation. 
Could you please hint me how to find and comment out the test cookie 
portion? I am only 6 months old with python and django, but I am willing 
to make an attempt.

Regards Ganesh


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



Re: Where can a save confirmation page be hooked into the admin? (similar to delete confirmation)

2008-09-22 Thread Erik Allik

You can check out how auth.UserAdmin does it, for example. I used that  
as a reference.

Erik

On 22.09.2008, at 14:27, Jacob Rigby wrote:

>
> That's a good idea. It looks I can get by with raising a
> ValidationError in a custom ModelAdmin form; it's almost as clear as a
> confirmation page and just a few lines of code.
>
> Thanks,
> Jacob
>
> On Sep 22, 6:40 pm, Erik Allik <[EMAIL PROTECTED]> wrote:
>> You should check out the ModelAdmin class and how to override certain
>> parts of it such as the save_model, change_view and add_view methods.
>>
>> Hope that helps.
>>
>> Erik
>>
>> On 22.09.2008, at 13:08, Jacob Rigby wrote:
>>
>>
>>
>>> I want to emulate the delete confirmation page behavior before  
>>> saving
>>> certain models in the admin.  In my case if I change one object,
>>> certain others should be deleted as they depend upon the object's  
>>> now
>>> out-of-date state.
>>
>>> I understand where to implement the actual cascaded updates (inside
>>> the parent model's save method), but I don't see a quick way to ask
>>> the user for confirmation (and then rollback if they decide not to
>>> save). I suppose I could implement some weird confirmation logic
>>> directly inside the save method (sort of a two phase save) but that
>>> seems...ugly.
>>
>>> Any thoughts, even general pointers into the django codebase?
>>
>>> Thanks a lot,
>>> Jacob
> >


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



Re: Where can a save confirmation page be hooked into the admin? (similar to delete confirmation)

2008-09-22 Thread Jacob Rigby

That's a good idea. It looks I can get by with raising a
ValidationError in a custom ModelAdmin form; it's almost as clear as a
confirmation page and just a few lines of code.

Thanks,
Jacob

On Sep 22, 6:40 pm, Erik Allik <[EMAIL PROTECTED]> wrote:
> You should check out the ModelAdmin class and how to override certain  
> parts of it such as the save_model, change_view and add_view methods.
>
> Hope that helps.
>
> Erik
>
> On 22.09.2008, at 13:08, Jacob Rigby wrote:
>
>
>
> > I want to emulate the delete confirmation page behavior before saving
> > certain models in the admin.  In my case if I change one object,
> > certain others should be deleted as they depend upon the object's now
> > out-of-date state.
>
> > I understand where to implement the actual cascaded updates (inside
> > the parent model's save method), but I don't see a quick way to ask
> > the user for confirmation (and then rollback if they decide not to
> > save). I suppose I could implement some weird confirmation logic
> > directly inside the save method (sort of a two phase save) but that
> > seems...ugly.
>
> > Any thoughts, even general pointers into the django codebase?
>
> > Thanks a lot,
> > Jacob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANN: Updated Django Cheat Sheet

2008-09-22 Thread Andrew Durdin

On Sep 21, 8:23 am, "Nikos Delibaltadakis" <[EMAIL PROTECTED]>
wrote:
> Shouldn't ForeignKeyField to be just ForeignKey?
> Am I missing something?

No, you're absolutely correct -- thanks for spotting the error!  We'll
get a corrected version out ASAP.

Cheers,

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



Re: Cookie problem

2008-09-22 Thread plungerman

On Sep 19, 11:40 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
> Getting the following error message when I try to access the admin page
> of my spanking new django 1.0 installation :
> "Looks like your browser isn't configured to accept cookies. Please
> enable cookies, reload this page, and try again."

are you using a login form that is not using the
django.contrib.auth.auth_views.login view for GET?  that is, you have
a form that might be, say, part of your sidebar navigation and that
form uses that a URI like /accounts/login/ as the action of a "post"
form, which has as its view  django.contrib.auth.auth_views.login.  if
that is the case, then you would be seeing the error you described
above.  we have a couple of clients that wanted a login form on all
pages in the header.  the action of the form is /accounts/login/ and
the form would be replaced by user links like change password, update
info, etc.  the form did not work at first and we saw the same error
about cookies, which is because that view tries set a test cookie and
if the test cookie is not present, then upon POST, the form returns
the cookie error.  the only solution i found was to comment out the
test cookie portion of the django source, which IMO is not necessary
and sort of a relic from a time when folks would actually turn off
cookies for privacy reasons.

> Other information :
> 1. django 0.96 working well in the same laptop and browser. My
> production site continues to run
> 2. Using Firefox 3 on Linux Mint OS (an Ubuntu derivative)
> 3. In Firefox preferences both 'Accept cookies from sites' and 'Accept
> third-party cookies' options are enabled
> 4. My google search brought-up Changeset 8509, but that's t
> technical for me to comprehend
>
> Thanks for the help in advance
>
> Regards Ganesh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom tag for html fragment with dynamic content

2008-09-22 Thread christian

This is how i am now doing it i call the template:

  {% instance block %}
{% include_feed "http://localhost:8080/feeds/news/"; 5 feeds/
test.html %}
  {% endinstance %}

my code is:

@register.tag(name="instance")
def make_instance(parser, token):
  try:
tag_name, arg = token.contents.split(None,1)
  except ValueError:
msg = '%r tag requires arguments' % token.contents[0]
raise template.TemplateSyntaxError(msg)
  nodelist = parser.parse(('endinstance',))
  parser.delete_first_token()
  return InstanceNode(nodelist)

class InstanceNode(template.Node):
  def __init__(self, nodelist, arg):
self.nodelist = nodelist
self.arg = arg
  def render(self, context):
output = {'content': ''}
output['content'] = self.nodelist.render(context)
return render_to_string("block.html", output)



and my template for the tag is:



{{ content }}



it works like this. i still don't know if this is the correct way to
do this or not?

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



Re: Where can a save confirmation page be hooked into the admin? (similar to delete confirmation)

2008-09-22 Thread Erik Allik

You should check out the ModelAdmin class and how to override certain  
parts of it such as the save_model, change_view and add_view methods.

Hope that helps.

Erik

On 22.09.2008, at 13:08, Jacob Rigby wrote:

>
> I want to emulate the delete confirmation page behavior before saving
> certain models in the admin.  In my case if I change one object,
> certain others should be deleted as they depend upon the object's now
> out-of-date state.
>
> I understand where to implement the actual cascaded updates (inside
> the parent model's save method), but I don't see a quick way to ask
> the user for confirmation (and then rollback if they decide not to
> save). I suppose I could implement some weird confirmation logic
> directly inside the save method (sort of a two phase save) but that
> seems...ugly.
>
> Any thoughts, even general pointers into the django codebase?
>
> Thanks a lot,
> Jacob
>
> >


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



  1   2   >