A model is just a class, so the methods just "go there", yes.
You could check out apps in django.contrib for styling best practices (the
django doc itself also covers this I think*,* but I can't remember where)
Le 17 juil. 2012 19:49, "jeffsarge" a écrit :
> Hi,
> I'm learning Django and Python
> Do these just get stuck onto the end of my class Poll(models.Model):? like
> this...
Yes, that's right
perhaps you should start here:
http://docs.python.org/tutorial/classes.html
you should probably at least be comfortable enough with python to know
how to define classes before diving into dj
Hey Jeff,
Yes, these methods would go inside of your Poll Class. I'm not sure if the
indentation was messed up through e-mail, but make sure that your method
body is indented one step deeper than your method signature. For example:
class Poll(...):
#
def __unicode__(self):
ret
Yes, the methods are part of your model class. You almost have it right,
and just need to fix your indentations:
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was
Yep..that's it. Thanks!
On Apr 11, 12:55 pm, Jonathan Baker
wrote:
> The method should begin and end with two underscores: __unicode__(self):
>
>
>
>
>
> On Wed, Apr 11, 2012 at 11:30 AM, Brandy wrote:
> > I am working through the tutorial and have already added the def
> > _unicode_ statements
Have you resynced?
On Wed, Apr 11, 2012 at 12:30 PM, Brandy wrote:
> I am working through the tutorial and have already added the def
> _unicode_ statements to my code. However, when running
> Poll.objects.all(), I still get this output: []
>
> Here is the code:
>
> from django.db import models
I don't know if its because I'm reading this mail from my phone but
you should have
__unicode__() not _unicode_() ie is 2 underscores before and after not 1
On 4/11/12, Brandy wrote:
> I am working through the tutorial and have already added the def
> _unicode_ statements to my code. However, wh
The method should begin and end with two underscores: __unicode__(self):
On Wed, Apr 11, 2012 at 11:30 AM, Brandy wrote:
> I am working through the tutorial and have already added the def
> _unicode_ statements to my code. However, when running
> Poll.objects.all(), I still get this output: []
>
Using a database doesn't by default make your site searchable. It's a
more efficient storage system (usually) than having a bunch of static
files.
SQLite is an easy way to develop, especially if you're running Python
2.5, but I usually move to a PostgreSQL backend for "production"
sites, since SQ
you make a good point i will say but I have a few reasons for this:
1.I try and keep things easy
2. I don't want them to be searchable(I know that sound odd but I my
site is designed so that I do not have the need for search
3. I don't really want to add another thing to my "to learn list" as
wel
On Fri, Apr 11, 2008 at 5:20 AM, sebey <[EMAIL PROTECTED]> wrote:
> i am on a mac and I am running a podcasting network so I will proabley
> be storing all my files in XML/RSS
I think you're suffering from very severe conceptual confusion.
Take a podcast and think about it logically:
Each pod
i am on a mac and I am running a podcasting network so I will proabley
be storing all my files in XML/RSS
On Apr 11, 11:11 am, Brett Parker <[EMAIL PROTECTED]>
wrote:
> On 11 Apr 01:35, sebey wrote:
>
>
>
> > I see that in page 1 of the django tutorial in the django docs it sets
> > you up with a
On 11 Apr 01:35, sebey wrote:
>
> I see that in page 1 of the django tutorial in the django docs it sets
> you up with a database
>
> can you skip this or is the a very easy way to get a database setup
> and then uninstaill or is the another tutorial that you can learn
> without a database neede
13 matches
Mail list logo