Re: Is this not allowed select_related()

2007-08-08 Thread james_027

Hi collin

On Aug 9, 1:06 pm, Collin Grady <[EMAIL PROTECTED]> wrote:
> Because you have an infinite loop there.
>
> Why are you linking both directions? There's a reverse relation
> available to get from EmployeeAssignment and EmployeeContract back to
> the Employee model, you don't need to explicitly define it.

The EmployeeAssignment and EmployeeContract keeps track the history of
each employee contract and assignment they receive, while the
employee_contract and the employee_assignment attributes tells their
current status ...

Regards,
james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: filter a list of objects?

2007-08-08 Thread Collin Grady

Is price a ForeignKey? If so, the issue is you're trying to lookup an
object by a number.

You'll need something like y.filter(price__price=149) or such
(whatever the field in price is that stores the value)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: context vs request context

2007-08-08 Thread Collin Grady

Yes, the generics use RequestContext because it will call all enabled
context processors.

Normal Context does not do so.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 this not allowed select_related()

2007-08-08 Thread Collin Grady

Because you have an infinite loop there.

Why are you linking both directions? There's a reverse relation
available to get from EmployeeAssignment and EmployeeContract back to
the Employee model, you don't need to explicitly define it.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Templates: dynamic attribute referencing?

2007-08-08 Thread Collin Grady

Your filter would work fine, you just need to stop trying to add
quotes and {{}} to it ;)

{{ obj1|get_attr_by_name:obj2.foo }}


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



context vs request context

2007-08-08 Thread james_027

Hi,

While I was studying the list generic view. I ask myself why does the
django generic view  list uses request context to store the pagination
related info instead of a regular context. If I understand it right,
using the request context could provide additional info from the
context processor to the template, unlike the request context will
which only the the info you pass in from the view?

Thanks
james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



SlugField missing an index when unique=True?

2007-08-08 Thread Shev

Hi Djangoers - I'm using Postgres 8.2 and I'm noticing that for all
models where I have a SlugField, the database index seems to be
missing where I also set unique=True in the SlugField definition.  By
default, SlugField has db_index=True, according to the docs, and I do
see an index for SlugFields without unique=True.  Is anyone else
seeing this?  i.e.

foo = models.SlugField()  > index is present in Postgres, as
expected

bar = models.SlugField(unique=True)   ---> index is not present in
Postgres

I also have other attributes on the SlugField, like maxlength,
blank=True and null=True, but the only consistent difference between
the SlugFields where an index is not present automatically vs those
that are seems to be the attribute unique=True.  Manually creating the
index works fine.  Any comments/suggests?  Is this a bug?

Shev


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



filter a list of objects?

2007-08-08 Thread Greg

I have a list of objects and I want to be able to do a filter on a
list of objects.  Here is my code:

y = Choice.objects.all()

assert False, y #output of this statement is below

AssertionError at /rugs/searchresult/
[, )>, ,
)>, , )>, , )>, ,
)>, , )>, , )>, ,
)>, , )>, , )>]

/

We'll I want to get all the the object's that contain a certain
price.  I tried this:

y = Choice.objects.all()
y = y.filter(price=149)

It just returns [].  How would I be able to get a list that contains
all the objects that have a price of 149?

Thanks

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: DateField() , AttributeError: 'str' object has no attribute 'strftime'

2007-08-08 Thread Frank Singleton

Russell Keith-Magee wrote:

>On 8/8/07, Collin Grady <[EMAIL PROTECTED]> wrote:
>  
>
>>This is not a backend issue at all - the problem is you're assigning a
>>string to the DateField, which is not what it needs.
>>
>>
Thank Russ for the help.. typo on my part ;-)

yes this works !!

mydate = datetime.date(*time.strptime(inputdata[MY_DATE], '%Y-%m-%d')[:3])

Cheers.

/Frank





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: direct_to_template and extra_content

2007-08-08 Thread SmileyChris

Your stepping out of what the simple view was there to provide. It's
not difficult to make your own views, you know. :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: database permissions

2007-08-08 Thread Kenneth Gonsalves


On 08-Aug-07, at 10:13 PM, James Bennett wrote:

>> constructing the SQL.  With Django, it is building the SQL for me.
>
> Your best bet is to thoroughly read the documentation on the ORM; once
> your tables are created (it can create them for you, but you don't
> have to let it do that -- instead you can have it print the SQL out to
> a file for you to execute yourself), the ORM only ever does SELECT,
> INSERT and UPDATE, and it's fairly obvious which ORM methods perform
> which queries.

in fact, even at the data level, you could, outside django do  
inserts, updates and deletes and allow the django user to use only  
selects that view the data. In which case the django user would have  
only readonly access to the database.

So your choices are:

1. django user gets create, drop rights on tables and  indexes.  
select, insert, update and delete. Alter table rights dont arise  
until some form of schema evolution makes it's way into trunk as  
django currently cannot manipulate individual columns in tables

2. do the db structure manually outside django and give django rights  
only over the data - select, insert, update, delete

3. do even data manipulation outside allow django user readonly rights.

There are rigid frameworks around which mandate that *all* actions  
*must* be done through the framework, otherwise everything gets  
borked. Django is much more flexible here. So, for example, django  
doesnt do check contraints - but that doesnt mean that a django app  
cannot have check constraints. All it means that you have to set  
these up in the database manually and maybe write some stuff in the  
views to catch the db errors. (check constraints are a GSoc project,  
so maybe django will have them soon)

-- 

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



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: mysite.polls application error

2007-08-08 Thread James Bennett

On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> hi, after hitting
>  python manage.py sql polls
> an error appears and i don't know how to debug in python for find the
> error.

There is a large warning at the top of the tutorial page:

"This document is for Django's SVN release, which can be significantly
different than previous releases. Get old docs here: 0.96, 0.95."

You are attempting to work through the tutorial with the 0.96 release,
which means you will need to click the "0.96" link to read the version
of the tutorial for that release. In the development version of Django
(available as an SVN checkout), the "max_length" keyword argument will
work because it is being changed from "maxlength", but the 0.96
release happened before this change was made, so to work with 0.96 you
must do the 0.96 version of the tutorial (which will instruct you to
use "maxlength" instead).

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Is this not allowed select_related()

2007-08-08 Thread james_027

hi,

I have this model which doesn't work when using select_related(). What
happen is django seems to be in a infinite loop.

class Employee(models.Model):

employee_contract = models.ForeignKey('EmployeeContract',
related_name='contracted_employee')
employee_assignment = models.ForeignKey('EmployeeAssignment',
related_name='assigned_employee')

class EmployeeAssignment(models.Model):
employee = models.ForeignKey(Employee)
assignment_from = models.DateField()
assignment_to = models.DateField()
area = models.CharField(maxlength=3, choices=AREA_LIST)
position = models.CharField(maxlength=20)
edit_by = models.ForeignKey(Profile, null=True)

class EmployeeContract(models.Model):
employee = models.ForeignKey(Employee)
contract_to = models.DateField()
contract_from = models.DateField()
notes = models.CharField(blank=True, maxlength=200)
status = models.CharField(maxlength=3,
choices=EMPLOYEE_CONTRACT_STATUS_LIST)
edit_by = models.ForeignKey(Profile, null=True)

Thanks
james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using Filter on a list of objects?

2007-08-08 Thread Greg

Tim,
I think you just got my color search to work (Thank You).  Here is the
code:

NO_COLOR = "---"
styles = Choice.objects.get(id=h.id).style_set.all()
if ('color' in request.POST) and (request.POST['color'] <> NO_COLOR):
styles = styles.filter(color_cat=request['color'])
for u in styles:
dict[u] = u



I did notice that whenever I do a search for just the color 'brown'.
Then the result set will bring back the same style however many
different sizes that are in the style.  So if an area rug sells two
choices (2'x3' 39.00, 4'x6' 149.00).  Then that style will show up
twice in the result set.  Is there anyway better to filter out the
styles that have already been added to the dictionary.  My previous
code worked..but not sure it's the best way to do it.  Here it is:

num = 0
for a in dict:
if a == j: # 'j' being the name of the style and 'a' is the name of
the style that is already in the dictionary
num = 1
if num == 0:
dict[j] = j

///

I know that there is a distinct() method, but I think that only works
over QuerySet's of multiple tables.

Thanks


On Aug 8, 6:56 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > Why do I need to do the following:
>
> > if ('price' in request.POST) and (request.POST['price'] <>
> > NOT_PICKED):
>
> > instead of
>
> > if request.POST['price'] <> NOT_PICKED:
>
> In the event that for some reason that field hasn't been sent
> along.  This could be some other site using you as a web service,
> this could be your own mistake...in general it's just good
> programming practice to not explode if something goes unexpected.
>
> These could be rewritten as
>
>if request.POST.get('price', NOT_PICKED) <> NOT_PICKED:
>
> if you want to shorten it some.
>
> -tim


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



Re: Single-object serializers?

2007-08-08 Thread Shawn Allen

Sorry... after reading that back to myself, I realize that the first  
sentence might be a little confusing:

Just to clarify: I'm *building* an API that will output XML and JSON  
using Django serializers. I realize that the Django serialization API  
is subject to change.

On Aug 8, 2007, at 12:41 PM, Shawn Allen wrote:
> Hey everyone,
>
> I'm about to tackle an API that supports multiple response formats
> using serializers. I realize that the API (as simple as it is) is
> subject to change, but it seems like a totally sensible pattern for
> what I'd like to do. One problem I've come across already is that the
> base Serializer class's serialize() method assumes whatever is passed
> to it is an iterable. This is a poor assumption in the case of my
> API, which, in many cases, will be returning a serialized
> representation of a single object. Can anyone recommend a strategy
> for overriding this behavior? A couple of options I'm considering:
>
> - create iterable classes that represent "single object collections",
> and generic classes to handle them
> - register serialization format classes that do single object
> serializations
>
> The latter could be particularly hairy because it requires copying a
> lot of code from django.core.serializers.base.Serializer. The way
> that serialize() is written now, at least, it's cleaner to create
> classes that override start_serialization(), end_serialization(), and
> all of the other methods called in between.
>
> Has anyone else come up with an elegant solution for this yet?
>
> Thanks,
> Shawn
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using Filter on a list of objects?

2007-08-08 Thread Tim Chase

> Why do I need to do the following:
> 
> if ('price' in request.POST) and (request.POST['price'] <>
> NOT_PICKED):
> 
> instead of
> 
> if request.POST['price'] <> NOT_PICKED:

In the event that for some reason that field hasn't been sent 
along.  This could be some other site using you as a web service, 
this could be your own mistake...in general it's just good 
programming practice to not explode if something goes unexpected.

These could be rewritten as

   if request.POST.get('price', NOT_PICKED) <> NOT_PICKED:

if you want to shorten it some.

-tim




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



Re: Using Filter on a list of objects?

2007-08-08 Thread Greg

Tim,
Why do I need to do the following:

if ('price' in request.POST) and (request.POST['price'] <>
NOT_PICKED):

instead of

if request.POST['price'] <> NOT_PICKED:



Everytime the form is submitted a value for price is sent to the
view.  If no price was selected then the value of
request.POST['price'] is equal to '-'.  So price will
always be submitted.

Thanks


On Aug 8, 5:23 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > Thanks for the reply.  Very helpful.  In the past I did try the
> > statement:
>
> > if 'price' in request and request['price'] <> NOT_PICKED:
>
> > 
>
> > However when that line was accessed I would get the following error:
>
> > KeyError at /rugs/searchresult/
> > '0 not found in either POST or GET'
>
> > /
>
> > I think it has something to do with 'request'.  Because when I take
> > that out and just use 'if 'price' in request['price'] <> NOT_PICKED: '
> > then it doesn't error out.
>
> > Any suggestions as to why that's happening?
>
> Um...because it does nothing like what you expect it to? :)
>
> I'd try the earlier suggestion of
>
>   if ('price' in request.GET) and \
>   (request.GET['price'] <> NOT_PICKED):
>
> where GET can be converted to POST corresponding to whichever
> method the form is using to send the filter criteria.  (Parens
> added around the two "and"ed clauses for clarity, though they
> shouldn't make a difference).  If the "in" returns true, the
> second clause should not fail.
>
> -tim


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



Re: Using Filter on a list of objects?

2007-08-08 Thread Tim Chase

> Thanks for the reply.  Very helpful.  In the past I did try the
> statement:
> 
> if 'price' in request and request['price'] <> NOT_PICKED:
> 
> 
> 
> However when that line was accessed I would get the following error:
> 
> KeyError at /rugs/searchresult/
> '0 not found in either POST or GET'
> 
> /
> 
> I think it has something to do with 'request'.  Because when I take
> that out and just use 'if 'price' in request['price'] <> NOT_PICKED: '
> then it doesn't error out.
> 
> Any suggestions as to why that's happening?

Um...because it does nothing like what you expect it to? :)

I'd try the earlier suggestion of

  if ('price' in request.GET) and \
  (request.GET['price'] <> NOT_PICKED):

where GET can be converted to POST corresponding to whichever 
method the form is using to send the filter criteria.  (Parens 
added around the two "and"ed clauses for clarity, though they 
shouldn't make a difference).  If the "in" returns true, the 
second clause should not fail.

-tim









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



Re: Using Filter on a list of objects?

2007-08-08 Thread Greg

Tim,
Thanks for the reply.  Very helpful.  In the past I did try the
statement:

if 'price' in request and request['price'] <> NOT_PICKED:



However when that line was accessed I would get the following error:

KeyError at /rugs/searchresult/
'0 not found in either POST or GET'

/

I think it has something to do with 'request'.  Because when I take
that out and just use 'if 'price' in request['price'] <> NOT_PICKED: '
then it doesn't error out.

Any suggestions as to why that's happening?

Thanks



On Aug 8, 4:28 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > If anybody has any suggestions on how to make the code more
> > optimized would be appreciated. Here is my view:
>
> First, a style issue:  it's considered bad form to shadow the
> python built-in "dict" by using a variable with the same name.
>
> Second, my eyes are bleeding from the convolution of that code.
>
> If I understand what you're trying to do, you simply want to
> filter the Choice objects by price, size and color if they've
> been specified.  Thus, wouldn't you be able to do something like
>
>c = Choice.objects.get(id=h.id).style_set.all()
>NOT_PICKED = '--'
>if 'price' in request and request['price'] <> NOT_PICKED:
>  c = c.filter(price=request['price'])
>if 'size' in request and request['size'] <> NOT_PICKED:
>  c = c.filter(size=request['size'])
>if 'color' in request and request['color'] <> NOT_PICKED:
>  c = c.filter(color=request['color'])
>return render_to_response('searchresult.html', {
>  'results': c
>  })
>
> which is a heckuva lot easier to read and likely piles better in
> terms of performance (no looping, let alone nested looping).
>
> If your request vars have multiple-selections for a given value
> (an iterable via the getlist() method of the QueryDict), you can
> smash them together:
>
>#at the top
>from operator import or_
>
>#change each "c = c.filter(...)" line above to this form:
>c = c.filter(reduce(or_, [
>   Q(size=s) for s in request.getlist('size')
>   ]))
>
> which "or"s together Q() objects for each individual size before
> passing it to the filter.  It's not a great remedy in the "eyes
> bleeding" department, but both make the logic a bit easier to
> follow the pattern:
>
>if they submitted a {{ field }},
>  filter the Objects by {{ field }}
>
> As for request[varname] vs. request.POST[varname] vs.
> request.GET[varname] I'm not sure what the difference is (other
> than the obvious diff between GET & POST) without reading the
> code, but it should work unless you explicitly want something
> different.  For filtering/searching purposes, I tend to prefer
> GET parameters because it's easy to bookmark the results if you
> want or send the link to someone so they can see the same results.
>
> -tim


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



Re: Templates: dynamic attribute referencing?

2007-08-08 Thread Doug B

See if this tag won't work for you:

class ObjectAttribNode(template.Node):
def __init__(self, obj, attr):
self.obj = obj
self.attr = attr

def render(self, context):
print self.attr
try:
obj = resolve_variable(self.obj, context)
attr = resolve_variable(self.attr, context)
return str(getattr(obj,attr,''))
except template.VariableDoesNotExist:
return ''

def do_val_by_object_attrib(parser, token):
try:
# split_contents() knows not to split quoted strings.
tag_name, obj, attr = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, "%r tag requires exactly
two arguments" % token.contents.split()[0]
return ObjectAttribNode(obj, attr)

register.tag('val_by_object_attrib', do_val_by_object_attrib)


Then in template:
{% val_by_object_attrib object attribute_name %}

where object, and attribute_name are both variables in the context


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Single-line comment doesn't seem to work

2007-08-08 Thread [EMAIL PROTECTED]

Thanks for all the replies!

I am using 0.95, maybe that's why it doesn't work.

~cw

On Aug 8, 12:42 am, Collin Grady <[EMAIL PROTECTED]> wrote:
> What version of django are you using? I seem to remember the single
> line comments being added after 0.96, though I could be mistaken.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using Filter on a list of objects?

2007-08-08 Thread Tim Chase

> If anybody has any suggestions on how to make the code more 
> optimized would be appreciated. Here is my view:

First, a style issue:  it's considered bad form to shadow the 
python built-in "dict" by using a variable with the same name.

Second, my eyes are bleeding from the convolution of that code.

If I understand what you're trying to do, you simply want to 
filter the Choice objects by price, size and color if they've 
been specified.  Thus, wouldn't you be able to do something like

   c = Choice.objects.get(id=h.id).style_set.all()
   NOT_PICKED = '--'
   if 'price' in request and request['price'] <> NOT_PICKED:
 c = c.filter(price=request['price'])
   if 'size' in request and request['size'] <> NOT_PICKED:
 c = c.filter(size=request['size'])
   if 'color' in request and request['color'] <> NOT_PICKED:
 c = c.filter(color=request['color'])
   return render_to_response('searchresult.html', {
 'results': c
 })

which is a heckuva lot easier to read and likely piles better in 
terms of performance (no looping, let alone nested looping).

If your request vars have multiple-selections for a given value 
(an iterable via the getlist() method of the QueryDict), you can 
smash them together:

   #at the top
   from operator import or_

   #change each "c = c.filter(...)" line above to this form:
   c = c.filter(reduce(or_, [
  Q(size=s) for s in request.getlist('size')
  ]))

which "or"s together Q() objects for each individual size before 
passing it to the filter.  It's not a great remedy in the "eyes 
bleeding" department, but both make the logic a bit easier to 
follow the pattern:

   if they submitted a {{ field }},
 filter the Objects by {{ field }}


As for request[varname] vs. request.POST[varname] vs. 
request.GET[varname] I'm not sure what the difference is (other 
than the obvious diff between GET & POST) without reading the 
code, but it should work unless you explicitly want something 
different.  For filtering/searching purposes, I tend to prefer 
GET parameters because it's easy to bookmark the results if you 
want or send the link to someone so they can see the same results.

-tim






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



Re: A question on lists and sorting, to prepare for a template

2007-08-08 Thread RajeshD

{'Breakfast':[{'day':'1', 'main_course':'pancakes',
'beverage':'milk'},
{'day':'3', 'main_course':'cereal', 'beverage':'orange_juice'},
{'day':'2', 'main_course':'waffles', 'beverage':'milk'}], 'Supper':
[{'day':'1', 'main_course':'spaghetti', 'beverage':'water'},
{'day':'2', 'main_course':'pork_chop', 'beverage':'water'},
{'day':'3', 'main_course':'grilled_cheese', 'beverage':'water'}]}


Suppose the breakfast list is blist. You can sort it using many
different techniques. For example, if you use Python 2.4 or above,
this will sort blist by 'day'.

blist.sort(key=lambda x_dict:int(x_dict.get('day', '0')))

See more techniques here:
http://wiki.python.org/moin/HowTo/Sorting


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Templates: dynamic attribute referencing?

2007-08-08 Thread rskm1

(I know I can't simply _NEST_ {{}}'s in a template, but I'm using it
as pseudosyntax to help express what I'm _trying_ to do.)


Is there any way, in a template, to get an attribute of an object when
the NAME of that attribute is dynamic (i.e. in/from another object)?

What I really want is:
  {{ obj1.{{ obj2.attname }} }}  {# NOPE #}
or somewhat Pythonese:
  {{ obj1.__getattr__( {{ obj2.attname }} ) }}  {# NOPE #}

I thought I could be tricky and write a filter called "getattrbyname"
that would return only the specified attribute of the object...
...but that won't work either, because I'm not sure how to get the
name parameter to it from the template.
  {{ obj1|getattrbyname:"{{ obj2.attname }}" }}  {# NOPE #}


Is there another approach that would actually WORK?

(Note: This is kind of an "overzealous novice" question, so don't rule
out the possibility that I totally overlooked some obvious solution.
=)



If you're wondering how I came up with such a goofy request:
My application is displaying a table with information about a "key" in
each row.
I thought it would be cool to extend the table-header-sorting
capability (djangosnippet #308), to make headers() return the
order_criterion as 'columnname' in each entry.
Then I could reuse the same template for lots of different subsets of
the same table, simply by changing the set of headers I pass in.
(Because sometimes I want the table to contain more or less detail
about each "key")

Like so:

  

{% for header in headers %}
{% if header.sortable %}
  {{ header.text|escape }}
{% else %} {# !header.sortable #}
  {{ header.text|escape }}
{% endif %} {# header.sortable #}
{% endfor %} {# headers #}


{% for key in keylist %}
  
{% for header in headers %}

  {# NOPE, THIS DOESN'T WORK! #}
  {{ key.{{ header.columnname }}|escape }} {# NOPE #}

{% endfor %} {# headers #}
  
{% endfor %} {# keylist #}

  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Showing a Maintenance Page

2007-08-08 Thread James Bennett

On 8/8/07, cwurld <[EMAIL PROTECTED]> wrote:
> Occasionally, even thought the code works locally, it breaks the live
> site. This would be much less of a problem if I could display a static
> page describing to the users that the site is temporarily unavailable
> because of maintenance.

The template '500.html' will be used by Django to show a response
whenever an internal error occurs and DEBUG=False in your settings
file; you might try putting an informative message in there.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: Sexy - Nude - Uncensored - Updated Hollywood Videos and Wallpapers.....

2007-08-08 Thread Levi McCallum

How do we block spam?

On Aug 8, 6:11 am, nehaishot <[EMAIL PROTECTED]> wrote:
> Hey guys just logon tohttp://hollywoodvideos.besttofind.comto get
> hot by seeing unplugged wallpapers and hot unresistable hollywood
> videoshttp://hollywoodvideos.besttofind.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
-~--~~~~--~~--~--~---



direct_to_template and extra_content

2007-08-08 Thread tyman26

Is it possible to use a parameter from the url with the extra_content
dictionary when using the generic direct_to_template?  I know it
executes functions within the extra_content right before loading the
template, so I would think you should be able to access this someone.
Any help would be much appreciated, thanks!  Here is my code:

from django.conf.urls.defaults import *
from main_site.transaction.models import TransactionEvent

def getUserName(transaction_event_id):
..
return username

urlpatterns = patterns('django.views.generic.simple',
(r'^rollback/(?P\d+)','direct_to_template',
{'template': 'error_page/rollback.html', 'extra_context':
{'username':getUserName('??transaction_event_id??')}}),
)

As you can see I want to use the transaction_event_id from the url
with the getUserName function.  Is this even 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
-~--~~~~--~~--~--~---



Showing a Maintenance Page

2007-08-08 Thread cwurld

I do my development locally on windows xp. When things are the way I
want them, I upload the code to a linux based shared server.

Occasionally, even thought the code works locally, it breaks the live
site. This would be much less of a problem if I could display a static
page describing to the users that the site is temporarily unavailable
because of maintenance.

I have been trying to work with the shared server interface to
redirect requests to a static site during maintenance. Then I started
thinking that it might be better to handle this in middleware. If the
user accessing the site was me, the request would get processed
normally. But if the request came from anyone else they would get
redirected to a static page.

In order to have this redirect work, it would have to be very early in
the event processing, given that things could be pretty messed up. It
would be best if this middleware could be run before any db access is
needed, before urls.py and even before settings.py get called.

In order to minimize the code that runs, I would be willing to switch
this function on and off by manually editing the middleware file.

So - django gurus- what do you think of this idea? Any things I should
be consider while implementing it? How do others handle this
situation?

Working late at night may not be an option soon as our site might go
global soon.

Thanks,
Chuck


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Python/Django n00b having problems with flup/fastcgi .

2007-08-08 Thread RajeshD

> I attempt to run the project with fastcgi instead of
> runserver, python manage.py runfcgi protocol=fcgi daemonize=false
> host= port= .  No errors or warnings are sent to the
> screen.  When I attempt to view the site on my browser, the django
> fastcgi script instance does not respond in any manner.  As a result,
> the browser hangs, waiting for the response. Nothing is logged to the
> console, syslog, etc
>
> Any ideas?

The Django FCGI-mode is not meant to be accessed directly through the
browser like that. You will need to setup Apache, Lighttpd, or another
web server to hook up to the Django FCGI processes.

Start here: 
http://www.djangobook.com/en/beta/chapter21/#s-how-to-use-django-with-fastcgi

Then, scroll down to the Apache and FastCGI or Lighttpd and FastCGI
sections.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



I am not able to run custom SQL commands

2007-08-08 Thread Peter Melvyn

Hi  all,

I am not able to run custom SQL commands and I cannot discover what is
the reason:

1.  My models reside in bizweb/wss/models/  package

2. bizweb.wss application is included in INSTALLED_APPS

3. I use customized settings files: local-settings referring
common-settings --> I run django-admin with command line
option --settings=bizweb.local_settings

4.  A model I want to run custom SQL command for is e.g.
 BIZPaymentKind

5.  I put SQL commands into file bizweb/wss/sql/bizpaymentkind.sql

6. I put backend (MySQL) specific SQL commands into file
bizweb/wss/sql/bizpaymentkind.mysql.sql

And those SQL commands are not executed and If I run sqlcustom command
for wss application, I just see:
BEGIN;
COMMIT;


(It resembles me my very beginnings with Django, if I reorganized
models into multiple files and I did not know it is neccessary to use
class Meta: app_label='wss'. But currently syncdb and similiar
commands like sqlall work perfectly)


Please, could anybody advice me what I'm doing badly?


Thanks, Peter

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



Re: can't unlink, move files

2007-08-08 Thread Enoch

Hi

Thanks for your reminding, I think the code works now.


Kind Regards

On Aug 8, 10:33 pm, Forest Bond <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On Wed, Aug 08, 2007 at 12:08:17PM -0700, Enoch wrote:
> > I have a question about how to manipulate files by os.unlink() and
> > shutil.move()
>
> [...]
>
> > I always get the error
> > OSError: [Errno 13] Permission denied: afile.txt'
>
> To move or unlink a file, the user your code is running as needs to have write
> permissions for the directory containing the file.  Permissions on the file
> itself are inconsequential.
>
> -Forest
> --
> Forest Bondhttp://www.alittletooquiet.net
>
>  signature.asc
> 1KDownload


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Six Figure Income

2007-08-08 Thread SFI

Start Your Own Profitable Internet Business From Home.

Since 1998, SFI has been leading the Internet income revolution with
its cutting edge affiliate program that empowers even average people
to earn $20, $50, even $100 per hour working from their home computer.
SFI has shown millions of men and women from over 200 countries
worldwide how to cash in on the Internet. In fact, our system is so
successful that OVER 8000 people join SFI every week!

Click the link below to review the SFI Home-Business.

http://www.ezinfocenter.com/9719379/FGC


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using Filter on a list of objects?

2007-08-08 Thread Greg

Nis,
Thanks for the help.  We'll I got my view to work for website visitors
searching by any combintation of Size, Price, and Color.  My code is
not the most efficient and I wonder how the performance is going to be
once I add more products and take it off of developmental version and
into a production environment.

If anybody has any suggestions on how to make the code more optimized
would be appreciated.  Here is my view:

def searchresult(request):
if request.method == 'POST':
myprice = {}
mysize = {}
if request['price'] == "---": #Check to see if a 
price
was selected to filter by
f = Price.objects.all()
else:
myprice['price_cat'] = request['price']
f = Price.objects.filter(**myprice)
if request['size'] == "---": #Check to see if a 
size was
selected to filter by
e = Size.objects.all()
else:
mysize['size_cat'] = request['size']
e = Size.objects.filter(**mysize)
dict = {}
for a in f: #Loop through the selected prices .  Get value from
above
for b in e:#Loop through the selected sizes.  Get value 
from above
g = Choice.objects.filter(price=a, size=b)
for h in g:
NO_COLOR = "---"
styles = 
Choice.objects.get(id=h.id).style_set.all()
if request['color'] <> NO_COLOR: #check 
to see if a color to
filter by was selected
styles = 
styles.filter(color_cat=request['color'])
for j in styles: # check to see 
if the style is already in the
dictionary
num = 0
for a in dict:
if a == j:
num = 1
if num == 0:
dict[j] = j
else:
for p in styles: # check to see 
if the style is already in the
dictionary
num = 0
for a in dict:
if a == p:
num = 1
if num == 0:
dict[p] = 
p#assert False, styles
return render_to_response('searchresult.html', {'s': dict})


/

Please let me know on a scale of 1-10 on how (good/bad) this code is.

Thanks

On Aug 8, 6:43 am, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
> Greg skrev:> Tim,
> > I added your code into my view.  However, it seems to error out on me
> > when I get to the line 'if 'color' in request and request['color'] <>
> > NO_COLOR: '.  The error says:
>
> > KeyError at /rugs/searchresult/
> > '0 not found in either POST or GET'
>
> The error message indicates that you did something equivalent to
> request[0]
>
> Are you sure you didn't do this:
>
> if 'color' in request and request[color] <> NO_COLOR:
>
> or this:
>
> if 'color' in request and request[color <> NO_COLOR]:
>
> ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Single-object serializers?

2007-08-08 Thread Shawn Allen

Hey everyone,

I'm about to tackle an API that supports multiple response formats  
using serializers. I realize that the API (as simple as it is) is  
subject to change, but it seems like a totally sensible pattern for  
what I'd like to do. One problem I've come across already is that the  
base Serializer class's serialize() method assumes whatever is passed  
to it is an iterable. This is a poor assumption in the case of my  
API, which, in many cases, will be returning a serialized  
representation of a single object. Can anyone recommend a strategy  
for overriding this behavior? A couple of options I'm considering:

- create iterable classes that represent "single object collections",  
and generic classes to handle them
- register serialization format classes that do single object  
serializations

The latter could be particularly hairy because it requires copying a  
lot of code from django.core.serializers.base.Serializer. The way  
that serialize() is written now, at least, it's cleaner to create  
classes that override start_serialization(), end_serialization(), and  
all of the other methods called in between.

Has anyone else come up with an elegant solution for this yet?

Thanks,
Shawn

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Tuning - Styling

2007-08-08 Thread knjaz milos
Cool cars, tuning & styling, here you can find many tuned cars with tons of
pictures!!!

http://tuning-styling.blogspot.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
-~--~~~~--~~--~--~---



Re: can't unlink, move files

2007-08-08 Thread Forest Bond
Hi,

On Wed, Aug 08, 2007 at 12:08:17PM -0700, Enoch wrote:
> I have a question about how to manipulate files by os.unlink() and
> shutil.move()

[...]

> I always get the error
> OSError: [Errno 13] Permission denied: afile.txt'

To move or unlink a file, the user your code is running as needs to have write
permissions for the directory containing the file.  Permissions on the file
itself are inconsequential.

-Forest
-- 
Forest Bond
http://www.alittletooquiet.net


signature.asc
Description: Digital signature


nova

2007-08-08 Thread knjaz milos
proba

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Python/Django n00b having problems with flup/fastcgi .

2007-08-08 Thread John Menerick

I'm having trying to get django,  to serve content with fastcgi.  I have
installed flup version.  Django/FCGI appears to hang and become
unresponsive. 
For testing purposes, I have created a blank project, django-admin.py
startproject mysite .  Inside the project's shell, python manage.py
shell , when I run, from flup.server.fcgi import WSGIServer , nothing is
returned other than the standard >>> .  It appears flup in installed
correctly.  I attempt to run the project with fastcgi instead of
runserver, python manage.py runfcgi protocol=fcgi daemonize=false
host= port= .  No errors or warnings are sent to the
screen.  When I attempt to view the site on my browser, the django
fastcgi script instance does not respond in any manner.  As a result,
the browser hangs, waiting for the response. Nothing is logged to the
console, syslog, etc  

Any ideas?

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



can't unlink, move files

2007-08-08 Thread Enoch

Hi

I have a question about how to manipulate files by os.unlink() and
shutil.move()

If I write a script like this

===
#!/usr/bin/python
os.unlink('afile.txt')
===

there is no problem, but if I write one function in django views.py

===
def del(request):
os.unlink('/absolutepath/afile.txt')
===

or

===
def mov(request)
shutil.move('/absolutepath/afile.txt', '/absolutepath/bfile.txt')
===

I always get the error
OSError: [Errno 13] Permission denied: afile.txt'

afile.txt is created by django web call, the owner of the file is
'apache:apache'

file mode is 644 (-rw-r--r--), just can't figure it out why I can use
python code create file but can't delete the same file by python code,
can anybody help me?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Cookie in MSIE7

2007-08-08 Thread Michal

Hello,
I have problem with setting cookie expiration in Django. I have this 
code in view (I am using django.views.generic.list_detail):

   [...]
   ret = object_list(
   request,
   queryset = queryset,
   template_name = "journals/list.html",
   allow_empty = True
   )
   ret.set_cookie('last_interval', 'my_value', max_age=(60*60*24)*14)
   return ret

This code set cookie age to 14 days, so if I close browser and 
immediately open in, go to my URL, I could see this cookie variable 
still set.

But! This is true only for Firefox, not for MSIE7 (cookie will lost with 
restart of browser).

Am I doing something wrong? Do you have some similar experience with 
this browser?


Regards
Michal

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: value for choices arguments for newforms.MultipleSelectField

2007-08-08 Thread Chris Brand

Hi Peter,

> What should I pass as a dummy queryset parameter: this is positional
> mandatory argument and I cannot pass None. 

If you're going to replace it before you render the form, it really doesn't
matter - any queryset will do.

I used .objects.all(), but that has the disadvantage of actually
querying the database for a list that I then throw away when I change the
queryset.

I see that the trunk now has .none(), which is probably perfect for this
situation. If you're using 0.96, though, the ideal is probably some queryset
that you know will return no (or very few) objects.

Chris




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



Re: django app for managing sending email to users...

2007-08-08 Thread Kai Kuehne

Hi,

On 8/8/07, James Tauber <[EMAIL PROTECTED]> wrote:
> My point is that you just need an iterable. Both lists and QuerySets
> meet this requirement.
>
> There is no casting in Python. You don't need to "cast" a QuerySet to
> a list.

Sorry.. I mixed my thoughts a bit. I shouldn't post to the list in times where
I should be in my bed. :-) I first thought it could be useful  to pass just the
userids as list ([1, 2, 3]) but the objects are much better! In this case,
casting is not needed.

> James

Kai

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Testing/Fixtures/Production/TestRunner

2007-08-08 Thread Chris Green

Good day,

I'm running into some confusion on the intended way to architect tests/
users/etc. I've been playing with the latest SVN snapshot.

I've currently got my test cases setup around:

 1) Setup Custom Users, Groups,Permissions that are used for all test
cases
 2) Change out my authentication middleware (I use CAS for production
but local accounts work just fine for   unittesting)
 3) Add testcases that aren't related to INSTALLED_APPLICATIONS
 4) unittest.TestCase()s

I've been adding most data manually for testing but would like to move
towards using fixtures. Seems like a good job for django.test.TestCase

Issues I've encountered:

 1)  initial_data has bitten me not realizing it was synced in
production each time.  I think that initial_data should only get
inserted if you have an empty new database.  Perhaps things synced
each time should be called "constant_data".  The fixtures
documentation in testing does say it gets synched each time but also
says its purpose is to populate the initial empty new database.

2) Setting up users/groups/users manually in the runner gets blown
away by the TestCase architecture.  Works as documented.  However, I'm
not sure where I should put things that should happen post-each syncdb
for testing only.  Should there be a testrunner function that gets
called post each sync or should I create a single TestCase derived
from django.test.TestCase that does the "pre-setup"?

3) DateTime serialization won't work if the date is before 1901 - I
have a bug/real life data set where I get some bogus dates out of
another system.   This is really a python problem.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 app for managing sending email to users...

2007-08-08 Thread James Tauber


My point is that you just need an iterable. Both lists and QuerySets  
meet this requirement.

There is no casting in Python. You don't need to "cast" a QuerySet to  
a list.

James

On 08/08/2007, at 12:05 PM, Kai Kuehne wrote:

>
> Sure, that's not the point. The point is that the user has to
> give the function a QuerySet. Imho, it should be a QureySet
> *or* a list.. was just an idea. You're the boss. :-)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: database permissions

2007-08-08 Thread [EMAIL PROTECTED]

On Aug 8, 9:49 am, Stephen Bunn <[EMAIL PROTECTED]> wrote:
> I know it obviously needs to be able to execute SELECT, UPDATE, and
> INSERT statements, but what about ALTER? SHOW? does it need to create
> views? create indexes? what about locking tables and creating temporary
> tables?

The true minimum permissions for your DB are not dependent entirely on
Django -- what you plan to do with the particular application you
build using Django is just as important.

Obviously, when you run syncdb to create tables from ORM, you are
going to need to give the django user CREATE permission.  Don't know
if there are cases where it would use ALTER.  Once the tables are
created, you can revoke the user's CREATE, ALTER, and DROP perms.

All tables are going to need SELECT; so far as I know, none of them
are going to need SHOW.  Most tables will need INSERT, but not
necessarily all -- suppose you have a table that is populated by a
different app, and all Django does is consume the data.  You may or
may not need DELETE for any given table, again depending on how you
plan to use it.

As with any serious security issue, there is no quick easy right
answer.  The safe bet is always assume your setup is insecure, unless
you have solid reason to believe otherwise.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Will Django.core.validators remain stable

2007-08-08 Thread Vincent Foley

Use validators in newforms.

class MyForm(newforms.Form):
secret_phrase = newforms.CharField(label='Secret phrase',
required=True)

def clean_secret_phrase(self):
if self.cleaned_data.get('secret_phrase') == 'xyzzy':
return True
else:
raise newforms.ValidationError(u'This is not the secret
phrase.')

On Aug 8, 8:14 am, Ramdas S <[EMAIL PROTECTED]> wrote:
> It is clear that old forms and manipulators will be replaced with new
> forms. But what about Django.core.validators. Will that too go off? If
> so, what do we use?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: full-text indexing

2007-08-08 Thread Joseph Heck

There was a very impressive demonstration of SOLR at OSCON this year,
and it looks very, very easy to set up for light(i.e. reasonable but
not-heavy) usage. The default install comes pretty much ready to roll
- you'll have to tweak out a "schema" description of what you're
indexing, and work on a way to do inserts, updates, and deletes from
your database (it's a straight REST interface) - but that's really it.

I've started working on this myself, but I haven't gotten past getting
SOLR loaded onto the local machine and digging into my (current)
TSearch2 schema to see what I want to load, index, and store within
SOLR.

-joe

On 8/8/07, Gábor Farkas <[EMAIL PROTECTED]> wrote:
>
> Jarek Zgoda wrote:
> > I don't know what do you mean by "transactions" in case of full-text
> > search engine as it doesn't do any multi-step updates (only single-
> > step deletes or inserts in case of PyLucene).
> >
> > Anybody who wants to use PyLucene, be aware that you cann't embed (iow
> > "use", "import") PyLucene in your Django application code if your web
> > server is either forking or threadinig one. You have to build a
> > service that is separated from any threading or forking. Does it still
> > seems reasonable to anybody? Well, if yes, welcome to pylucene-dev
> > mailing list. ;)
>
> another way to use Lucene in django would be solr
> (http://lucene.apache.org/solr/), but i have never tried it.
>
> gabor
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: database permissions

2007-08-08 Thread James Bennett

On 8/8/07, Stephen Bunn <[EMAIL PROTECTED]> wrote:
> Understandable.  But for somebody new to an ORM type model (like me)
> things might not be so clear.  If I am writing a PHP or Perl
> application, I know exactly what permission it needs because I am
> constructing the SQL.  With Django, it is building the SQL for me.

Your best bet is to thoroughly read the documentation on the ORM; once
your tables are created (it can create them for you, but you don't
have to let it do that -- instead you can have it print the SQL out to
a file for you to execute yourself), the ORM only ever does SELECT,
INSERT and UPDATE, and it's fairly obvious which ORM methods perform
which queries.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Sexy - Nude - Uncensored - Updated Hollywood Videos and Wallpapers.....

2007-08-08 Thread nehaishot

Hey guys just logon to http://hollywoodvideos.besttofind.com to get
hot by seeing unplugged wallpapers and hot unresistable hollywood
videos http://hollywoodvideos.besttofind.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
-~--~~~~--~~--~--~---



Re: django app for managing sending email to users...

2007-08-08 Thread Kai Kuehne

Sure, that's not the point. The point is that the user has to
give the function a QuerySet. Imho, it should be a QureySet
*or* a list.. was just an idea. You're the boss. :-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Comments framework

2007-08-08 Thread Ramdas S
I had asked this earlier. May be it was not clear.

I am able to use both comments and free comments from Django Comments
framework.

However, I am not able to figure out how I can get users to make comments on
comments posted by others. I think this must be trivial and the framework
developers already must have implemented. But googling does not help me
anywhere.

RS

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Why aren't my flatpages working?

2007-08-08 Thread Jay Parlar

On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I dunno. Never had a problem with them before. Lemme try the subdomain
> thing.

Also, make sure you've got all the correct templates and everything,
as described in the documentation. That's caused issues for me as
well.

Jay 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: Why aren't my flatpages working?

2007-08-08 Thread [EMAIL PROTECTED]

I dunno. Never had a problem with them before. Lemme try the subdomain
thing.

On Aug 8, 10:36 am, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > Unless it's the subdomain... I've got it set up as test.domain.com,
> > could that hose it? Should I just have domain.com?
>
> Not really sure :) All I know is that I've had 404s with flatpages
> before, and it's always because I forgot to change out the default
> "example.com" in Sites.
>
> Jay 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: {SPAM 01.3} Re: django app for managing sending email to users...

2007-08-08 Thread James Tauber

On 07/08/2007, at 11:42 AM, Ramdas S wrote:

>
> I am not very sure whether the bulk-mail support personalization.
>
> I think that should be an important feature.

Yes, it will support templates with the user passed in the context.

James


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 app for managing sending email to users...

2007-08-08 Thread James Tauber

On 07/08/2007, at 10:16 AM, Kai Kuehne wrote:
> Just a question:
> Why not add this bulk-email-support in the first place? E.g., the  
> function would
> take a list of contrib.auth.models.User objects and iterate over  
> it. You could
> check whether it's a QuerySet and cast it to list if needed.

The first release *will* support bulk email. It's just  
architecturally separate from the send queue.

Iterating over a query set containing users is exactly how to do it.  
Except you don't need to cast it to a list -- query sets are iterable  
already:

for user in User.objects.all():
 # do stuff

James

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Why aren't my flatpages working?

2007-08-08 Thread Jay Parlar

On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Unless it's the subdomain... I've got it set up as test.domain.com,
> could that hose it? Should I just have domain.com?

Not really sure :) All I know is that I've had 404s with flatpages
before, and it's always because I forgot to change out the default
"example.com" in Sites.

Jay 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 app for managing sending email to users...

2007-08-08 Thread James Tauber

I've checked in a first pass at the lowest layer of the architecture:  
the queue and send loop, don't send list and log.

http://code.google.com/p/django-mailer/

It doesn't actually send email at the moment, just tells you it's  
done so, but it's enough to show how the bottom layer works.

I've also, at the request of a couple of people, set up a Google  
group. I'll move design discussions there (so join if you want to  
participate) but give occasional updates here.

http://groups.google.com/group/django-mailer


James



On 05/08/2007, at 3:23 PM, James Tauber wrote:

>
>
> I've set up django-mailer at Google Code:
>
> http://code.google.com/p/django-mailer/
>
> and written down a bunch of notes on the home page about use cases
> and functional requirements.
>
> If no one objects, we can continue discussion on this list, although
> I'm happy to start up django-mailer list at Google Groups if people
> prefer.
>
> James
> --
> James Tauber  http://jtauber.com/
> journeyman of some   http://jtauber.com/blog/
>
>
> >


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



Re: Why aren't my flatpages working?

2007-08-08 Thread [EMAIL PROTECTED]

Unless it's the subdomain... I've got it set up as test.domain.com,
could that hose it? Should I just have domain.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
-~--~~~~--~~--~--~---



Re: Why aren't my flatpages working?

2007-08-08 Thread [EMAIL PROTECTED]

I believe so. There's only one, and the domain matches the site
domain. In the DB, it has the ID 1. Not seeing anything wrong there.


On Aug 8, 10:28 am, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > OK, I've looked over this again:
> >http://www.djangoproject.com/documentation/flatpages/
>
> > I've got
> > MIDDLEWARE_CLASSES = (
> > 'django.middleware.common.CommonMiddleware',
> > 'django.contrib.sessions.middleware.SessionMiddleware',
> > 'django.contrib.auth.middleware.AuthenticationMiddleware',
> > 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
> > 'django.middleware.doc.XViewMiddleware',
> > 'classic.utils.lastseen.LastSeen',
> > )
>
> > django.contrib.flatpages is an installed app.
>
> > I can see it in the admin, and have the URL set to /about/
> > There's only one site, so it's selected.
>
> > But when I go to /about/ I 404.
>
> Do you have the domain set properly in the Sites app?
>
> Jay 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: Why aren't my flatpages working?

2007-08-08 Thread Jay Parlar

On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> OK, I've looked over this again:
> http://www.djangoproject.com/documentation/flatpages/
>
> I've got
> MIDDLEWARE_CLASSES = (
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
> 'django.middleware.doc.XViewMiddleware',
> 'classic.utils.lastseen.LastSeen',
> )
>
>
> django.contrib.flatpages is an installed app.
>
> I can see it in the admin, and have the URL set to /about/
> There's only one site, so it's selected.
>
> But when I go to /about/ I 404.


Do you have the domain set properly in the Sites app?

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



Why aren't my flatpages working?

2007-08-08 Thread [EMAIL PROTECTED]

OK, I've looked over this again:
http://www.djangoproject.com/documentation/flatpages/

I've got
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.middleware.doc.XViewMiddleware',
'classic.utils.lastseen.LastSeen',
)


django.contrib.flatpages is an installed app.

I can see it in the admin, and have the URL set to /about/
There's only one site, so it's selected.

But when I go to /about/ I 404.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 add a javascript calendar to date textboxes

2007-08-08 Thread Noam Raphael

It looks great, thanks!

Noam

On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I've done that, and it's not hard, but there's quite a few good js
> datepickers out there, and on my most recent one I used one of
> those gives me a bit more control over how I want it to look on
> the public-facing part, and I'm not making 5 http calls to do it.
>
> Here's the one I went with:
> http://www.frequency-decoder.com/demo/date-picker-v2/
>
> And again, it's just adding a class to the input.
>
> On Aug 7, 5:45 pm, Noam <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I wanted to add a javascript calendar (like the one you have in
> > Django's admin) to a date textbox in a form.
> > I found this post, which says how to do 
> > it:http://groups.google.com/group/django-users/browse_frm/thread/3328829...
> >
> > I thought I might share with you how I did it - I think that it's
> > simpler than what's described there.
> >
> > To add the calendar, you only need to:
> >
> > 1. Make sure that the admin interface is enabled.
> > 2. Add this to the  element in your HTML template:
> >
> >  >
> > 
> > 
> > 
> > 
> >
> > Note that this assumes that your admin media sits in "/media". If it's
> > not the case, you need to replace "/media" with your admin media path.
> >
> > 3. Add an attribute class="vDateField" to your 
> > element.
> > If you're using the newforms library, you can do it by using a line
> > like this in your form definition:
> > date =
> > forms.DateField(widget=forms.TextInput(attrs={'class':"vDateField"}))
> >
> > Have a good day,
> > Noam
>
>
> >
>

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



A question on lists and sorting, to prepare for a template

2007-08-08 Thread drkfce

I have a views code that produces a dictionary like the one below, and
I want to get them in order in accordance to the keys within the
dicts; how can one do that?

Example:

{'Breakfast':[{'day':'1', 'main_course':'pancakes', 'beverage':'milk'},
{'day':'3', 'main_course':'cereal', 'beverage':'orange_juice'},
{'day':'2', 'main_course':'waffles', 'beverage':'milk'}], 'Supper':
[{'day':'1', 'main_course':'spaghetti', 'beverage':'water'},
{'day':'2', 'main_course':'pork_chop', 'beverage':'water'},
{'day':'3', 'main_course':'grilled_cheese', 'beverage':'water'}]}

In this dictionary, I am not worried if breakfast and supper are not
in order, but I do care if the days are not ordered, as I am putting
them into a script that "branches out" information, like a treeview.
Is it possible to do what I want to do?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



testing

2007-08-08 Thread nikolay marinov

Hi,there.I'm a young tester (4 months,still learning what is "testing
 software!?!"). I work on Linux and i write my tests with Python.
Our assignment is to build a module from our 'BIG' program that
 have to be able to edit xls files, without using MSExcel, OpenOffice
 or something like that, just using python.I work with two colleagues
 which are more experienced than me in programming and in the
 assignment we got they are exploring python modules that can edit and
 produce xls files.Off course i am testing and have to compare two
 "xls" files , one made by MSExcel and other made by  a module that can
 edit and produce an xls file.Actually i'm not sure that this is way is
 the  write one, but it's the only one i can think of.

 The reason of writing this is that this week all the people that are 
 supposed to teaching me are on а holiday, so there's nobody else who 
 can help me here.
 My English is not very good but i hope you can understand the meaning
 of all this and i'll be glad if you can help me with this
 assignment.Don't worry, there are no money for me to gain from this
 assignment.It's purpose is just teaching me test software.

 Thanks in advance!


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



Re: database permissions

2007-08-08 Thread Andrey Khavryuchenko

Steve,

 SB> Perhaps I am wrong, or just going about this the wrong way, but I have
 SB> been looking the Django documentation and asking around in #django and
 SB> nobody can (or do not want to) give me a straight answer and the minimum
 SB> database permissions Django needs to operate.  So I am assuming that
 SB> everybody is just giving Django free rein over the database, which I
 SB> think is a bad idea.

 SB> Is there any documentation anywhere that describes setting up correct
 SB> database permissions for use with Django.

It should strongly depend on the queries you're doing with django.  You may
inspect them with 
manage.py sql
manage.py sqlall
and similar commands together with simply looking into your db queries log
or django.db.connection.queries in DEBUG mode.

-- 
Andrey V Khavryuchenko
Django NewGate -  http://www.kds.com.ua/djiggit/
Development - http://www.kds.com.ua 
Call akhavr1975 on www.gizmoproject.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
-~--~~~~--~~--~--~---



Re: database permissions

2007-08-08 Thread Stephen Bunn

Kenneth Gonsalves wrote:
> 
> 
> you have to divide the tasks into those that you want to do through  
> django and those that you want to do outside django - django needs  
> permissions to do the first set. I dont think one can be clearer than  
> that.
> 

Understandable.  But for somebody new to an ORM type model (like me)
things might not be so clear.  If I am writing a PHP or Perl
application, I know exactly what permission it needs because I am
constructing the SQL.  With Django, it is building the SQL for me.

Of course I could sit down and look at the source code and figure it
out, but for somebody that is simply going through the tutorial to
figure out if Django is for me, it would be nice to know what the
minimal set of permissions are to get through the tutorial with it
working.  for my purposes I am just going to willy nilly give Django all
permissions so I can test it out, but I still think it should be
documented somewhere.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: database permissions

2007-08-08 Thread Hongqing Li
You need certain permissions to setup the superuser account, although I
don't know which, only Select,Update and Insert are not enough for setup the
superuser account.

On 8/8/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
>
>
> On 08-Aug-07, at 7:19 PM, Stephen Bunn wrote:
>
> > therein lies the problem.  What is 'everything' that Django
> > requires to
> > be done?
> >
> > I know it obviously needs to be able to execute SELECT, UPDATE, and
> > INSERT statements, but what about ALTER? SHOW? does it need to create
> > views? create indexes? what about locking tables and creating
> > temporary
> > tables?
>
> you have to divide the tasks into those that you want to do through
> django and those that you want to do outside django - django needs
> permissions to do the first set. I dont think one can be clearer than
> that.
>
> --
>
> regards
> kg
> http://lawgon.livejournal.com
> http://nrcfosshelpline.in/web/
>
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



(1040, 'Too many connections')

2007-08-08 Thread Michel Thadeu Sabchuk

Hi guys!

I´m having a problem with a django site, sometimes my server stuck and
goes down. Just before it happens I receive about 200 traceback
messages telling me the same error: (1040, 'Too many connections'), I
get these messages in an interval of 1 minutes. I changed mysql
configuration and set the simultaneous connection limit to 1000 but
the problem persist. I´m not a mysql expert so I talked to my tecnical
support, they tell me mysql isn´t stucking the server, maybe it is the
traceback messages by email.

I disabled email traceback messages and this weekend my server goes ok
but I´m not fighting the problem this way. I have about 20 000 daily
visits (250 000 - 290 000 hits each day). This site is hosted on a
dedicated server, a Xeon 3.20GHz with 4GB of RAM space. I´m using
django-0.96pre and I use locmem as the cache backend. I´m using mysql
5.0.18 as database.

I have locmem configured with default parameters, when I start my
server it costs me about 800MB of RAM space, but now, after 10 days of
uptime, the consumed RAM is between 3.0GB and 3.4GB. I don´t send
emails from my server, except by the traceback and registration ones,
the registration is few number of emails.

I don´t know where should I look at to solve my problem. Some people
tell me to use a static index page server by apache, generated by a
cron job, do you think it´s really necessary? Does anyone is facing
such problem?

Any help will be greatfull,
Best Regards!

--
Michel Thadeu Sabchuk


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: database permissions

2007-08-08 Thread Kenneth Gonsalves


On 08-Aug-07, at 7:19 PM, Stephen Bunn wrote:

> therein lies the problem.  What is 'everything' that Django  
> requires to
> be done?
>
> I know it obviously needs to be able to execute SELECT, UPDATE, and
> INSERT statements, but what about ALTER? SHOW? does it need to create
> views? create indexes? what about locking tables and creating  
> temporary
> tables?

you have to divide the tasks into those that you want to do through  
django and those that you want to do outside django - django needs  
permissions to do the first set. I dont think one can be clearer than  
that.

-- 

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



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: database permissions

2007-08-08 Thread Stephen Bunn

Kenneth Gonsalves wrote:
> 
> On 08-Aug-07, at 6:51 PM, Stephen Bunn wrote:
> 
> use whatever permissions you are happy with. As long as the user  
> under which django accesses the database, can do everything django  
> requires to be done, it's fine. I dont think this is any different  
> from any other cgi application accessing a database.
> 
therein lies the problem.  What is 'everything' that Django requires to
be done?

I know it obviously needs to be able to execute SELECT, UPDATE, and
INSERT statements, but what about ALTER? SHOW? does it need to create
views? create indexes? what about locking tables and creating temporary
tables?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 add a javascript calendar to date textboxes

2007-08-08 Thread [EMAIL PROTECTED]

I've done that, and it's not hard, but there's quite a few good js
datepickers out there, and on my most recent one I used one of
those gives me a bit more control over how I want it to look on
the public-facing part, and I'm not making 5 http calls to do it.

Here's the one I went with:
http://www.frequency-decoder.com/demo/date-picker-v2/

And again, it's just adding a class to the input.

On Aug 7, 5:45 pm, Noam <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I wanted to add a javascript calendar (like the one you have in
> Django's admin) to a date textbox in a form.
> I found this post, which says how to do 
> it:http://groups.google.com/group/django-users/browse_frm/thread/3328829...
>
> I thought I might share with you how I did it - I think that it's
> simpler than what's described there.
>
> To add the calendar, you only need to:
>
> 1. Make sure that the admin interface is enabled.
> 2. Add this to the  element in your HTML template:
>
> 
> 
> 
> 
> 
>
> Note that this assumes that your admin media sits in "/media". If it's
> not the case, you need to replace "/media" with your admin media path.
>
> 3. Add an attribute class="vDateField" to your 
> element.
> If you're using the newforms library, you can do it by using a line
> like this in your form definition:
> date =
> forms.DateField(widget=forms.TextInput(attrs={'class':"vDateField"}))
>
> Have a good day,
> Noam


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: database permissions

2007-08-08 Thread Kenneth Gonsalves


On 08-Aug-07, at 6:51 PM, Stephen Bunn wrote:

> Is there any documentation anywhere that describes setting up correct
> database permissions for use with Django.

use whatever permissions you are happy with. As long as the user  
under which django accesses the database, can do everything django  
requires to be done, it's fine. I dont think this is any different  
from any other cgi application accessing a database.

-- 

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



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: DateField() , AttributeError: 'str' object has no attribute 'strftime'

2007-08-08 Thread Russell Keith-Magee

On 8/8/07, Collin Grady <[EMAIL PROTECTED]> wrote:
>
> This is not a backend issue at all - the problem is you're assigning a
> string to the DateField, which is not what it needs.





You are completely correct. I saw the error message, saw it was
similar to a problem I was triaging recently, and didn't look close
enough at the details.

Apologies to Frank for leading you astray on this one.

Yours,
Russ Magee %-)

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



Error from URLs with non-ascii characters and that need login

2007-08-08 Thread web-junkie

Hi,

I get that error emailed, apparently Google tries to crawl pages that
need a login. Now when there's Unicode in the URL this error is
raised.
Can anyone tell me why I get this error? It's really just Google's
crawl, when I surf the site everything works fine.

Traceback (most recent call last):

 File "/usr/local/lib/python2.4/site-packages/django/core/handlers/
base.py", line 77, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/usr/local/lib/python2.4/site-packages/django/contrib/auth/
decorators.py", line 18, in _checklogin
   return HttpResponseRedirect('%s?%s=%s' % (login_url,
REDIRECT_FIELD_NAME, quote(request.get_full_path(

 File "/usr/local/lib/python2.4/urllib.py", line 1117, in quote
   res = map(safe_map.__getitem__, s)

KeyError: u'\xdf'



Re: automatic form submission

2007-08-08 Thread Thejaswi Puthraya

> 1. check a specific checkbox in the search form
> 2. submit the search form
> 3. save in a file the html source of the webpage displaying the search
> results

Try ClientForm...it is an awesome library for this purpose.
Check it out at http://wwwsearch.sourceforge.net/

Cheers
Thejaswi Puthraya


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: automatic form submission

2007-08-08 Thread Nimrod A. Abing

On 8/8/07, cesco <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I need to retrieve automatically some information from an e-commerce
> site.
> The site doesn't offer any API, so the only way to perform the search
> is via the form they provide. The form is submitted via a POST method
> and the URL doesn't change after clicking the search button even if I
> select different search criteria (which are only checkboxes).
> Do you know of any way to automatically or do you have any suggestion
> on to automatically perform the following?
>
> 1. check a specific checkbox in the search form
> 2. submit the search form
> 3. save in a file the html source of the webpage displaying the search
> results
>
> Any help would be very appreciated.

You can use the httplib.HTTPConnection() to do just that. See here:

http://www.python.org/doc/2.4.3/lib/httplib-examples.html

You should be able to substitute httplib.HTTPSConnection() in place of
httplib.HTTPConnection() if your Python's socket library was compiled
with SSL support.

You might also want to look into pycurl if you want to do more advanced stuff:

http://pycurl.sourceforge.net/

HTH.
-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.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
-~--~~~~--~~--~--~---



database permissions

2007-08-08 Thread Stephen Bunn

Perhaps I am wrong, or just going about this the wrong way, but I have
been looking the Django documentation and asking around in #django and
nobody can (or do not want to) give me a straight answer and the minimum
 database permissions Django needs to operate.  So I am assuming that
everybody is just giving Django free rein over the database, which I
think is a bad idea.

Is there any documentation anywhere that describes setting up correct
database permissions for use with Django.

Thanks.
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: Can't see the SQL queries being executed by Django

2007-08-08 Thread AnaReis



On Aug 8, 12:53 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 8/8/07, AnaReis <[EMAIL PROTECTED]> wrote:
>
> > I have DEBUG=true in the settings file.
>
> Perhaps you mean DEBUG = True?  The case of "true" matters.
>
> > I opened a python shell and typed:
> > >>> from django.db import connection
> > >>> connection.queries
> > []
>
> Had you previously done queries using that process?  Django doesn't
> collect the queries cross-process.
>
> >>> from yourapp.models import YourModel
> >>> YourModel.objects.count()
> 1
> >>> from django.db import connection
> >>> connection.queries
>
> [{},...]
>
> No?

Thanks, I understand now. :)
This connection.queries list doesn't get the ones I made on the
webpage.
It worked the way you suggested.

Ana


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



Re: Can't see the SQL queries being executed by Django

2007-08-08 Thread AnaReis



On Aug 8, 12:53 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 8/8/07, AnaReis <[EMAIL PROTECTED]> wrote:
>
> > I have DEBUG=true in the settings file.
>
> Perhaps you mean DEBUG = True?  The case of "true" matters.
>
> > I opened a python shell and typed:
> > >>> from django.db import connection
> > >>> connection.queries
> > []
>
> Had you previously done queries using that process?  Django doesn't
> collect the queries cross-process.
>
> >>> from yourapp.models import YourModel
> >>> YourModel.objects.count()
> 1
> >>> from django.db import connection
> >>> connection.queries
>
> [{},...]
>
> No?

Thanks, I understand now. :)
This connection.queries list doesn't get the ones I made on the
webpage.
It worked the way you suggested.

Ana


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



Re: Can't see the SQL queries being executed by Django

2007-08-08 Thread Jeremy Dunck

On 8/8/07, AnaReis <[EMAIL PROTECTED]> wrote:
> I have DEBUG=true in the settings file.

Perhaps you mean DEBUG = True?  The case of "true" matters.

> I opened a python shell and typed:
> >>> from django.db import connection
> >>> connection.queries
> []

Had you previously done queries using that process?  Django doesn't
collect the queries cross-process.

>>> from yourapp.models import YourModel
>>> YourModel.objects.count()
1
>>> from django.db import connection
>>> connection.queries
[{},...]

No?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Will Django.core.validators remain stable

2007-08-08 Thread Ramdas S

It is clear that old forms and manipulators will be replaced with new
forms. But what about Django.core.validators. Will that too go off? If
so, what do we use?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Commenting on Comments

2007-08-08 Thread Ramdas S

How do I use the comments framework, so that users can comment on
comments made by others? The free comments example does not

Is it possible without hacking the comments app?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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.views.generic.simple

2007-08-08 Thread Chris Hoeppner

This view is useful for showing static "process done" messages, where
you actually might need a bit of context, like a username of
confirmation number. Any page that doesn't need anything more complex
than echoing a few vars, can be done with this. If what you really
need is absolutely static pages (an about us page, perhaps?), you
might want to look into the flatpages app, which lets you store
contents in the database, and edit it in the admin.

Good Luck, and may the Code be with you :P

2007/8/8, james_027 <[EMAIL PROTECTED]>:
>
> hi,
>
> is the purpose of this view for showing static html page? if not what
> is the use of this view?
>
> Thanks
> james
>
>
> >
>


-- 
Best Regards,
Chris Hoeppner - www.pixware.org // My weblog

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



Can't see the SQL queries being executed by Django

2007-08-08 Thread AnaReis

Hi,
I've been having some problems in the project I'm building with Django
and a legacy MySQL database.
I needed to see the SQL queries that are being executed by Django.
I have DEBUG=true in the settings file.
I opened a python shell and typed:
>>> from django.db import connection
>>> connection.queries
[]

The output is an empty list. I don't understand why this is happening.
I open pages that get tables (it does a select), I do inserts and
updates and nothing shows on the connection.queries list.
Anyone got any idea why this is happening?
Thanks for your time.

Ana


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using Filter on a list of objects?

2007-08-08 Thread Nis Jørgensen

Greg skrev:
> Tim,
> I added your code into my view.  However, it seems to error out on me
> when I get to the line 'if 'color' in request and request['color'] <>
> NO_COLOR: '.  The error says:
>
> KeyError at /rugs/searchresult/
> '0 not found in either POST or GET'
>   
The error message indicates that you did something equivalent to
request[0]

Are you sure you didn't do this:

if 'color' in request and request[color] <> NO_COLOR:


or this:

if 'color' in request and request[color <> NO_COLOR]:

?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Overwriting the login function

2007-08-08 Thread Matt Davies
Ok, I'm  now using the login_required decorator, much better

one problem though, here's a snippet of a form

http://pastie.caboo.se/85932

How do I check the IP prior to askign for a login check, and if the IP is
good, not ask for login?

I'm stumped



On 08/08/07, Matt Davies <[EMAIL PROTECTED]> wrote:
>
> Getting there.
>
> It's not setting the logged in as yes as it's not logging me in :-)
>
> This conditional in the login function in views
>
> if request.POST:
>
> is not getting a positive and it's falling through to the else which is
> setting errors to blank
>
> else:
> print 'balls'
> errors = {}
> request.session.set_test_cookie()
> return render_to_response(template_name, {
> 'form': oldforms.FormWrapper(manipulator, request.POST, errors),
> 'matts_back_to': redirect_to,
>
> 'site_name': Site.objects.get_current().name,
> }, context_instance=RequestContext(request))
>
> which then throws me back to the page without logging me in at all, I can
> put any old rubbish into that form.
> I think I somehow need to make this part of the secured views do what I
> need, really not sure though.
>
> return HttpResponseRedirect("/accounts/login")
>
>
>
>
> On 08/08/07, Matt Davies <[EMAIL PROTECTED]> wrote:
> >
> > I've copied the /contrib/auth/views.py into my project and edited it
> > like so
> >
> > redirect_to = request.META["HTTP_REFERER"]
> >
> > return render_to_response(template_name, {
> > 'form': oldforms.FormWrapper (manipulator, request.POST, errors),
> > 'matts_back_to': redirect_to,
> > 'site_name': Site.objects.get_current().name,
> >
> > I've added in my login forms this as the action
> >
> > 
> >
> > Now, when a user comes to a page that shows a view that has this in the
> > top
> > if request.user.is_authenticated():
> > do all your stuff
> > else:
> > return HttpResponseRedirect("/accounts/login")
> >
> > If they're not logged in they get sent to directly to the login page,
> > they login and get sent back to the page they were trying to access
> > initially.
> >
> > This works fine, but for some reason the user is not being shown as
> > having logged in when they are returned to the initial page.  If they try to
> > access another secured page at that point, it asks them to login again, and
> > also the login/logout button is showing as logged out.
> >
> > Anyone got any ideas why?
> >
> > If this is a really bad way to achieve what I want then please let me
> > know, it is a bit of a workaround I suppose.
> >
> >
> >
> >
> >
> >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/file/cms/trunk/apps/cms/search.py whyit is not working any more

2007-08-08 Thread Mary

I just want to take a look on the search.py there as i need to use
search in my cms and i tried this lin
https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/file/cms/trunk/apps/cms/search.py
but it is not working
any help ??

Thanks
Mary Adel


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Overwriting the login function

2007-08-08 Thread Matt Davies
Getting there.

It's not setting the logged in as yes as it's not logging me in :-)

This conditional in the login function in views

if request.POST:

is not getting a positive and it's falling through to the else which is
setting errors to blank

else:
print 'balls'
errors = {}
request.session.set_test_cookie()
return render_to_response(template_name, {
'form': oldforms.FormWrapper(manipulator, request.POST, errors),
'matts_back_to': redirect_to,

'site_name': Site.objects.get_current().name,
}, context_instance=RequestContext(request))

which then throws me back to the page without logging me in at all, I can
put any old rubbish into that form.
I think I somehow need to make this part of the secured views do what I
need, really not sure though.

return HttpResponseRedirect("/accounts/login")




On 08/08/07, Matt Davies <[EMAIL PROTECTED]> wrote:
>
> I've copied the /contrib/auth/views.py into my project and edited it like
> so
>
> redirect_to = request.META["HTTP_REFERER"]
>
> return render_to_response(template_name, {
> 'form': oldforms.FormWrapper (manipulator, request.POST, errors),
> 'matts_back_to': redirect_to,
> 'site_name': Site.objects.get_current().name,
>
> I've added in my login forms this as the action
>
> 
>
> Now, when a user comes to a page that shows a view that has this in the
> top
> if request.user.is_authenticated():
> do all your stuff
> else:
> return HttpResponseRedirect("/accounts/login")
>
> If they're not logged in they get sent to directly to the login page, they
> login and get sent back to the page they were trying to access initially.
>
> This works fine, but for some reason the user is not being shown as having
> logged in when they are returned to the initial page.  If they try to access
> another secured page at that point, it asks them to login again, and also
> the login/logout button is showing as logged out.
>
> Anyone got any ideas why?
>
> If this is a really bad way to achieve what I want then please let me
> know, it is a bit of a workaround I suppose.
>
>
>
>
>
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: value for choices arguments for newforms.MultipleSelectField

2007-08-08 Thread Peter Melvyn

On 8/7/07, Chris Brand <[EMAIL PROTECTED]> wrote:

>  self.fields[f].queryset = queryset
>  # Have to force the widget to update itself (bug 4787)
>  self.fields[f].widget.choices = self.fields[f].choices

Hi Chris,

thanks for your help - it solved my problem, but another one has arised:

What should I pass as a dummy queryset parameter: this is positional
mandatory argument and I cannot pass None. Is it correct if I pass

 queryset = _QuerySet()

Thanks, Peter

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



Overwriting the login function

2007-08-08 Thread Matt Davies
I've copied the /contrib/auth/views.py into my project and edited it like so

redirect_to = request.META["HTTP_REFERER"]

return render_to_response(template_name, {
'form': oldforms.FormWrapper(manipulator, request.POST, errors),
'matts_back_to': redirect_to,
'site_name': Site.objects.get_current().name,

I've added in my login forms this as the action



Now, when a user comes to a page that shows a view that has this in the top
if request.user.is_authenticated():
do all your stuff
else:
return HttpResponseRedirect("/accounts/login")

If they're not logged in they get sent to directly to the login page, they
login and get sent back to the page they were trying to access initially.

This works fine, but for some reason the user is not being shown as having
logged in when they are returned to the initial page.  If they try to access
another secured page at that point, it asks them to login again, and also
the login/logout button is showing as logged out.

Anyone got any ideas why?

If this is a really bad way to achieve what I want then please let me know,
it is a bit of a workaround I suppose.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 filter_interface for groups in User model?

2007-08-08 Thread Jarek Zgoda

On 8 Sie, 09:53, Collin Grady <[EMAIL PROTECTED]> wrote:
> Only if you edit the django source :)

God, I was hoping we wouldn't have to do that... :(

Cheers
J.


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



django.views.generic.simple

2007-08-08 Thread james_027

hi,

is the purpose of this view for showing static html page? if not what
is the use of this view?

Thanks
james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 filter_interface for groups in User model?

2007-08-08 Thread Collin Grady

Only if you edit the django source :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: DateField() , AttributeError: 'str' object has no attribute 'strftime'

2007-08-08 Thread Collin Grady

This is not a backend issue at all - the problem is you're assigning a
string to the DateField, which is not what it needs.

DateField/TimeField/DateTimeField need the python objects for them,
not strings.

They convert it to a string internally before save, so that the
database gets the right value, but by keeping it the python objects
outside of that, you don't have to do a lot of string processing if
you need to change a date :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Overriding save methot problem

2007-08-08 Thread Collin Grady

There is no solution, really - the links can't be added until the
model is saved, so they will not be available in save()

The only way you could work with m2m data is in a custom view, since
then you can connect them and do whatever.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Single-line comment doesn't seem to work

2007-08-08 Thread Collin Grady

What version of django are you using? I seem to remember the single
line comments being added after 0.96, though I could be mistaken.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: full-text indexing

2007-08-08 Thread Gábor Farkas

Jarek Zgoda wrote:
> I don't know what do you mean by "transactions" in case of full-text
> search engine as it doesn't do any multi-step updates (only single-
> step deletes or inserts in case of PyLucene).
> 
> Anybody who wants to use PyLucene, be aware that you cann't embed (iow
> "use", "import") PyLucene in your Django application code if your web
> server is either forking or threadinig one. You have to build a
> service that is separated from any threading or forking. Does it still
> seems reasonable to anybody? Well, if yes, welcome to pylucene-dev
> mailing list. ;)

another way to use Lucene in django would be solr 
(http://lucene.apache.org/solr/), but i have never tried it.

gabor

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Trigger a django user password change...

2007-08-08 Thread Jens Diemer

RajeshD schrieb:
> Create a custom view to allow your users to change just their
> password. In that view, you will be able to tell in a straightforward
> fashion if the user has changed her password and take action
> accordingly.

Yes. That would work fine.
Now, i realized that i need the raw_password for my things. With signals i can 
only get the hashed password, not the raw plaintext password.

On the other side, wit signals i can catch every changes from every views. So i 
must build my own views and the user can used the default django views to 
change 
his password.

Is there is an other way to trigger a django user password change and get the 
raw password???


-- 
Mfg.

Jens Diemer



A django powered CMS: http://www.pylucid.org


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



Re: a rather big, new django site:

2007-08-08 Thread [EMAIL PROTECTED]

Hi,
It's cool :)
Can I ask one question: have you used patch 2070 to allow users to
upload stuff? Or have you created one internally? Or do you just use
Django default upload system, where everything goes into RAM?

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