Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » newbie help with console, can't run Django function [RSS Feed]

#1 Jan. 27, 2011 01:03:01

Casual C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


I'd like to get handy with using the console. Do I have a setup
problem or a usage problem?

See following pydev console output. Am I not able to run
get_version() like that?

Thanks...

>>> import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
C:\Python25\python.exe 2.5.4 (r254:67916, Dec 23 2008, 15:10:54)
>>> sys.path

>>> from django import VERSION
>>> get_version()
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'get_version' is not defined
>>> print 'darn'
darn
>>>

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 27, 2011 01:13:25

Mike D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


On 27/01/2011 12:02pm, Casual Coder wrote:I'd like to get handy with using the console. Do I have a setup
problem or a usage problem?>>> from django import VERSION
>>> VERSION
(1, 3, 0, 'alpha', 1)
>>>See following pydev console output. Am I not able to run
get_version() like that?

Thanks...import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))C:\Python25\python.exe 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) sys.pathfrom django import VERSION
get_version()Traceback (most recent call last):
File "<console>", line 1, in<module>
NameError: name 'get_version' is not definedprint 'darn'darn--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 27, 2011 01:28:04

Casual C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


On Jan 26, 8:13 pm, Mike Dewhirst <mi...@dewhirst.com.au> wrote:
>  >>> from django import VERSION
>  >>> VERSION
> (1, 3, 0, 'alpha', 1)


Ah. That works. I have suddenly become quite powerful. Thanks!

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 27, 2011 02:02:53

Casual C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


Thanks Mike.

But Darn I'm not as powerful as I had hoped. I expected DUMPDATA to
work the same way, but it doesn't. How did VERSION work?

and why doesn't django-admin.py dumpdata work?

>>> django-admin.py dumpdata
File "<console>", line 1
django-admin.py dumpdata
^
SyntaxError: invalid syntax
>>> print 'darn'
darn

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 Jan. 27, 2011 03:01:01

Mike D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


On 27/01/2011 1:02pm, Casual Coder wrote:Thanks Mike.

But Darn I'm not as powerful as I had hoped. I expected DUMPDATA to
work the same way, but it doesn't. How did VERSION work?VERSION didn't actually "work". It is a constant which is an attributeof django. Bear in mind that django is just python code.You can import anything from the django python package using dotnotation. That includes constants in __init__.py.I just had a look in there and see now why you were trying to callget_version(). The correct way to do that is ...>>> import django
>>> django.get_version()
u'1.3 alpha 1 SVN-14914'
>>>

or

>>> from django import get_version
>>> get_version()
u'1.3 alpha 1 SVN-14914'
>>>and why doesn't django-admin.py dumpdata work?Because that isn't how python code works. Within the interpreter (and inyour code) you need to import packages or modules without mentioning the.py file extension. Python relies on finding things via the python pathand dot notation.Try getting a shell command line or Windows DOS prompt and do ...

python django-admin.py dumpdata

hth

Mdjango-admin.py dumpdataFile "<console>", line 1
django-admin.py dumpdata
^
SyntaxError: invalid syntaxprint 'darn'darn--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#6 Jan. 27, 2011 03:26:39

Casual C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


Mike I appreciate your answers and am trying them lots of ways. Still
not getting that Django linkage in my console.

>>> import django
>>> django.get_version()
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'get_version'

Is there a way to see what all got imported from django?

I tried it the other way too

>>> from django import get_version
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: cannot import name get_version

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#7 Jan. 27, 2011 03:35:37

Casual C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


>>> import django
>>> django.VERSION
(0, 96.400000000000006, None)

>>> django.get_version()
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'get_version'

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#8 Jan. 27, 2011 04:20:54

Mike D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


On 27/01/2011 2:35pm, Casual Coder wrote:import django
django.VERSION(0, 96.400000000000006, None)django.get_version()Traceback (most recent call last):
File "<console>", line 1, in<module>
AttributeError: 'module' object has no attribute 'get_version'Maybe Django version 0.96 didn't use a get_version() function?Have a look inside <path to>/site-packages/django/__init__.py to seewhat is happening.If you are just beginning with django it would be better to start with amore up-to-date version. I recommend using the development version butif that worries you then at least the most recent production release.I don't know for sure but I wouldn't be surprised if 0.96 is no longersupported.Mike

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#9 Jan. 27, 2011 04:37:50

Russell K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


On Thu, Jan 27, 2011 at 12:22 PM, Mike Dewhirst <mi...@dewhirst.com.au> wrote:
> On 27/01/2011 2:35pm, Casual Coder wrote:
>>>>>
>>>>> import django
>>>>> django.VERSION
>>
>> (0, 96.400000000000006, None)
>>
>>>>> django.get_version()
>>
>> Traceback (most recent call last):
>>   File "<console>", line 1, in<module>
>> AttributeError: 'module' object has no attribute 'get_version'
>>
>
> Maybe Django version 0.96 didn't use a get_version() function?

No, it didn't. get_version() was added in v1.0.

> Have a look inside <path to>/site-packages/django/__init__.py to see what is
> happening.
>
> If you are just beginning with django it would be better to start with a
> more up-to-date version. I recommend using the development version but if
> that worries you then at least the most recent production release.
>
> I don't know for sure but I wouldn't be surprised if 0.96 is no longer
> supported.

No, it isn't, and 0.96 hasn't been supported in *any* capacity for
almost a year. For a year prior to that, it only received critical
security updates.

There are quite a few very important differences between 0.96 and 1.0
-- if you're just starting out, you *definitely* want to be using a
recent release. Django 1.2 is the currently stable supported version;
a new stable version (1.3) is due out very soon (hopefully within a
couple of weeks).

Yours,
Russ Magee %-)

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#10 Jan. 27, 2011 19:42:35

Casual C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

newbie help with console, can't run Django function


Thanks Mike & Russ,

I was using 0.96 for development with Google App Engine.

Stubbornly. I really didn't HAVE to use GAE. I picked it as a
hosting & auth headstart.

My rampup has been embarrassingly slow (Python, Django, Eclipse
newbie) so I think I'll switch over to a newer version of Django.
Then after I have an app I'll decide whether to port back it to GAE.

Cheers!

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » newbie help with console, can't run Django function [RSS Feed]

Board footer

Moderator control

Enjoy the 13th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support