Re: Tests not passing in suite but pass individually

2015-12-08 Thread learn django
Hi Tim,

My test case was working with new app in new project which was
using default database.

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

So I went back to my old app and debugged a bit.
If I make following changes in Database dictionary (commenting the bolded 
test) and
make my router for this app to point to default database the tests pass.
Is it because am using postgres that this issue is seen ?

DATABASES = {
'default': {
  *  'ENGINE': 'django.db.backends.sqlite3',*
*'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),*
*#'ENGINE': 'django.db.backends.postgresql_psycopg2',*
*#'USER': 'postgres',*
*#'NAME': 'testdb',*
*# 'PASSWORD':'v1ptela0212',*
*# 'HOST':'localhost',*
*# 'PORT':'',*
*#'TEST': {*
*#'NAME': 'testdb',*
*#},*
},
'sztp': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'sztpdb',
'USER':'postgres',
},
'orca': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'orcadb',
'USER':'postgres',
}
}


On Wednesday, December 2, 2015 at 4:18:25 PM UTC-8, learn django wrote:
>
> Will try to send minimal project by end of the day.
> Hopefully I can discover the reason during this exercise.
>
> On Wednesday, December 2, 2015 at 3:33:30 PM UTC-8, Tim Graham wrote:
>>
>> It looks correct. I'd like a minimal project I could download to 
>> reproduce the issue. In putting that together, you might discover the 
>> reason for the failure.
>>
>> On Wednesday, December 2, 2015 at 6:29:07 PM UTC-5, learn django wrote:
>>>
>>> Below is the test file & logs.
>>> No matter in which order (using --reverse) I run the suite it fails.
>>> The database backend is postgres. Is that an issue ?
>>>
>>> File:-
>>> ===
>>> import datetime
>>> import pdb
>>>
>>> from rest_framework import status
>>> from rest_framework.test import APIClient
>>>
>>> from django.http import HttpRequest
>>> from django.contrib.auth.models import User
>>> from django.utils import timezone
>>> from django.test import TestCase
>>>
>>> from orca.models import *
>>>
>>> import orca.handlers.customer_handler as ch
>>>
>>> # Create your tests here.
>>> class OrcaTestCase(TestCase):
>>>
>>> def test_customer_create_modify_delete(self):
>>> '''Test customer object create, modify and delete operations in 
>>>  DB.'''
>>> # Create.
>>> CustomerDb.objects.create(c_name='Zoo', c_role='Admin',
>>>   c_date_created=timezone.now(),
>>>   c_date_updated=timezone.now())
>>> customer_list = CustomerDb.objects.all()
>>> self.assertEqual(len(customer_list), 1)
>>>
>>> def test_launch(self):
>>> '''Test launch.'''
>>> CustomerDb.objects.create(c_name='Foo', c_role='Admin',
>>>   c_date_created=timezone.now(),
>>>   c_date_updated=timezone.now())
>>> customer_list = CustomerDb.objects.all()
>>> self.assertEqual(len(customer_list), 1)
>>>
>>>
>>> Logs:-
>>> 
>>> ==
>>> FAIL: test_customer_create_modify_delete (orca.tests.tmp.OrcaTestCase)
>>> Test customer object create, modify and delete operations in  DB.
>>> --
>>> Traceback (most recent call last):
>>>   File "/home/sidhesh/workspace/sztp/orca/tests/tmp.py", line 26, in 
>>> test_customer_create_modify_delete
>>> self.assertEqual(len(customer_list), 1)
>>> AssertionError: 2 != 1
>>>
>>> --
>>> Ran 2 tests in 0.014s
>>>
>>> FAILED (failures=1)
>>>
>>>
>>>
>>> On Wednesday, December 2, 2015 at 9:14:54 AM UTC-8, Tim Graham wrote:

 How does the test fail? Please show the entire test file including 
 imports.

 On Wednesday, December 2, 2015 at 11:20:27 AM UTC-5, learn django wrote:
>
> Hi Tim,
>
> Below is what am trying to achieve.
>
> class OrcaTestCase(TestCase):
>
> def test_customer_create_modify_delete(self):
> '''Test customer object create, modify and delete operations 
> in  DB.'''
> # Create.
> CustomerDb.objects.create(c_name='Pnc', c_role='ADFS-Admin',
>   c_date_created=timezone.now(),
>   c_date_updated=timezone.now())
> customer_list = CustomerDb.objects.all()
>* self.assertEqual(len(customer_list), 1)*
>
> # Modify.
> customer = CustomerDb.objects.get(c_name='Pnc')
> self.assertNotEqual(customer, None)
> setattr(customer, 'c_name', 'Zoo')
> customer.save()
>  

Re: problem in first part of polls app

2015-12-08 Thread sum abiut
try adding the line below at the top of your view.py if you haven't already
done so.

from django.http import HttpResponse


Cheers,

On Tue, Dec 8, 2015 at 2:56 PM, Yogs  wrote:

> Can somebody hlep me out with this?
> This the error I get when i run the polls app
>
>
> NameError at /polls/
>
> global name 'HttpResponse' is not defined
>
> Request Method: GET Request URL: http://127.0.0.1:8000/polls/ Django
> Version: 1.9 Exception Type: NameError Exception Value:
>
> global name 'HttpResponse' is not defined
>
> Exception Location: /home/yogitha/Desktop/mysite/polls/views.py in index,
> line 6 Python Executable: /usr/bin/python Python Version: 2.7.6 Python
> Path:
>
> ['/home/yogitha/Desktop/mysite',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages/PILcompat',
>  '/usr/lib/python2.7/dist-packages/gtk-2.0',
>  '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
>
> Server time: Mon, 7 Dec 2015 16:35:58 +
>
> Please tell me what needs to be done
>
> --
> 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/a36291ff-a524-45ca-be3e-48ce884b6643%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/CAPCf-y7x7p8L5ojbMjMR08puM6DLFVp73z44XtN2ua2JO221dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template can't find image file

2015-12-08 Thread Gary Roach

OOPs forgot to include these.

/root/tango/tango/urls.py is:

from django.conf.urls import include, url

from django.contrib import admin


urlpatterns = [

url(r'^admin/', include(admin.site.urls)),

url(r'^rango/', include('rango.urls', namespace='rango')),

]


/root/tango/rango/urls.py is:


from django.conf.urls import patterns, url

from rango import views

urlpatterns = patterns('',

url(r'^$', views.index, name='index'),

)


rango/views.py is:

from django.shortcuts import render

def index(request):

context = {'boldmessage': "I am bold font from the context"}

return render(request, 'rango/index.html', context)

--
I hope this helps


Gary R.




On 12/08/2015 03:59 AM, Lucas Magnum wrote:
Have you changed your urls.py? 
https://docs.djangoproject.com/en/1.9/howto/static-files/#serving-static-files-during-development






[]'s

Lucas Magnum.

2015-12-07 21:45 GMT-02:00 Gary Roach >:


While I'm working with "Tango with Django" I am using Django 1.8
and Python 3.4 (debian linux).

My project tree (somewhat truncated) is in the /root directory and
looks as follows:

tango
├── bin
├── include
├── lib
└── tango
├── db.sqlite3
├── __init__.py
├── manage.py
├── rango
├── requirements.txt
├── static
│   ├── images
│   └── __init__.py
├── tango
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── __pycache__
│   ├── settings.py
│   ├── settings.pyc
│   ├── urls.py
│   └── wsgi.py
├── tango.nja
└── templates
├── __init__.py
└── rango

The pertinent parts of the settings.py file are:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {

STATIC_PATH = os.path.join(BASE_DIR, 'static')

STATIC_URL = '/static/'

STATICFILES_DIRS = (
STATIC_PATH,
)

The rango index.html file is:



{% load static from staticfiles %}



Rango



Rango says...
hello world! {{ boldmessage }}
About





The apache2.png is just a handy image file.

The result of 127.0.0.1:8000/rango/
   is:

Rango says...
hello world! I am bold font from the context
About
Picture of Apache logo

I've tried everything I can think of to try to get the image
served and have totally failed. The firefox debugger just says
"failed to load the given URL"

What am I doing wrong.

Gary R



-- 
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/56661A1E.30803%40verizon.net.
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/CAAB7jOxe-yN%3DVDpUc8ZzgX%2B8tw2CWf7OTTHA2svbeHm3G1sMPQ%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/56670AAF.2060206%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: How to write Model.get_absolute_url()?

2015-12-08 Thread Jon Ribbens
On Tuesday, 8 December 2015 00:44:02 UTC, knbk wrote:
>
> It seems a bit weird that that's not automatic.
>>
>
> That's what I thought, so it's automatic in 1.9.
>

Ah, brilliant.
 

> That still leaves the question of what Model.get_absolute_url() should do, 
>> given that it has no way to get the current app that I can see. Thank you 
>> for your very helpful comments though.
>>
>
> It can't know the current app. I never use it for anything but the helpful 
> "View on site" link in the admin. I have some plans to revisit this API, 
> but that depends on some other work I'm still finishing. 
>

Thanks. I think I have a vague idea what's going on now ;-) 

-- 
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/93a7eb69-03f9-41fa-a4e0-a09639f04b76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem in first part of polls app

2015-12-08 Thread James Schneider
On Dec 8, 2015 5:08 AM, "Yogs"  wrote:
>
> Can somebody hlep me out with this?
> This the error I get when i run the polls app
>
>
> NameError at /polls/
>
> global name 'HttpResponse' is not defined
>
> Request Method:
> GET
> Request URL:
> http://127.0.0.1:8000/polls/
> Django Version:
> 1.9
> Exception Type:
> NameError
> Exception Value:
>
> global name 'HttpResponse' is not defined
>
> Exception Location:
> /home/yogitha/Desktop/mysite/polls/views.py in index, line 6
> Python Executable:
> /usr/bin/python
> Python Version:
> 2.7.6
> Python Path:
>
> ['/home/yogitha/Desktop/mysite',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages/PILcompat',
>  '/usr/lib/python2.7/dist-packages/gtk-2.0',
>  '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
>
> Server time:
> Mon, 7 Dec 2015 16:35:58 +
>
>
> Please tell me what needs to be done
>

It appears you are missing an import statement for HTTPResponse at the top
of your views.py. Admittedly, the tutorial does omit those statements in
most places since they assume you have already added the necessary imports
from the first couple of steps.

See the first line of code in the first code block here:

https://docs.djangoproject.com/en/1.9/intro/tutorial01/#write-your-first-view

-James

-- 
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/CA%2Be%2BciXpvheGVGVr60DGmjWZXuXZYpW4OE-qQwsEPoem0uwZkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


problem in first part of polls app

2015-12-08 Thread Yogs
Can somebody hlep me out with this?
This the error I get when i run the polls app


NameError at /polls/ 

global name 'HttpResponse' is not defined

Request Method: GET Request URL: http://127.0.0.1:8000/polls/ Django 
Version: 1.9 Exception Type: NameError Exception Value: 

global name 'HttpResponse' is not defined

Exception Location: /home/yogitha/Desktop/mysite/polls/views.py in index, 
line 6 Python Executable: /usr/bin/python Python Version: 2.7.6 Python Path: 

['/home/yogitha/Desktop/mysite',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']

Server time: Mon, 7 Dec 2015 16:35:58 +

Please tell me what needs to be done

-- 
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/a36291ff-a524-45ca-be3e-48ce884b6643%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template can't find image file

2015-12-08 Thread Lucas Magnum
Have you changed your urls.py?
https://docs.djangoproject.com/en/1.9/howto/static-files/#serving-static-files-during-development





[]'s

Lucas Magnum.

2015-12-07 21:45 GMT-02:00 Gary Roach :

> While I'm working with "Tango with Django" I am using Django 1.8 and
> Python 3.4 (debian linux).
>
> My project tree (somewhat truncated) is in the /root directory and looks
> as follows:
>
> tango
> ├── bin
> ├── include
> ├── lib
> └── tango
> ├── db.sqlite3
> ├── __init__.py
> ├── manage.py
> ├── rango
> ├── requirements.txt
> ├── static
> │   ├── images
> │   └── __init__.py
> ├── tango
> │   ├── __init__.py
> │   ├── __init__.pyc
> │   ├── __pycache__
> │   ├── settings.py
> │   ├── settings.pyc
> │   ├── urls.py
> │   └── wsgi.py
> ├── tango.nja
> └── templates
> ├── __init__.py
> └── rango
>
> The pertinent parts of the settings.py file are:
>
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [os.path.join(BASE_DIR, 'templates')],
> 'APP_DIRS': True,
> 'OPTIONS': {
>
> STATIC_PATH = os.path.join(BASE_DIR, 'static')
>
> STATIC_URL = '/static/'
>
> STATICFILES_DIRS = (
> STATIC_PATH,
> )
>
> The rango index.html file is:
>
> 
>
> {% load static from staticfiles %}
> 
>
> 
> Rango
> 
>
> 
> Rango says...
> hello world! {{ boldmessage }}
> About
> 
> 
>
> 
>
> The apache2.png is just a handy image file.
>
> The result of 127.0.0.1:8000/rango/   is:
>
> Rango says...
> hello world! I am bold font from the context
> About
> Picture of Apache logo
>
> I've tried everything I can think of to try to get the image served and
> have totally failed. The firefox debugger just says "failed to load the
> given URL"
>
> What am I doing wrong.
>
> Gary R
>
>
>
> --
> 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/56661A1E.30803%40verizon.net
> .
> 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/CAAB7jOxe-yN%3DVDpUc8ZzgX%2B8tw2CWf7OTTHA2svbeHm3G1sMPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.