Re: OperationalError happening after giving authorization to the class based view

2014-06-08 Thread yutaka kobayashi

I made two models on models.py

they are Contacts and Address

along with this http://effectivedjango.com/tutorial/related.html page I 
tried to use the both of this models.
Which means Address model under the Contact model.

The authentication stuff that I had problem with went well after I 
commented out all codes related to Address model.

So I guessed that the error came out of this and tried to fix things out of 
it but nothing went well


quite a dead end for me  hmmm


2014年6月7日土曜日 20時00分49秒 UTC+9 yutaka kobayashi:
>
> hmmm
>
> I tried that but the first error i saw came back on terminal
>
>
> django.db.utils.OperationalError: table "contacts_contact" already exists
>
>
> this is weird.
>
> 2014年6月7日土曜日 19時30分49秒 UTC+9 Andromeda Yelton:
>
> It sounds to me like south has not been fully configured yet, so the 
> migrations aren't working right.  Have you done a manage.py syncdb?  You 
> need to do that to create the south_migrationhistory table before manage.py 
> migrate will be effective: 
> http://south.readthedocs.org/en/latest/installation.html#configuring-your-django-installation
>  
> .
>
> south can be a little finicky to get started with but once you've got the 
> hang of it it will be your best friend; do spend some quality time reading 
> its docs if you haven't yet.  If you've found yourself in a state where 
> your database and south's beliefs about your database are out of sync, 
> you'll be happiest just dropping your database and starting over with it.
>
>
> On Sat, Jun 7, 2014 at 5:58 AM, yutaka kobayashi <
> yutaka.k...@todai-dream-net.com> wrote:
>
> thank you so much for your advice!!
>
> i tried the number1 option but it didn't work
>
> when i try to migrate it gave me an error
>
>
> -
>
> $ python manage.py migrate
>
> Traceback (most recent call last):
>
>   File "manage.py", line 10, in 
>
> execute_from_command_line(sys.argv)
>
>   File 
> "/Library/Python/2.7/site-packages/django/core/management/__init__.py", 
> line 399, in execute_from_command_line
>
> utility.execute()
>
>   File 
> "/Library/Python/2.7/site-packages/django/core/management/__init__.py", 
> line 392, in execute
>
> self.fetch_command(subcommand).run_from_argv(self.argv)
>
>   File "/Library/Python/2.7/site-packages/django/core/management/base.py", 
> line 242, in run_from_argv
>
> self.execute(*args, **options.__dict__)
>
>   File "/Library/Python/2.7/site-packages/django/core/management/base.py", 
> line 285, in execute
>
> output = self.handle(*args, **options)
>
>   File 
> "/Library/Python/2.7/site-packages/South-0.8.4-py2.7.egg/south/management/commands/migrate.py",
>  
> line 111, in handle
>
> ignore_ghosts = ignore_ghosts,
>
>   File 
> "/Library/Python/2.7/site-packages/South-0.8.4-py2.7.egg/south/migration/__init__.py",
>  
> line 200, in migrate_app
>
> applied_all = check_migration_histories(applied_all, delete_ghosts, 
> ignore_ghosts)
>
>   File 
> "/Library/Python/2.7/site-packages/South-0.8.4-py2.7.egg/south/migration/__init__.py",
>  
> line 79, in check_migration_histories
>
> for h in histories:
>
>   File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 
> 96, in __iter__
>
> self._fetch_all()
>
>   File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 
> 857, in _fetch_all
>
> self._result_cache = list(self.iterator())
>
>   File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 
> 220, in iterator
>
> for row in compiler.results_iter():
>
>   File 
> "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py", line 
> 713, in results_iter
>
> for rows in self.execute_sql(MULTI):
>
>   File 
> "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py", line 
> 786, in execute_sql
>
> cursor.execute(sql, params)
>
>   File "/Library/Python/2.7/site-packages/django/db/backends/util.py", 
> line 69, in execute
>
> return super(CursorDebugWrapper, self).execute(sql, params)
>
>   File "/Library/Python/2.7/site-packages/django/db/backends/util.py", 
> line 53, in execute
>
> return self.cursor.execute(sql, params)
>
>   File "/Library/Python/2.7/site-packages/django/db/utils.py", line 99, in 
> __exit__
>
> six.reraise(dj_exc_type, dj_exc_value, traceback)
>
>   File "/Library/Python/2.7/site-packages/django/db/backends/util.py", 
> line 53, in execute
>
> return self.cursor.execute(sql, params)
>
>   File 
> "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py", 
> line 451, in execute
>
> return Database.Cursor.execute(self, query, params)
>
> django.db.utils.OperationalError: no such table: south_migrationhistory
>
> -
>
> this whole error message is completely alian to me..
>
>
> as for option number2 I didn't have enough knowledge to comprehend but is 
> it possible to create field from terminal?
>
> I don't know how..
>
> thanks for your help in advance
>
>
>
> 2014年6月6日金曜日 23時52分07秒 UTC+9 sacrac:
>
> Hi, 2

Re: The Django 1.7 tees!

2014-06-08 Thread Russell Keith-Magee
Hi Lloyd,

You should have got an email when you placed your order, and another when
the campaign completed (i.e., last Sunday). If you didn't get either of
those emails, then I don't know what's happened with your order - you might
want to contact TeeSpring support.

Yours,
Russ Magee %-)

On Sunday, June 8, 2014, Sithembewena Lloyd Dube  wrote:

> Hi Russell,
>
> Emails from Teespring? I cannot seem to find any - not even in my trash??
> :( You are right though, the currency arbitrage at most banks is shocking -
> and the fees are not insignificant.
>
> I am not sure what went on here and I am really jittery because I badly
> want a 1.7 tee. This is a milestone release and I want to keep  a memento.
> I actually wanted to go back and buy a second, which is when I realised I
> knew nothing of the first transaction. If nothign happens i will just ask
> the mailing list if anyone has a small tee they want to let go off.
>
> Again, thanks for your help (and patience).
>
> Kind regards,
> Lloyd
>
>
> On Sun, Jun 8, 2014 at 2:32 AM, Russell Keith-Magee <
> russ...@keith-magee.com
> > wrote:
>
>> Hi Lloyd;
>>
>> The emails you've received from Teespring give all the details, including
>> a link that should let you track progress of your order. I don't have
>> access to any info beyond that.
>>
>> However, personally, I wouldn't take absence of a bank record to be
>> evidence of anything. Interbank currency arbitrage is a mess :-)
>>
>> Yours,
>> Russ Magee %-)
>>
>>
>> On Sunday, June 8, 2014, Sithembewena Lloyd Dube 
>> wrote:
>>
>>  Hi Russell,
>>
>> Thanks for the feedback. I still do not see anything processed on the
>> card - am getting a bit worried here. Is there some way I could find out
>> what happened to my order?
>>
>> Kind regards,
>> Lloyd
>>
>>
>> On Tue, Jun 3, 2014 at 1:56 AM, Russell Keith-Magee <
>> russ...@keith-magee.com> wrote:
>>
>> Hi Lloyd,
>>
>> The card won't be debited until the campaign completes, which was over
>> the weekend; I'm guessing that means the bank wouldn't have processed
>> anything until Monday, and as with all bank things, it might take a day or
>> two to show up in statements.
>>
>> The actual shirts should have gone into production on Monday as well, and
>> generally ship within 2 weeks. US deliveries take 7-14 days from end of
>> campaign; international take 14-21 days.
>>
>> Yours,
>> Russ Magee %-)
>>
>>
>> On Mon, Jun 2, 2014 at 8:13 PM, Sithembewena Lloyd Dube <
>> zebr...@gmail.com> wrote:
>>
>> Hey Russell,
>>
>> I placed an order for a small tee, but I see my card has not been debited
>> in my bank statement? When do they get charged/ shipped?
>>
>> Thanks,
>> Lloyd
>>
>>
>> On Wed, May 21, 2014 at 2:17 PM, Sithembewena Lloyd Dube <
>> zebr...@gmail.com> wrote:
>>
>> Hi Russell,
>>
>> Thank you! I really appreciate you bringing the campaign back :)
>>
>> Kind regards,
>> Sithu
>>
>>
>> On Wed, May 21, 2014 at 1:35 PM, Russell Keith-Magee <
>> russ...@keith-magee.com> wrote:
>>
>> Hi Sithu,
>>
>> Good news! It turns out you weren't the only person to have problems
>> placing an order, so we've re-opened the campaign for one last run to make
>> sure everyone who wants a shirt can get one. You can place your order here:
>>
>> http://teespring.com/django17-v2
>>
>> You have until the end of May.
>>
>> Yours,
>> Russ Magee %-)
>>
>>
>>
>> On Thu, May 1, 2014 at 7:03 PM, Sithembewena Lloyd Dube <
>> zebr...@gmail.com> wrote:
>>
>> Hi Russell,
>>
>> Thank you for the feedback. I'm hoping that others may show interest so
>> that the campaign could be re-opened. I will be watching this closely :)
>>
>> Kind regards,
>> Sithu
>>
>>
>> On Thu, May 1, 2014 at 2:39 AM, Russell Keith-Magee <
>> russ...@keith-magee.com> wrote:
>>
>> Hi Sithu,
>>
>> Unfortunately, we can't add orders once the campaign is closed - this is
>> one of the features of TeeSpring as a fund raising method.
>>
>> We *can* relaunch the campaign, but that campaign would be independent to
>> the original. It would have its own sales target, its own closing date, and
>> so on.
>>
>> The lowest we can set the sales target is 20 shirts. I know there are
>> about 6 other orders out there from people who missed the deadline; if
>> there's any other interest out there (speak up in a reply if you're
>> interested), we might consider reopening the campaign for a week.
>>
>> Yours,
>>
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAJxq84_c5M9PhGT%2BGyr7erbgZOiaZbicc4dL8dkN7nG9G_517g%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django

newcomer to django testing

2014-06-08 Thread monoBOT
Im new on testing ... to be honest its my first django test XD

Now i wanted to test one of my applications and after the innitial tweaking
of allowing the django user to be able to create databases i get this error:

​The error was: relation "usuario_usuario" does not exist

Error in migration: comunidad:0001_initial
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 399, in execute_from_command_line
utility.execute()
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
line 50, in run_from_argv
super(Command, self).run_from_argv(argv)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
line 71, in execute
super(Command, self).execute(*args, **options)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
line 285, in execute
output = self.handle(*args, **options)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/test.py",
line 8, in handle
super(Command, self).handle(*args, **kwargs)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
line 88, in handle
failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line
145, in run_tests
old_config = self.setup_databases()
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line
107, in setup_databases
return setup_databases(self.verbosity, self.interactive, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line
279, in setup_databases
verbosity, autoclobber=not interactive)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/hacks/django_1_0.py",
line 104, in wrapper
return f(*args, **kwargs)
  File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/creation.py",
line 339, in create_test_db
load_initial_data=False)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 159, in call_command
return klass.execute(*args, **defaults)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
line 285, in execute
output = self.handle(*args, **options)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
line 415, in handle
return self.handle_noargs(**options)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/syncdb.py",
line 103, in handle_noargs
management.call_command('migrate', **options)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 159, in call_command
return klass.execute(*args, **defaults)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
line 285, in execute
output = self.handle(*args, **options)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/migrate.py",
line 111, in handle
ignore_ghosts = ignore_ghosts,
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/migration/__init__.py",
line 220, in migrate_app
success = migrator.migrate_many(target, workplan, database)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
line 305, in migrate_many
result = self.migrate(migration, database)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
line 134, in migrate
result = self.run(migration, database)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
line 115, in run
return self.run_migration(migration, database)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
line 86, in run_migration
south.db.db.execute_deferred_sql()
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/db/generic.py",
line 318, in execute_deferred_sql
self.execute(sql)
  File
"/home/monobot/.local/lib/python2.7/site-packages/south/db/generic.py",
line 282, in execute
cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py",
line 53, in execute
return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line
99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py",
line 53, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "usuario_usuari

Running a test from other folder using manage.py

2014-06-08 Thread Kim
Hi everyone,

I have a question on unit tests.
I have manage.py file placed in the upper superlists folder and the 
tests.py placed in lists folder. 
I keep getting an error message saying "ImportError: No module named 
lists.tests”. 

Would anyone know how to access a test file from other folder using 
manage.py?

My Django project directory looks like below. 

superlists
  db.sqlite3
  functional_test.py
  manage.py
  lists
__init__.py
admin.py
models.py
tests.py
views.py
  superlists
__init__.py
settings.py
urls.py 
wsgi.py
__init__.py

The error message is below:

$ python manage.py test
Creating test database for alias 'default'...
E
==
ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
--
ImportError: Failed to import test module: superlists.lists.tests
Traceback (most recent call last):
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
 
line 254, in _find_tests
module = self._get_module_from_name(name)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
 
line 232, in _get_module_from_name
__import__(name)
ImportError: No module named lists.tests


--
Ran 1 test in 0.000s

FAILED (errors=1)
Destroying test database for alias 'default'...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/536ef74f-633e-40d7-80d4-25934f517301%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why doesn't saving a related model update the _id field?

2014-06-08 Thread Malcolm Box
I'm confused by Django's behaviour when saving related models. Take for 
example:

class X(models.Model):
pass

class Y(models.Model):
   x = models.ForeignKey(X)

Now if I create some objects (unsaved):

x = X()
y = Y(x=x)

All well so far. But now odd things happen when I save:

A) y.save() throws an integrity error because there's no PK for x

I kind of understand this, but it's not obvious to me why Django doesn't at 
least try to save the related object first

B) y.x.save(); y.save() also throws an integrity error because y.x_id is 
None. 

However, y.x.id is not None, so I don't understand why it can't update 
y.x_id (and thus make the save succeed).

C) y.x.save(); y.x = y.x; y.save() - succeeds, but I don't see why the y.x 
= y.x is needed.

Is this a deliberate design decision, something I'm misunderstanding, or a 
bug/implementation artefact?

I'm running into this with serialization in Django Rest Framework - my API 
provides a facade over something that's actually stored across two models, 
so when creating the resource I want to deserialise the data into the two 
related models. DRF serializers by default return unsaved versions of the 
model, but this is broken by the above.

Any insight into what's going on and why would be much appreciated.

Cheers,

Malcolm


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21f29ffc-29ba-40f3-9143-25fed227d4af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newcomer to django testing

2014-06-08 Thread Esau Rodriguez
The testing process creates  db itself when using south it migrate all
apps with migrations. Could you have a problem with your migrations
when run from zero?.

Regards
Esau Rodriguez.



On Sun, Jun 8, 2014 at 10:20 AM, monoBOT  wrote:
> Im new on testing ... to be honest its my first django test XD
>
> Now i wanted to test one of my applications and after the innitial tweaking
> of allowing the django user to be able to create databases i get this error:
>
> The error was: relation "usuario_usuario" does not exist
>
> Error in migration: comunidad:0001_initial
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 399, in execute_from_command_line
> utility.execute()
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
> line 50, in run_from_argv
> super(Command, self).run_from_argv(argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
> line 71, in execute
> super(Command, self).execute(*args, **options)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 285, in execute
> output = self.handle(*args, **options)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/test.py",
> line 8, in handle
> super(Command, self).handle(*args, **kwargs)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
> line 88, in handle
> failures = test_runner.run_tests(test_labels)
>   File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line
> 145, in run_tests
> old_config = self.setup_databases()
>   File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line
> 107, in setup_databases
> return setup_databases(self.verbosity, self.interactive, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line
> 279, in setup_databases
> verbosity, autoclobber=not interactive)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/hacks/django_1_0.py",
> line 104, in wrapper
> return f(*args, **kwargs)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/creation.py",
> line 339, in create_test_db
> load_initial_data=False)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 159, in call_command
> return klass.execute(*args, **defaults)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 285, in execute
> output = self.handle(*args, **options)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 415, in handle
> return self.handle_noargs(**options)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/syncdb.py",
> line 103, in handle_noargs
> management.call_command('migrate', **options)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 159, in call_command
> return klass.execute(*args, **defaults)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 285, in execute
> output = self.handle(*args, **options)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/migrate.py",
> line 111, in handle
> ignore_ghosts = ignore_ghosts,
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/__init__.py",
> line 220, in migrate_app
> success = migrator.migrate_many(target, workplan, database)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
> line 305, in migrate_many
> result = self.migrate(migration, database)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
> line 134, in migrate
> result = self.run(migration, database)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
> line 115, in run
> return self.run_migration(migration, database)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
> line 86, in run_migration
> south.db.db.execute_deferred_sql()
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/db/generic.py", line
> 318, in execute_deferred_sql
> self.execute(sql)
>   File
> "/home/monobot/.local/lib/python2.7/site-packages/south/db/generic.py", line
> 282, in execute
> cursor.execute(sql, params)
>   File "/usr/l

Django Python

2014-06-08 Thread hito koto
Hi,

I want to change recursive definition from  function,

this code change to recursive definition, So how can i do to?

def foo(n, m):
sum = 0
while m > 0:
sum = sum + n
m = m -1
return sum


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65921e2a-7b85-49fb-886b-90b847be8c06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Python

2014-06-08 Thread Thiago borges dos reis
without identaction !!!

def foo(n, m):
sum = 0
   while m > 0:
   sum = sum + n
   m = m -1
   return sum


2014-06-08 12:06 GMT-03:00 hito koto :

> Hi,
>
> I want to change recursive definition from  function,
>
> this code change to recursive definition, So how can i do to?
>
> def foo(n, m):
> sum = 0
> while m > 0:
> sum = sum + n
> m = m -1
> return sum
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/65921e2a-7b85-49fb-886b-90b847be8c06%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHQaGTAEN7q3rMMOfh5C4itvKoBQvJsZX9J3ZBbQZ%2Brerktn%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Python

2014-06-08 Thread Thiago borges dos reis
I'm sorry, i made a mistacke !

def foo(n,m):
... sum = n
... if m>1:
... sum+=foo(n,m-1)
... return sum


2014-06-08 12:19 GMT-03:00 Thiago borges dos reis :

> without identaction !!!
>
> def foo(n, m):
>  sum = 0
>while m > 0:
>sum = sum + n
>m = m -1
>return sum
>
>
> 2014-06-08 12:06 GMT-03:00 hito koto :
>
> Hi,
>>
>> I want to change recursive definition from  function,
>>
>> this code change to recursive definition, So how can i do to?
>>
>> def foo(n, m):
>>  sum = 0
>> while m > 0:
>> sum = sum + n
>> m = m -1
>> return sum
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/65921e2a-7b85-49fb-886b-90b847be8c06%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHQaGTCHJQyAE9O2YWnm%2BN2yRbynm%3Dgz3V2KAJVNQ7HgBbPgtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: newcomer to django testing

2014-06-08 Thread monoBOT
Hi Esau.

Funny to see you here ;.D

I checked what you told me and its true ... if I try to create the database
starting with the comunidad table it  raises the error but when starting
the migrations with usuario it goes smooth.

Simply changing the app order in the settings.py file fixed the problem ...

Thanks mate


2014-06-08 15:39 GMT+01:00 Esau Rodriguez :

> The testing process creates  db itself when using south it migrate all
> apps with migrations. Could you have a problem with your migrations
> when run from zero?.
>
> Regards
> Esau Rodriguez.
>
>
>
> On Sun, Jun 8, 2014 at 10:20 AM, monoBOT  wrote:
> > Im new on testing ... to be honest its my first django test XD
> >
> > Now i wanted to test one of my applications and after the innitial
> tweaking
> > of allowing the django user to be able to create databases i get this
> error:
> >
> > The error was: relation "usuario_usuario" does not exist
> >
> > Error in migration: comunidad:0001_initial
> > Traceback (most recent call last):
> >   File "manage.py", line 10, in 
> > execute_from_command_line(sys.argv)
> >   File
> >
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> > line 399, in execute_from_command_line
> > utility.execute()
> >   File
> >
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> > line 392, in execute
> > self.fetch_command(subcommand).run_from_argv(self.argv)
> >   File
> >
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
> > line 50, in run_from_argv
> > super(Command, self).run_from_argv(argv)
> >   File
> > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> > line 242, in run_from_argv
> > self.execute(*args, **options.__dict__)
> >   File
> >
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
> > line 71, in execute
> > super(Command, self).execute(*args, **options)
> >   File
> > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> > line 285, in execute
> > output = self.handle(*args, **options)
> >   File
> >
> "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/test.py",
> > line 8, in handle
> > super(Command, self).handle(*args, **kwargs)
> >   File
> >
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py",
> > line 88, in handle
> > failures = test_runner.run_tests(test_labels)
> >   File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py",
> line
> > 145, in run_tests
> > old_config = self.setup_databases()
> >   File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py",
> line
> > 107, in setup_databases
> > return setup_databases(self.verbosity, self.interactive, **kwargs)
> >   File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py",
> line
> > 279, in setup_databases
> > verbosity, autoclobber=not interactive)
> >   File
> >
> "/home/monobot/.local/lib/python2.7/site-packages/south/hacks/django_1_0.py",
> > line 104, in wrapper
> > return f(*args, **kwargs)
> >   File
> > "/usr/local/lib/python2.7/dist-packages/django/db/backends/creation.py",
> > line 339, in create_test_db
> > load_initial_data=False)
> >   File
> >
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> > line 159, in call_command
> > return klass.execute(*args, **defaults)
> >   File
> > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> > line 285, in execute
> > output = self.handle(*args, **options)
> >   File
> > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> > line 415, in handle
> > return self.handle_noargs(**options)
> >   File
> >
> "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/syncdb.py",
> > line 103, in handle_noargs
> > management.call_command('migrate', **options)
> >   File
> >
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> > line 159, in call_command
> > return klass.execute(*args, **defaults)
> >   File
> > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> > line 285, in execute
> > output = self.handle(*args, **options)
> >   File
> >
> "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/migrate.py",
> > line 111, in handle
> > ignore_ghosts = ignore_ghosts,
> >   File
> >
> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/__init__.py",
> > line 220, in migrate_app
> > success = migrator.migrate_many(target, workplan, database)
> >   File
> >
> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
> > line 305, in migrate_many
> > result = self.migrate(migration, database)
> >   File
> >
> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
> > line 134, in migrate
> > result = self.run(migration, database)
> >

Re: Django Python

2014-06-08 Thread John
This list is about the use of Django, a python framework for websites.
You might get better help using a list which covers python more generally.

By the way, your function doesn't need recursion:

def foo(n,m):

  return m*n


John

On 08/06/14 16:39, Thiago borges dos reis wrote:
> I'm sorry, i made a mistacke !
>
> def foo(n,m):
> ... sum = n
> ... if m>1:
> ... sum+=foo(n,m-1)
> ... return sum
>
>
> 2014-06-08 12:19 GMT-03:00 Thiago borges dos reis  >:
>
> without identaction !!! 
>
> def foo(n, m):
>  sum = 0
>while m > 0:
>sum = sum + n
>m = m -1
>return sum
>
>
> 2014-06-08 12:06 GMT-03:00 hito koto  >:
>
> Hi,
>
> I want to change recursive definition from  function,
>
> this code change to recursive definition, So how can i do to?
>
> def foo(n, m):
>  sum = 0
> while m > 0:
> sum = sum + n
> m = m -1
> return sum
>
>
> -- 
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to django-users+unsubscr...@googlegroups.com
> .
> To post to this group, send email to
> django-users@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/65921e2a-7b85-49fb-886b-90b847be8c06%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHQaGTCHJQyAE9O2YWnm%2BN2yRbynm%3Dgz3V2KAJVNQ7HgBbPgtA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5394AC07.9000604%40martinhome.org.uk.
For more options, visit https://groups.google.com/d/optout.


Re: HELP on unittest.loader.ModuleImportFailure

2014-06-08 Thread Kelvin Wong
You need to be in the first superlists directory. You have a db created so 
you must have run syncdb at some point. Go back to that folder:

$ pwd
/home/you/superlists

$ ls
__init__.py   db.sqlite3superlistslistsmanage.py

$ ls lists/tests.py
lists/tests.py

$ python manage.py test

Creating test database for alias 'default'...
...etc...



On Saturday, June 7, 2014 2:00:39 AM UTC-7, Kim wrote:
>
> Hi,
>
> I started learning Django and am using "Test Driven Web Development with 
> Python" book. 
>
> On page 21, the book mentions to test using lists/tests.py.
> The book uses the code:
> $ python3 manage.py test
> to run the test. 
>
> However, the manage.py file sits in the upper superlists folder and the 
> tests.py sits in lists folder. 
> I keep getting an error message saying "ImportError: No module named 
> lists.tests”. 
>
> Could someone help me figure this out? 
>
> My Django project directory looks like below. 
>
> superlists
>   db.sqlite3
>   functional_test.py
>   manage.py
>   lists
> __init__.py
> admin.py
> models.py
> tests.py
> views.py
>   superlists
> __init__.py
> settings.py
> urls.py 
> wsgi.py
> __init__.py
>
> The error message is below:
>
> $ python manage.py test
> Creating test database for alias 'default'...
> E
> ==
> ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
> --
> ImportError: Failed to import test module: superlists.lists.tests
> Traceback (most recent call last):
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>  
> line 254, in _find_tests
> module = self._get_module_from_name(name)
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>  
> line 232, in _get_module_from_name
> __import__(name)
> ImportError: No module named lists.tests
>
>
> --
> Ran 1 test in 0.000s
>
> FAILED (errors=1)
> Destroying test database for alias 'default'...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/46587e62-3642-4709-9ccf-ae91fec50d20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Python

2014-06-08 Thread hito koto
Hi, Thiago borges dos reis 

Thank you!


2014年6月9日月曜日 3時32分34秒 UTC+9 John:
>
>  This list is about the use of Django, a python framework for websites. 
> You might get better help using a list which covers python more generally.
>
> By the way, your function doesn't need recursion:
>
> def foo(n,m):
>
>   return m*n
>
>
> John
>
> On 08/06/14 16:39, Thiago borges dos reis wrote:
>  
> I'm sorry, i made a mistacke ! 
>
>  def foo(n,m):
> ... sum = n
>  ... if m>1:
> ... sum+=foo(n,m-1)
> ... return sum
>
>  
> 2014-06-08 12:19 GMT-03:00 Thiago borges dos reis  >:
>
>>  without identaction !!! 
>>  
>>  def foo(n, m):
>>  sum = 0
>>while m > 0:
>>sum = sum + n
>>m = m -1
>>return sum
>>  
>>
>> 2014-06-08 12:06 GMT-03:00 hito koto >: 
>>
>>
>>  Hi, 
>>>
>>>  I want to change recursive definition from  function,
>>>
>>>  this code change to recursive definition, So how can i do to?
>>>
>>>  def foo(n, m):
>>>  sum = 0
>>> while m > 0:
>>> sum = sum + n
>>> m = m -1
>>> return sum
>>>  
>>>  
>>>   -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com 
>>> .
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/65921e2a-7b85-49fb-886b-90b847be8c06%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>   
>>   
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com 
> .
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAHQaGTCHJQyAE9O2YWnm%2BN2yRbynm%3Dgz3V2KAJVNQ7HgBbPgtA%40mail.gmail.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cbb61df7-4dd6-48b4-9abd-9e5125275001%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Python

2014-06-08 Thread Thiago borges dos reis
When you use m>0, you will do m+1 interaction .

Ex.:  foo(2,2): sum+=foo(2,1)  last interaction


2014-06-08 18:57 GMT-03:00 hito koto :

> I have a question
>
> This is why :
> if m >1
> and why you not use 0?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c7d1de6b-3575-4cd0-9426-d54781674beb%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHQaGTCTJgzASSR1NozJ%3D1K9rGQtaS5w1bsWenDsMNTDLfqePQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Python

2014-06-08 Thread hito koto
I have a question

This is why :
if m >1  
and why you not use 0?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c7d1de6b-3575-4cd0-9426-d54781674beb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Python

2014-06-08 Thread hito koto
Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/92d5f7c8-559c-43cf-bf31-897256d5a530%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why doesn't saving a related model update the _id field?

2014-06-08 Thread Russell Keith-Magee
On Sun, Jun 8, 2014 at 10:34 PM, Malcolm Box  wrote:

> I'm confused by Django's behaviour when saving related models. Take for
> example:
>
> class X(models.Model):
> pass
>
> class Y(models.Model):
>x = models.ForeignKey(X)
>
> Now if I create some objects (unsaved):
>
> x = X()
> y = Y(x=x)
>
> All well so far. But now odd things happen when I save:
>
> A) y.save() throws an integrity error because there's no PK for x
>
> I kind of understand this, but it's not obvious to me why Django doesn't
> at least try to save the related object first
>

Ok - so how does Django decide that the related object needs to be saved?

If it saves all related objects, then saving one object could result in a
save call being invoked on every object in the database (since y points to
x, which points to a, which points to b,…). I hope we can agree that a
cascading save like this would be a bad idea.

If it's not *every* related object, then we need to make a decision - which
ones get saved? Ok - so lets say we just save the newly created objects
(i.e., objects with no primary keys.

That means that the following would work:

x = X(value=37)
y = Y(x=x)
y.save()

and on retrieval, y.x.value == 37. Sure - that makes sense. But what about:

x = X(value=37)
x.save()
x.value = 42
y = Y(x=x)
y.save()

and on retrieval, y.x.value == 37. Huh? Why? Oh - it's because in *that*
case, x was already in existence, so it wasn't re-saved as a result of y
being created. So now we've got inconsistent behaviour, depending on when
save() has been called on an object.

The only way I can see to rectify *this* problem would be to keep a track
of every value that has been modified, and save any "modified" objects.
This is in the realm of the possible -- and it has been proposed in the
past -- but it means carrying a lot of accounting baggage around on *every*
attribute change.


> B) y.x.save(); y.save() also throws an integrity error because y.x_id is
> None.
>
> However, y.x.id is not None, so I don't understand why it can't update
> y.x_id (and thus make the save succeed).
>
> C) y.x.save(); y.x = y.x; y.save() - succeeds, but I don't see why the y.x
> = y.x is needed.
>
> Is this a deliberate design decision, something I'm misunderstanding, or a
> bug/implementation artefact?
>

It's a deliberate design decision, for reasons that my example above
hopefully makes clear. The reason the re-assignment is needed in your
example is because y.x implies a query; if you directly save the original
object (i.e., x.save(), not y.x.save()), you should find the reassignment
isn't needed.

I'm running into this with serialization in Django Rest Framework - my API
> provides a facade over something that's actually stored across two models,
> so when creating the resource I want to deserialise the data into the two
> related models. DRF serializers by default return unsaved versions of the
> model, but this is broken by the above.
>
> Any insight into what's going on and why would be much appreciated.
>

Unfortunately, I don't have enough experience with DRF to suggest a
solution here.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq848JLpcRC8b%2BBzPtego4jPfCTbDY5LZc_7iu6y7d2TjSfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: HELP on unittest.loader.ModuleImportFailure

2014-06-08 Thread Kimitaka Nakazawa
Hi Kelvin,

Thank you very much for your reply!
I tried your codes above but I still get the same error...

Kind regards,
Kim


On Mon, Jun 9, 2014 at 3:33 AM, Kelvin Wong  wrote:

> You need to be in the first superlists directory. You have a db created so
> you must have run syncdb at some point. Go back to that folder:
>
> $ pwd
> /home/you/superlists
>
> $ ls
> __init__.py   db.sqlite3superlistslistsmanage.py
>
> $ ls lists/tests.py
> lists/tests.py
>
> $ python manage.py test
>
> Creating test database for alias 'default'...
> ...etc...
>
>
>
> On Saturday, June 7, 2014 2:00:39 AM UTC-7, Kim wrote:
>>
>> Hi,
>>
>> I started learning Django and am using "Test Driven Web Development with
>> Python" book.
>>
>> On page 21, the book mentions to test using lists/tests.py.
>> The book uses the code:
>> $ python3 manage.py test
>> to run the test.
>>
>> However, the manage.py file sits in the upper superlists folder and the
>> tests.py sits in lists folder.
>> I keep getting an error message saying "ImportError: No module named
>> lists.tests”.
>>
>> Could someone help me figure this out?
>>
>> My Django project directory looks like below.
>>
>> superlists
>>   db.sqlite3
>>   functional_test.py
>>   manage.py
>>   lists
>> __init__.py
>> admin.py
>> models.py
>> tests.py
>> views.py
>>   superlists
>> __init__.py
>> settings.py
>> urls.py
>> wsgi.py
>> __init__.py
>>
>> The error message is below:
>>
>> $ python manage.py test
>> Creating test database for alias 'default'...
>> E
>> ==
>> ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
>> --
>> ImportError: Failed to import test module: superlists.lists.tests
>> Traceback (most recent call last):
>>   File 
>> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>> line 254, in _find_tests
>> module = self._get_module_from_name(name)
>>   File 
>> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>> line 232, in _get_module_from_name
>> __import__(name)
>> ImportError: No module named lists.tests
>>
>>
>> --
>> Ran 1 test in 0.000s
>>
>> FAILED (errors=1)
>> Destroying test database for alias 'default'...
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/46587e62-3642-4709-9ccf-ae91fec50d20%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN6%3DZ4KM1UzygLunGuEqmutdtxxO2-Fk%3D%3DkiHVPkcKVc2MB67w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: HELP on unittest.loader.ModuleImportFailure

2014-06-08 Thread Kelvin Wong
Find out which versions you are using

$ python --version
Python 2.7.6

$ django-admin.py version
1.4.10

Try importing the lists app from the shell

$ python manage.py shell

Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import lists
>>> lists.__file__
'/users/you/superlists/lists/__init__.py'
>>> from lists.tests import *
>>>

If you see all that, run the lists app explicitly by label

$ python manage.py test lists

If that doesn't work, maybe there is something weird in your manage.py 
messing the paths. Paste it.

K


On Sunday, June 8, 2014 7:43:43 PM UTC-7, Kim wrote:
>
> Hi Kelvin,
>
> Thank you very much for your reply!
> I tried your codes above but I still get the same error...
>
> Kind regards,
> Kim
>
>
> On Mon, Jun 9, 2014 at 3:33 AM, Kelvin Wong  > wrote:
>
>> You need to be in the first superlists directory. You have a 
>> db created so you must have run syncdb at some point. Go back to that 
>> folder:
>>
>> $ pwd
>> /home/you/superlists
>>
>> $ ls
>> __init__.py   db.sqlite3superlistslistsmanage.py
>>
>> $ ls lists/tests.py
>> lists/tests.py
>>
>> $ python manage.py test
>>
>> Creating test database for alias 'default'...
>> ...etc...
>>
>>
>>
>> On Saturday, June 7, 2014 2:00:39 AM UTC-7, Kim wrote:
>>>
>>> Hi,
>>>
>>> I started learning Django and am using "Test Driven Web Development with 
>>> Python" book. 
>>>
>>> On page 21, the book mentions to test using lists/tests.py.
>>> The book uses the code:
>>> $ python3 manage.py test
>>> to run the test. 
>>>
>>> However, the manage.py file sits in the upper superlists folder and the 
>>> tests.py sits in lists folder. 
>>> I keep getting an error message saying "ImportError: No module named 
>>> lists.tests”. 
>>>
>>> Could someone help me figure this out? 
>>>
>>> My Django project directory looks like below. 
>>>
>>> superlists
>>>   db.sqlite3
>>>   functional_test.py
>>>   manage.py
>>>   lists
>>> __init__.py
>>> admin.py
>>> models.py
>>> tests.py
>>> views.py
>>>   superlists
>>> __init__.py
>>> settings.py
>>> urls.py 
>>> wsgi.py
>>> __init__.py
>>>
>>> The error message is below:
>>>
>>> $ python manage.py test
>>> Creating test database for alias 'default'...
>>> E
>>> ==
>>> ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
>>> --
>>> ImportError: Failed to import test module: superlists.lists.tests
>>> Traceback (most recent call last):
>>>   File 
>>> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>>>  
>>> line 254, in _find_tests
>>> module = self._get_module_from_name(name)
>>>   File 
>>> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>>>  
>>> line 232, in _get_module_from_name
>>> __import__(name)
>>> ImportError: No module named lists.tests
>>>
>>>
>>> --
>>> Ran 1 test in 0.000s
>>>
>>> FAILED (errors=1)
>>> Destroying test database for alias 'default'...
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/46587e62-3642-4709-9ccf-ae91fec50d20%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e741dc9-c97e-413b-97f4-2f1244e5bd59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running a test from other folder using manage.py

2014-06-08 Thread Jimish Parekh
Hi,
Try running
python manage.py test lists.tests

and see if tests are running or not.

Thanks,

On Sunday, June 8, 2014 6:18:45 PM UTC+5:30, Kim wrote:
>
> Hi everyone,
>
> I have a question on unit tests.
> I have manage.py file placed in the upper superlists folder and the 
> tests.py placed in lists folder. 
> I keep getting an error message saying "ImportError: No module named 
> lists.tests”. 
>
> Would anyone know how to access a test file from other folder using 
> manage.py?
>
> My Django project directory looks like below. 
>
> superlists
>   db.sqlite3
>   functional_test.py
>   manage.py
>   lists
> __init__.py
> admin.py
> models.py
> tests.py
> views.py
>   superlists
> __init__.py
> settings.py
> urls.py 
> wsgi.py
> __init__.py
>
> The error message is below:
>
> $ python manage.py test
> Creating test database for alias 'default'...
> E
> ==
> ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
> --
> ImportError: Failed to import test module: superlists.lists.tests
> Traceback (most recent call last):
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>  
> line 254, in _find_tests
> module = self._get_module_from_name(name)
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>  
> line 232, in _get_module_from_name
> __import__(name)
> ImportError: No module named lists.tests
>
>
> --
> Ran 1 test in 0.000s
>
> FAILED (errors=1)
> Destroying test database for alias 'default'...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8624ab0f-c7c8-4e14-8397-06bba9e896e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HELP on unittest.loader.ModuleImportFailure

2014-06-08 Thread Kimitaka Nakazawa
Thank you very much for the reply!

Going through your suggestion below,
at ">>> from lists.tests import *” part, I got an error which is below. 
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/kim/Desktop/Python/python3/superlists/lists/tests.py", line 3, 
in 
    from superlists.lists.views import home_page
ImportError: No module named lists.views

The code of the manage.py file is:
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

Kind regards,
Kim


On 2014年6月9日 at 12:11:44, Kelvin Wong (wongo...@gmail.com) wrote:

Find out which versions you are using

$ python --version
Python 2.7.6

$ django-admin.py version
1.4.10

Try importing the lists app from the shell

$ python manage.py shell

Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import lists
>>> lists.__file__
'/users/you/superlists/lists/__init__.py'
>>> from lists.tests import *
>>>

If you see all that, run the lists app explicitly by label

$ python manage.py test lists

If that doesn't work, maybe there is something weird in your manage.py messing 
the paths. Paste it.

K


On Sunday, June 8, 2014 7:43:43 PM UTC-7, Kim wrote:
Hi Kelvin,

Thank you very much for your reply!
I tried your codes above but I still get the same error...

Kind regards,
Kim


On Mon, Jun 9, 2014 at 3:33 AM, Kelvin Wong  wrote:
You need to be in the first superlists directory. You have a db created so you 
must have run syncdb at some point. Go back to that folder:

$ pwd
/home/you/superlists

$ ls
__init__.py   db.sqlite3    superlists    lists    manage.py

$ ls lists/tests.py
lists/tests.py

$ python manage.py test

Creating test database for alias 'default'...
...etc...



On Saturday, June 7, 2014 2:00:39 AM UTC-7, Kim wrote:
Hi,

I started learning Django and am using "Test Driven Web Development with 
Python" book. 

On page 21, the book mentions to test using lists/tests.py.
The book uses the code:
$ python3 manage.py test
to run the test. 

However, the manage.py file sits in the upper superlists folder and the 
tests.py sits in lists folder. 
I keep getting an error message saying "ImportError: No module named 
lists.tests”. 

Could someone help me figure this out? 

My Django project directory looks like below. 

superlists
  db.sqlite3
  functional_test.py
  manage.py
  lists
    __init__.py
    admin.py
    models.py
    tests.py
    views.py
  superlists
    __init__.py
    settings.py
    urls.py 
    wsgi.py
__init__.py

The error message is below:

$ python manage.py test
Creating test database for alias 'default'...
E
==
ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
--
ImportError: Failed to import test module: superlists.lists.tests
Traceback (most recent call last):
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
 line 254, in _find_tests
    module = self._get_module_from_name(name)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
 line 232, in _get_module_from_name
    __import__(name)
ImportError: No module named lists.tests


--
Ran 1 test in 0.000s

FAILED (errors=1)
Destroying test database for alias 'default'...
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/46587e62-3642-4709-9ccf-ae91fec50d20%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e741dc9-c97e-413b-97f4-2f1244e5bd59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving email

Re: HELP on unittest.loader.ModuleImportFailure

2014-06-08 Thread Kelvin Wong
Open this file

/Users/kim/Desktop/Python/python3/superlists/lists/tests.py

On line 3 change

from superlists.lists.views import home_page

to

from lists.views import home_page

For the future, check your paths with the following

import sys; print(sys.path)

K



On Sunday, June 8, 2014 9:31:03 PM UTC-7, Kim wrote:
>
> Thank you very much for the reply!
>
> Going through your suggestion below,
> at ">>> from lists.tests import *” part, I got an error which is below. 
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/Users/kim/Desktop/Python/python3/superlists/lists/tests.py", line 
> 3, in 
> from superlists.lists.views import home_page
> ImportError: No module named lists.views
>
> The code of the manage.py file is:
> #!/usr/bin/env python
> import os
> import sys
>
> if __name__ == "__main__":
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.settings")
>
> from django.core.management import execute_from_command_line
>
> execute_from_command_line(sys.argv)
>
> Kind regards,
> Kim
>
>
> On 2014年6月9日 at 12:11:44, Kelvin Wong (wong...@gmail.com ) 
> wrote:
>
>  Find out which versions you are using
>
> $ python --version
> Python 2.7.6
>
> $ django-admin.py version
> 1.4.10
>
> Try importing the lists app from the shell
>
> $ python manage.py shell
>
> Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
> [GCC 4.2.1 (Apple Inc. build 5577)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import lists
> >>> lists.__file__
> '/users/you/superlists/lists/__init__.py'
> >>> from lists.tests import *
> >>>
>
> If you see all that, run the lists app explicitly by label
>
> $ python manage.py test lists
>
> If that doesn't work, maybe there is something weird in your manage.py 
> messing the paths. Paste it.
>
> K
>
>
> On Sunday, June 8, 2014 7:43:43 PM UTC-7, Kim wrote: 
>>
>> Hi Kelvin, 
>>
>> Thank you very much for your reply!
>> I tried your codes above but I still get the same error...
>>
>> Kind regards,
>> Kim
>>  
>>
>> On Mon, Jun 9, 2014 at 3:33 AM, Kelvin Wong  wrote:
>>
>>>  You need to be in the first superlists directory. You have a 
>>> db created so you must have run syncdb at some point. Go back to that 
>>> folder:
>>>
>>> $ pwd
>>> /home/you/superlists
>>>
>>> $ ls
>>> __init__.py   db.sqlite3superlistslistsmanage.py
>>>
>>> $ ls lists/tests.py
>>> lists/tests.py
>>>  
>>> $ python manage.py test
>>>
>>> Creating test database for alias 'default'...
>>>  ...etc...
>>>  
>>>
>>>
>>> On Saturday, June 7, 2014 2:00:39 AM UTC-7, Kim wrote: 

 Hi, 

 I started learning Django and am using "Test Driven Web Development 
 with Python" book.  

  On page 21, the book mentions to test using lists/tests.py.
 The book uses the code:
 $ python3 manage.py test
 to run the test. 

 However, the manage.py file sits in the upper superlists folder and the 
 tests.py sits in lists folder. 
 I keep getting an error message saying "ImportError: No module named 
 lists.tests”. 

 Could someone help me figure this out? 

  My Django project directory looks like below. 

 superlists
db.sqlite3
   functional_test.py
   manage.py
lists
 __init__.py
 admin.py
 models.py
 tests.py
 views.py
   superlists
 __init__.py
 settings.py
 urls.py 
 wsgi.py
 __init__.py

  The error message is below:

  $ python manage.py test
 Creating test database for alias 'default'...
 E
  ==
 ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
  --
 ImportError: Failed to import test module: superlists.lists.tests
 Traceback (most recent call last):
   File 
 "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
  
 line 254, in _find_tests
 module = self._get_module_from_name(name)
   File 
 "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
  
 line 232, in _get_module_from_name
 __import__(name)
 ImportError: No module named lists.tests


  --
 Ran 1 test in 0.000s

 FAILED (errors=1)
 Destroying test database for alias 'default'...
   
>>>   --
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>>  To view thi