I'm still struggling with the tutorial. Now I have the code snippet from:
http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02

def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
was_published_today.short_description = 'Published today?'



I can't figure out what to do with this code.
I'm I supposed to swop this code with the

def was_published_today(self):
    return self.pub_date.date() == datetime.date.today()

in models.py?

No mater what I do I get errors?




2008/12/31 johan <johan.post...@gmail.com>

> Thank you for the response. Good explanation Briel.
>
> Turned out I was loading the wrong URL but start to get an understanding
> for how Django works now. (I think!)
>
>
>
>  till Django
> 2008/12/29 Briel <toppe...@gmail.com>
>
>
>> The quick answer:
>> This goes into views.py (copied from the tutorial).
>>
>> def detail(request, poll_id):
>>    return HttpResponse("You're looking at poll %s." % poll_id)
>>
>> Now to understand what happens a bit better:
>> In your views.py file you can make as many "def something(request):"
>> as you like. This is where you write your code to handle what or how
>> you'll make some http response. In your urls.py you write what model
>> in your views.py need to handle what urls. So when you write an url,
>> Django will find out if that is a valid url, comparing to the urls you
>> have in your urls.py file(s). If there is a match, then it will run
>> the model in your views file.
>>
>> In the code from the tutorial, 'mysite.polls.views.detail' will run
>> the above code, if it's written in the views.py in your polls app. It
>> returns a simple http response, a text string: "You're looking at poll
>> %s." % poll_id. The poll_id varible is gotten from the url.
>>
>> -Briel
>>
>>
>> johan skrev:
>> > yes of course my bad!
>> >
>> > http://docs.djangoproject.com/en/dev/intro/tutorial03/#intro-tutorial03
>> >
>> >
>> >
>> > 2008/12/29 Abdel Bolanos Martinez <abdel.bola...@etecsa.cu>
>> >
>> > >  send me the url of the tutorial  where you are, now!!!
>> > >
>> > >
>> > > On Mon, 2008-12-29 at 06:19 -0800, kallep wrote:
>> > >
>> > > that was a fast reply :)
>> > >
>> > > In  part 3 I do not understand if I'm suppose to create a new view
>> > > called detail.py or if this code should be in to the views.py. The
>> > > problem is that I cant load the detail page or even figure out if I'm
>> > > supposed to be able to do that. I do not know what I'm building here!
>> > >
>> > > On Dec 29, 10:02 pm, Abdel Bolanos Martinez <abdel.bola...@etecsa.cu>
>> > > wrote:
>> > > > what you have just done until now ???
>> > > >
>> > > > On Mon, 2008-12-29 at 05:52 -0800, kallep wrote:
>> > > > > This is my first question here.  I find it extremely difficult to
>> > > > > follow the "Writing your first Django app tutorial".  I'm  now
>> stocked
>> > > > > on the third part. Is it possible to see the finished source code
>> > > > > somewhere?   The main difficulty is to understand what code are
>> > > > > supposed to go where.
>> > > >
>> > > > Abdel Bola�os Mart�nez
>> > > > Ing. Inf�rmatico
>> > > > Telf. 266-8562
>> > > > 5to piso, oficina 526, Edificio Beijing, Miramar Trade Center.
>> ETECSA
>> > >
>> > >
>> > >
>> > >
>> > > Abdel Bola�os Mart�nez
>> > > Ing. Inf�rmatico
>> > > Telf. 266-8562
>> > > 5to piso, oficina 526, Edificio Beijing, Miramar Trade Center. ETECSA
>> > > >
>> > >
>>
>> >>
>>
>

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