Re: to add counter in the project

2012-07-03 Thread Bharati Sharma
sorry  kenneth ...but I have stored information(resume) of professors in
the database.
in models.py , i have taken fields like name, dob,
qualification,designation etc. then these are saved in the database of
every professor.
but the point is designation of professors vary(like there are professors,
assistant professors and associate professors).I want that it should count
 the no of   professors, assistant professors and associate
professors automatically and increments their value after I fill and save
the next resume in the database. Is there any logic like this...plz help
me. I shall be very thankfull.

On Tue, Jul 3, 2012 at 4:22 AM, kenneth gonsalves wrote:

> On Tue, 2012-07-03 at 04:16 -0700, Bharati Sharma wrote:
> > thanks  kenneth ...but will it count those entries also which I will
> > enter
> > in the database after using filter() and count()?
>
> if you want to know the number of assistant profs do a query like this:
>
> no_of_asstprofs =
> Faculty.objects.filter(job_title='AssistantProf').count()
>
> do not store this in the database - call it when you need it. If you
> have a counter, you need to maintain it - increment when adding, reduce
> when deleting - which also means setting up signals to adjust the
> counter when a model is changed. A huge waste of time and energy.
>
>
> --
> 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: to add counter in the project

2012-07-03 Thread kenneth gonsalves
On Tue, 2012-07-03 at 04:16 -0700, Bharati Sharma wrote:
> thanks  kenneth ...but will it count those entries also which I will
> enter
> in the database after using filter() and count()? 

if you want to know the number of assistant profs do a query like this:

no_of_asstprofs =
Faculty.objects.filter(job_title='AssistantProf').count()

do not store this in the database - call it when you need it. If you
have a counter, you need to maintain it - increment when adding, reduce
when deleting - which also means setting up signals to adjust the
counter when a model is changed. A huge waste of time and energy.


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



Re: to add counter in the project

2012-07-03 Thread Bharati Sharma
thanks  kenneth ...but will it count those entries also which I will enter
in the database after using filter() and count()?

On Tue, Jul 3, 2012 at 4:06 AM, kenneth gonsalves wrote:

> On Tue, 2012-07-03 at 01:08 -0700, Bharati Sharma wrote:
> > actually I am making project of faculty management system of my
> > college.I
> > have added some of the faculty member's resume in the database. i want
> > a
> > counter in my project that should increment its value whenever a new
> > faculty member's resume is added into the database. yes, it will
> > require
> > filter also as i want it should count no of assistant professors,no of
> > associate professors etc seperatelyhelp me please..
>
> you are storing redundant data in the database - not good. If you want
> the number of assistant professors, use filter() and count().
> --
> 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: to add counter in the project

2012-07-03 Thread Bharati Sharma
thanks jon...

On Tue, Jul 3, 2012 at 4:06 AM, kenneth gonsalves wrote:

> On Tue, 2012-07-03 at 01:08 -0700, Bharati Sharma wrote:
> > actually I am making project of faculty management system of my
> > college.I
> > have added some of the faculty member's resume in the database. i want
> > a
> > counter in my project that should increment its value whenever a new
> > faculty member's resume is added into the database. yes, it will
> > require
> > filter also as i want it should count no of assistant professors,no of
> > associate professors etc seperatelyhelp me please..
>
> you are storing redundant data in the database - not good. If you want
> the number of assistant professors, use filter() and count().
> --
> 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: to add counter in the project

2012-07-03 Thread kenneth gonsalves
On Tue, 2012-07-03 at 01:08 -0700, Bharati Sharma wrote:
> actually I am making project of faculty management system of my
> college.I
> have added some of the faculty member's resume in the database. i want
> a
> counter in my project that should increment its value whenever a new
> faculty member's resume is added into the database. yes, it will
> require
> filter also as i want it should count no of assistant professors,no of
> associate professors etc seperatelyhelp me please.. 

you are storing redundant data in the database - not good. If you want
the number of assistant professors, use filter() and count(). 
-- 
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.



Re: to add counter in the project

2012-07-03 Thread Jon Black
It sounds like you have different user's (User) with different
roles (Group with permission set) that have a resume:

class Resume(models.Model):
  resume = models.FileField()
  date_uploaded = models.DateTimeField()

You can then query by aggregating across the group and
date_uploaded fields. That's one option.

--
Jon Black
www.jonblack.org


On Tue, Jul 3, 2012, at 01:08, Bharati Sharma wrote:

  thanks Jon...

actually I am making project of faculty management system of my
college.I have added some of the faculty member's resume in the
database. i want a counter in my project that should increment
its value whenever a new faculty member's resume is added into
the database. yes, it will require filter also as i want it
should count no of assistant professors,no of associate
professors etc seperatelyhelp me please..
On Tue, Jul 3, 2012 at 12:48 AM, Jon Black <[1]jon_bl...@mm.st>
wrote:

That's quite a vague requirement. You could override form_valid()
in your view and increment a counter in your model manually
before saving. It might pay to ask yourself why you need a
counter. Does it make more sense to record the actions in a
separate table and count the records? Will the count require
filtering later (e.g. number of counts each month, week, day).

--
Jon Black
[2]www.jonblack.org


On Mon, Jul 2, 2012, at 23:25, Bharati Sharma wrote:

I want to add counter in my project so that the value in the
table increases as the data is put in the database. Can anyone
help me plz.


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  [3]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [4]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [5]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
  [6]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [7]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [8]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.

References

1. mailto:jon_bl...@mm.st
2. http://www.jonblack.org/
3. mailto:django-users@googlegroups.com
4. mailto:django-users%2bunsubscr...@googlegroups.com
5. http://groups.google.com/group/django-users?hl=en
6. mailto:django-users@googlegroups.com
7. mailto:django-users%2bunsubscr...@googlegroups.com
8. 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: to add counter in the project

2012-07-03 Thread Bharati Sharma
thanks Jon...
actually I am making project of faculty management system of my college.I
have added some of the faculty member's resume in the database. i want a
counter in my project that should increment its value whenever a new
faculty member's resume is added into the database. yes, it will require
filter also as i want it should count no of assistant professors,no of
associate professors etc seperatelyhelp me please..

On Tue, Jul 3, 2012 at 12:48 AM, Jon Black <jon_bl...@mm.st> wrote:

>  That's quite a vague requirement. You could override form_valid() in your
> view and increment a counter in your model manually before saving. It might
> pay to ask yourself why you need a counter. Does it make more sense to
> record the actions in a separate table and count the records? Will the
> count require filtering later (e.g. number of counts each month, week, day).
>
>  --
>  Jon Black
>  www.jonblack.org
>
>
>  On Mon, Jul 2, 2012, at 23:25, Bharati Sharma wrote:
>
> I want to add counter in my project so that the value in the table
> increases as the data is put in the database. Can anyone help me plz.
>
>
> --
> You received this message because you are subscribed to the Google 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.
>

-- 
You received this message because you are subscribed to the Google 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: to add counter in the project

2012-07-03 Thread Sandeep kaur
On Tue, Jul 3, 2012 at 11:55 AM, Bharati Sharma <bharati21...@gmail.com> wrote:
> I want to add counter in my project so that the value in the table increases
> as the data is put in the database. Can anyone help me plz.
>
If you want a counter in database, you can make it auto-increment.
Like I want job_no as a counter field in a table, then in models.py, add this :

job_no = models.AutoField(primary_key=True)

But if you want the counter in tables in the template file then add
{{forloop.counter}} as your table field.

Correct me if I am wrong anywhere.

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.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: to add counter in the project

2012-07-03 Thread Jon Black
That's quite a vague requirement. You could override form_valid()
in your view and increment a counter in your model manually
before saving. It might pay to ask yourself why you need a
counter. Does it make more sense to record the actions in a
separate table and count the records? Will the count require
filtering later (e.g. number of counts each month, week, day).

--
Jon Black
www.jonblack.org


On Mon, Jul 2, 2012, at 23:25, Bharati Sharma wrote:

  I want to add counter in my project so that the value in the
  table increases as the data is put in the database. Can anyone
  help me plz.


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



to add counter in the project

2012-07-03 Thread Bharati Sharma
I want to add counter in my project so that the value in the table
increases as the data is put in the database. Can anyone help me plz.

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