meta.Model extrass

1 view
Skip to first unread message

Krzysztof Drozd

unread,
Nov 22, 2005, 8:36:07 AM11/22/05
to Django developers
it would by nice to have a new extra field in the django admin panel
thats can work as a publish un publish poll/site/... or
publish_on_date.

now django show all stufffs in the DB, what when i have write a TEXT or
Poll and won publish it in next week??

my english is poor and ugly i know that :) i'm work on it

Jacob Kaplan-Moss

unread,
Nov 22, 2005, 8:50:20 AM11/22/05
to django-d...@googlegroups.com
On Nov 22, 2005, at 7:36 AM, Krzysztof Drozd wrote:
> it would by nice to have a new extra field in the django admin panel
> thats can work as a publish un publish poll/site/... or
> publish_on_date.

This is best done at the view level; an object is an object and the
database shouldn't know about pesky things like publication
schedules. All you've got to do is add a "pub_date" field to your
objects, then in your view do:

object_list = module.get_list(pub_date__lte=datetime.datetime.now())

to fetch all objects with a pub date before today.

Jacob

Adrian Holovaty

unread,
Nov 22, 2005, 9:38:27 AM11/22/05
to django-d...@googlegroups.com
On 11/22/05, Krzysztof Drozd <krzy...@asi.pwr.wroc.pl> wrote:
> it would by nice to have a new extra field in the django admin panel
> thats can work as a publish un publish poll/site/... or
> publish_on_date.
>
> now django show all stufffs in the DB, what when i have write a TEXT or
> Poll and won publish it in next week??

Hi Krzysztof,

That's very easy to do. Just add a pub_date field to your model and
check that field's value in your view, so that whenever you retrieve
polls from the system, you check the pub_date is less than or equal to
datetime.datetime.now().

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

Krzysztof Drozd

unread,
Nov 22, 2005, 12:07:02 PM11/22/05
to Django developers
yes, that is it :) thanks

can i do that with the lang field?? see:
http://groups.google.com/group/django-developers/browse_thread/thread/3491a40d8b680ee9
on "Multi-language support in Django" thred on this group???

if yes, then django is the best thing on the world :)

Adrian Holovaty

unread,
Nov 22, 2005, 12:23:07 PM11/22/05
to django-d...@googlegroups.com
On 11/22/05, Krzysztof Drozd <krzy...@asi.pwr.wroc.pl> wrote:
> can i do that with the lang field?? see:
> http://groups.google.com/group/django-developers/browse_thread/thread/3491a40d8b680ee9
> on "Multi-language support in Django" thred on this group???

Yes, that's definitely possible -- you can make any sort of
calculation you need to make based on the language field.

Krzysztof Drozd

unread,
Nov 22, 2005, 1:08:32 PM11/22/05
to Django developers
in my case:

class Conteiner(meta.Model):
name = meta.CharField()
class META:
admin = meta.Admin()

class Site(meta.Model):
title = meta.CharField()
con = meta.ForeginKey(Conteiner)
class META:
admin = meta.Admin()

and now when i have:
con1:
s1.lang=pl,s2.lang=en,s3=lang=de
con2:
s1.lang=pl,s2.lang=en,s3=lang=de

how will now look :
object_list = module.get_list())

siplty it returns all (con1 and con2) all have sites with
lang=en,de,pl...

Reply all
Reply to author
Forward
0 new messages