have you read the documentation already?  i think this might help you
http://docs.djangoproject.com/en/1.2/topics/db/queries/

On Mon, Mar 14, 2011 at 11:20 AM, django beginner <djangop...@gmail.com>wrote:

> Hi all,
>
> I would like to know is there any way I can search any data from
> tables given some parameters:
> Suppose I have this person model:
>
> class Person(models.Model):
>    userid = models.AutoField(primary_key=True)
>    fname = models.CharField(max_length=30)
>    lname = models.CharField(max_length=30)
>    age = models.IntegerField(max_length=2)
>    nationality = models.CharField(max_length=50)
>    def __unicode__(self):
>        return self.fname
>
> ------------------------------------------
> and, suppose I have these existing data from person_table:
>
> userid      fname              lname                 age
> nationality
> 1             Marie              Santos
> 21                Canadian
> 2             Ann                Reyes
> 18                Canadian
> 3             John               Smith
> 17                American
> 4             Beth               Anderson
> 17                American
> 5             Lani                Jackson
> 17               American
>
> -----------------------------------------
> Now, I have these user input as search parameters:
> Nationality:  American
> Age: 17
>
> ---------------------------------------
> The results should output these data:
> userid      fname              lname                 age
> nationality
> 3             John               Smith
> 17                American
> 4             Beth               Anderson
> 17                American
> 5             Lani                Jackson
> 17               American
>
> ---------------------------------------
> Could someone please give me a sample code for this simple search
> query using Django? Thank you 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.
>
>

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

Reply via email to