I keep getting an error for line 7, what's wrong with this?
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice 8 1141
On Aug 9, 6:47 pm, eggie5 <egg...@gmail.comwrote:
I keep getting an error for line 7, what's wrong with this?
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
The "def" statements have to be at the same indentation level as
what's before it.
On Aug 9, 4:52 pm, Dan Bishop <danb...@yahoo.comwrote:
On Aug 9, 6:47 pm, eggie5 <egg...@gmail.comwrote:
I keep getting an error for line 7, what's wrong with this?
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
The "def" statements have to be at the same indentation level as
what's before it.
will they still be a part of the classes?
On Aug 9, 7:02 pm, eggie5 <egg...@gmail.comwrote:
On Aug 9, 4:52 pm, Dan Bishop <danb...@yahoo.comwrote:
On Aug 9, 6:47 pm, eggie5 <egg...@gmail.comwrote:
I keep getting an error for line 7, what's wrong with this?
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
The "def" statements have to be at the same indentation level as
what's before it.
will they still be a part of the classes?
If you indent them twice, it's a syntax error.
If you indent them once, they'll be methods of the class.
If you don't indent them at all, they'll be global functions.
But this still isn't valid:
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice
On Aug 9, 5:52 pm, Dan Bishop <danb...@yahoo.comwrote:
On Aug 9, 7:02 pm, eggie5 <egg...@gmail.comwrote:
On Aug 9, 4:52 pm, Dan Bishop <danb...@yahoo.comwrote:
On Aug 9, 6:47 pm, eggie5 <egg...@gmail.comwrote:
I keep getting an error for line 7, what's wrong with this?
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
The "def" statements have to be at the same indentation level as
what's before it.
will they still be a part of the classes?
If you indent them twice, it's a syntax error.
If you indent them once, they'll be methods of the class.
If you don't indent them at all, they'll be global functions.
On Aug 9, 8:28 pm, James Stroud <jstr...@mbi.ucla.eduwrote:
eggie5 wrote:
But this still isn't valid:
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice
You want this:
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice
But this mixes tabs and spaces.
Rules:
1. Don't use tabs!
2. If you are clueless enough to violate (1), then don't mix tabs and
spaces.
3. Don't use tabs!
Tabs are for tables, hence the name. "Use spaces for space and use tabs
for tables" can be a little mnemonic to help you remember the rules. We
can make a little song together if you can think of some things that
rhyme with "don't" and "use" and "tabs".
"won't"
"blues", "booze", "bruise", "choose", "cruise", "fuse", "hues",
"Jews", "lose", "muse", "news", "snooze", "views", etc.
"abs", "cabs", "crabs", "dabs", "grabs", "labs", "scabs", "slabs",
"stabs", etc.
Dan Bishop wrote:
>Tabs are for tables, hence the name. "Use spaces for space and use tabs for tables" can be a little mnemonic to help you remember the rules. We can make a little song together if you can think of some things that rhyme with "don't" and "use" and "tabs".
"won't"
"blues", "booze", "bruise", "choose", "cruise", "fuse", "hues",
"Jews", "lose", "muse", "news", "snooze", "views", etc.
"abs", "cabs", "crabs", "dabs", "grabs", "labs", "scabs", "slabs",
"stabs", etc.
When you want to screw your whitespace--don't!
Take this little pledge and I know you won't:
When I was in school I would take of booze
While my typing teacher said I'm free to use
Space or formfeed or even tabs
And I punched so hard with my pinkie that scabs
Covered my Jake and Elwood tatoos.
(You didn't see that one coming did yous?)
James Stroud <js*****@mbi.ucla.eduwrites:
When you want to screw your whitespace--don't!
Take this little pledge and I know you won't:
James, you're a poet
And you don't even realise
--
\ "[...] a Microsoft Certified System Engineer is to information |
`\ technology as a McDonalds Certified Food Specialist is to the |
_o__) culinary arts." —Michael Bacarella |
Ben Finney
On Aug 9, 10:37 pm, James Stroud <jstr...@mbi.ucla.eduwrote:
Dan Bishop wrote:
Tabs are for tables, hence the name. "Use spaces for space and use tabs
for tables" can be a little mnemonic to help you remember the rules. We
can make a little song together if you can think of some things that
rhyme with "don't" and "use" and "tabs".
"won't"
"blues", "booze", "bruise", "choose", "cruise", "fuse", "hues",
"Jews", "lose", "muse", "news", "snooze", "views", etc.
"abs", "cabs", "crabs", "dabs", "grabs", "labs", "scabs", "slabs",
"stabs", etc.
When you want to screw your whitespace--don't!
Take this little pledge and I know you won't:
When I was in school I would take of booze
While my typing teacher said I'm free to use
Space or formfeed or even tabs
And I punched so hard with my pinkie that scabs
Covered my Jake and Elwood tatoos.
(You didn't see that one coming did yous?)
I'm so confused, I have no idea what's going on... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hadi |
last post by:
Hi,
I have two files and the array that contains 20 words in it.
I'm trying to write python script that suppose achieve the following:
-Open file-1, read the line that contains 20 words separated...
|
by: Dwayne Epps |
last post by:
I've created a function that checks form fields that only will have letters.
This is the script:
<script type="text/javascript" language="javascript">
function validateString(field, msg, min,...
|
by: dld_id |
last post by:
Hi;
I've got an intermittent whitespace problem between IE6 and this page:
http://www.cooperforidaho.com
Under firefox & moz, everything's fine. Under IE6, certain window
sizes cause the...
|
by: David Pratt |
last post by:
Hi. I am splitting a string on a non whitespace character. One or more
whitespace characters can be returned as items in the list. I do not
want the items in the list that are only whitespace (can...
|
by: amattie |
last post by:
Does anyone have any idea on how I can strip the extra whitespace in
the XML that shows up when I receive a response from an ASP.NET 2.0
webservice? This has been discussed before, but no one has...
|
by: kaens |
last post by:
Hey everyone, this may be a stupid question, but I noticed the
following and as I'm pretty new to using xml and python, I was
wondering if I could get an explanation.
Let's say I write a simple...
|
by: bryan rasmussen |
last post by:
Hi,
Basically I want to get sys.argv but the problem is that actually
the argument should maintain whitespace. Thus if the arguments are
something something with only one space between them, or...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I trim whitespace -
trim/trimRight/trimLeft...
|
by: John Gordon |
last post by:
My XSLT files have many occurrences of this general pattern:
<a>
<xsl:attribute name="href">
<xsl:value-of select="xyz" />
</xsl:attribute>
</a>
When I execute an XSL transform, the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |