Hi, I'm following the "Writing your first Django app, part 1" in the https://docs.djangoproject.com/en/1.5/intro/tutorial01/ web site.

In more and more days...I'm arrived really near near the end. But I'm unable to do that.

I reach this section: "Playing with the API" From here, I'm unable to continue. Can someone help me to reach the end?

TIA

Renato

asked 12 Sep '13, 11:53

Renato's gravatar image

Renato
1113
accept rate: 0%


sure we can , what kind of help you need?

link

answered 12 Sep '13, 13:09

DjangoForum's gravatar image

DjangoForum ♦♦
634
accept rate: 8%

ok, (TIA) let's start: running:

python manage.py shell

I receive: SytaxError: invalid syntax (models.py, line 7)

this is my models.py (inside the polls folder)

from django.db import models

# Create your models here.
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_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
    def_unicode_(self)
        return self.choice_text

What is the prob?

Renato

link

answered 13 Sep '13, 04:58

Renato's gravatar image

Renato
1113
accept rate: 0%

can you check which django version are you using via following commands in command line

python import django django.VERSION

(13 Sep '13, 05:00) DjangoForum ♦♦

sorry, I apologize. I've correct the prob (:-( )

this is what I obtain with the correct command:

renato1@ssh:~/mysite$ python manage.py shell
Python 2.6.6 (r266:84292, Dec  6 2010, 18:49:07)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]:

on the userguide, i find this:

Once you’re in the shell, explore the database API:

but I have just this:

In [1]:

what is this? what do I have to do?

Renato

link

answered 13 Sep '13, 05:07

Renato's gravatar image

Renato
1113
accept rate: 0%

you are in wrong shell, start it in your django project path where your manage.py file is then you can work with model objects etc

(13 Sep '13, 05:09) DjangoForum ♦♦

but I am in the dir where I have the manage.py:

renato1@ssh:~/mysite$ ls
manage.py  mysite  polls  public
renato1@ssh:~/mysite$

renato

link

answered 13 Sep '13, 05:15

Renato's gravatar image

Renato
1113
accept rate: 0%

could it be a Path problems?

link

answered 13 Sep '13, 06:24

Renato's gravatar image

Renato
1113
accept rate: 0%

Renato, if you're at "In [1]:" you just need to start typing in what the tutorial is telling you. Since you're using ipython it may look a little different than what the tutorial shows, but that's ok. Looking at "Playing With The Api" in the tutorial (I assume this is where you are), just type in "from polls.models import Question, Choice" and continue with the rest of the instructions.

link

answered 14 Sep '13, 23:56

chriskavanagh's gravatar image

chriskavanagh
111
accept rate: 0%

if i make in this way, I receive:

In [1]: from polls.models import Question, Choice

ImportError Traceback (most recent call last)

/nfs/http11/renato1/djangoproject/<ipython console=""> in <module>()

ImportError: No module named polls.models

I cannot go forward :-(

link

answered 15 Sep '13, 14:11

Renato's gravatar image

Renato
1113
accept rate: 0%

should be a space between def and unicode

link

answered 20 Sep '13, 10:05

mcihad's gravatar image

mcihad
112
accept rate: 0%

edited 20 Sep '13, 10:05

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×41

Asked: 12 Sep '13, 11:53

Seen: 5,429 times

Last updated: 20 Sep '13, 10:05

powered by OSQA