Re: django docs __unicode__ return u'%s %s

2012-01-27 Thread coded kid
Hey Petr, thats what I'm trying to say. Just that I didnt construct my
sentences well. Thanks.

JohnA wrote:
> Just to fill in some more info,  __unicode__  methods are also part of
> core python and just happen to appear a lot in django code because of
> its preference for 16-bit unicode strings (though I think the methods
> are actually mostly invoked in the admin).  There is also a __str__
> function for “ordinary” (8 bit potentially mbcs) strings.  (This is
> Python 2.x; Python 3.x is somewhat different.)
>
> User-defined __unicode__ methods are overrides of builtin methods that
> all objects are guaranteed to have.  As the __...__ in the name
> suggests, these methods are called implicitly in certain kinds of
> expressions.  Two cases I know of in Python 2.7 are expressions of
> form unicode(obj) and expressions of form u’...%s...’ % obj (and I
> assume other format expression tyopes where the format string is
> unicode).  In both, obj is converted to a unicode string using
> whatever __unicode__ method is defined for the object.
>
>
> On Jan 24, 6:04 pm, Krondaj  wrote:
> > Hi,
> >
> > in the django docs about __unicode__  it says the following:
> >
> > class Person(models.Model):
> >     first_name = models.CharField(max_length=50)
> >     last_name = models.CharField(max_length=50)
> >
> >     def __unicode__(self):
> >         return u'%s %s' % (self.first_name, self.last_name)
> >
> > what does the u'%s %s' % mean... I cannot find any exaplanation of
> > this in the docs?
> >
> > i've seen this in someones code that was kindly lent to me by one of
> > the RC chat room people:
> >
> > return u'ID%s: %s - %s - %s - %s' % (self.id, self.user,
> > self.question, self.answer, self.get_status_display())
> >
> > but all this u' %s  %s'   %%%sss or what ever is most confusing
> >
> > is there a document or help guide some where that explains this
> > nomenclature, or method, system???
> >
> > as I believe if you take the top example you should be able to do:
> >  def __unicode__(self):
> >         return(self.first_name, self.last_name)
> >
> > If there is no documentation (for dummies) can anyone explain it to
> > me??
> >
> > Thanks
> >
> > Krondaj

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



ipaddress

2012-01-27 Thread Jisson Varghese
Hi all,

First am sorry ,its a python specific question not django based.
 I am developing a mobile application, using  python in server side. I want
to get user's ipaddress(Now user's request not sending ipaddress as a
parameter to my server). I am using cherrypy server , Now I take IPaddress
using following code,
   ipaddress = cherrypy.request.remote.ip
  I have a doubt whether this generate an ipaddress in the form
xx.0.0.0/32
( a private range ).?
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: Determine gender from first name

2012-01-27 Thread walter capio

All depends on how many users you have and how accurate you want your data to 
be. If your language uses specific morphemes for women (usually non-european 
languages have marked feminine morphemes; male names and pronouns are not 
marked), then you could write a parser for these names. Yet I doubt your data 
will be any better than 90% accurate. Don't forget people construct virtual 
identities and often use loanwords. You could also parse their content (blogs, 
comments,... *is this legal?) and see which first person pronouns, verbs, etc. 
they use. If the latter are explicit feminine forms, use a feminine welcome.
So, I would just work around the gender-specific welcome. Replace it somehow. 
Convince your client it is somehow spooky to directly address the visitor.
Or, even better, add a gender category to your db and register form and 
convince your client that some day it will prove interesting for data mining 
purposes.
greetings,djinja


> Subject: Re: Determine gender from first name
> From: law...@thenilgiris.com
> To: django-users@googlegroups.com
> Date: Wed, 25 Jan 2012 15:20:36 +0530
> 
> On Wed, 2012-01-25 at 09:49 +0100, Demetrio Girardi wrote:
> > How can I go about this? Is there a publicly available database of
> > first names divided by language and gender? A public web-service that
> > guesstimates the gender? 
> 
> not possible in my opinion. There may be some languages where a name
> *has* to have gender specific suffix. All the languages I know do not.
> Maria, Rama, Krishna, for example are not gender specific.
> -- 
> regards
> Kenneth Gonsalves
> 
> -- 
> You received this message because you are subscribed to the Google 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.
> 
  

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



Re: How do you pass dissimilar data from view to template?

2012-01-27 Thread BillB1951
Thanks for the additional thought on this.  It is a much appreciated
confirmation to me.  Last night I was torturing my brain over the
logistics of what I had conceived, and by this morning I had pretty
much concluded that I would have to go the route you are suggesting.
Now I just have to find an existing solution ... or learn Javascript.
--Bill

On Jan 27, 11:19 am, Dennis Lee Bieber  wrote:
> On Thu, 26 Jan 2012 14:01:50 -0800 (PST), BillB1951 
> wrote:
>
> >Brett, Thanks.  That is what I needed.  BillB1951
>
>         Just an aside: seems like a convoluted plan to keep round-tripping
> to the server/database each time you refine the filter.
>
>         I'm presuming the initial data set being sent is the "full" list. If
> so, might it not be useful to somehow (Caveat: I'm /not/ skilled at
> this, only toyed with Javascript too many years ago) embed a Javascript
> action to count the categories, render the filter selections and, when
> one is picked, have the Javascript modify the page in-place to display
> only the filtered data?
>
>         Granted, adding another language on top of Python, Django, and the
> template language, may be more than desirable.
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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



Re: How do you pass dissimilar data from view to template?

2012-01-27 Thread Thorsten Sanders
If the data is presented as table, datatables is a really nice jquery 
plugin for such stuff:


http://datatables.net/

On 27.01.2012 17:31, BillB1951 wrote:

Thanks for the additional thought on this.  It is a much appreciated
confirmation to me.  Last night I was torturing my brain over the
logistics of what I had conceived, and by this morning I had pretty
much concluded that I would have to go the route you are suggesting.
Now I just have to find an existing solution ... or learn Javascript.
--Bill

On Jan 27, 11:19 am, Dennis Lee Bieber  wrote:
   

On Thu, 26 Jan 2012 14:01:50 -0800 (PST), BillB1951
wrote:

 

Brett, Thanks.  That is what I needed.  BillB1951
   

 Just an aside: seems like a convoluted plan to keep round-tripping
to the server/database each time you refine the filter.

 I'm presuming the initial data set being sent is the "full" list. If
so, might it not be useful to somehow (Caveat: I'm /not/ skilled at
this, only toyed with Javascript too many years ago) embed a Javascript
action to count the categories, render the filter selections and, when
one is picked, have the Javascript modify the page in-place to display
only the filtered data?

 Granted, adding another language on top of Python, Django, and the
template language, may be more than desirable.
--
 Wulfraed Dennis Lee Bieber AF6VN
 wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
 
   


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



saving in a view

2012-01-27 Thread MikeKJ
I have 2 models Count is purely an incremental counter a model called Sale,
the reason for the Count models is to increment a reference for Sale and
other models

In a view I get the latest sale and count then I want to save the incemented
count (number) to Count also save number to Sale

customer =
Sale.objects.all().order_by('-id').filter(email_address=email).distinct()0
this = Count.objects.all().order_by('-id')0
number = this.number + 1
a = this.save(force_insert=True)
ref = number
reference = number
name = customer.name
salutation = customer.salutation
b = customer.save(force_update=True)

I know the field names are rubbish but can anyone spot where I am going
wrong please 

--
View this message in context: 
http://python.6.n6.nabble.com/saving-in-a-view-tp4343606p4343606.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: saving in a view

2012-01-27 Thread Ian Clelland
On Fri, Jan 27, 2012 at 9:26 AM, MikeKJ  wrote:

> I have 2 models Count is purely an incremental counter a model called Sale,
> the reason for the Count models is to increment a reference for Sale and
> other models
>
> In a view I get the latest sale and count then I want to save the
> incemented
> count (number) to Count also save number to Sale
>
>
First off, the instances of "0" at the end of the first two lines should be
[0] (surrounded by square brackets), but I'm assuming that that's an
artifact of the email transport.

Past that, your code doesn't actually *do* anything, other than pull two
objects out of the database, and save them again, unmodified. Let's look at
the method you've pasted, line by line:

customer
> = Sale.objects.all().order_by('-id').filter(email_address=email).distinct()[0]
> this = Count.objects.all().order_by('-id')[0]


This part retrieves two objects from the database. You may want to guard
these two lines with an exception handler -- if there are no matching Sale
objects, or if the Count table is empty, either of these lines could raise
a KeyError.

number = this.number + 1


This line creates a new local variable called number, and assigns it the
value of this.number + 1. It doesn't do anything to the 'this' object at
all.

a = this.save(force_insert=True)


So this line forces 'this' to be re-saved (remember, though, that it hasn't
been modified, so the save doesn't really do anything). Model.save()
doesn't return anything, so 'a' is assigned the value None.

ref = number
> reference = number
> name = customer.name
> salutation = customer.salutation


Again, these just create some new local variables, but they don't actually
change your customer object at all, so this line:

b = customer.save(force_update=True)


Just forces a re-save of the unmodified customer object.

I"m not sure exactly what it is that you're trying to do with this view,
but I think that you are going to need some lines that actually update the
'this' and 'customer' object. You would do that like this:

this.number = this.number + 1

or
customer.reference = number

Then, when you save the objects (and just use "customer.save()", the
force_update=True isn't really necessary), then the new values you have
assigned will be saved in the database.

-- 
Regards,
Ian Clelland


-- 
You received this message because you are subscribed to the Google 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: /?next= not redirect user

2012-01-27 Thread snow leung
first:
use 
in your html template.

second:
you can do it in your login method:
def login(request):
if reqeust.GET:
#do something u want.
return render_to_response('your html template',
{next_url:request.GET.get('next',None)})
if request.POST:
if login():#do login
  next_url = request.POST.get('next',None)
  if next_url:
return HttpResponseRedirect('next_url')
  else:
return HttpResponseRedirect('where u want')


On 1月11日, 上午10时39分, Weldan  wrote:
> hi. can anyone show me how to do this . after successfully login user not
> redirected to request.path. thanks for advance

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



Re: language="JavaScript" solves onload in chrome

2012-01-27 Thread snow leung
how about in firefox ? if the same that we can do anything about this.

if not  you can u jquery method
$(function(){
   //do your initrail or other.
})

jquery method was not like body onload.

On 1月10日, 上午11时34分, Charles Cossé  wrote:
> Hello,
>
> Just writing to share a revelation -- that using:
>
> 
>
> instead of
>
>