Is there any possibility that one project connect with more than one databases?

2008-12-25 Thread David

Dear all,

I am a newbie in Django and python, now trying to construct a website
with more than one databases on the backend.

My question here is, if there any possibility that using 2 different
databases inside one project(website)?
If yes, how can I do this?
If no, why does Django framwork not support this requirement?

Thx a lot!

David

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



Re: Comma or Currency formats

2009-01-03 Thread David

On Jan 3, 5:33 am, phoebebright  wrote:
> On Jan 2, 7:06 pm, Shay Ben Dov  wrote:
>
> > Hi,
>
> > I'm using GAE and wondering how come there is no comma insertion 
> > orcurrencyformating of floating numbers like:
>
> > {{ value|floatformat:2 }} built_in filter
>
> > Shay
>
> You could 
> tryhttp://docs.djangoproject.com/en/dev/ref/templates/builtins/#floatformat
> o rhttp://docs.djangoproject.com/en/dev/ref/templates/builtins/#stringfo...

If the reference to "comma insertion" is for commas as 1000s
separators, we use the following addition to contrib.humanize.py:

def floatcomma(value):
"""
Converts a float to a string containing commas every three digits.
For example, 3000.65 becomes '3,000.65' and -45000.00 becomes
'-45,000.00'.
"""
orig = force_unicode(value)
intpart, dec = orig.split(".")
intpart = intcomma(intpart)
return ".".join([intpart, dec])
floatcomma.is_safe = True
register.filter(floatcomma)

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



Re: Model inheritance problem in admin

2008-07-14 Thread David

Thanks, Malcolm. It was great to see inheritance in the first place,
and we'll just wait for newforms-admin to use an admin interface to
it.

On Jul 14, 5:51 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-07-14 at 14:46 -0700, David wrote:
> > When I save objects from the admin pages, I get COPIES of what I'm
> > saving. When I save them through the API, I don't get the duplicates.
> > I'd like to know if I'm doing something wrong or misunderstanding
> > something.
>
> You're assuming that model inheritance is supported in the admin
> interface. It isn't. That would be the main problem here.
>
> It's just not worth doing all the work required to change existing admin
> when newforms-admin is arriving so soon. So you'll just have to wait a
> bit (or not use the admin for inherited models).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django and dynamic database'ing

2008-09-01 Thread David

Hi,

I am still learning django and was wondering on the following question
as to how one would go about doing it in the django framework:

If I have a cron job that dynamically creates new tables that are
spawned out of new entries in a main table. For example Table 'Global'
has a new entry 'A' this will generate a new Table called 'A' (and
Table 'A' will be linked to its entry in 'Global') etc.

How would one go about having django interact with this (or perhaps
create)? actually, this leads to another question - can one have
similar procedures to cron job's working with django? such as regular
maintenance or in my case creation of tables due to an external
factor.

If any clarification is needed, just email me.

Also, does anyone have simple example or using django with
script.aculo.us?

Much obliged!
Best,
David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Handling 'unique'

2008-09-02 Thread David

Hi,

when setting (for example)

name = models.CharField('Name', max_length=50, unique = True)

How does one go about handling the exception if a name is entered that
already exists in the database?

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



handling unique entries

2008-09-03 Thread David

Hi,
when setting (for example)
name = models.CharField('Name', max_length=50, unique = True)
How does one go about handling the exception if a name is entered
that
already exists in the database?
Thanks,
David,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 and sql databases

2008-09-03 Thread David

Hi,

I am still learning django and was wondering on the following
question
as to how one would go about doing it in the django framework:
If I have a cron job that dynamically creates new tables that are
spawned out of new entries in a main table. For example Table
'Global'
has a new entry 'A' this will generate a new Table called 'A' (and
Table 'A' will be linked to its entry in 'Global') etc.
How would one go about having django interact with this (or perhaps
create)? actually, this leads to another question - can one have
similar procedures to cron job's working with django? such as regular
maintenance or in my case creation of tables due to an external
factor.

thanks
David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: handling unique entries

2008-09-04 Thread David

In the admin, I just get a trace of errors yayks!


On Sep 3, 5:28 pm, [EMAIL PROTECTED] wrote:
> In the admin, or on the site in a view?
>
> On Sep 3, 12:12 pm, David <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > when setting (for example)
> > name = models.CharField('Name', max_length=50, unique = True)
> > How does one go about handling the exception if a name is entered
> > that
> > already exists in the database?
> > Thanks,
> > David,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 and sql databases

2008-09-04 Thread David

Thanks for your reply, I haven't described the tables (or how) as I am
still trying to rationalise the best approach. Perhaps if I describe
to you want I want to do you'll see the best approach.

Consider the case of a shop (for example) and items can be added to
the shop and their prices continually updated with a date stamp
(although you want to keep the historical prices), but if an item is
discontinued you do not want to remove its historical prices from the
table.

My thinking (which could be wrong) was to generate a table per item
but if I am understanding your suggestion correctly one can add an
extra column within an existing table (and then I assume have another
table for date stamps, or two columns in the original table). In
either case, how would you go about adding columns and have django
deal with the change in table structure?

Thanks,
David

On Sep 3, 10:25 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote:
> Django won't deal well with dynamically-generated tables, as it maps
> classes to tables, so you'd need dynamically-generated classes, and then
> code that could use those classes.  This is the way all ORMs work.
>
> You haven't described these tables, or how (or even why) they are being
> generated.  If they all have the same schema, then "dynamically
> generated tables" means you are going against the grain of a relational
> database.  You will likely be much happier adding one more column to
> your table and using one statically defined table to hold all of the data.
>
> --Ned.http://nedbatchelder.com
>
>
>
> David wrote:
> > Hi,
>
> > I am still learning django and was wondering on the following
> > question
> > as to how one would go about doing it in the django framework:
> > If I have a cron job that dynamically creates new tables that are
> > spawned out of new entries in a main table. For example Table
> > 'Global'
> > has a new entry 'A' this will generate a new Table called 'A' (and
> > Table 'A' will be linked to its entry in 'Global') etc.
> > How would one go about having django interact with this (or perhaps
> > create)? actually, this leads to another question - can one have
> > similar procedures to cron job's working with django? such as regular
> > maintenance or in my case creation of tables due to an external
> > factor.
>
> > thanks
> > David
>
> --
> Ned Batchelder,http://nedbatchelder.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: handling unique entries

2008-09-05 Thread David

Thanks Karen, I've updated.

On Sep 4, 6:02 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Sep 4, 2008 at 12:52 PM, David <[EMAIL PROTECTED]> wrote:
>
> > In the admin, I just get a trace of errors yayks!
>
> What level of Django are you running?  Code was added to admin fairly
> recently to properly check unique constraints:
>
> http://code.djangoproject.com/ticket/8209
>
> If you are running with a level later than that fix (r8805) then details of
> the traceback you see would be helpful.  If you are running an earlier level
> I suggest you upgrade.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Extending User Model with obligatory fields

2008-09-05 Thread David

Hi,

I have a clients table, and I need each user to belong to a client. So
in fact what I need is to extend the user model with one additional
obligatory field.

I have already seen the UserProfile approach, but that is not
obligatory, meaning I can create a user without the profile, because
the profile is in another table, so this approach is not enough.

I have tried the idea in 
http://www.amitu.com/blog/2007/july/django-extending-user-model/,
but i keep getting this error:
'MyUserAdmin.fieldsets[4][1]['fields']' refers to field 'client' that
is missing from the form

The code that originate this is the definition of the fieldsets
following:

User.add_to_class('client',models.ForeignKey(Client))

class MyUserAdmin(UserAdmin):
fieldsets = (
(None, { 'fields': ('client', 'username', 'password') }),
) + UserAdmin.fieldsets[1:]
list_display = ('client', ) + UserAdmin.list_display

Even if this get resolved how can I customize the User add in Admin to
have also the client, and not only the username and password.

Regards

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



form_for_instance

2008-09-06 Thread David

Hi,

newforms and form_for_instance have been removed
How would I write the following using the new notation

I have replaced
from django import newforms as forms
with
from django import forms

but unsure as to what to do with the following

def person_form(request, pID="0")
  p = get_object_or_404(Person, pk=pID)
  PersonForm = forms.form_for_instance(p)
  pForm = PersonForm()
  return render_to_response('person_form.html', {'pForm':pForm})

Thanks,
David.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: form_for_instance

2008-09-06 Thread David

nm i figured it out.

class PersonForm(ModelForm):
class Meta:
  model = Person

def person_form(request, pID='0'):
p = get_object_or_404(Person,pk=pID)
#PersonForm = forms.ModelForm()
pForm = PersonForm()


On Sep 6, 5:03 pm, David <[EMAIL PROTECTED]> wrote:
> Hi,
>
> newforms and form_for_instance have been removed
> How would I write the following using the new notation
>
> I have replaced
> from django import newforms as forms
> with
> from django import forms
>
> but unsure as to what to do with the following
>
> def person_form(request, pID="0")
>       p = get_object_or_404(Person, pk=pID)
>       PersonForm = forms.form_for_instance(p)
>       pForm = PersonForm()
>       return render_to_response('person_form.html', {'pForm':pForm})
>
> Thanks,
> David.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: form_for_instance

2008-09-06 Thread David

oops, should be.

pForm = PersonForm(instance=p)


On Sep 6, 5:14 pm, David <[EMAIL PROTECTED]> wrote:
> nm i figured it out.
>
> class PersonForm(ModelForm):
>     class Meta:
>           model = Person
>
> def person_form(request, pID='0'):
>     p = get_object_or_404(Person,pk=pID)
> #    PersonForm = forms.ModelForm()
>     pForm = PersonForm()
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



interacting django with external programs

2008-09-06 Thread David

Hey'a I have a newbie question.

I want to execute an external (lets say python, but can be any)
program given a interval set by a user (which would be in the user
table). The external program would update the sql database.

I thought of doing this with a cronjob but as they may be a number of
users with a different set intervals, and this can be changed at any
time by the user so I don't feel as a cronjob would be seamless.

How would I go about accomplishing something like this? does anyone
have any pointers, tutorials, advise

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



Re: interacting django with external programs

2008-09-07 Thread David

Thanks Ned, and what about the case when it may be an unreasonable
interval?
is there any other way of interaction than crontab (eitherway, are
they any example
of this - as I've mentioned I am a complete newbie).

Thx.

On Sep 6, 10:03 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote:
> You're right: making a crontab entry for each user's needs would be
> cumbersome.  But if you have a reasonable minimum interval (say 10
> minutes), then write one cronjob that looks for all of the user's jobs
> that need to be run.  Then you have one crontab entry, and the rest of
> the work is in your Python code.
>
> --Ned.http://nedbatchelder.com
>
>
>
> David wrote:
> > Hey'a I have a newbie question.
>
> > I want to execute an external (lets say python, but can be any)
> > program given a interval set by a user (which would be in the user
> > table). The external program would update the sql database.
>
> > I thought of doing this with a cronjob but as they may be a number of
> > users with a different set intervals, and this can be changed at any
> > time by the user so I don't feel as a cronjob would be seamless.
>
> > How would I go about accomplishing something like this? does anyone
> > have any pointers, tutorials, advise
>
> > Thanks,
> > D.
>
> --
> Ned Batchelder,http://nedbatchelder.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
-~--~~~~--~~--~--~---



Forms

2008-09-09 Thread David

Hey, I seem to be doing something wrong as when I click on the button
on the page the message does not change?

-

{% block title %}Person Form{% endblock %}
{% block content %}
{{ message }}



{{ pForm }}



{% endblock %}

-

class PersonForm(ModelForm):
class Meta:
  model = Person

def person_form(request, pID='0'):
f = PersonForm()
message= 'Unknown Request'
p = get_object_or_404(Person,pk=pID)

if request.method == 'GET':
f = PersonForm(instance=p)
message = 'Editing person %s ' % p.name

if request.method == 'POST':
if request.POST['submit'] == 'update':
message = 'Update Request for %s ' % p.name

return render_to_response('People/person_form.html', {'pForm':
f,'message': message})


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



Re: Forms

2008-09-09 Thread David

duh! apologies - misspelt 'FORM' (Jesus)


On Sep 9, 6:34 pm, David <[EMAIL PROTECTED]> wrote:
> Hey, I seem to be doing something wrong as when I click on the button
> on the page the message does not change?
>
> --- 
> --
>
> {% block title %}Person Form{% endblock %}
> {% block content %}
> {{ message }}
>
> 
> 
> {{ pForm }}
> 
> 
> 
> {% endblock %}
>
> --- 
> --

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



updating entry from form in django 1.0!?

2008-09-10 Thread David

whereas once you had

p = get_object_or_404(Person, pk=pID)
MyForm = forms.form_for_instance(p)
f = MyForm(request.POST.copy())

how on earth do you do it now?
I've tried simply f = MyForm(request.POST.copy()) where MyForm is
previously defined as a class with model=Person, but then django
thinks its a new entry rather than an update (have unique) how can I
specify that this is an update and linked to 'p'?

I can't find a straight forward example yelp!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: updating entry from form in django 1.0!?

2008-09-10 Thread David

Thanks, are they also any example of the case of form_for_model (as I
am assuming the above is only with respect to form_for_instance)

Thx.
D.

On Sep 10, 9:32 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Sep 10, 8:56 am, David <[EMAIL PROTECTED]> wrote:
>
> > whereas once you had
>
> > p = get_object_or_404(Person, pk=pID)
> > MyForm = forms.form_for_instance(p)
> > f = MyForm(request.POST.copy())
>
> > how on earth do you do it now?
> > I've tried simply f = MyForm(request.POST.copy()) where MyForm is
> > previously defined as a class with model=Person, but then django
> > thinks its a new entry rather than an update (have unique) how can I
> > specify that this is an update and linked to 'p'?
>
> > I can't find a straight forward example yelp!
>
> f = MyForm(request.POST, instance=p)
>
> Seehttp://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: updating entry from form in django 1.0!?

2008-09-10 Thread David

not exactly, it seems that originally form_for_instance and
form_for_object had different functions.

I have a class

class Blog(models.Model):
   title = models.CharField('Title',max_length=200)
   text = models.TextField('Text',max_length=2048)
   date = models.DateTimeField('Last Modified')

   def __unicode__(self):
  return '%s' % (self.title)

and I wanted to have something along these lines but don't know how to
convert to the new convention

BlogForm = forms.form_for_model(Blog, fields=('title','text')
bf = BlogForm()
p = get_object_or_404(Person,pk=pID)

if request.method == 'POST':
   if request.POST['submit'] == 'add':
  bf = BlogForm(request.POST.copy())
  SaveForm = forms.form_for_model(Blog)
...

On Sep 10, 10:42 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Sep 10, 9:56 am, David <[EMAIL PROTECTED]> wrote:
>
> > Thanks, are they also any example of the case of form_for_model (as I
> > am assuming the above is only with respect to form_for_instance)
>
> > Thx.
> > D.
>
> But that's just what you had already:
>
> > > > I've tried simply f = MyForm(request.POST.copy()) where MyForm is
> > > > previously defined as a class with model=Person, but then django
> > > > thinks its a new entry rather than an update
>
> Isn't that what you want?
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



POST data delay

2008-10-14 Thread david

Hi hope all is well.  Please tell me if this is related to Django.

Using Django 1.0 with Apache 2.2.9.

Have a very simple form by writing to the Httpresponse directly.


r = HttpResponse()
r.write('')
r.write('First name: ')
r.write('')
r.write('')
return r

After the form is displayed on the browser, if I don't wait about 5
seconds before clicking the submit button, the POST content is lost.
As in, when i try to write out the POST content, it doesn't write
anything, whereas I can write out the current time, and the time
changes as expected.  Could this be to do with some configuration on
Django?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: POST data delay

2008-10-14 Thread david



On Oct 15, 11:42 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-10-14 at 17:38 -0700, david wrote:
> > Hi hope all is well.  Please tell me if this is related to Django.
>
> > Using Django 1.0 with Apache 2.2.9.
>
> > Have a very simple form by writing to the Httpresponse directly.
>
> > r = HttpResponse()
> > r.write('')
> > r.write('First name: ')
> > r.write('')
> > r.write('')
> > return r
>
> If you look at the source, you can see that all write() does is append
> to the content of the class. So the net effect of the above code is the
> same as constructing it all at once and returning.
>
> This is something else. There's no reason at all to suspect Django here,
> since all Django's work is done before any content is returned.
>
> Regards,
> Malcolm

Thanks for the quick reply Malcolm. I don't doubt the code, as they
are almost a straight copy from the example directory.  I'll keep
looking.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Non-Programmer Help: filter_insterface error?

2008-10-14 Thread David

Hello,

I'm not a python programmer, this is the first time I've ever worked
with a python app.  I'm trying to install "Surftrackr" for my company
and I have a problem.  I have searched and can not find any clear
answers.

I have the installed the latest svn of Django. (I started out with the
released tarball)  This is the error I get:

[EMAIL PROTECTED]:/usr/local/surftrackr# ./manage.py syncdb
Traceback (most recent call last):
  File "./manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 340, in execute_manager
utility.execute()
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 221, in execute
self.validate()
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 128, in get_app_errors
self._populate()
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "/usr/local/surftrackr/../surftrackr/log/models.py", line 72,
in 
class User(models.Model):
  File "/usr/local/surftrackr/../surftrackr/log/models.py", line 87,
in User
workstation   = models.ManyToManyField(Workstation,
null=True, blank=True, filter_interface=True)
  File "/usr/lib/python2.5/site-packages/django/db/models/fields/
related.py", line 759, in __init__
Field.__init__(self, **kwargs)
TypeError: __init__() got an unexpected keyword argument
'filter_interface'

Can someone please help me with this?

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



Re: Non-Programmer Help: filter_insterface error?

2008-10-15 Thread David

Thank you Karen.

I've gotten a little further on this, here is my new error after
downgrading to 0.96.3:

[EMAIL PROTECTED]:/usr/local/surftrackr# ./manage.py syncdb
Error: Couldn't install apps, because there were errors in one or more
models:
surftrackr.httpauth: __init__() got an unexpected keyword argument
'max_length'
surftrackr.log: __init__() got an unexpected keyword argument
'max_length'
surftrackr.wordsearch: __init__() got an unexpected keyword argument
'max_length'
surftrackr.trackr: __init__() got an unexpected keyword argument
'max_length'
surftrackr.preferences: __init__() got an unexpected keyword argument
'max_length'



On Oct 14, 11:25 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 15, 2008 at 1:20 AM, David <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I'm not a python programmer, this is the first time I've ever worked
> > with a python app.  I'm trying to install "Surftrackr" for my company
> > and I have a problem.  I have searched and can not find any clear
> > answers.
>
> > I have the installed the latest svn of Django. (I started out with the
> > released tarball)  This is the error I get:
>
> > [EMAIL PROTECTED]:/usr/local/surftrackr# ./manage.py syncdb
> > [snipped]
>
>    workstation           = models.ManyToManyField(Workstation,> null=True, 
> blank=True, filter_interface=True)
> >  File "/usr/lib/python2.5/site-packages/django/db/models/fields/
> > related.py", line 759, in __init__
> >    Field.__init__(self, **kwargs)
> > TypeError: __init__() got an unexpected keyword argument
> > 'filter_interface'
>
> > Can someone please help me with this?
>
> This "Surftrackr"is apparently coded to an earlier version of Django than
> 1.0.  This specific error is related to a larger change in the way admin
> definitions are done, see:
>
> http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Moved...
>
> Ideally you'd want to get a version of this app from its makers that has
> been migrated to Django 1.0, but from a brief look 
> athttp://surftrackr.net/blog/index/they call their March 26, 2008 release
> "probably final" so it sounds like they are no longer maintaining it.  The
> "About" page lists an email address for the owner, though, so you could try
> that and see if there are any plans to make it compatible with 1.0.
>
> Django 0.96.3 is still available from the download page, so you could try
> installing this app on that level.  I'd really hesitate to do any
> development of new code on that old level, though.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Non-Programmer Help: filter_insterface error?

2008-10-15 Thread David

Can you tell me what the last Revision from the SVN that supported the
filter_interface.
The Surftrackr docs specifically state that 0.96 is not support and to
use the latest svn.
This is in April of 2008.

On Oct 14, 11:25 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 15, 2008 at 1:20 AM, David <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I'm not a python programmer, this is the first time I've ever worked
> > with a python app.  I'm trying to install "Surftrackr" for my company
> > and I have a problem.  I have searched and can not find any clear
> > answers.
>
> > I have the installed the latest svn of Django. (I started out with the
> > released tarball)  This is the error I get:
>
> > [EMAIL PROTECTED]:/usr/local/surftrackr# ./manage.py syncdb
> > [snipped]
>
>    workstation           = models.ManyToManyField(Workstation,> null=True, 
> blank=True, filter_interface=True)
> >  File "/usr/lib/python2.5/site-packages/django/db/models/fields/
> > related.py", line 759, in __init__
> >    Field.__init__(self, **kwargs)
> > TypeError: __init__() got an unexpected keyword argument
> > 'filter_interface'
>
> > Can someone please help me with this?
>
> This "Surftrackr"is apparently coded to an earlier version of Django than
> 1.0.  This specific error is related to a larger change in the way admin
> definitions are done, see:
>
> http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Moved...
>
> Ideally you'd want to get a version of this app from its makers that has
> been migrated to Django 1.0, but from a brief look 
> athttp://surftrackr.net/blog/index/they call their March 26, 2008 release
> "probably final" so it sounds like they are no longer maintaining it.  The
> "About" page lists an email address for the owner, though, so you could try
> that and see if there are any plans to make it compatible with 1.0.
>
> Django 0.96.3 is still available from the download page, so you could try
> installing this app on that level.  I'd really hesitate to do any
> development of new code on that old level, though.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Non-Programmer Help: filter_insterface error?

2008-10-15 Thread David

THANK YOU
THANK YOU
THANK YOU
THANK YOU

7388 worked perfectly!

On Oct 15, 8:40 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 15, 2008 at 11:15 AM, David <[EMAIL PROTECTED]> wrote:
>
> > Can you tell me what the last Revision from the SVN that supported the
> > filter_interface.
> > The Surftrackr docs specifically state that 0.96 is not support and to
> > use the latest svn.
> > This is in April of 2008.
>
> Scanning the revision log (http://code.djangoproject.com/log/django/trunk),
> r7388 was the last revision made in March of 2008.  I'd pick one from around
> there vs. going to the last before filter_interface was dropped (which was a
> few months later) because there may be other backwards-incompatible changes
> you'll hit with code last changed in March of 2008.  If you stick with a
> revision from around when it was released you'll avoid that.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django Production Setup / Threading / Fcgi

2009-01-27 Thread David

Hello,

iam new to django and in the phase of researching django production features. 
Iam planing to run django as fcgi behind a thin webserver. Can some point me 
out a good read or resource to find more about this topics. Iam specially 
interested in the problem about scaling, regarding threading and the GIL 
problem coming with that. 
Do i have to plan a 1-process-per-client setup ( and the memfootprint cominng 
with this) or does the fcgi/django run threaded?  
I found a few older posting on this list regarding the threading issues in 
django, but iam still not sure what kind of behaviour and problems i will 
expect in a bigger production enviroment.
 
Regards David

 


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



Is it possible to write this with Q package?

2009-07-10 Thread David

Hello,

I have some records in MySQL database. Each record has

id: Primary Key, autoincrement
Type: varchar
Price: float
Date: dateTime

Type can be a "car" or a "truck".  There are many records whose Type
is "car" or whose Type is "truck".
Date has a format of "2009-07-07 20:00:00".  This values changes on a
hourly basis.

Now for each Type ("car" or "truck"),  I need to find how its price
changes for the last hour vs. the previous hour. For example,  assume
that it is now 6:00am and the price for "car" is $16,000. Just one
hour ago (5:00am) the price for "car" was $16,500.  Then the price
changes by 16,000 / 16,500 = 0.97.  I need this value 0.97.

Is it possible to finish this work with Q package? Can anybody give me
a hint how to do it? I have studied Q package and related examples
however I still feel at loss.

Thanks so much.









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



How to get this value

2009-07-13 Thread David

Hello,

I have following code:

alertcriteria1 = Alert_Criteria1.objects.all
()...(1.)

for eachcriterion in
alertcriteria1:.
(2.)
dataset1 =
eachcriterion.dataset.(3.)
criteria1_metric1=
eachcriterion.criteria1_metric1.(4.)

alerts   = Alert.objects.filter(Q(dataset =
dataset1))...(5.)

for eachalert in
alerts:.
(6.)
e_metric1 =
eachalert.criteria1_metric1(7.)


In line 7, the "criteria1_metric1" is acutally a value from line 4.
Right now Django complains. How to replace this value?

Thanks so much.


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



Re: How to get this value

2009-07-13 Thread David

I do not know why the code gets seperated. Here it is.

   alertcriteria1 = Alert_Criteria1.objects.all()

for eachcriterion in alertcriteria1:
dataset1 =
eachcriterion.dataset
criteria1_metric1=
eachcriterion.criteria1_metric1

alerts   = Alert.objects.filter(Q(dataset =
dataset1))

for eachalert in alerts:
e_metric1 =
eachalert.criteria1_metric1

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



Re: How to get this value

2009-07-13 Thread David

Thanks Amit. Here is the problem that I meet.

alerts = Alert.objects.filter((Q(dataset=dataset1)

for eachalert in alerts:
e_metric1 = eachalert.criteria1_metric1


Django complains that there is no such item "criteria1_metric1" in
Alert class. This is correct as Alert class does not have such an
item. The "criteria1_metric1" is a variable here that has a value. And
this value is an item in the Alert class.

How to let Django know that the "criteria1_metric1" is a variable
instead of a class item (table column)?
Thanks again.


On Jul 13, 2:14 pm, Amit Sethi  wrote:
> I am not sure what you are trying to do. And the code seems almost unreadable 
> .
> You could try posting the code to :http://pastebin.com/
>
> Also what might be helpful:
> What is the problem statement what is this code trying to solve ?
>
> What value you want  and  where ?
>
> And what error does django give ...
>
> --
> A-M-I-T S|S
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get this value

2009-07-13 Thread David

Thanks Javier. I got


Traceback (most recent call last):
  File "", line 1, in 
  File "/home/dwang/alert/../alert/message/models.py", line 245, in
check_criteria1
metric11 = eachalert[criteria1_metric1]
TypeError: 'Alert' object is unsubscriptable
>>>

any more ideas? I am also googling online to see if I can find a
solution.



On Jul 13, 3:29 pm, Javier Guerra  wrote:
> On Mon, Jul 13, 2009 at 4:36 PM, David wrote:
>
> > Thanks Amit. Here is the problem that I meet.
>
> > alerts = Alert.objects.filter((Q(dataset=dataset1)
>
> > for eachalert in alerts:
> >    e_metric1 = eachalert.criteria1_metric1
>
> try "e_metric1 = eachalert[criteria1_metric1]"
>
> --
> Javier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get this value

2009-07-13 Thread David

still no lucky...

Traceback (most recent call last):
  File "", line 1, in 
  File "/home/dwang/alert/../alert/message/models.py", line 245, in
check_criteria1
metric11 = eachalert.get(criteria1_metric1)
AttributeError: 'Alert' object has no attribute 'get'
>>>




On Jul 13, 3:53 pm, Javier Guerra  wrote:
> On Mon, Jul 13, 2009 at 5:48 PM, David wrote:
> > TypeError: 'Alert' object is unsubscriptable
>
> sorry, i was mixing languages.
>
> try "e_metric1 = eachalert.get (criteria1_metric1)"
>
> --
> Javier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get this value

2009-07-13 Thread David

Hi Sam,

Cool! It works.

Thanks so much!

On Jul 13, 4:49 pm, Sam Lai  wrote:
> Try:
>
> getattr(eachalert, criteria1_metric1) or something similar. look up
> the getattr python function.
>
> On 7/14/09, David  wrote:
>
>
>
>
>
>
>
> > still no lucky...
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/home/dwang/alert/../alert/message/models.py", line 245, in
> > check_criteria1
> >     metric11     = eachalert.get(criteria1_metric1)
> > AttributeError: 'Alert' object has no attribute 'get'
>
> > On Jul 13, 3:53 pm, Javier Guerra  wrote:
> >> On Mon, Jul 13, 2009 at 5:48 PM, David wrote:
> >> > TypeError: 'Alert' object is unsubscriptable
>
> >> sorry, i was mixing languages.
>
> >> try "e_metric1 = eachalert.get (criteria1_metric1)"
>
> >> --
> >> Javier
>
> --
> Sent from my mobile device- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get this value

2009-07-13 Thread David

Hi Karen,

Thanks for your long reply. Though this problem has been solved
(Thanks to all for your replies, especially Sam), let me explain a
little more.

The 2nd for loop is actually an embedded loop in the 1st for loop.
>From the 1st loop I retrieve some values, and use these values (as
"model instance") to retrieve other values in the 2nd for loop.  This
logic is clear. And with Sam's help, I have got all those values that
I wanted.

I should say that the bad format in my original post should be blamed
for this confusion. I noticed that you put the 2nd for loop outside
the first for loop. This is not what I wanted.

Thanks again.





On Jul 13, 4:52 pm, Karen Tracey  wrote:
> On Mon, Jul 13, 2009 at 5:36 PM, David  wrote:
>
> > Thanks Amit. Here is the problem that I meet.
>
> > alerts = Alert.objects.filter((Q(dataset=dataset1)
>
> > for eachalert in alerts:
> >    e_metric1 = eachalert.criteria1_metric1
>
> > Django complains that there is no such item "criteria1_metric1" in
> > Alert class. This is correct as Alert class does not have such an
> > item. The "criteria1_metric1" is a variable here that has a value. And
> > this value is an item in the Alert class.
>
> What do you mean "this value is an item in the Alert class"?  Items in the
> Alert class are model instances which presumably have a set of different
> field values.  So I can't figure out what you by this sentence.
>
> > How to let Django know that the "criteria1_metric1" is a variable
> > instead of a class item (table column)?
> > Thanks again.
>
> The code you originally posted, reformatted to not wrap somewhat randomly
> and removing the long strings of dots and line number is:
>
> alertcriteria1 = Alert_Criteria1.objects.all()
> for eachcriterion in alertcriteria1:
>     dataset1 = eachcriterion.dataset
>     criteria1_metric1 = eachcriterion.criteria1_metric1
> alerts = Alert.objects.filter(Q(dataset = dataset1))
> for eachalert in alerts:
>     e_metric1 = eachalert.criteria1_metric1
>
> First you loop through all of the Alert_Criteria1 objects.  In that loop you
> set a couple of variables, dataset1 and criteria1_metric1.  As written,
> these are local variables in your function.  The loop seems pretty pointless
> as at each iteration of the loop you simply overwrite the local variable
> values from the last iteration.  So on exit from the loop these two
> variables will have values from the last item in
> Alert_Criteria1.objects.all().  The values from all of the other
> Alert_Criteria1 objects have not been saved anywhere.
>
> Then you loop through a different set of objects, Alert.  And you try to set
> a local variable, e_metric1, to be the value of the 'criteria1_metric1'
> attribute of the current loop iteration's Alert model instance.  But you say
> that you know 'criteria1_metric!1' is not an attribute of an Alert, rather
> you want what you set back up in the first loop.  If that was what you
> really wanted, your line of code would be:
>
>     e_metric1 = criteria1_metric1
>
> But I don't think that can be what you really want because it would be
> pretty pointless to set the value of one local variable to be equal to while
> looping over a set of objects.  That line of code would have nothing to do
> with the objects you are iterating over.
>
> If you could take a step back and explain what it is at a high level that
> you are trying to do, someone may be able to help.  As it is I suspect your
> code is nowhere near doing what you are looking for, and solving the exact
> attribute error or whatever it is you are seeing now is not really going to
> get you any closer to whatever it is you are trying to achieve.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get this value

2009-07-13 Thread David

Before I posted my code, I formatted them carefully on wordpad.
However, they became so messy after I posted them.

Is it possible to do anything to clear such a problem?  just wondering
this.






On Jul 13, 5:15 pm, David  wrote:
> Hi Karen,
>
> Thanks for your long reply. Though this problem has been solved
> (Thanks to all for your replies, especially Sam), let me explain a
> little more.
>
> The 2nd for loop is actually an embedded loop in the 1st for loop.
> From the 1st loop I retrieve some values, and use these values (as
> "model instance") to retrieve other values in the 2nd for loop.  This
> logic is clear. And with Sam's help, I have got all those values that
> I wanted.
>
> I should say that the bad format in my original post should be blamed
> for this confusion. I noticed that you put the 2nd for loop outside
> the first for loop. This is not what I wanted.
>
> Thanks again.
>
> On Jul 13, 4:52 pm, Karen Tracey  wrote:
>
>
>
> > On Mon, Jul 13, 2009 at 5:36 PM, David  wrote:
>
> > > Thanks Amit. Here is the problem that I meet.
>
> > > alerts = Alert.objects.filter((Q(dataset=dataset1)
>
> > > for eachalert in alerts:
> > >    e_metric1 = eachalert.criteria1_metric1
>
> > > Django complains that there is no such item "criteria1_metric1" in
> > > Alert class. This is correct as Alert class does not have such an
> > > item. The "criteria1_metric1" is a variable here that has a value. And
> > > this value is an item in the Alert class.
>
> > What do you mean "this value is an item in the Alert class"?  Items in the
> > Alert class are model instances which presumably have a set of different
> > field values.  So I can't figure out what you by this sentence.
>
> > > How to let Django know that the "criteria1_metric1" is a variable
> > > instead of a class item (table column)?
> > > Thanks again.
>
> > The code you originally posted, reformatted to not wrap somewhat randomly
> > and removing the long strings of dots and line number is:
>
> > alertcriteria1 = Alert_Criteria1.objects.all()
> > for eachcriterion in alertcriteria1:
> >     dataset1 = eachcriterion.dataset
> >     criteria1_metric1 = eachcriterion.criteria1_metric1
> > alerts = Alert.objects.filter(Q(dataset = dataset1))
> > for eachalert in alerts:
> >     e_metric1 = eachalert.criteria1_metric1
>
> > First you loop through all of the Alert_Criteria1 objects.  In that loop you
> > set a couple of variables, dataset1 and criteria1_metric1.  As written,
> > these are local variables in your function.  The loop seems pretty pointless
> > as at each iteration of the loop you simply overwrite the local variable
> > values from the last iteration.  So on exit from the loop these two
> > variables will have values from the last item in
> > Alert_Criteria1.objects.all().  The values from all of the other
> > Alert_Criteria1 objects have not been saved anywhere.
>
> > Then you loop through a different set of objects, Alert.  And you try to set
> > a local variable, e_metric1, to be the value of the 'criteria1_metric1'
> > attribute of the current loop iteration's Alert model instance.  But you say
> > that you know 'criteria1_metric!1' is not an attribute of an Alert, rather
> > you want what you set back up in the first loop.  If that was what you
> > really wanted, your line of code would be:
>
> >     e_metric1 = criteria1_metric1
>
> > But I don't think that can be what you really want because it would be
> > pretty pointless to set the value of one local variable to be equal to while
> > looping over a set of objects.  That line of code would have nothing to do
> > with the objects you are iterating over.
>
> > If you could take a step back and explain what it is at a high level that
> > you are trying to do, someone may be able to help.  As it is I suspect your
> > code is nowhere near doing what you are looking for, and solving the exact
> > attribute error or whatever it is you are seeing now is not really going to
> > get you any closer to whatever it is you are trying to achieve.
>
> > Karen- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to create this filter

2009-07-24 Thread David

Hello,

Here is a table "myTable" with columns of "col1", "col2", "col3", ...,
"col5". The types of these columns are all float. Now for two values
from any two columns of these columns, I may need to add, or subtract,
or multiply or divide these two values. With this result, I do a
condition check.

For example, I want to retrieve all objects that meet "col1_value /
col2_value >= 2.0". How to create such a filter? It seems to me that F
() might be the right choice, however the document on this part in
QuerySet API is quite rough.

Anybody knows how to create such a filter? or anybody knows any url
links that introduce F() in details?

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



Re: How to create this filter

2009-07-24 Thread David

Such a transformation is fine. I found that my Django has no F().
Checking the Django doc I saw that this new feature is "New in Django
Development version".

So I have to wait for the new version? Are there any other ways to
create such a filter?

Any ideas?

Thanks again.



On Jul 24, 2:01 pm, Frédéric Hébert  wrote:
> It seems to me that you have to transform your fields lookup like that :
>
>  col1_value >= col2_value * 2
>
> something like col1__gte=F('col2') * 2
>
> Frédéric
>
> 2009/7/24 David :
>
>
>
>
>
>
>
> > Hello,
>
> > Here is a table "myTable" with columns of "col1", "col2", "col3", ...,
> > "col5". The types of these columns are all float. Now for two values
> > from any two columns of these columns, I may need to add, or subtract,
> > or multiply or divide these two values. With this result, I do a
> > condition check.
>
> > For example, I want to retrieve all objects that meet "col1_value /
> > col2_value >= 2.0". How to create such a filter? It seems to me that F
> > () might be the right choice, however the document on this part in
> > QuerySet API is quite rough.
>
> > Anybody knows how to create such a filter? or anybody knows any url
> > links that introduce F() in details?
>
> > Thanks so much.
>
> --http://www.openidfrance.fr/fhebert- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create this filter

2009-07-24 Thread David

Great. I go to pick up extra() to use.

Thanks Tim.



On Jul 24, 2:33 pm, Tim Chase  wrote:
> > Such a transformation is fine. I found that my Django has no F().
> > Checking the Django doc I saw that this new feature is "New in Django
> > Development version".
>
> > So I have to wait for the new version? Are there any other ways to
> > create such a filter?
> >>  col1_value >= col2_value * 2
>
> >> something like col1__gte=F('col2') * 2
>
> You can always fall back to the .extra() method[1]:
>
>    results = MyFoo.objects.extra(where=[
>      "col1_value >= col2_value * 2",
>      ])
>
> which is how it was done back in the day before ya'll young
> whippersnappers had such fancy shenanigans as F() objects...and
> to get data, we walked up hill, in the snow.  Both ways.  ;-)
>
> -tim
>
> [1]http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-sele...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create this filter

2009-07-24 Thread David

Here comes a new problem. I do not know which columns' values to use;
all I know is that they are represented with variables. These
variables are

col_var_1, condition_operator, col_var_2, manipulation_operator,
constant_value

where:
col_var_1:  col1, or col2, or col3, etc
condition_operator: >, >=, <, =, etc
col_var_2: col1, or col2, etc
manipulation_operator: +, -, x, /
constant_value: float value

in the where clause, I have to use these variables. What's the
syntax?

any help? thanks so much.







On Jul 24, 2:39 pm, David  wrote:
> Great. I go to pick up extra() to use.
>
> Thanks Tim.
>
> On Jul 24, 2:33 pm, Tim Chase  wrote:
>
>
>
> > > Such a transformation is fine. I found that my Django has no F().
> > > Checking the Django doc I saw that this new feature is "New in Django
> > > Development version".
>
> > > So I have to wait for the new version? Are there any other ways to
> > > create such a filter?
> > >>  col1_value >= col2_value * 2
>
> > >> something like col1__gte=F('col2') * 2
>
> > You can always fall back to the .extra() method[1]:
>
> >    results = MyFoo.objects.extra(where=[
> >      "col1_value >= col2_value * 2",
> >      ])
>
> > which is how it was done back in the day before ya'll young
> > whippersnappers had such fancy shenanigans as F() objects...and
> > to get data, we walked up hill, in the snow.  Both ways.  ;-)
>
> > -tim
>
> > [1]http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-sele...-
> >  Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create this filter

2009-07-24 Thread David

I used this syntax


.extra(where=['%s >= %s - %s'], params=['criteria1_metric1',
'criteria1_metric2',  'criteria1_value'])

however I got error.


On Jul 24, 4:16 pm, David  wrote:
> Here comes a new problem. I do not know which columns' values to use;
> all I know is that they are represented with variables. These
> variables are
>
> col_var_1, condition_operator, col_var_2, manipulation_operator,
> constant_value
>
> where:
> col_var_1:  col1, or col2, or col3, etc
> condition_operator: >, >=, <, =, etc
> col_var_2: col1, or col2, etc
> manipulation_operator: +, -, x, /
> constant_value: float value
>
> in the where clause, I have to use these variables. What's the
> syntax?
>
> any help? thanks so much.
>
> On Jul 24, 2:39 pm, David  wrote:
>
>
>
> > Great. I go to pick up extra() to use.
>
> > Thanks Tim.
>
> > On Jul 24, 2:33 pm, Tim Chase  wrote:
>
> > > > Such a transformation is fine. I found that my Django has no F().
> > > > Checking the Django doc I saw that this new feature is "New in Django
> > > > Development version".
>
> > > > So I have to wait for the new version? Are there any other ways to
> > > > create such a filter?
> > > >>  col1_value >= col2_value * 2
>
> > > >> something like col1__gte=F('col2') * 2
>
> > > You can always fall back to the .extra() method[1]:
>
> > >    results = MyFoo.objects.extra(where=[
> > >      "col1_value >= col2_value * 2",
> > >      ])
>
> > > which is how it was done back in the day before ya'll young
> > > whippersnappers had such fancy shenanigans as F() objects...and
> > > to get data, we walked up hill, in the snow.  Both ways.  ;-)
>
> > > -tim
>
> > > [1]http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-sele...Hide
> > >  quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create this filter

2009-07-24 Thread David

anybody likes to give me help? thanks so much.



On Jul 24, 4:23 pm, David  wrote:
> I used this syntax
>
> .extra(where=['%s >= %s - %s'], params=['criteria1_metric1',
> 'criteria1_metric2',  'criteria1_value'])
>
> however I got error.
>
> On Jul 24, 4:16 pm, David  wrote:
>
>
>
> > Here comes a new problem. I do not know which columns' values to use;
> > all I know is that they are represented with variables. These
> > variables are
>
> > col_var_1, condition_operator, col_var_2, manipulation_operator,
> > constant_value
>
> > where:
> > col_var_1:  col1, or col2, or col3, etc
> > condition_operator: >, >=, <, =, etc
> > col_var_2: col1, or col2, etc
> > manipulation_operator: +, -, x, /
> > constant_value: float value
>
> > in the where clause, I have to use these variables. What's the
> > syntax?
>
> > any help? thanks so much.
>
> > On Jul 24, 2:39 pm, David  wrote:
>
> > > Great. I go to pick up extra() to use.
>
> > > Thanks Tim.
>
> > > On Jul 24, 2:33 pm, Tim Chase  wrote:
>
> > > > > Such a transformation is fine. I found that my Django has no F().
> > > > > Checking the Django doc I saw that this new feature is "New in Django
> > > > > Development version".
>
> > > > > So I have to wait for the new version? Are there any other ways to
> > > > > create such a filter?
> > > > >>  col1_value >= col2_value * 2
>
> > > > >> something like col1__gte=F('col2') * 2
>
> > > > You can always fall back to the .extra() method[1]:
>
> > > >    results = MyFoo.objects.extra(where=[
> > > >      "col1_value >= col2_value * 2",
> > > >      ])
>
> > > > which is how it was done back in the day before ya'll young
> > > > whippersnappers had such fancy shenanigans as F() objects...and
> > > > to get data, we walked up hill, in the snow.  Both ways.  ;-)
>
> > > > -tim
>
> > > > [1]http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-sele...quoted
> > > >  text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create this filter

2009-07-25 Thread David

If I use variable names without quotes in "params[]", I get errors
too.

My Python is 2.5.  It does not have this string formatting feature.
It's new in 2.6.



On Jul 25, 6:58 am, Necmettin  wrote:
> On 25 Temmuz, 02:23, David  wrote:
>
> > I used this syntax
>
> > .extra(where=['%s >= %s - %s'], params=['criteria1_metric1',
> > 'criteria1_metric2',  'criteria1_value'])
>
> > however I got error.
>
> You seem to be using the variables' names as strings:>>> criteria1_metric1 = 
> 'somevalue'
> >>> criteria1_metric1
> 'somevalue'
> >>> 'criteria1_metric1'
>
> 'criteria1_metric1'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is it possible to combine these two queries?

2009-07-30 Thread David

Hi,

I have two queries as follows.


al_1 = Alert.objects.filter(creation_date__regex=today).values
('dimension1').annotate(Sum('metric1')).order_by('dimension1')

and

al_2 = Alert.objects.filter(creation_date__regex=yesterday).values
('dimension1').annotate(Sum('metric1')).order_by('dimension1')

They are almost the same except that al_1 is for today's data and al_2
is for yesterday's data. They summarize data in column "metric1" that
is grouped and ordered by "dimension1".

Sample data from al_1:

[{'metric1__sum': 0.0, 'dimension1': u'1'}, {'metric1__sum': 14.0,
'dimension1': u'110044'}, {'metric1__sum': 2658.0, 'dimension1':
u'110085'}, {'metric1__sum': 0.0, 'dimension1': u'110181'},
{'metric1__sum': 71.0, 'dimension1': u'110208'}, {'metric1__sum':
5850.0, 'dimension1': u'110219'}, {'metric1__sum': 97.0, 'dimension1':
u'110235'}, {'metric1__sum': 48253.0, 'dimension1': u'110251'}, ...]

and sample data from al_2:

[{'metric1__sum': 0.0, 'dimension1': u'1'}, {'metric1__sum': 16.0,
'dimension1': u'110044'}, {'metric1__sum': 2758.0, 'dimension1':
u'110085'}, {'metric1__sum': 67.0, 'dimension1': u'110208'},
{'metric1__sum': 5783.0, 'dimension1': u'110219'}, {'metric1__sum':
100.0, 'dimension1': u'110235'}, {'metric1__sum': 50688.0,
'dimension1': u'110251'},]


What I need to do is to find a ratio value for each "dimension1"
between its today's value and yesterday's value.  For example, for
dimension1 = '110085', I need to find 2758.0 / 2658.0 = 1.04.
Then I compare this value "1.04" with a threshold and process
further.

I know that I can use a for loop to traverse those results (al_1 and
al_2), get ratio values, compare them, etc. However, I wonder if there
is a way to do all this work with one query instead of using two
queries and one for loop?

Any ideas and suggestions?

Thanks so much.











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



Template and substitute

2009-08-01 Thread David

Hi,

When I  tested sql of MySQL in Python interactive shell, I got an
error of "not enough arguments for format string". I checked the
arguments however I could not find anything wrong.

Can anybody give me a clue?

Thanks so much.


>>> sql = Template('select dimension1 ,adddate(current_date,-1),current_date, 
>>> ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = 
>>> adddate(current_date,-1) then ifnull($ss_1,0) end),0) as \'PreviousDay\', 
>>> ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = current_date 
>>> then ifnull($ss_2,0) end),0) as \'Today\' from   message_alert where  
>>> dataset_id = $ss_3 and dimension1 in ($ss_4) andhour(creation_date) = 
>>> hour(now())-1 group by dimension1 having (ifnull(sum(case when 
>>> date_format(creation_date,\'%Y-%m-%d\') = current_date then ifnull($ss_5,0) 
>>> end),0) / ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = 
>>> adddate(current_date,-1) then ifnull($ss_6,0) end),0)) $ss_7   $ss_8')

>>>
>>> sql = sql.substitute(ss_1='metric1', ss_2='metric1', ss_3=2, 
>>> ss_4='557796,558069,558230', ss_5='metric1', ss_6='metric1', ss_7='>=', 
>>> ss_8=0.05)
>>>


>>> cursor.execute(sql)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
line 22, in execute
sql = self.db.ops.last_executed_query(self.cursor, sql, params)
  File "/usr/lib/python2.5/site-packages/django/db/backends/
__init__.py", line 217, in last_executed_query
return smart_unicode(sql) % u_params
TypeError: not enough arguments for format string
>>>



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



Re: Is it possible to combine these two queries?

2009-08-02 Thread David

Thanks Tim. Your reply is quite helpful.



On Jul 30, 6:25 pm, Tim Chase  wrote:
> > al_1 = Alert.objects.filter(creation_date__regex=today).values
> > ('dimension1').annotate(Sum('metric1')).order_by('dimension1')
>
> > and
>
> > al_2 = Alert.objects.filter(creation_date__regex=yesterday).values
> > ('dimension1').annotate(Sum('metric1')).order_by('dimension1')
>
> > They are almost the same except that al_1 is for today's data and al_2
> > is for yesterday's data. They summarize data in column "metric1" that
> > is grouped and ordered by "dimension1".
>
> > Sample data from al_1:
>
> > [{'metric1__sum': 0.0, 'dimension1': u'1'}, {'metric1__sum': 14.0,
> [snip]
> > What I need to do is to find a ratio value for each "dimension1"
> > between its today's value and yesterday's value.  For example, for
> > dimension1 = '110085', I need to find 2758.0 / 2658.0 = 1.04.
> > Then I compare this value "1.04" with a threshold and process
> > further.
>
> You can do something like
>
>  >>> map1 = dict((d['dimension1'], d['metric1__sum']) for d in al_1)
>  >>> map2 = dict((d['dimension1'], d['metric1__sum']) for d in al_2)
>  >>> ratios = [(dim, metric/map2[dim]) for dim, metric in
> map1.iteritems() if map2.get(dim, 0) != 0]
>  >>> results = [(dim, ratio) for dim, ratio in ratios if ratio >=
> threshold]
>
> It may lose ordering if that is significant (dicts aren't ordered
> by default), and skips over those where there are problems (items
> don't exist in the opposite map, or the previous value was 0
> making for a divide-by-zero problem).
>
> Things might change a little depending on what you'd expect on
> those edge cases (dim in a1 but not in a2; dim in a2 but not in
> a1; a2.metric = 0)
>
> -tim- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template and substitute

2009-08-04 Thread David

Thanks for your replies.



On Aug 4, 4:16 am, David De La Harpe Golden
 wrote:
> Malcolm Tredinnick wrote:
> > You seem to be trying to create raw SQL using Django's template system.
> > Please don't do that. It's like trying to use a shovel to hammer in a
> > nail, but less effective.
>
> Pybatis, FWIW, is an sql templating thingy. Using jinja2 rather than
> django templates, just mentioning as an example of someone using
> templates for sql:
>
> http://www.cystemstechnology.com/pybatis/doc.html
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Simultaneous use of the admin interface

2009-08-05 Thread David

Using Django 1.1 if I do:

1) sign into admin as user A in one browser and begin to edit a record
2) sign into admin as user B in another browser and begin to edit the
SAME record
3) make a change as user A and press Save
4) make a different change as user B and press Save

The result is that A's change is silently overwritten with user B's
change.

How do I make it so that user B gets an error telling them the record
has been changed by someone else since they started editing it? That's
what I would have expected to be the default behaviour.

I did some searching of the documentation but didn't find anything
obviously related. I also looked here at past posts and saw some
people asking similar questions but no obvious solutions. There was
some talk of adding SELECT FOR UPDATE functionality to Django 1.1, but
I don't know if that made it in, or how to use it if it did.

Can I perhaps add hooks to save a copy of the model object at the HTTP
GET time, and at HTTP POST pull another copy of the model back from
the db (distinct from the copy that is about to be saved) and compare
to the previous one from the HTTP GET then error if they're different?

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



Re: Simultaneous use of the admin interface

2009-08-05 Thread David



On Aug 5, 5:21 pm, Margie  wrote:
>   I think
> that when fields became editable in 1.1, this was not handled and
> needs to be adressed in order for multiple people to modify at once.
>

Thanks Margie. I wasn't referring to list_editable though, but perhaps
the problem is the same?

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



Re: Simultaneous use of the admin interface

2009-08-05 Thread David

> 1) sign into admin as user A in one browser and begin to edit a record
> 2) sign into admin as user B in another browser and begin to edit the
> SAME record

To clarify, both users have their browsers pointing at the editing
form for the same instance of the same model, e.g.:
http://example.com/admin/myproject/mymodel/1

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



How to get this URI

2009-08-07 Thread David

Hello,

My project is Web-based and I work in Django environment on Linux. Let
me give a Scenario first.

A user whose username is "peter" logins into "www.myfoo.com" online.
After his username/password get authenticated, he arrives this webpage
"www.myfoo.com/user_login".   On this page it looks like this.

Welcome Peter
(1.) Go to my profile
(2.) Check my total credit points
(3.) 

(1.), (2.), (3), etc, are all links. If peter clicks one of them, then
he will be redirected to a new webpage. For example, if he clicks
(1.), then he will be transferred to webpage "www.myfoo.com/peter/
profile/".  For this webpage there is a def (or module) "user_profile
(request)" in View. This module needs to get this URI (or at least "/
peter/profile/) and parse it so that peter's profile can be retrieved
from a database.

Now my question is: how can the module "user_profile(request)" get
"peter"? Or, how can the module get the URI?

os.environ[...] does not work here as this is not cgi. request.user is
not good either as it gives in-exact result.

Any ideas and suggestions?

Thanks so much.

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



Re: How to get this URI

2009-08-07 Thread David

I never know why I missed that part when I read it before.

Anyway, thanks DR for your clue.



On Aug 7, 10:23 am, Daniel Roseman  wrote:
> On Aug 7, 6:16 pm, David  wrote:
>
>
>
>
>
> > Hello,
>
> > My project is Web-based and I work in Django environment on Linux. Let
> > me give a Scenario first.
>
> > A user whose username is "peter" logins into "www.myfoo.com" online.
> > After his username/password get authenticated, he arrives this webpage
> > "www.myfoo.com/user_login".   On this page it looks like this.
>
> > Welcome Peter
> > (1.) Go to my profile
> > (2.) Check my total credit points
> > (3.) 
>
> > (1.), (2.), (3), etc, are all links. If peter clicks one of them, then
> > he will be redirected to a new webpage. For example, if he clicks
> > (1.), then he will be transferred to webpage "www.myfoo.com/peter/
> > profile/".  For this webpage there is a def (or module) "user_profile
> > (request)" in View. This module needs to get this URI (or at least "/
> > peter/profile/) and parse it so that peter's profile can be retrieved
> > from a database.
>
> > Now my question is: how can the module "user_profile(request)" get
> > "peter"? Or, how can the module get the URI?
>
> > os.environ[...] does not work here as this is not cgi. request.user is
> > not good either as it gives in-exact result.
>
> > Any ideas and suggestions?
>
> > Thanks so much.
>
> Surely the username is just the parameter to the user_profile
> function? Getting parameters from URLs is absolutely basic Django
> stuff, covered in the tutorial. I'd recommend reading that then
> posting here if you have any more questions.
> --
> DR.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Question about request.user

2009-08-10 Thread David

hello,

Here is what I met.  I logined into my Django application online with
a username "peter". Then I logined with another username "john". All
seemed fine. Now I printed user name in "john" account, and it gave
"peter".

I used following code.

if request.user.is_authenticated():
 print request.user.username

Why request.user.username did not bind to "john" in this scenario?
Anybody knows what caused such a problem? And any ideas how to fix
it?

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



Re: Question about request.user

2009-08-10 Thread David

Hi Carlos,

Thanks for your reply. I opened two broswers. I first logined as
"peter" and I left IE there; then I double-clicked IE icon on my
desktop to open a new one. On this new one I logined as "john".

There is only one user table as I use
"django.contrib.auth.models.User".

any more ideas?



On Aug 10, 2:33 pm, "Carlos A. Carnero Delgado"
 wrote:
> Hi,
>
> On Mon, Aug 10, 2009 at 4:46 PM, David wrote:
> > Why request.user.username did not bind to "john" in this scenario?
> > Anybody knows what caused such a problem? And any ideas how to fix
> > it?
>
> Are you using the same web browser? Maybe two tabs?
>
> HTH,
> Carlos.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is it possible to skip this field?

2009-08-10 Thread David

Hello,

When I use the following code,

  

{{ form.as_table }}


.


It prints all form fields with corresponding values on a user's
monitor. Now that in that form there is a field "username", for some
reasons I can not show this information to that user even though this
is his/her username. So, is there any way to skip printing this
field?

Any suggestions?

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



Re: Is it possible to skip this field?

2009-08-10 Thread David

Great. Thanks Daniel!


On Aug 10, 3:04 pm, Daniel Roseman  wrote:
> On Aug 10, 10:58 pm, David  wrote:
>
>
>
>
>
> > Hello,
>
> > When I use the following code,
>
> >   
> >         
> >             {{ form.as_table }}
> >         
>
> > .
>
> > It prints all form fields with corresponding values on a user's
> > monitor. Now that in that form there is a field "username", for some
> > reasons I can not show this information to that user even though this
> > is his/her username. So, is there any way to skip printing this
> > field?
>
> > Any suggestions?
>
> > Thanks.
>
> Use 'exclude' in the form's Meta 
> class.http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a...
> --
> DR.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question about request.user

2009-08-10 Thread David

I tested this again with IE and Firefox. On IE I logined as "peter"
and then I logined as "john" on Firefox.

Now I checked user in "peter" account with "request.user.username",
and I got "john".

Can anybody do this test on your machine?

Thanks so much.





On Aug 10, 2:48 pm, David  wrote:
> Hi Carlos,
>
> Thanks for your reply. I opened two broswers. I first logined as
> "peter" and I left IE there; then I double-clicked IE icon on my
> desktop to open a new one. On this new one I logined as "john".
>
> There is only one user table as I use
> "django.contrib.auth.models.User".
>
> any more ideas?
>
> On Aug 10, 2:33 pm, "Carlos A. Carnero Delgado"
>
>
>
>  wrote:
> > Hi,
>
> > On Mon, Aug 10, 2009 at 4:46 PM, David wrote:
> > > Why request.user.username did not bind to "john" in this scenario?
> > > Anybody knows what caused such a problem? And any ideas how to fix
> > > it?
>
> > Are you using the same web browser? Maybe two tabs?
>
> > HTH,
> > Carlos.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question about request.user

2009-08-11 Thread David

This fixes the problem. Thanks Gustavo!


On Aug 11, 6:07 am, Gustavo Henrique  wrote:
> maybe a problem with cache.
> try this:
>
> from django.views.decorators.cache import never_cache
> @never_cache
> def yourview(request):
>    # your code here
>
> --
> Gustavo Henriquehttp://www.gustavohenrique.nethttp://blog.gustavohenrique.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to get this auto-field id value

2009-08-11 Thread David

Hello,

I am trying to retrieve an autoField id value in my following code
when I update records.

def update_record(request):
if request.POST:
form = Model_Form(request.POST)
if form.is_valid():
form.save(pk=form.id, force_update=True)

I got an error that "Model_Form" object has no attribute 'id'.

Model_Form is a model-based form class that has an autoField id that
increases one by one. When I update a record, I need to give this
value.

I even tried "pk=form.pk", however it did not work either.

Any suggestions how to fix this?

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



Re: How to get this auto-field id value

2009-08-11 Thread David

Just a little more information. The autoField id is in the model
class.  Model_Form is a form based on this model class.



On Aug 11, 9:20 am, David  wrote:
> Hello,
>
> I am trying to retrieve an autoField id value in my following code
> when I update records.
>
> def update_record(request):
>     if request.POST:
>         form = Model_Form(request.POST)
>         if form.is_valid():
>             form.save(pk=form.id, force_update=True)
>
> I got an error that "Model_Form" object has no attribute 'id'.
>
> Model_Form is a model-based form class that has an autoField id that
> increases one by one. When I update a record, I need to give this
> value.
>
> I even tried "pk=form.pk", however it did not work either.
>
> Any suggestions how to fix this?
>
> Thanks so much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get this auto-field id value

2009-08-11 Thread David

Any tips/suggestions are highly appreciated...



On Aug 11, 9:26 am, David  wrote:
> Just a little more information. The autoField id is in the model
> class.  Model_Form is a form based on this model class.
>
> On Aug 11, 9:20 am, David  wrote:
>
>
>
> > Hello,
>
> > I am trying to retrieve an autoField id value in my following code
> > when I update records.
>
> > def update_record(request):
> >     if request.POST:
> >         form = Model_Form(request.POST)
> >         if form.is_valid():
> >             form.save(pk=form.id, force_update=True)
>
> > I got an error that "Model_Form" object has no attribute 'id'.
>
> > Model_Form is a model-based form class that has an autoField id that
> > increases one by one. When I update a record, I need to give this
> > value.
>
> > I even tried "pk=form.pk", however it did not work either.
>
> > Any suggestions how to fix this?
>
> > Thanks so much.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Modification difference in Adm and user accounts

2009-08-14 Thread David

Hello,

Here is what I meet. In "Admin" account I can see all users' records.
If I modify a user's record, say "Peter", then I can see Peter's
modified record immediately if i refresh my browser.

However, If I login into "Peter" account (as a user) and do this
modification, then I can not see the new modified record immediately
no matter how many times I refresh my broswer. I need to wait a period
of time (3 or 5 minutes?) before I can see this modification.

This is the same browser. It's IE.

Anybody knows how to handle this problem?

Thanks so much.

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



QuerySet's cache

2009-08-16 Thread David

Hi all,

I'm a bit puzzled by the caching behaviour of QuerySets, when used in
iteration and when called with repr(). According to the documentation,
when a QuerySet is evaluated for the first time, the results are
cached.

Trying this out in the shell, this works as expected for iteration.
However when used with repr(), the QuerySet does not seem to be using
the cache, and I was just wondering if this is the correct behaviour.

I'll just illustrate this with a quick example. The Tag model has a
single field, name.

# starting with no tags
>>> Tag.objects.all()
[]

# create a tag
>>> Tag.objects.create(name='one')


# as expected
>>> Tag.objects.all()
[]

# assigning the QuerySet, as illustrated in documentation
>>> queryset = Tag.objects.all()

# evaluate, by implicitly calling repr()
>>> queryset
[]

>>> Tag.objects.create(name='two')


# expecting queryset to use cache, which does not contain new tag
>>> queryset
[, ]

# hmm, maybe not??

Any help on clarifying this would be greatly appreciated!

David

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



Re: QuerySet's cache

2009-08-16 Thread David

Ah, ok that makes more sense now. Thank you!

On Aug 16, 5:52 pm, Alex Gaynor  wrote:
> On Sun, Aug 16, 2009 at 8:42 AM, David wrote:
>
> > Hi all,
>
> > I'm a bit puzzled by the caching behaviour of QuerySets, when used in
> > iteration and when called with repr(). According to the documentation,
> > when a QuerySet is evaluated for the first time, the results are
> > cached.
>
> > Trying this out in the shell, this works as expected for iteration.
> > However when used with repr(), the QuerySet does not seem to be using
> > the cache, and I was just wondering if this is the correct behaviour.
>
> > I'll just illustrate this with a quick example. The Tag model has a
> > single field, name.
>
> > # starting with no tags
> >>>> Tag.objects.all()
> > []
>
> > # create a tag
> >>>> Tag.objects.create(name='one')
> > 
>
> > # as expected
> >>>> Tag.objects.all()
> > []
>
> > # assigning the QuerySet, as illustrated in documentation
> >>>> queryset = Tag.objects.all()
>
> > # evaluate, by implicitly calling repr()
> >>>> queryset
> > []
>
> >>>> Tag.objects.create(name='two')
> > 
>
> > # expecting queryset to use cache, which does not contain new tag
> >>>> queryset
> > [, ]
>
> > # hmm, maybe not??
>
> > Any help on clarifying this would be greatly appreciated!
>
> > David
>
> The issue here is how __repr__ works on QuerySets, specifically it
> does repr(list(self[:MAX_REPR_SIZE])) that slicing causes it to create
> a new queryset, and so the result cache isn't populated in your
> QuerySet.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with "Cancel" button

2009-08-18 Thread David

Hello,

I have a "Cancel" button on one of my Webpages. The button sometimes
works as expected, sometimes it does not. After the button has been
clicked, it is supposed that the webpage is re-directed to another
page. However, this re-direction seems not work all the time.
Following is my script.

In my urls.py:


 (r'^cancel/$', cancel),
.

In my view.py:

def save_view(request):

if request.POST:
action = request.POST['action']

if action == 'Cancel':
url = '/cancel/'
#this_url = reverse('cancel')
#return HttpResponseRedirect(this_url)
return HttpResponseRedirect(url)

And my "cancel" view is really simple. It is

def cancel(request):
return render_to_response('cancel.html')


I even tried "reverse", however problem did not get fixed. (see the
commented code).

Anybody knows how to fix this?

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



Re: Problem with "Cancel" button

2009-08-19 Thread David

Thanks Thomas for your reply. I just tested it with Firefox. "Cancel"
button works perfect.
With IE "Cancel" button has such a problem.

Let me do more test and see.


On Aug 19, 7:50 am, Thomas Guettler  wrote:
> Hi David,
>
> David schrieb:
>
> > Hello,
>
> > I have a "Cancel" button on one of my Webpages. The button sometimes
> > works as expected, sometimes it does not. After the button has been
> > clicked, it is supposed that the webpage is re-directed to another
> > page. However, this re-direction seems not work all the time.
> > Following is my script.
>
> When does it work and when not? Does it work in one browser always, and
> in a different browser never? Django does not do any random stuff.
> What happens if the redirect does not work?
>
>
>
> > In my urls.py:
>
> > 
> >  (r'^cancel/$', cancel),
> > .
>
> > In my view.py:
>
> > def save_view(request):
>
> >     if request.POST:
> >         action = request.POST['action']
>
> I stopped getting any values from request.POST or request.GET. I use
> the form library.
>
> >         if action == 'Cancel':
> >             url = '/cancel/'
> > #            this_url = reverse('cancel')
> > #            return HttpResponseRedirect(this_url)
> >             return HttpResponseRedirect(url)
>
> > And my "cancel" view is really simple. It is
>
> > def cancel(request):
> >         return render_to_response('cancel.html')
>
> I guess the error is in cancel.html. You need to post it here.
>
> HTH,
>   Thomas Güttler
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Column font: strong or not strong

2009-08-20 Thread David

Hello,

I searched this list and googled online, however I could not find an
answer. So I post my question here.

In my model I have

 criteria1_value = models.FloatField(max_length=12)
 condition_dimension1= models.CharField(max_length=255,
null=True, blank=True,)


When I login into "Admin" account, I can see that the font for
"criteria1_value" is strong (bolded) whereas the font for
"condition_dimension1" is not. This makes sense.

However, when I login into a user's account, I see that the font for
both of columns become strong. I used

 
{{ form.as_table }}
 


to print. So my question is: can I reach the same effect as that in
"Admin" account with {{form.as_table}}?

Thanks for your replies.


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



Chaining filters on a ManyToManyField

2009-08-25 Thread David

Hi all,

I am trying to understand spanning multi-valued relationships (as
documented here 
http://docs.djangoproject.com/en/dev/topics/db/queries/#spanning-multi-valued-relationships).
More specifically, these paragraphs:

"Everything inside a single filter() call is applied simultaneously to
filter out items matching all those requirements. Successive filter()
calls further restrict the set of objects, but for multi-valued
relations, they apply to any object linked to the primary model,
***not necessarily*** those objects that were selected by an earlier
filter() call.

[...] the first filter restricted the queryset to all those blogs
linked to that particular type of entry. The second filter restricted
the set of blogs further to those that are also linked to the second
type of entry. The entries select by the second filter ***may or may
not be*** the same as the entries in the first filter."

To place this into context, here is the problem I'm grappling with.
Say I have a model, Entry, with a ManyToManyField, tags. The Tag model
contains just a name field.

If I want to filter entries by all those entries that have tags
'apples' AND 'oranges', the above would suggest something along the
lines of

>>> Entry.objects.filter(tags__name='apples', tags__name='oranges')

which of course, does not work, as the latter argument overrides the
former. So, I was wondering specifically about that "not necessarily"
clause.

Having experimented briefly in the shell, I've discovered that

>>> Entry.objects.filter(tags__name='apples').filter(tags__name='oranges')

seems to do what I want. However, I don't quite understand why!

If I am understanding the excerpt above, it basically means that if
you filter a model on its ManyToManyField, subsequent chained filters
may either use the restricted set returned by the former filter; or it
may ignore it altogether, and effectively filter as if the former was
not there, and thus the result is a union of the two sets of results.
Is that 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Configure Django project in a subdirectory using mod_python. Apps and Admin not found.

2009-08-26 Thread David

HI guys. I was trying to configure my django project in a subdirectory
of the root, but didn't get things working.(Locally it works perfect).
I followed the django official django documentarion to deploy a
project with mod_python. The real problem is that I am getting "Page
not found" errors, whenever I try to go to the admin or any view of my
apps.

Here is my python.conf file located in /etc/httpd/conf.d/ in Fedora 7

LoadModule python_module modules/mod_python.so

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/var/www/vhosts/mysite.com/httpdocs','/var/www/vhosts/
mysite.com/httpdocs/mysite'] + sys.path"

I know /var/www/ is not the best place to put my django project, but I
just want to send a demo of my work in progress to my customer, later
I will change the location.

For example. If I go to www.domain.com/mysite/ I get the index view I
configured in mysite.urls. But I cannot access to my app.urls
(www.domain.com/mysite/app/) and any of the admin.urls.(www.domain.com/
mysite/admin/)

Here is mysite.urls:

urlpatterns = patterns('',

 url(r'^admin/password_reset/$',
'django.contrib.auth.views.password_reset',  name='password_reset'),
(r'^password_reset/done/$',
'django.contrib.auth.views.password_reset_done'),
(r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$',
'django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/$',
'django.contrib.auth.views.password_reset_complete'),
(r'^$', 'app.views.index'),
(r'^admin/', include(admin.site.urls)),
(r'^app/', include('mysite.app.urls')),
(r'^photologue/', include('photologue.urls')),
)

I also tried changing admin.site.urls with
''django.contrib.admin.urls' , but it didn't worked. I googled a lot
to solve this problem and read how other developers configure their
django project, but didn't find too much information to deploy django
in a subdirectory. I have the admin enabled in INSTALLED_APPS and the
settings.py is ok.

Please if you have any guide or telling me what I am doing wrong it
will be much appreciated.

Thanks.

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



Session problem?

2009-08-28 Thread David

hello Django community,

I met this problem and can not find a solution. I wonder if any people
has met this problem before? Can anybody give a clue or hint how to
fix it?

For my project, I have enabled sessions and I use
contrib.auth.models.User. If one user logins into his/her account, all
is perfect. However, if another user logins (no matter if it is from
the same computer or from another computer), then the two users sees
each other's information in their own account.

I also found that

(1.) request.user.username gives another logined user's name instead
of this one (the correct one) even though I called
request.user.is_authenticated().

(2.)  request.session['username']  does not give the username that I
assigned it earlier.

(3.) Old session is still there even though a user log-out correctly,
closes the browser (IE) and then opens another browser (Firefox).

I have put "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" in settings
already. In my code I have request.session.set_expiry(0).

Checking my session table, I can see that the "expire date" for
sessions are in two weeks. Does this mean that
"SESSION_EXPIRE_AT_BROWSER_CLOSE = True" did not work?

Any suggestions?

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



Re: Session problem?

2009-08-28 Thread David

Hi Angel,

Thanks for your reply. I just tested with decorator @login_required.
The problem still exists.

Following is script for my homepage.

# this is the homepage
@login_required
def my_view(request):
if request.session.test_cookie_worked():
#username = request.user.username
if request.user.is_authenticated():
username = request.session['username']
#username = request.user.username
return render_to_response('my_view.html',
{'username':username})
else:
return HttpResponse("Please enable cookies and try again.")


Neither request.session nor request.user can give a correct user's
name all the time. In my login(request) I have

 if request.method == "POST" :
username = request.POST['username']
password = request.POST['password']

user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:

request.session['password'] = password
request.session['username'] = username
request.session.set_expiry(0)

login(request, user)


So, why can not session bind username to it? And why can not
request.user give the correct logined user? it seems to me that
sessions are interweaved when two users login at the same time. Or one
session over-writes the other? Checking session keys in session table,
I can see that each session key is unique.

Thanks again for your reply. I appreciate it. Do you have more ideas
where I missed?










On Aug 28, 12:35 pm, Angel Cruz  wrote:
> How does your view.py look like?
>
> I use the decorator @login_required right before each def that I want to
> ensure is viewable only to the logged-in user.
>
>
>
> On Fri, Aug 28, 2009 at 12:00 PM, David  wrote:
>
> > hello Django community,
>
> > I met this problem and can not find a solution. I wonder if any people
> > has met this problem before? Can anybody give a clue or hint how to
> > fix it?
>
> > For my project, I have enabled sessions and I use
> > contrib.auth.models.User. If one user logins into his/her account, all
> > is perfect. However, if another user logins (no matter if it is from
> > the same computer or from another computer), then the two users sees
> > each other's information in their own account.
>
> > I also found that
>
> > (1.) request.user.username gives another logined user's name instead
> > of this one (the correct one) even though I called
> > request.user.is_authenticated().
>
> > (2.)  request.session['username']  does not give the username that I
> > assigned it earlier.
>
> > (3.) Old session is still there even though a user log-out correctly,
> > closes the browser (IE) and then opens another browser (Firefox).
>
> > I have put "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" in settings
> > already. In my code I have request.session.set_expiry(0).
>
> > Checking my session table, I can see that the "expire date" for
> > sessions are in two weeks. Does this mean that
> > "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" did not work?
>
> > Any suggestions?
>
> > Thanks so much.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Session problem?

2009-08-28 Thread David

Hi Angel,

Thanks so much for your prompt reply. Appreciated.

Reading your script, I can see that you use my_id=request.user.id. In
my code I used username = request.user.username. (notice my commented
code? I just tested request.user.id. The problem exists.)  So there is
no major difference as it has the same logic. However, the problem
loops back to my original question: why can not request.user give the
correct logined user? Why one session seems to over-write the other?

When I wrote my scripts, I used request.user first. As it could not
give me a correct user's name, I turned to session. However, session
had the same problem.

I read online DjangoBook again and again, trying to find what I missed
or what I did wrong. I spent much time on googling online. However I
can not find what caused this problem.



On Aug 28, 2:57 pm, Angel Cruz  wrote:
> Your implementation is dependent upon session cookies, and I am sure you
> have a good reason for it.  I am as stomped as you are why that is (unless
> you are like me, who confuses 127.0.0.1:8080 w/ localhost as I open multiple
> browsers in testing my site...each will have different session cookies).
>
> My implementation is dependent more on the user id being passed in from the
> login page if a user is not logged in and just passing the User object into
> the template:
>
> my view.py has:
> ---
> @login_required
> def index(request):
> .
> .
> .
>  if request.user.is_authenticated():
>      my_id=request.user.id
>      user = get_object_or_404(User, id=my_id)
>
>      context = {'my_auth_user': user, blah blah }
> .
> .
> .
>      return render_to_response('registration/detail.html',
>                                   context,
>                                   context_instance =
> RequestContext(request))
>
> my template ('registration/detail.html') has:
> -
> {{ my_auth_user.username}}
> {{ my_auth_user.first_name}}
> {{ my_auth_user.last_name}}
> {{ my_auth_user.email}}
>
> This ensures the the User object for that id belongs to is being called to
> get the username and other information.
>
> Of course, you can pass into the template the cookies and session id stuff
> by placing them in the context variable.
>
>
>
> On Fri, Aug 28, 2009 at 1:15 PM, David  wrote:
>
> > Hi Angel,
>
> > Thanks for your reply. I just tested with decorator @login_required.
> > The problem still exists.
>
> > Following is script for my homepage.
>
> > # this is the homepage
> > @login_required
> > def my_view(request):
> >    if request.session.test_cookie_worked():
> >        #username = request.user.username
> >        if request.user.is_authenticated():
> >            username = request.session['username']
> >            #username = request.user.username
> >            return render_to_response('my_view.html',
> > {'username':username})
> >    else:
> >        return HttpResponse("Please enable cookies and try again.")
>
> > Neither request.session nor request.user can give a correct user's
> > name all the time. In my login(request) I have
>
> >  if request.method == "POST" :
> >        username = request.POST['username']
> >        password = request.POST['password']
>
> >        user = authenticate(username=username, password=password)
> >        if user is not None:
> >            if user.is_active:
>
> >                request.session['password'] = password
> >                request.session['username'] = username
> >                request.session.set_expiry(0)
>
> >                login(request, user)
> > 
>
> > So, why can not session bind username to it? And why can not
> > request.user give the correct logined user? it seems to me that
> > sessions are interweaved when two users login at the same time. Or one
> > session over-writes the other? Checking session keys in session table,
> > I can see that each session key is unique.
>
> > Thanks again for your reply. I appreciate it. Do you have more ideas
> > where I missed?
>
> > On Aug 28, 12:35 pm, Angel Cruz  wrote:
> > > How does your view.py look like?
>
> > > I use the decorator @login_required right before each def that I want to
> > > ensure is viewable only to the logged-in user.
>
> > > On Fri, Aug 28, 2009 at 12:00 PM, David  wrote:
>
> > > > hello Django community,
>
> > > > I met this problem and

manage.py syncdb error

2009-04-29 Thread David

Hi,

i followed django tutorial part 1 to learn django, however i met
following error when i used "python manage.py syncdb".

da...@django:~/mysite$ python manage.py syncdb
Creating table auth_permission
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 340, in execute_manager
utility.execute()


File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line
166, in execute
self.errorhandler(self, exc, value)
  File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
line 35, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1142, "CREATE command denied to
user 'david'@'localhost' for table 'auth_permission'")
da...@django:~/mysite$

anybody knows how to fix it?

thanks.

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



Re: manage.py syncdb error

2009-04-29 Thread David


mysql> show grants;
+--
+
| Grants for
da...@localhost
|
+--
+
| GRANT USAGE ON *.* TO 'david'@'localhost' IDENTIFIED BY PASSWORD
'*2A032F7C5BA932872F0F045E0CF6B53CF702F2C5' |
| GRANT ALL PRIVILEGES ON `david_database`.`david_database` TO
'david'@'localhost' |
+--
+
2 rows in set (0.00 sec)

mysql>


thanks for your prompt reply. i tried this already. why does not it
work?


On Apr 29, 3:29 pm, Kai Kuehne  wrote:
> Hi,
>
> On Thu, Apr 30, 2009 at 12:17 AM, David  wrote:
> > [error message]
> > anybody knows how to fix it?
>
> Grant CREATE permission for your user on that database.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: manage.py syncdb error

2009-04-29 Thread David

i see. i should grant priviliges on the database that table
'auth_permission' belongs to.  let me do it.

thanks.


On Apr 29, 3:32 pm, David  wrote:
> mysql> show grants;
> +--­
> +
> | Grants for
> da...@localhost
> |
> +--­----
> +
> | GRANT USAGE ON *.* TO 'david'@'localhost' IDENTIFIED BY PASSWORD
> '*2A032F7C5BA932872F0F045E0CF6B53CF702F2C5' |
> | GRANT ALL PRIVILEGES ON `david_database`.`david_database` TO
> 'david'@'localhost'                             |
> +--­
> +
> 2 rows in set (0.00 sec)
>
> mysql>
>
> thanks for your prompt reply. i tried this already. why does not it
> work?
>
> On Apr 29, 3:29 pm, Kai Kuehne  wrote:
>
>
>
> > Hi,
>
> > On Thu, Apr 30, 2009 at 12:17 AM, David  wrote:
> > > [error message]
> > > anybody knows how to fix it?
>
> > Grant CREATE permission for your user on that database.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: manage.py syncdb error

2009-04-29 Thread David

sorry i can not find a database that table
'auth_permission' belongs to. any more hints what i should do?

thanks so much.


On Apr 29, 3:35 pm, David  wrote:
> i see. i should grant priviliges on the database that table
> 'auth_permission' belongs to.  let me do it.
>
> thanks.
>
> On Apr 29, 3:32 pm, David  wrote:
>
>
>
> > mysql> show grants;
> > +--­­
> > +
> > | Grants for
> > da...@localhost
> > |
> > +--­­
> > +
> > | GRANT USAGE ON *.* TO 'david'@'localhost' IDENTIFIED BY PASSWORD
> > '*2A032F7C5BA932872F0F045E0CF6B53CF702F2C5' |
> > | GRANT ALL PRIVILEGES ON `david_database`.`david_database` TO
> > 'david'@'localhost'                             |
> > +--­­
> > +
> > 2 rows in set (0.00 sec)
>
> > mysql>
>
> > thanks for your prompt reply. i tried this already. why does not it
> > work?
>
> > On Apr 29, 3:29 pm, Kai Kuehne  wrote:
>
> > > Hi,
>
> > > On Thu, Apr 30, 2009 at 12:17 AM, David  wrote:
> > > > [error message]
> > > > anybody knows how to fix it?
>
> > > Grant CREATE permission for your user on that database.- Hide quoted text 
> > > -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: manage.py syncdb error

2009-04-29 Thread David

it works now.  thanks Kai.

On Apr 29, 3:54 pm, Kai Kuehne  wrote:
> No TOFU please.
>
> On Thu, Apr 30, 2009 at 12:49 AM, David  wrote:
> > sorry i can not find a database that table
> > 'auth_permission' belongs to. any more hints what i should do?
>
> Did you FLUSH PRIVILEGES?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Help: django.contrib.admin

2009-04-30 Thread David

Hello,

I followed Django tutorial 2 to activate the admin site, however I got

da...@django:~/mysite$ python manage.py syncdb
Error: No module named admindjango.contrib

after I added "django.contrib.admin" to your INSTALLED_APPS setting.
This is how it looks like.

INSTALLED_APPS = (
'django.contrib.admin'
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite.polls'
)


anybody knows how to fix it?

Thanks so much.

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



Re: Help: django.contrib.admin

2009-04-30 Thread David

fixed... thanks!

david


On Apr 30, 8:42 am, Karen Tracey  wrote:
> On Thu, Apr 30, 2009 at 11:36 AM, David  wrote:
>
> > Hello,
>
> > I followed Django tutorial 2 to activate the admin site, however I got
>
> > da...@django:~/mysite$ python manage.py syncdb
> > Error: No module named admindjango.contrib
>
> > after I added "django.contrib.admin" to your INSTALLED_APPS setting.
> > This is how it looks like.
>
> > INSTALLED_APPS = (
> >    'django.contrib.admin'
> >    'django.contrib.auth',
> >    'django.contrib.contenttypes',
> >    'django.contrib.sessions',
> >    'django.contrib.sites',
> >    'mysite.polls'
> > )
>
> > anybody knows how to fix it?
>
> Put a comma on the end of the 'django.contrib.admin' line.  Lacking the
> comma, it's being combined with the next line.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Can not get Django admin page

2009-05-05 Thread David

Hello,

I am following  those steps in django tutorial 2,  however I can not
get "django administration: Username and Password" page. I still get
the "Welcome" page.

I did these steps twice but I got the same result.

1.   Add "django.contrib.admin" to your INSTALLED_APPS setting.
2.   Run python manage.py syncdb. Since you have added a new
application to INSTALLED_APPS, the database tables need to be
updated.
3.   Edit your mysite/urls.py file and uncomment the lines below the
“Uncomment the next two lines...”

Can anybody tell me what I should do to fix this?

Thanks so much.

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



Re: Can not get Django admin page

2009-05-05 Thread David

...and I re-started the dev server as the 4th step


david


On May 5, 8:57 am, David  wrote:
> Hello,
>
> I am following  those steps in django tutorial 2,  however I can not
> get "django administration: Username and Password" page. I still get
> the "Welcome" page.
>
> I did these steps twice but I got the same result.
>
> 1.   Add "django.contrib.admin" to your INSTALLED_APPS setting.
> 2.   Run python manage.py syncdb. Since you have added a new
> application to INSTALLED_APPS, the database tables need to be
> updated.
> 3.   Edit your mysite/urls.py file and uncomment the lines below the
> “Uncomment the next two lines...”
>
> Can anybody tell me what I should do to fix this?
>
> Thanks so much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can not get Django admin page

2009-05-05 Thread David

yes, i added "/admin" to the url.

thanks,

david


On May 5, 9:05 am, Matthias Petermann  wrote:
> Did you add /admin to the URL?
>
> Kind regards,
> Matthias
>
> Am Dienstag, den 05.05.2009, 09:03 -0700 schrieb David:
>
>
>
> > ...and I re-started the dev server as the 4th step
>
> > david
>
> > On May 5, 8:57 am, David  wrote:
> > > Hello,
>
> > > I am following  those steps in django tutorial 2,  however I can not
> > > get "django administration: Username and Password" page. I still get
> > > the "Welcome" page.
>
> > > I did these steps twice but I got the same result.
>
> > > 1.   Add "django.contrib.admin" to your INSTALLED_APPS setting.
> > > 2.   Run python manage.py syncdb. Since you have added a new
> > > application to INSTALLED_APPS, the database tables need to be
> > > updated.
> > > 3.   Edit your mysite/urls.py file and uncomment the lines below the
> > > “Uncomment the next two lines...”
>
> > > Can anybody tell me what I should do to fix this?
>
> > > Thanks so much.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can not get Django admin page

2009-05-05 Thread David

Hi Nate,

You are right... I did not uncomment (r^...).   now it works.

thanks so much!  and thanks too to Adam and Matthias!

David


On May 5, 9:43 am, Domain Admin  wrote:
> In the urls.py did you also uncomment the last line where it says:
> # Uncomment the next line to enable the admin:
>     (r'^admin/(.*)', admin.site.root), ?
>
> -Nate
>
>
>
> On Tue, May 5, 2009 at 12:34 PM, David  wrote:
>
> > yes, i added "/admin" to the url.
>
> > thanks,
>
> > david
>
> > On May 5, 9:05 am, Matthias Petermann  wrote:
> > > Did you add /admin to the URL?
>
> > > Kind regards,
> > > Matthias
>
> > > Am Dienstag, den 05.05.2009, 09:03 -0700 schrieb David:
>
> > > > ...and I re-started the dev server as the 4th step
>
> > > > david
>
> > > > On May 5, 8:57 am, David  wrote:
> > > > > Hello,
>
> > > > > I am following  those steps in django tutorial 2,  however I can not
> > > > > get "django administration: Username and Password" page. I still get
> > > > > the "Welcome" page.
>
> > > > > I did these steps twice but I got the same result.
>
> > > > > 1.   Add "django.contrib.admin" to your INSTALLED_APPS setting.
> > > > > 2.   Run python manage.py syncdb. Since you have added a new
> > > > > application to INSTALLED_APPS, the database tables need to be
> > > > > updated.
> > > > > 3.   Edit your mysite/urls.py file and uncomment the lines below the
> > > > > “Uncomment the next two lines...”
>
> > > > > Can anybody tell me what I should do to fix this?
>
> > > > > Thanks so much.- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mail add_flag

2009-05-12 Thread David

Hello,

I have read related part in python library and also searched this
list, however I still can not figure out where is wrong with my code.
so I post my question.

I am using the following code to process e-mails in a user account.



mmailbox = '/var/spool/mail/' + user

with open(mmailbox) as boxfile:
mbox = mailbox.UnixMailbox(boxfile,
self.msgfactory)
for mail in mbox:
if mail.get("Status") != "R" and
mail.get("Status") != "O":
begin to process
..
 mail.add_flag("Status") = "R"

==

Notice that I have used "add_flag" to change its status. However, it
does not work as my code still processes those e-mails that have been
processed already.

Can anybody tell me where is wrong? Thanks so much.




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



Where to configure this view

2009-06-02 Thread David

Hello,

I added a "telephone_number = models.CharField(max_length=15)" in the
"User" class in Django-1.0.2-final/django/contrib/auth/models.py.  Now
I need to add/update telephone numbers  on admin page. Which file
should I configure so that I can see this "telephone_number" on the
admin page?

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



Re: Where to configure this view

2009-06-02 Thread David

Thanks Alex

David

On Jun 2, 3:00 pm, Alex Gaynor  wrote:
> On Tue, Jun 2, 2009 at 4:56 PM, David  wrote:
>
> > Hello,
>
> > I added a "telephone_number = models.CharField(max_length=15)" in the
> > "User" class in Django-1.0.2-final/django/contrib/auth/models.py.  Now
> > I need to add/update telephone numbers  on admin page. Which file
> > should I configure so that I can see this "telephone_number" on the
> > admin page?
>
> > Can anybody give me a suggestion? Thanks a lot.
>
> This isn't really the right way to extend the django user 
> model:http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m
>  However, if you insist on doing it this way you would need to alter
> the
> admin.py file in the same directory.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to import this module

2009-06-05 Thread David

Hello,

In my project "mysite" directory I have "middleware.py". This
"middleware.py" has only one class "SiteLogin" and this class has only
one method "process_request".

Now I need to import this "process_request" into "urls.py" in the
"mysite" directory. Can anybody give me a clue how to do this?

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



Re: How to import this module

2009-06-05 Thread David

Thanks DR. I did put  'mysite.middleware.SiteLogin' into
MIDDLEWARE_CLASSES  in settings.py already, however I still get

Exception Value: name 'process_request' is not defined





On Jun 5, 8:35 am, Daniel Roseman 
wrote:
> On Jun 5, 3:51 pm, David  wrote:
>
> > Hello,
>
> > In my project "mysite" directory I have "middleware.py". This
> > "middleware.py" has only one class "SiteLogin" and this class has only
> > one method "process_request".
>
> > Now I need to import this "process_request" into "urls.py" in the
> > "mysite" directory. Can anybody give me a clue how to do this?
>
> > Thanks so much.
>
> Er, what? If it's a middleware, it needs to go in the
> MIDDLEWARE_CLASSES tuple in settings.py.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to import this module

2009-06-05 Thread David

Middleware class:

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'mysite.middleware.SiteLogin',
)

===
urls.py:

from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns('',

(r'^admin/(.*)', admin.site.root),
(r'^accounts/login/', process_request),
(r'^polls/', include('mysite.polls.urls')),
)


=

url: http://ip_address/accounts/login/

I got:

NameError at /accounts/login/
name 'process_request' is not definedRequest Method: GET
Request URL: http://10.0.1.244:8000/accounts/login/
Exception Type: NameError
Exception Value: name 'process_request' is not defined
Exception Location: /home/dwang/mysite/../mysite/urls.py in ,
line 26
Python Executable: /usr/bin/python
Python Version: 2.5.2
Python Path: ['/home/dwang/mysite', '/usr/lib/python2.5', '/usr/lib/
python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/
python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/
usr/lib/python2.5/site-packages', '/var/lib/python-support/
python2.5']
Server time: Fri, 5 Jun 2009 10:55:40 -0500


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



Re: How to import this module

2009-06-05 Thread David

I am trying to set up a user login page. A user needs to login first
before he/she can do anything.

I refered: "http://superjared.com/entry/requiring-login-entire-django-
powered-site/"

"Then put myproject.middleware.SiteLogin in your MIDDLEWARE_CLASSES in
settings.py (replace myproject with your project name) and you’re
done"


I must have did something wrong. Then how to enable a user login?






On Jun 5, 9:07 am, Daniel Roseman 
wrote:
> On Jun 5, 4:58 pm, David  wrote:
>
>
>
>
>
> > Middleware class:
>
> > MIDDLEWARE_CLASSES = (
> >     'django.middleware.common.CommonMiddleware',
> >     'django.contrib.sessions.middleware.SessionMiddleware',
> >     'django.contrib.auth.middleware.AuthenticationMiddleware',
> >     'mysite.middleware.SiteLogin',
> > )
>
> > ===
> > urls.py:
>
> > from django.conf.urls.defaults import *
> > from django.contrib import admin
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
>
> >     (r'^admin/(.*)', admin.site.root),
> >     (r'^accounts/login/', process_request),
> >     (r'^polls/', include('mysite.polls.urls')),
> > )
>
> Why are you doing this? You can't map middleware to a URL, it makes
> absolutely no sense. What are you trying to do?
> --
> DR.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to import this module

2009-06-05 Thread David

I am new in this Django field so please do not get surprised when you
see my stupid errors.

any more suggestions on how to set up a user login page?

Thanks.



On Jun 5, 9:17 am, David  wrote:
> I am trying to set up a user login page. A user needs to login first
> before he/she can do anything.
>
> I refered: "http://superjared.com/entry/requiring-login-entire-django-
> powered-site/"
>
> "Then put myproject.middleware.SiteLogin in your MIDDLEWARE_CLASSES in
> settings.py (replace myproject with your project name) and you’re
> done"
>
> I must have did something wrong. Then how to enable a user login?
>
> On Jun 5, 9:07 am, Daniel Roseman 
> wrote:
>
>
>
> > On Jun 5, 4:58 pm, David  wrote:
>
> > > Middleware class:
>
> > > MIDDLEWARE_CLASSES = (
> > >     'django.middleware.common.CommonMiddleware',
> > >     'django.contrib.sessions.middleware.SessionMiddleware',
> > >     'django.contrib.auth.middleware.AuthenticationMiddleware',
> > >     'mysite.middleware.SiteLogin',
> > > )
>
> > > ===
> > > urls.py:
>
> > > from django.conf.urls.defaults import *
> > > from django.contrib import admin
> > > admin.autodiscover()
>
> > > urlpatterns = patterns('',
>
> > >     (r'^admin/(.*)', admin.site.root),
> > >     (r'^accounts/login/', process_request),
> > >     (r'^polls/', include('mysite.polls.urls')),
> > > )
>
> > Why are you doing this? You can't map middleware to a URL, it makes
> > absolutely no sense. What are you trying to do?
> > --
> > DR.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to import this module

2009-06-05 Thread David

thanks for your information. it is quite helpful.

thanks again.

On Jun 5, 9:27 am, Daniel Roseman 
wrote:
> On Jun 5, 5:17 pm, David  wrote:
>
> > I am trying to set up a user login page. A user needs to login first
> > before he/she can do anything.
>
> > I refered: "http://superjared.com/entry/requiring-login-entire-django-
> > powered-site/"
>
> > "Then put myproject.middleware.SiteLogin in your MIDDLEWARE_CLASSES in
> > settings.py (replace myproject with your project name) and you’re
> > done"
>
> > I must have did something wrong. Then how to enable a user login?
>
> That quote - and indeed the whole page - says nothing at all about
> putting a reference to the middleware in your urls.py.
>
> Grabbing random bits of code off the Internet is not going to help you
> to create your site if you don't actually know what you're doing. This
> code does something very specific, which is to redirect an
> unauthorised user requesting any page to the login pages. It doesn't
> actually create the login pages for you. To learn how to do that,
> you're going to have to read the documentation.
>
> Start here:http://docs.djangoproject.com/en/dev/topics/auth/
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



accounts/profile question

2009-06-05 Thread David

Hello,

I have set up a user login page and it works. However I do not know
how to redirect this user to his/her account. I have

(r'^accounts/login/$', 'django.contrib.auth.views.login'),

in my urls.py. When a user types his/her username/password correctly,
the url transfers to

http://ip_address/accounts/profile/

Is there a homepage for users by default? Of course this user can only
see/update his/her account information there or do something that he/
she is authorized to do.

Anybody likes to give me a clue?

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



Re: accounts/profile question

2009-06-05 Thread David


ok. then is there a default userpage template that I can use?
thanks.


On Jun 5, 1:23 pm, Phil Mocek 
wrote:
> On Fri, Jun 05, 2009 at 01:21:50PM -0700, David wrote:
> > Is there a homepage for users by default?
>
> That is a question about your application, not about the Django
> framework.
>
> --
> Phil Mocek
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: accounts/profile question

2009-06-05 Thread David

I see. thanks.

On Jun 5, 1:30 pm, "Gabriel ."  wrote:
> On Fri, Jun 5, 2009 at 5:21 PM, David wrote:
>
> > Hello,
>
> > I have set up a user login page and it works. However I do not know
> > how to redirect this user to his/her account. I have
>
> > (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>
> > in my urls.py. When a user types his/her username/password correctly,
> > the url transfers to
>
> >http://ip_address/accounts/profile/
>
> > Is there a homepage for users by default? Of course this user can only
> > see/update his/her account information there or do something that he/
> > she is authorized to do.
>
> > Anybody likes to give me a clue?
>
> accounts/profile is the default redirect url, but you need to create
> the corresponding url conf and view :)
>
> Or you can modify the behavior with the LOGIN_REDIRECT_URL setting.
>
> --
> Kind Regards- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Question about login

2009-06-06 Thread David

Hello,

Just wonder if anybody has met this. I modified LOGIN_REDIRECT_URL
from "accounts/profile" to 'accounts' but Django still re-directs to
"accounts/profile" after a user has logined successfully. If
LOGIN_REDIRECT_URL is the url for default re-directing, then why it
still comes the word "profile"?

I tried to add that user's login name to the re-directed url but
failed. In 'django.contrib.auth.views.login', I added
"redirect_to = redirect_to + form.get_user()", however this had no
use. If I can append this user's userName to the url, then I can parse
the url and retrieve this user's information from database later. So
how to you add users' name to the url?

Can anybody help me? Thanks so much.


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



Re: Question about login

2009-06-06 Thread David

Your reply is truely helpful!

Thanks Gabriel!


On Jun 6, 7:22 pm, Gabriel  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> David escribió:
>
>
>
>
>
> > Hello,
>
> > Just wonder if anybody has met this. I modified LOGIN_REDIRECT_URL
> > from "accounts/profile" to 'accounts' but Django still re-directs to
> > "accounts/profile" after a user has logined successfully. If
> > LOGIN_REDIRECT_URL is the url for default re-directing, then why it
> > still comes the word "profile"?
>
> > I tried to add that user's login name to the re-directed url but
> > failed. In 'django.contrib.auth.views.login', I added
> > "redirect_to = redirect_to + form.get_user()", however this had no
> > use. If I can append this user's userName to the url, then I can parse
> > the url and retrieve this user's information from database later. So
> > how to you add users' name to the url?
>
> > Can anybody help me? Thanks so much.
>
> mmm, I can't imagine why LOGIN_REDIRECT_URL is not working for you.
> However you can also pass the url with a hidden field called 'next' in
> your login form.
>
> You don't need to parse anything to get the current logged in user, you
> have it available in request.user.
> I recommend you to 
> readhttp://docs.djangoproject.com/en/dev/topics/auth/#authentication-in-w...
>
> Regards.
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.9 (GNU/Linux)
>
> iEYEAREIAAYFAkorJFwACgkQNHr4BkRe3pKMHgCfepvXlBzGUNH6bzcPG/NCFehf
> sqQAoKr5J22MScuUxXJKYNB7qVJ3soqu
> =KXCc
> -END PGP SIGNATURE-- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



What template: admin site

2009-06-08 Thread David

Hello,

Following the online tutorial I have created "mysite" project. After I
have logined into admin, I can see Auth --- Mysite  Sites.

Now I would like to use the same layout/template for my user home page
as this admin page. I have read django/contrib/admin/sites.py but
could not find which template this admin pages uses. Can anybody give
me a clue where this template is?

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



Re: What template: admin site

2009-06-08 Thread David

Thanks Alex! Now I know where to start.

On Jun 8, 10:18 am, Alex Gaynor  wrote:
> On Mon, Jun 8, 2009 at 12:14 PM, David  wrote:
>
> > Hello,
>
> > Following the online tutorial I have created "mysite" project. After I
> > have logined into admin, I can see Auth --- Mysite  Sites.
>
> > Now I would like to use the same layout/template for my user home page
> > as this admin page. I have read django/contrib/admin/sites.py but
> > could not find which template this admin pages uses. Can anybody give
> > me a clue where this template is?
>
> > Thanks so much.
>
> There's a hierarchy of templates located t
> django/contrib/admin/templates/admin, but they all inherit base_site.html.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   3   4   5   6   7   8   9   10   >