Re: FieldError, But Only In Production

2014-02-13 Thread Javier Guerra Giraldez
On Thu, Feb 13, 2014 at 7:09 PM, Rich Jones  wrote:
> We're good now. No idea what the hell was happening, but this works now.
> Humbling to realize how little I know about the ORM internals.


are you using virtualenv?  it's possible that mod_wsgi was executing
in a different environment than the test server.

-- 
Javier

-- 
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/CAFkDaoSSrY5pe0gt1pXP9LjEQmkfh7_SncHYR8rvfBA7yenwnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: FieldError, But Only In Production

2014-02-13 Thread Rich Jones
Said fuck it, gave up and used Nginx + Gunicorn.

We're good now. No idea what the hell was happening, but this works now.
Humbling to realize how little I know about the ORM internals.

Thanks for listening,
R

On Thu, Feb 13, 2014 at 3:13 PM, Rich Jones  wrote:

>
> > Please show how you are doing this.
>
> Using mod_wsgi and Apache, using I think a fairly standard .wsgi:
>
> import os, sys
>
> path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
> if path not in sys.path:
> sys.path.append(path)
>
> sys.path.append('/srv/myapp')
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> With this in my sites_enabled:
>
> WSGIScriptAlias / /srv/myapp/myapp/django.wsgi
>
> Also, keep in mind that the application does _run_ with Apache, it is only
> on calls related to user.get_profile() which causes the problem.
>
> Is there anything else you'd need to know?
>
>
> On Thu, Feb 13, 2014 at 3:01 PM, Tom Evans wrote:
>
>> On Thu, Feb 13, 2014 at 6:00 AM, Rich Jones  wrote:
>> > Hey guys!
>> >
>> > I've got a real stumper here. Pulling my hair out over this one, would
>> > really appreciate some options!
>> >
>> > Anywhere in my application that calls user.get_profile() causes a
>> > FieldError.. but only in production. I'm using WSGI and Apache.
>> >
>>
>> Please show how you are doing this.
>>
>> I suspect mod_wsgi might be using a different version of django,
>> perhaps one in the system install.
>>
>> However, that is all just speculative without the config and comparing
>> it with how you start 'runserver'.
>>
>> Cheers
>>
>> Tom
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/E4UVZHf6kP8/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/CAFHbX1L%2BhYT32SnOwphBDJzmhpLTHDCe%2BQsA3dWFwwceqyLZHw%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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/CADJYzxJGMNbfqGhsDZkmUdAy1nKfy%3DcFbHEMmXex51A1p4FR4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django newbie frustrated

2014-02-13 Thread Lucas Klassmann
waveride,

You are alright!

But he have a two erros.

First, he loaded http://127.0.0.1:8000/ but dont have urls.py configured
for this.

Second, he loaded http://127.0.0.1:8000/admin/ and is showed a exception
because 'django' not found a 'polls' application, because 'django' in
recent versions, apps must be placed out from project folder or he must
define a complete path like 'MyDjangoApp.polls' in INSTALLED_APPS.

Greetings.


On Thu, Feb 13, 2014 at 8:12 PM, waverider  wrote:

> Is it just me or everything is actually working as expected?
>
> You're requesting http://127.0.0.1:8000/, while you define /polls/ and
> that tutorial specifically instructs to access http://127.0.0.1:8000/
> polls/
>
> -
> http://andreias.ro
>
> --
> 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/cd8fead4-03e9-43fd-ac95-2751af8f4f56%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Lucas Klassmann
Desenvolvedor de Software

Email: lucasklassm...@gmail.com
Web site: http://www.lucasklassmann.com

-- 
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/CAOz50pL77n7ARV_tDdBN_gXXU_HCPPFOct8uv8Ooe2ZcYL1C_g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: FieldError, But Only In Production

2014-02-13 Thread Rich Jones
> Please show how you are doing this.

Using mod_wsgi and Apache, using I think a fairly standard .wsgi:

import os, sys

path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if path not in sys.path:
sys.path.append(path)

sys.path.append('/srv/myapp')

os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

With this in my sites_enabled:

WSGIScriptAlias / /srv/myapp/myapp/django.wsgi

Also, keep in mind that the application does _run_ with Apache, it is only
on calls related to user.get_profile() which causes the problem.

Is there anything else you'd need to know?

On Thu, Feb 13, 2014 at 3:01 PM, Tom Evans  wrote:

> On Thu, Feb 13, 2014 at 6:00 AM, Rich Jones  wrote:
> > Hey guys!
> >
> > I've got a real stumper here. Pulling my hair out over this one, would
> > really appreciate some options!
> >
> > Anywhere in my application that calls user.get_profile() causes a
> > FieldError.. but only in production. I'm using WSGI and Apache.
> >
>
> Please show how you are doing this.
>
> I suspect mod_wsgi might be using a different version of django,
> perhaps one in the system install.
>
> However, that is all just speculative without the config and comparing
> it with how you start 'runserver'.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/E4UVZHf6kP8/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAFHbX1L%2BhYT32SnOwphBDJzmhpLTHDCe%2BQsA3dWFwwceqyLZHw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CADJYzx%2BZPnFUP4xX7HYusLCLWoodBjjqmWH98ZPYkH3nERf2eQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the send of file versus the django server

2014-02-13 Thread Russell Keith-Magee
On Thu, Feb 13, 2014 at 4:11 PM, simone monteleone wrote:

> Hi all,
>
> I have to send a file (ex. csv file) to the Django server.
>
> I think to use the requests python module.
>
> Is this the best way?
>

The "best" way will depend on your exact requirements - I'll come back to
this in a moment. However, Requests will certainly make it easy to write a
Python script that will send a file to a Django server.


> Second question; Django can receive this file?
>

If it can be sent over HTTP, Django can receive it.


> And also in this case, what it is the best way?
>

Django's file handling documentation contains details on how to set up this
sort of thing:

https://docs.djangoproject.com/en/1.6/topics/http/file-uploads/

My goal is to load the csv file information in the dabatase handles by
> django,
>

We need to be clear about your needs here.

Do you actually need to do this over HTTP? I.e., you may want the data to
be put into your database, but is there actually a requirement to upload
that file? Could you just load the file onto the database directly?

Django contains a bunch of tools for uploading files directly, without
going through a web interface. Look into loaddata management command for
details.

https://docs.djangoproject.com/en/1.6/ref/django-admin/

There isn't a native CSV importer, but there are a couple floating around
the web that you might be able to use.

The other approach - just write the data directly to the database. Write
some code to read the CSV file, and use Django's model objects to write the
data directly; e.g., if you've got a model called MyModel, with two fields
field1 and field2:

  MyModel.objects.create(field1=value1, field2=value2)

will create a record in the database with those values.

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/CAJxq84-ZUP0Qkeseo337q545dwd65FNvjGarK9nwO40Jw048fQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: FieldError, But Only In Production

2014-02-13 Thread Tom Evans
On Thu, Feb 13, 2014 at 6:00 AM, Rich Jones  wrote:
> Hey guys!
>
> I've got a real stumper here. Pulling my hair out over this one, would
> really appreciate some options!
>
> Anywhere in my application that calls user.get_profile() causes a
> FieldError.. but only in production. I'm using WSGI and Apache.
>

Please show how you are doing this.

I suspect mod_wsgi might be using a different version of django,
perhaps one in the system install.

However, that is all just speculative without the config and comparing
it with how you start 'runserver'.

Cheers

Tom

-- 
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/CAFHbX1L%2BhYT32SnOwphBDJzmhpLTHDCe%2BQsA3dWFwwceqyLZHw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: FieldError, But Only In Production

2014-02-13 Thread Rich Jones
Ah, okay, noted, although I believe this may be a bug in Django itself but
want to exhaust everything before I open a ticket.

-- 
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/CADJYzxKkn1h2eb6siuNbxy%3DCfK636WmPi%3DKf%2BvqDs0hcmmY7xg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: FieldError, But Only In Production

2014-02-13 Thread Javier Guerra Giraldez
On Thu, Feb 13, 2014 at 5:49 PM, Rich Jones  wrote:
> Since this seems to happening at a pretty deep level, would it be uncouth to
> kick this over do django-dev?


django-dev is not 'django support, level 2'.  it's about the
development of the Django framework.  if you have a concrete proposal,
or a full bug report, then by all means take it there.  but for usage
questions, this is the right place.  also, most (if not all) members
of django-dev also participate actively here.

-- 
Javier

-- 
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/CAFkDaoT60MAsGB%2BRpZwpcEKFuRy40bu0Qr0MD%3DPsQnnC929Q7A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: FieldError, But Only In Production

2014-02-13 Thread Rich Jones
Since this seems to happening at a pretty deep level, would it be uncouth
to kick this over do django-dev?


On Thu, Feb 13, 2014 at 9:17 AM, Rich Jones  wrote:

> Yes, all of these things worked just fine. The code is in the _same
> location_ on the _same machine_ with the _same settings_ and the _same
> database_. The only difference is devserver vs Apache.
>
> :(
>
>
> On Thu, Feb 13, 2014 at 2:21 AM, Vibhu Rishi wrote:
>
>> Seems to me somewhere in the code it is trying to put user into a field
>> instead of treating it as a table.
>> Basic sanity checks :
>> - is the djagno versions on both production and local same ?
>> - same for wsgi and apache ?
>> - syncdb worked fine ?
>>
>> V.
>>
>>
>>
>> On Thu, Feb 13, 2014 at 11:30 AM, Rich Jones  wrote:
>>
>>> Hey guys!
>>>
>>> I've got a real stumper here. Pulling my hair out over this one, would
>>> really appreciate some options!
>>>
>>> Anywhere in my application that calls user.get_profile() causes a
>>> FieldError.. but only in production. I'm using WSGI and Apache.
>>>
>>> When I run locally with:
>>>
>>>  python manage.py runserver 0.0.0.0:
>>>
>>> it works just fine. However, running the exact same code and the exact
>>> same database with Apache, I get a 500 and find this in the logs:
>>>
>>>  [Wed Feb 12 21:23:21 2014] [error] [client] FieldError: Cannot
>>> resolve keyword 'user' into field. Choices are: about_me, about_me_mkd,
>>> etc..
>>>
>>> (Full traceback: http://pastebin.com/6141pHZ2)
>>>
>>> When I run sqlall, there is a users_id entry for the model:
>>>
>>> "user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id")
>>> DEFERRABLE INITIALLY DEFERRED
>>>
>>> What could possibly be happening here? What could the difference between
>>> devserver and Apache?
>>>
>>> (For reference, this is using Django-Userena 1.0, Django 1.3.7. and
>>> Postgres 8.4.)
>>>
>>> I've tried a few things I found on the internet:
>>>
>>>
>>> http://stackoverflow.com/questions/19145787/fielderror-cannot-resolve-keyword--into-field
>>>
>>> http://chase-seibert.github.io/blog/2010/04/30/django-manytomany-error-cannot-resolve-keyword-xxx-into-a-field.html
>>>
>>> Which both suggest that it has something to do with the order of the
>>> imports, but I haven't had any success with this approach.
>>>
>>> There is an extremely old Django bug seemingly related to this,
>>>
>>> https://code.djangoproject.com/ticket/1796
>>>
>>> but I don't know how relevant this is, as this is not a ManyToMany
>>> problem, because Userena uses a OneToOne field:
>>>
>>> user = models.OneToOneField(User,
>>> unique=True,
>>> verbose_name=_('user'),
>>> related_name='profile')
>>>
>>> Can anybody help me? I'm going nuts over here. I just don't know why the
>>> behavior would be different for runserver and Apache!
>>>
>>> Any ideas?
>>>
>>> Thanks so much!,
>>> Rich
>>>
>>>  --
>>> 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/41e0fdbe-520d-44a4-b3b5-ee4914d0e099%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Simplicity is the ultimate sophistication. - Leonardo da Vinci
>> Life is really simple, but we insist on making it complicated. -
>> Confucius
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/E4UVZHf6kP8/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/CAPiONw%3DwazFkycVy%3DAwoj99uq4RgqhFu%2B2iotZz712AKa0U%3DYQ%40mail.gmail.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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 

Re: List of default Django tags that are "mid-block" like else

2014-02-13 Thread C. Kirby
Not sure if this is what you mean, but:

for
--empty
--forloop.counter/first/last/etc 

-- 
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/b1240d02-cca8-46dd-8326-2550468e0a78%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django newbie frustrated

2014-02-13 Thread waverider
Is it just me or everything is actually working as expected?

You're requesting http://127.0.0.1:8000/, while you define /polls/ and that 
tutorial specifically instructs to access http://127.0.0.1:8000/polls/

-
http://andreias.ro

-- 
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/cd8fead4-03e9-43fd-ac95-2751af8f4f56%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: heroku better for django?

2014-02-13 Thread Malik Rumi
Are you the same Daniel Roseman that replied to a search question of mine 
on Stack Overflow?

On Thursday, February 13, 2014 2:59:15 PM UTC-6, Daniel Roseman wrote:
>
> On Thursday, 13 February 2014 20:47:58 UTC, Malik Rumi wrote:
>>
>> Glyn, I am following your guide but when I get to LoadModule I have run 
>> into 'Permission Denied'. As soon as I finished with 'make install' the 
>> system reported back that wsgi.so was chmod 644. I tried sudo chmod o+w and 
>> did not get an error but I still get permission denied when trying to load 
>> this module even if I precede the load command with sudo. Can you help, 
>> please? Thanks. 
>>
>
> You are being very badly advised here. Firstly, for someone without 
> sysadmin experience, Heroku is a *much* better bet than trying to set up an 
> AWS server from scratch. Gondor is an equivalent alternative to Heroku.
>
> Secondly, even if you do go with AWS, there's absolutely no call to be 
> compiling mod_wsgi from scratch. If you're using an up-to-date version of 
> Ubuntu, which you should be, you can simply install mod_wsgi via apt-get. 
> Not only will that take away the problems if compiling it, it will have the 
> advantage of security updates provided via the distribution, rather than 
> relying on you to re-download and compile.
> --
> DR. 
>
>

-- 
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/fbb7bfa8-9234-44cd-b720-6107a2c5838b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


List of default Django tags that are "mid-block" like else

2014-02-13 Thread cool-RR
Hi guys,

Can someone please give me a list of default Django template tags that have 
"mid-block" behavior like `else`? I mean tags where instead of simply 
having a start tag and an end tag, you have an optional tag in the middle 
that divides the whole thing to blocks.

I can think of: 

if
ifchanged
ifequal
else
elif

Anything else? 


Thanks,
Ram.

-- 
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/3e69642f-f856-48db-8818-37697c85efd9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Tutorial 5 - First Tests

2014-02-13 Thread Jonathan Baker
Glad you worked it out. Enjoy the rest of the tutorial!

JDB


On Thu, Feb 13, 2014 at 1:54 PM, Paul Sermon wrote:

> OK thanks for your help.
>
> I've reviewed through the code, and I had a minor indentation typo that
> wasn't helping!
>
> Anyway, I worked it down to the lines self.assertContains.  You see that
> full-stop/period at the end of the string it was looking for?  That wasn't
> in the no polls message!  That'll teach me for copying and pasting!
>
> Thanks for your help!
>
> -Paul
>
> On Thursday, February 13, 2014 6:30:34 PM UTC, jondbaker wrote:
>
>> Cool, so we're making progress and you're using the test database now.
>> Since you have two tests failing, I'd comment out the 2nd of the two for
>> now and focus on getting the first to pass, and then moving on to the
>> second. Don't try to do too much at once, and do try and understand what
>> each function/method is doing.
>>
>> Firstly, I'm not a fan of assertions like:
>> self.assertContains(response, "No polls are available.", status_code=200)
>> ...because it's testing two things at once. I'd break that out in to two
>> separate statements:
>> self.assertEqual(response.status_code, 200)
>> self.assertContains(response, "No polls are available.")
>>
>> Run the tests again, and since it's likely still failing at the
>> assertContains point, I'd comment that out and print out the response and
>> inspect it manually to see what it actually contains. Perhaps there is a
>> typo in your 'No polls are available' string, or perhaps the view is
>> actually returning queryset results. Dig around a bit. Getting comfortable
>> with tests and good at writing them will give you a deeper understanding of
>> the framework than simply writing views, models and templates ever wil.
>>
>> JDB
>>
>>
>> On Thu, Feb 13, 2014 at 11:17 AM, Paul Sermon wrote:
>>
>>> Hmm, you'r right, I think I'm getting confused and attributed the error
>>> to something it isn't.  Ive just ran the test after changing all the polls
>>> to the future, and I still get the errors.  The errors are as follows:
>>>
>>> ==
>>> FAIL: test_index_view_with_a_future_poll (polls.tests.PollViewTests)
>>> --
>>> Traceback (most recent call last):
>>>   File "C:\Users\Alienware\Dropbox\coding 
>>> stuff\web\django\mysite\polls\tests.py",
>>> line 75, in test_index_view_with_a_fu
>>> ture_poll
>>> self.assertContains(response, "No polls are available.",
>>> status_code=200)
>>>   File "C:\Python27\lib\site-packages\django\test\testcases.py", line
>>> 351, in assertContains
>>> msg_prefix + "Couldn't find %s in response" % text_repr)
>>> AssertionError: Couldn't find 'No polls are available.' in response
>>>
>>> ==
>>> FAIL: test_index_view_with_no_polls (polls.tests.PollViewTests)
>>> --
>>> Traceback (most recent call last):
>>>   File "C:\Users\Alienware\Dropbox\coding 
>>> stuff\web\django\mysite\polls\tests.py",
>>> line 54, in test_index_view_with_no_p
>>> olls
>>> self.assertContains(response, "No polls are available.")
>>>   File "C:\Python27\lib\site-packages\django\test\testcases.py", line
>>> 351, in assertContains
>>> msg_prefix + "Couldn't find %s in response" % text_repr)
>>> AssertionError: Couldn't find 'No polls are available.' in response
>>>
>>> --
>>> Ran 8 tests in 0.037s
>>>
>>> FAILED (failures=2)
>>> Destroying test database for alias 'default'...
>>>
>>>
>>>
>>>
>>>
>>> On Thursday, February 13, 2014 5:29:50 PM UTC, jondbaker wrote:
>>>
 "setup_test_environment()
  installs a template renderer which will allow us to examine some
 additional attributes on responses such as response.context that
 otherwise wouldn't be available. Note that this method *does not* setup
 a test database, so the following will be run against the existing database
 and the output may differ slightly depending on what polls you already
 created."

 That's from the section you linked to, and it clearly explains that a
 test database will not be created. Two sections below that is
 https://docs.djangoproject.com/en/1.6/intro/tutorial05/#t
 esting-our-new-view which demonstrates how to create test cases that
 inherit from TestCase that can be found and executed by the Django test
 runner which will also handle creating the test database for you.

 JDB


 On Thu, Feb 13, 2014 at 10:20 AM, Paul Sermon 
 wrote:

> yes I am running through the manage.py shell (although initially I did
> 

Re: how to make https work in django REST framework

2014-02-13 Thread zhenwu he

Thanks all for your help. Finally we figured out how to do it from the doc 
link Kirby provided. Really appreciated your help.

thanks.

/zhenwu


On Thursday, February 13, 2014 11:20:53 AM UTC-8, zhenwu he wrote:
>
>
> Thank you! working on it. thanks.
>
> /zhenwu
>
> On Thursday, February 13, 2014 11:06:55 AM UTC-8, C. Kirby wrote:
>>
>> Use the django deployment docs for a howto: 
>> https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
>>
>> On Thursday, February 13, 2014 12:58:53 PM UTC-6, zhenwu he wrote:
>>>
>>>
>>> Thanks Kirby.
>>>
>>> You meant merge django into apache? ok, let me see what I can do. thanks.
>>>
>>> /zhenwu
>>>
>>> On Thursday, February 13, 2014 10:18:03 AM UTC-8, C. Kirby wrote:

 Zhenwu,

 You only mentioned it in passing in the last post, but did you say you 
 are running django in production via the manage.py runserver command? You 
 _really_ shouldn't use runserver in production. You should be using a 
 webserver (I guess apache in your case) and wsgi to serve up django.  

>>>

-- 
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/36d50beb-19d9-4bf0-a6a7-865f22634e00%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: heroku better for django?

2014-02-13 Thread Daniel Roseman
On Thursday, 13 February 2014 20:47:58 UTC, Malik Rumi wrote:
>
> Glyn, I am following your guide but when I get to LoadModule I have run 
> into 'Permission Denied'. As soon as I finished with 'make install' the 
> system reported back that wsgi.so was chmod 644. I tried sudo chmod o+w and 
> did not get an error but I still get permission denied when trying to load 
> this module even if I precede the load command with sudo. Can you help, 
> please? Thanks. 
>

You are being very badly advised here. Firstly, for someone without 
sysadmin experience, Heroku is a *much* better bet than trying to set up an 
AWS server from scratch. Gondor is an equivalent alternative to Heroku.

Secondly, even if you do go with AWS, there's absolutely no call to be 
compiling mod_wsgi from scratch. If you're using an up-to-date version of 
Ubuntu, which you should be, you can simply install mod_wsgi via apt-get. 
Not only will that take away the problems if compiling it, it will have the 
advantage of security updates provided via the distribution, rather than 
relying on you to re-download and compile.
--
DR. 

-- 
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/d4e9f260-c8fc-4c33-8e49-d76ca42aa42f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Tutorial 5 - First Tests

2014-02-13 Thread Paul Sermon
OK thanks for your help.

I've reviewed through the code, and I had a minor indentation typo that 
wasn't helping!

Anyway, I worked it down to the lines self.assertContains.  You see that 
full-stop/period at the end of the string it was looking for?  That wasn't 
in the no polls message!  That'll teach me for copying and pasting!

Thanks for your help!

-Paul

On Thursday, February 13, 2014 6:30:34 PM UTC, jondbaker wrote:
>
> Cool, so we're making progress and you're using the test database now. 
> Since you have two tests failing, I'd comment out the 2nd of the two for 
> now and focus on getting the first to pass, and then moving on to the 
> second. Don't try to do too much at once, and do try and understand what 
> each function/method is doing.
>
> Firstly, I'm not a fan of assertions like:
> self.assertContains(response, "No polls are available.", status_code=200)
> ...because it's testing two things at once. I'd break that out in to two 
> separate statements:
> self.assertEqual(response.status_code, 200)
> self.assertContains(response, "No polls are available.")
>
> Run the tests again, and since it's likely still failing at the 
> assertContains point, I'd comment that out and print out the response and 
> inspect it manually to see what it actually contains. Perhaps there is a 
> typo in your 'No polls are available' string, or perhaps the view is 
> actually returning queryset results. Dig around a bit. Getting comfortable 
> with tests and good at writing them will give you a deeper understanding of 
> the framework than simply writing views, models and templates ever wil.
>
> JDB
>
>
> On Thu, Feb 13, 2014 at 11:17 AM, Paul Sermon 
>  > wrote:
>
>> Hmm, you'r right, I think I'm getting confused and attributed the error 
>> to something it isn't.  Ive just ran the test after changing all the polls 
>> to the future, and I still get the errors.  The errors are as follows:
>>
>> ==
>> FAIL: test_index_view_with_a_future_poll (polls.tests.PollViewTests)
>> --
>> Traceback (most recent call last):
>>   File "C:\Users\Alienware\Dropbox\coding 
>> stuff\web\django\mysite\polls\tests.py", line 75, in 
>> test_index_view_with_a_fu
>> ture_poll
>> self.assertContains(response, "No polls are available.", 
>> status_code=200)
>>   File "C:\Python27\lib\site-packages\django\test\testcases.py", line 
>> 351, in assertContains
>> msg_prefix + "Couldn't find %s in response" % text_repr)
>> AssertionError: Couldn't find 'No polls are available.' in response
>>
>> ==
>> FAIL: test_index_view_with_no_polls (polls.tests.PollViewTests)
>> --
>> Traceback (most recent call last):
>>   File "C:\Users\Alienware\Dropbox\coding 
>> stuff\web\django\mysite\polls\tests.py", line 54, in 
>> test_index_view_with_no_p
>> olls
>> self.assertContains(response, "No polls are available.")
>>   File "C:\Python27\lib\site-packages\django\test\testcases.py", line 
>> 351, in assertContains
>> msg_prefix + "Couldn't find %s in response" % text_repr)
>> AssertionError: Couldn't find 'No polls are available.' in response
>>
>> --
>> Ran 8 tests in 0.037s
>>
>> FAILED (failures=2)
>> Destroying test database for alias 'default'...
>>
>>
>>
>>
>>
>> On Thursday, February 13, 2014 5:29:50 PM UTC, jondbaker wrote:
>>
>>> "setup_test_environment()
>>>  installs a template renderer which will allow us to examine some 
>>> additional attributes on responses such as response.context that 
>>> otherwise wouldn’t be available. Note that this method *does not* setup 
>>> a test database, so the following will be run against the existing database 
>>> and the output may differ slightly depending on what polls you already 
>>> created."
>>>
>>> That's from the section you linked to, and it clearly explains that a 
>>> test database will not be created. Two sections below that is 
>>> https://docs.djangoproject.com/en/1.6/intro/tutorial05/#
>>> testing-our-new-view which demonstrates how to create test cases that 
>>> inherit from TestCase that can be found and executed by the Django test 
>>> runner which will also handle creating the test database for you.
>>>
>>> JDB
>>>
>>>
>>> On Thu, Feb 13, 2014 at 10:20 AM, Paul Sermon 
>>> wrote:
>>>
 yes I am running through the manage.py shell (although initially I did 
 not).  

 I am doing the section: https://docs.djangoproject.com/en/1.6/
 intro/tutorial05/#the-django-test-client
 On the response.content line, I get back a line listing the polls made 
 earlier.


Re: heroku better for django?

2014-02-13 Thread Malik Rumi
Glyn, I am following your guide but when I get to LoadModule I have run 
into 'Permission Denied'. As soon as I finished with 'make install' the 
system reported back that wsgi.so was chmod 644. I tried sudo chmod o+w and 
did not get an error but I still get permission denied when trying to load 
this module even if I precede the load command with sudo. Can you help, 
please? Thanks. 

On Wednesday, February 12, 2014 12:02:37 PM UTC-6, Malik Rumi wrote:
>
> Thanks to both of you. Clearly both Heroku and AWS are more welcoming to 
> Django than GAE. I wasn't looking forward to running the server myself, but 
> the documentation on AWS as well as Glyn's post make it seem a little less 
> intimidating, so I am going to take a test flight on AWS and see what 
> happens. If I crash and burn, it's hello Heroku!
>
> On Tuesday, February 11, 2014 3:35:24 PM UTC-6, Glyn Jackson wrote:
>>
>> If you have a small app it's darn easy. I have personal experience with 
>> Amazon AWS which is by far a better choice. 
>> I wrote a guide on setup with Django if it helps:
>>
>> http://glynjackson.org/weblog/entry/django-15-deployement-amazon-ec2-ubuntu.html
>>
>> At the end of the day Heroku runs on AWS instances, why not cut out the 
>> middle man. I personally don't like Platform as a Service (PaaS), AWS 
>> offer Infrastructure as a Service (IaaS). 
>>
>> Read more: 
>> http://www.quora.com/Heroku/How-easy-is-it-to-get-off-Heroku-once-you-grow-out-of-it
>>
>> As you can see not a big fan.
>>
>

-- 
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/40032df9-217f-4ba8-82bd-a6fbcf7838ed%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to make https work in django REST framework

2014-02-13 Thread zhenwu he

Thank you! working on it. thanks.

/zhenwu

On Thursday, February 13, 2014 11:06:55 AM UTC-8, C. Kirby wrote:
>
> Use the django deployment docs for a howto: 
> https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
>
> On Thursday, February 13, 2014 12:58:53 PM UTC-6, zhenwu he wrote:
>>
>>
>> Thanks Kirby.
>>
>> You meant merge django into apache? ok, let me see what I can do. thanks.
>>
>> /zhenwu
>>
>> On Thursday, February 13, 2014 10:18:03 AM UTC-8, C. Kirby wrote:
>>>
>>> Zhenwu,
>>>
>>> You only mentioned it in passing in the last post, but did you say you 
>>> are running django in production via the manage.py runserver command? You 
>>> _really_ shouldn't use runserver in production. You should be using a 
>>> webserver (I guess apache in your case) and wsgi to serve up django.  
>>>
>>

-- 
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/6a2f9b00-4b43-41cc-88ae-00d2680e91f8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to make https work in django REST framework

2014-02-13 Thread C. Kirby
Use the django deployment docs for a howto: 
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/

On Thursday, February 13, 2014 12:58:53 PM UTC-6, zhenwu he wrote:
>
>
> Thanks Kirby.
>
> You meant merge django into apache? ok, let me see what I can do. thanks.
>
> /zhenwu
>
> On Thursday, February 13, 2014 10:18:03 AM UTC-8, C. Kirby wrote:
>>
>> Zhenwu,
>>
>> You only mentioned it in passing in the last post, but did you say you 
>> are running django in production via the manage.py runserver command? You 
>> _really_ shouldn't use runserver in production. You should be using a 
>> webserver (I guess apache in your case) and wsgi to serve up django.  
>>
>

-- 
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/9b423b5f-d5b0-4e79-a124-73e1aaa8f6c6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to make https work in django REST framework

2014-02-13 Thread zhenwu he

Thanks Kirby.

You meant merge django into apache? ok, let me see what I can do. thanks.

/zhenwu

On Thursday, February 13, 2014 10:18:03 AM UTC-8, C. Kirby wrote:
>
> Zhenwu,
>
> You only mentioned it in passing in the last post, but did you say you are 
> running django in production via the manage.py runserver command? You 
> _really_ shouldn't use runserver in production. You should be using a 
> webserver (I guess apache in your case) and wsgi to serve up django.  
>

-- 
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/4b0f73c1-49ec-4c94-9251-27f1b2869319%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Tutorial 5 - First Tests

2014-02-13 Thread Jonathan Baker
Cool, so we're making progress and you're using the test database now.
Since you have two tests failing, I'd comment out the 2nd of the two for
now and focus on getting the first to pass, and then moving on to the
second. Don't try to do too much at once, and do try and understand what
each function/method is doing.

Firstly, I'm not a fan of assertions like:
self.assertContains(response, "No polls are available.", status_code=200)
...because it's testing two things at once. I'd break that out in to two
separate statements:
self.assertEqual(response.status_code, 200)
self.assertContains(response, "No polls are available.")

Run the tests again, and since it's likely still failing at the
assertContains point, I'd comment that out and print out the response and
inspect it manually to see what it actually contains. Perhaps there is a
typo in your 'No polls are available' string, or perhaps the view is
actually returning queryset results. Dig around a bit. Getting comfortable
with tests and good at writing them will give you a deeper understanding of
the framework than simply writing views, models and templates ever wil.

JDB


On Thu, Feb 13, 2014 at 11:17 AM, Paul Sermon wrote:

> Hmm, you'r right, I think I'm getting confused and attributed the error to
> something it isn't.  Ive just ran the test after changing all the polls to
> the future, and I still get the errors.  The errors are as follows:
>
> ==
> FAIL: test_index_view_with_a_future_poll (polls.tests.PollViewTests)
> --
> Traceback (most recent call last):
>   File "C:\Users\Alienware\Dropbox\coding
> stuff\web\django\mysite\polls\tests.py", line 75, in
> test_index_view_with_a_fu
> ture_poll
> self.assertContains(response, "No polls are available.",
> status_code=200)
>   File "C:\Python27\lib\site-packages\django\test\testcases.py", line 351,
> in assertContains
> msg_prefix + "Couldn't find %s in response" % text_repr)
> AssertionError: Couldn't find 'No polls are available.' in response
>
> ==
> FAIL: test_index_view_with_no_polls (polls.tests.PollViewTests)
> --
> Traceback (most recent call last):
>   File "C:\Users\Alienware\Dropbox\coding
> stuff\web\django\mysite\polls\tests.py", line 54, in
> test_index_view_with_no_p
> olls
> self.assertContains(response, "No polls are available.")
>   File "C:\Python27\lib\site-packages\django\test\testcases.py", line 351,
> in assertContains
> msg_prefix + "Couldn't find %s in response" % text_repr)
> AssertionError: Couldn't find 'No polls are available.' in response
>
> --
> Ran 8 tests in 0.037s
>
> FAILED (failures=2)
> Destroying test database for alias 'default'...
>
>
>
>
>
> On Thursday, February 13, 2014 5:29:50 PM UTC, jondbaker wrote:
>
>> "setup_test_environment()
>>  installs a template renderer which will allow us to examine some
>> additional attributes on responses such as response.context that
>> otherwise wouldn't be available. Note that this method *does not* setup
>> a test database, so the following will be run against the existing database
>> and the output may differ slightly depending on what polls you already
>> created."
>>
>> That's from the section you linked to, and it clearly explains that a
>> test database will not be created. Two sections below that is
>> https://docs.djangoproject.com/en/1.6/intro/tutorial05/#
>> testing-our-new-view which demonstrates how to create test cases that
>> inherit from TestCase that can be found and executed by the Django test
>> runner which will also handle creating the test database for you.
>>
>> JDB
>>
>>
>> On Thu, Feb 13, 2014 at 10:20 AM, Paul Sermon wrote:
>>
>>> yes I am running through the manage.py shell (although initially I did
>>> not).
>>>
>>> I am doing the section: https://docs.djangoproject.com/en/1.6/
>>> intro/tutorial05/#the-django-test-client
>>> On the response.content line, I get back a line listing the polls made
>>> earlier.
>>>
>>> And I presume that is why the test from the next section fail, because
>>> they are picking up the entries from the database, rather than the test
>>> database.
>>>
>>> I am on windows 7, if that makes any difference.
>>>
>>>
>>>
>>>
>>> On Thursday, February 13, 2014 2:58:37 PM UTC, jondbaker wrote:
>>>
 Are you running your tests on the command line using:

 $ python manage.py test polls

 ...or are you trying to run them from a Python shell? It'd be helpful
 if you could provide the internal link to the area of the page you linked
 to that you're 

Re: Django Tutorial 5 - First Tests

2014-02-13 Thread C. Kirby
The names of both those tests imply that your setup will fail them. (I 
didn't look at the test internals, so I am assuming the test names do what 
they say)
1. "test_index_view_with_a_future_poll" - you have future polls
2. "test_index_view_with_no_polls" - you have polls in the database
 

On Thursday, February 13, 2014 12:17:20 PM UTC-6, Paul Sermon wrote:
>
> Hmm, you'r right, I think I'm getting confused and attributed the error to 
> something it isn't.  Ive just ran the test after changing all the polls to 
> the future, and I still get the errors.  The errors are as follows:
>
> ==
> FAIL: test_index_view_with_a_future_poll (polls.tests.PollViewTests)
> --
> Traceback (most recent call last):
>   File "C:\Users\Alienware\Dropbox\coding 
> stuff\web\django\mysite\polls\tests.py", line 75, in 
> test_index_view_with_a_fu
> ture_poll
> self.assertContains(response, "No polls are available.", 
> status_code=200)
>   File "C:\Python27\lib\site-packages\django\test\testcases.py", line 351, 
> in assertContains
> msg_prefix + "Couldn't find %s in response" % text_repr)
> AssertionError: Couldn't find 'No polls are available.' in response
>
> ==
> FAIL: test_index_view_with_no_polls (polls.tests.PollViewTests)
> --
> Traceback (most recent call last):
>   File "C:\Users\Alienware\Dropbox\coding 
> stuff\web\django\mysite\polls\tests.py", line 54, in 
> test_index_view_with_no_p
> olls
> self.assertContains(response, "No polls are available.")
>   File "C:\Python27\lib\site-packages\django\test\testcases.py", line 351, 
> in assertContains
> msg_prefix + "Couldn't find %s in response" % text_repr)
> AssertionError: Couldn't find 'No polls are available.' in response
>
> --
> Ran 8 tests in 0.037s
>
> FAILED (failures=2)
> Destroying test database for alias 'default'...
>
>
>
>
>
> On Thursday, February 13, 2014 5:29:50 PM UTC, jondbaker wrote:
>>
>> "setup_test_environment()
>>  installs 
>> a template renderer which will allow us to examine some additional 
>> attributes on responses such as response.context that otherwise wouldn’t 
>> be available. Note that this method *does not* setup a test database, so 
>> the following will be run against the existing database and the output may 
>> differ slightly depending on what polls you already created."
>>
>> That's from the section you linked to, and it clearly explains that a 
>> test database will not be created. Two sections below that is 
>> https://docs.djangoproject.com/en/1.6/intro/tutorial05/#testing-our-new-viewwhich
>>  demonstrates how to create test cases that inherit from TestCase that 
>> can be found and executed by the Django test runner which will also handle 
>> creating the test database for you.
>>
>> JDB
>>
>>
>> On Thu, Feb 13, 2014 at 10:20 AM, Paul Sermon wrote:
>>
>>> yes I am running through the manage.py shell (although initially I did 
>>> not).  
>>>
>>> I am doing the section: 
>>> https://docs.djangoproject.com/en/1.6/intro/tutorial05/#the-django-test-client
>>> On the response.content line, I get back a line listing the polls made 
>>> earlier.
>>>
>>> And I presume that is why the test from the next section fail, because 
>>> they are picking up the entries from the database, rather than the test 
>>> database.
>>>
>>> I am on windows 7, if that makes any difference.
>>>
>>>
>>>
>>>
>>> On Thursday, February 13, 2014 2:58:37 PM UTC, jondbaker wrote:
>>>
 Are you running your tests on the command line using:

 $ python manage.py test polls

 ...or are you trying to run them from a Python shell? It'd be helpful 
 if you could provide the internal link to the area of the page you linked 
 to that you're experiencing the failure at, as well as the output of the 
 error you're receiving and the command that causes it.

 JDB


 On Thu, Feb 13, 2014 at 3:19 AM, Paul Sermon 
 wrote:

> This is the tutorial: https://docs.djangoproject.com/en/1.6/
> intro/tutorial05/
>
> I've followed the tutorials pretty much to the letter since tutorial 
> one.
>
> Thanks for the help!
>
> -Paul
>
>
> On Wednesday, February 12, 2014 10:33:16 PM UTC, jondbaker wrote:
>
>> You're correct in thinking that tests use a test database that is 
>> independent of your formally defined project database. Without knowing 
>> exactly which Django tutorials you are referring to, I can only assume 
>> that 
>> perhaps you:
>>

Re: how to make https work in django REST framework

2014-02-13 Thread C. Kirby
Zhenwu,

You only mentioned it in passing in the last post, but did you say you are 
running django in production via the manage.py runserver command? You 
_really_ shouldn't use runserver in production. You should be using a 
webserver (I guess apache in your case) and wsgi to serve up django.  

-- 
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/32ec32c0-1e7b-44ab-848f-1ec5065068e8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Tutorial 5 - First Tests

2014-02-13 Thread Paul Sermon
Hmm, you'r right, I think I'm getting confused and attributed the error to 
something it isn't.  Ive just ran the test after changing all the polls to 
the future, and I still get the errors.  The errors are as follows:

==
FAIL: test_index_view_with_a_future_poll (polls.tests.PollViewTests)
--
Traceback (most recent call last):
  File "C:\Users\Alienware\Dropbox\coding 
stuff\web\django\mysite\polls\tests.py", line 75, in 
test_index_view_with_a_fu
ture_poll
self.assertContains(response, "No polls are available.", 
status_code=200)
  File "C:\Python27\lib\site-packages\django\test\testcases.py", line 351, 
in assertContains
msg_prefix + "Couldn't find %s in response" % text_repr)
AssertionError: Couldn't find 'No polls are available.' in response

==
FAIL: test_index_view_with_no_polls (polls.tests.PollViewTests)
--
Traceback (most recent call last):
  File "C:\Users\Alienware\Dropbox\coding 
stuff\web\django\mysite\polls\tests.py", line 54, in 
test_index_view_with_no_p
olls
self.assertContains(response, "No polls are available.")
  File "C:\Python27\lib\site-packages\django\test\testcases.py", line 351, 
in assertContains
msg_prefix + "Couldn't find %s in response" % text_repr)
AssertionError: Couldn't find 'No polls are available.' in response

--
Ran 8 tests in 0.037s

FAILED (failures=2)
Destroying test database for alias 'default'...





On Thursday, February 13, 2014 5:29:50 PM UTC, jondbaker wrote:
>
> "setup_test_environment()
>  installs 
> a template renderer which will allow us to examine some additional 
> attributes on responses such as response.context that otherwise wouldn’t 
> be available. Note that this method *does not* setup a test database, so 
> the following will be run against the existing database and the output may 
> differ slightly depending on what polls you already created."
>
> That's from the section you linked to, and it clearly explains that a test 
> database will not be created. Two sections below that is 
> https://docs.djangoproject.com/en/1.6/intro/tutorial05/#testing-our-new-viewwhich
>  demonstrates how to create test cases that inherit from TestCase that 
> can be found and executed by the Django test runner which will also handle 
> creating the test database for you.
>
> JDB
>
>
> On Thu, Feb 13, 2014 at 10:20 AM, Paul Sermon 
>  > wrote:
>
>> yes I am running through the manage.py shell (although initially I did 
>> not).  
>>
>> I am doing the section: 
>> https://docs.djangoproject.com/en/1.6/intro/tutorial05/#the-django-test-client
>> On the response.content line, I get back a line listing the polls made 
>> earlier.
>>
>> And I presume that is why the test from the next section fail, because 
>> they are picking up the entries from the database, rather than the test 
>> database.
>>
>> I am on windows 7, if that makes any difference.
>>
>>
>>
>>
>> On Thursday, February 13, 2014 2:58:37 PM UTC, jondbaker wrote:
>>
>>> Are you running your tests on the command line using:
>>>
>>> $ python manage.py test polls
>>>
>>> ...or are you trying to run them from a Python shell? It'd be helpful if 
>>> you could provide the internal link to the area of the page you linked to 
>>> that you're experiencing the failure at, as well as the output of the error 
>>> you're receiving and the command that causes it.
>>>
>>> JDB
>>>
>>>
>>> On Thu, Feb 13, 2014 at 3:19 AM, Paul Sermon wrote:
>>>
 This is the tutorial: https://docs.djangoproject.com/en/1.6/
 intro/tutorial05/

 I've followed the tutorials pretty much to the letter since tutorial 
 one.

 Thanks for the help!

 -Paul


 On Wednesday, February 12, 2014 10:33:16 PM UTC, jondbaker wrote:

> You're correct in thinking that tests use a test database that is 
> independent of your formally defined project database. Without knowing 
> exactly which Django tutorials you are referring to, I can only assume 
> that 
> perhaps you:
>
> 1) Have defined initial_data.json fixtures
> 2) Have defined other fixtures that your tests are referencing (likely 
> in their setUp method)
>
> If none of the items above are correct, feel free to provide a link to 
> the tutorial you're going through and I'll take a look.
>
> JDB
>
>
> On Wed, Feb 12, 2014 at 2:33 PM, Paul Sermon 
> wrote:
>
>> So I'm working my way through the Django tutorials, and have got as 
>> far as the 

Re: how to make https work in django REST framework

2014-02-13 Thread zhenwu he

Hi, Eric:

After thinking further, I am a little lost. :(

Here is my understanding. 

1, I need have django run server running, for example, listen to port 1234
2, I enable https on apache, which is listening to 443. then I redirect all 
connections to 443 to port 1234 using config you provided.

Am I understanding correctly? based on your config, it seems that we are 
trying to redirect any request to port 80 to https, which is different from 
my step 1 and 2.

thanks.

/zhenwu


On Thursday, February 13, 2014 9:58:51 AM UTC-8, zhenwu he wrote:
>
>
> Thanks Eric for your help.
>
> Basically, user has to send REST API to apache using https, and then 
> apache redirect this call to django using http. Should I config anything on 
> django besides configuration redirect on apache. Based on what you are 
> saying, I do not need config anything on django side. thanks.
>
> /zhenwu
>
> On Thursday, February 13, 2014 12:20:51 AM UTC-8, Erik Cederstrand wrote:
>>
>> Den 13/02/2014 kl. 06.16 skrev zhenwu he : 
>>
>> > 
>> > Thanks for your help, Luca. 
>> > 
>> > Could you elaborate a little bit? I am kind of new to this kind of 
>> thing. What I am doing is that, I am using django to redirect all url calls 
>> to python API to handle something and then return as response. you want me 
>> to redirect this http call to where? and where do I setup this redirect? in 
>> django? BTW, I am using manage.py run server 0:, and it started 
>> listening to http port. 
>>
>> runserver doesn’t support HTTPS. You need to run a real webserver like 
>> Apache to start serving HTTPS requests, or at least install stunnel (
>> http://stackoverflow.com/questions/8023126/how-can-i-test-https-connections-with-django-as-easily-as-i-can-non-https-connec).
>>  
>>
>>
>> To tell your users that you are now serving everything over HTTPS instead 
>> of HTTP, tell your webserver to redirect everything. This is for Apache: 
>>
>>  
>> [...] 
>> ServerName example.com 
>> RewriteEngine On 
>> RewriteRule ^/(.*)$ https://example.com/$1 [R=301] 
>>  
>>
>>
>> You could also do the redirection in Django by looking at 
>> HttpRequest.is_secure(), if your redirection logic is more complicated. 
>>
>>
>> Erik
>
>

-- 
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/71c69145-f969-4788-8302-dc2af3e67524%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to make https work in django REST framework

2014-02-13 Thread zhenwu he

Thanks Luca.

Yeah, I have https setup, but that is for UI, not for REST, the REST is 
purely handled by django run server port. Based on Eric's comment, it seems 
that I need change user to send request to apache using https, and then I 
need config redirect on apache to django. then django will handle the call 
and return to apache and then apache response to user. 

Thanks again for your help. let me try to set it up to see it works.

thanks.

/zhenwu

On Thursday, February 13, 2014 3:38:35 AM UTC-8, Luca Corti wrote:
>
> Il 2014-02-13 06:16 zhenwu he ha scritto: 
> > Thanks for your help, Luca. 
> > 
> > Could you elaborate a little bit? I am kind of new to this kind of 
> > thing. What I am doing is that, I am using django to redirect all url 
> > calls to python API to handle something and then return as response. 
> > you want me to redirect this http call to where? and where do I setup 
> > this redirect? in django? BTW, I am using manage.py run server 0:, 
> > and it started listening to http port. 
>
> I'm guessing you have already setup your Django app behind a webserver 
> (Apache, nginx + uwsgi, whatever). 
> I'm also assuming you have already set up an HTTPS virtualhost in your 
> webserver to serve at least your REST API urls. 
>
> If I understand correctly, you want to avoid API access using standard 
> HTTP. So what you can do is, when accessing any webservice URL, redirect 
> the request via HTTP 301 to the equivalent HTTPS url. 
>
> With nginx you can easily do this in your HTTP virtualhost configuration 
> with something like 
>
> ... 
>
>  location /your-REST-URL-endpoint { 
>  rewrite ^(.*) https://www.example.com$1 permanent; 
>  } 
>
> ... 
>
> ciao 
>
> Luca 
>

-- 
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/02b59fa4-5b58-4997-b217-02873c9c6f00%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to make https work in django REST framework

2014-02-13 Thread zhenwu he

Thanks Eric for your help.

Basically, user has to send REST API to apache using https, and then apache 
redirect this call to django using http. Should I config anything on django 
besides configuration redirect on apache. Based on what you are saying, I 
do not need config anything on django side. thanks.

/zhenwu

On Thursday, February 13, 2014 12:20:51 AM UTC-8, Erik Cederstrand wrote:
>
> Den 13/02/2014 kl. 06.16 skrev zhenwu he : 
>
>
> > 
> > Thanks for your help, Luca. 
> > 
> > Could you elaborate a little bit? I am kind of new to this kind of 
> thing. What I am doing is that, I am using django to redirect all url calls 
> to python API to handle something and then return as response. you want me 
> to redirect this http call to where? and where do I setup this redirect? in 
> django? BTW, I am using manage.py run server 0:, and it started 
> listening to http port. 
>
> runserver doesn’t support HTTPS. You need to run a real webserver like 
> Apache to start serving HTTPS requests, or at least install stunnel (
> http://stackoverflow.com/questions/8023126/how-can-i-test-https-connections-with-django-as-easily-as-i-can-non-https-connec).
>  
>
>
> To tell your users that you are now serving everything over HTTPS instead 
> of HTTP, tell your webserver to redirect everything. This is for Apache: 
>
>  
> [...] 
> ServerName example.com 
> RewriteEngine On 
> RewriteRule ^/(.*)$ https://example.com/$1 [R=301] 
>  
>
>
> You could also do the redirection in Django by looking at 
> HttpRequest.is_secure(), if your redirection logic is more complicated. 
>
>
> Erik

-- 
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/0bc2eb08-6d60-415e-9422-c19465f9b4bd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Tutorial 5 - First Tests

2014-02-13 Thread Jonathan Baker
"setup_test_environment()
installs
a template renderer which will allow us to examine some additional
attributes on responses such as response.context that otherwise wouldn't be
available. Note that this method *does not* setup a test database, so the
following will be run against the existing database and the output may
differ slightly depending on what polls you already created."

That's from the section you linked to, and it clearly explains that a test
database will not be created. Two sections below that is
https://docs.djangoproject.com/en/1.6/intro/tutorial05/#testing-our-new-viewwhich
demonstrates how to create test cases that inherit from TestCase that
can be found and executed by the Django test runner which will also handle
creating the test database for you.

JDB


On Thu, Feb 13, 2014 at 10:20 AM, Paul Sermon wrote:

> yes I am running through the manage.py shell (although initially I did
> not).
>
> I am doing the section:
> https://docs.djangoproject.com/en/1.6/intro/tutorial05/#the-django-test-client
> On the response.content line, I get back a line listing the polls made
> earlier.
>
> And I presume that is why the test from the next section fail, because
> they are picking up the entries from the database, rather than the test
> database.
>
> I am on windows 7, if that makes any difference.
>
>
>
>
> On Thursday, February 13, 2014 2:58:37 PM UTC, jondbaker wrote:
>
>> Are you running your tests on the command line using:
>>
>> $ python manage.py test polls
>>
>> ...or are you trying to run them from a Python shell? It'd be helpful if
>> you could provide the internal link to the area of the page you linked to
>> that you're experiencing the failure at, as well as the output of the error
>> you're receiving and the command that causes it.
>>
>> JDB
>>
>>
>> On Thu, Feb 13, 2014 at 3:19 AM, Paul Sermon wrote:
>>
>>> This is the tutorial: https://docs.djangoproject.com/en/1.6/
>>> intro/tutorial05/
>>>
>>> I've followed the tutorials pretty much to the letter since tutorial one.
>>>
>>> Thanks for the help!
>>>
>>> -Paul
>>>
>>>
>>> On Wednesday, February 12, 2014 10:33:16 PM UTC, jondbaker wrote:
>>>
 You're correct in thinking that tests use a test database that is
 independent of your formally defined project database. Without knowing
 exactly which Django tutorials you are referring to, I can only assume that
 perhaps you:

 1) Have defined initial_data.json fixtures
 2) Have defined other fixtures that your tests are referencing (likely
 in their setUp method)

 If none of the items above are correct, feel free to provide a link to
 the tutorial you're going through and I'll take a look.

 JDB


 On Wed, Feb 12, 2014 at 2:33 PM, Paul Sermon 
 wrote:

> So I'm working my way through the Django tutorials, and have got as
> far as the view tests.  It seems that when running the test client, rather
> than returning data from an empty test database (is this what is meant to
> happen?) it is returning polls from the existing database, which has the
> polls created in the previous tutorials.  This means the tests that expect
> empty result sets fail.
>
> Any idea why it would be doing this?  Am I correct in thinking the
> test should create it's own empty database to test this?
>
> --
> 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/e1782c5f-d8e7-4fc6-93d8-88d01aafbd4f%40goog
> legroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
   --
>>> 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/4031d95b-7f80-4839-a25a-800649e33cf1%
>>> 40googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Jonathan D. Baker
>> Developer
>> http://jonathandbaker.com
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To 

Re: Django Tutorial 5 - First Tests

2014-02-13 Thread Paul Sermon
yes I am running through the manage.py shell (although initially I did 
not).  

I am doing the 
section: 
https://docs.djangoproject.com/en/1.6/intro/tutorial05/#the-django-test-client
On the response.content line, I get back a line listing the polls made 
earlier.

And I presume that is why the test from the next section fail, because they 
are picking up the entries from the database, rather than the test database.

I am on windows 7, if that makes any difference.




On Thursday, February 13, 2014 2:58:37 PM UTC, jondbaker wrote:
>
> Are you running your tests on the command line using:
>
> $ python manage.py test polls
>
> ...or are you trying to run them from a Python shell? It'd be helpful if 
> you could provide the internal link to the area of the page you linked to 
> that you're experiencing the failure at, as well as the output of the error 
> you're receiving and the command that causes it.
>
> JDB
>
>
> On Thu, Feb 13, 2014 at 3:19 AM, Paul Sermon 
>  > wrote:
>
>> This is the tutorial: 
>> https://docs.djangoproject.com/en/1.6/intro/tutorial05/
>>
>> I've followed the tutorials pretty much to the letter since tutorial one.
>>
>> Thanks for the help!
>>
>> -Paul
>>
>>
>> On Wednesday, February 12, 2014 10:33:16 PM UTC, jondbaker wrote:
>>
>>> You're correct in thinking that tests use a test database that is 
>>> independent of your formally defined project database. Without knowing 
>>> exactly which Django tutorials you are referring to, I can only assume that 
>>> perhaps you:
>>>
>>> 1) Have defined initial_data.json fixtures
>>> 2) Have defined other fixtures that your tests are referencing (likely 
>>> in their setUp method)
>>>
>>> If none of the items above are correct, feel free to provide a link to 
>>> the tutorial you're going through and I'll take a look.
>>>
>>> JDB
>>>
>>>
>>> On Wed, Feb 12, 2014 at 2:33 PM, Paul Sermon wrote:
>>>
 So I'm working my way through the Django tutorials, and have got as far 
 as the view tests.  It seems that when running the test client, rather 
 than 
 returning data from an empty test database (is this what is meant to 
 happen?) it is returning polls from the existing database, which has the 
 polls created in the previous tutorials.  This means the tests that expect 
 empty result sets fail.

 Any idea why it would be doing this?  Am I correct in thinking the test 
 should create it's own empty database to test this?

 -- 
 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/e1782c5f-d8e7-4fc6-93d8-88d01aafbd4f%
 40googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.

>>>   -- 
>> 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/4031d95b-7f80-4839-a25a-800649e33cf1%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Jonathan D. Baker
> Developer
> http://jonathandbaker.com
>  

-- 
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/0d1f956e-3ba2-4737-a33f-a6dc4610542a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: FieldError, But Only In Production

2014-02-13 Thread Rich Jones
Yes, all of these things worked just fine. The code is in the _same
location_ on the _same machine_ with the _same settings_ and the _same
database_. The only difference is devserver vs Apache.

:(


On Thu, Feb 13, 2014 at 2:21 AM, Vibhu Rishi  wrote:

> Seems to me somewhere in the code it is trying to put user into a field
> instead of treating it as a table.
> Basic sanity checks :
> - is the djagno versions on both production and local same ?
> - same for wsgi and apache ?
> - syncdb worked fine ?
>
> V.
>
>
>
> On Thu, Feb 13, 2014 at 11:30 AM, Rich Jones  wrote:
>
>> Hey guys!
>>
>> I've got a real stumper here. Pulling my hair out over this one, would
>> really appreciate some options!
>>
>> Anywhere in my application that calls user.get_profile() causes a
>> FieldError.. but only in production. I'm using WSGI and Apache.
>>
>> When I run locally with:
>>
>>  python manage.py runserver 0.0.0.0:
>>
>> it works just fine. However, running the exact same code and the exact
>> same database with Apache, I get a 500 and find this in the logs:
>>
>>  [Wed Feb 12 21:23:21 2014] [error] [client] FieldError: Cannot
>> resolve keyword 'user' into field. Choices are: about_me, about_me_mkd,
>> etc..
>>
>> (Full traceback: http://pastebin.com/6141pHZ2)
>>
>> When I run sqlall, there is a users_id entry for the model:
>>
>> "user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id")
>> DEFERRABLE INITIALLY DEFERRED
>>
>> What could possibly be happening here? What could the difference between
>> devserver and Apache?
>>
>> (For reference, this is using Django-Userena 1.0, Django 1.3.7. and
>> Postgres 8.4.)
>>
>> I've tried a few things I found on the internet:
>>
>>
>> http://stackoverflow.com/questions/19145787/fielderror-cannot-resolve-keyword--into-field
>>
>> http://chase-seibert.github.io/blog/2010/04/30/django-manytomany-error-cannot-resolve-keyword-xxx-into-a-field.html
>>
>> Which both suggest that it has something to do with the order of the
>> imports, but I haven't had any success with this approach.
>>
>> There is an extremely old Django bug seemingly related to this,
>>
>> https://code.djangoproject.com/ticket/1796
>>
>> but I don't know how relevant this is, as this is not a ManyToMany
>> problem, because Userena uses a OneToOne field:
>>
>> user = models.OneToOneField(User,
>> unique=True,
>> verbose_name=_('user'),
>> related_name='profile')
>>
>> Can anybody help me? I'm going nuts over here. I just don't know why the
>> behavior would be different for runserver and Apache!
>>
>> Any ideas?
>>
>> Thanks so much!,
>> Rich
>>
>>  --
>> 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/41e0fdbe-520d-44a4-b3b5-ee4914d0e099%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Simplicity is the ultimate sophistication. - Leonardo da Vinci
> Life is really simple, but we insist on making it complicated. - Confucius
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/E4UVZHf6kP8/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAPiONw%3DwazFkycVy%3DAwoj99uq4RgqhFu%2B2iotZz712AKa0U%3DYQ%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CADJYzxLTsF19wSLdztgyoBPDOU2m9_4dQqdd0kqLKyka7MMV9w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Login at the end of form wizard

2014-02-13 Thread Thomas Leo

Sorry I meant to say NamedUrlSessionWizardView not NamedUrlWizardView

On Thursday, February 13, 2014 11:08:36 AM UTC-5, Thomas Leo wrote:
>
> >> when a user logs in and gets redirected to the order page the wizard 
> starts again from the beginning (loosing all the data inserted the first 
> time).
>
> The issue is that in WizardView, triggering the get function causes the 
> session 
> to 
> reset.
>  
> I would suggest that you switch from using a plain SessionWizardView to 
> a NamedUrlWizardView.
>
> >> Can I keep/move the wizard session data from the anonymous user to the 
> logged user?
>
> I believe that session data is only cleaned when you log out, however when 
> logging in you should not loose that data.
>
> On Thursday, February 13, 2014 9:51:08 AM UTC-5, parnigot wrote:
>>
>> Hello fellow django users,
>>
>> I’m using a form wizard (a very basic SessionWizardView) to create a 
>> simple “order page”.
>> The four steps of the wizard must be accessible to both logged in and 
>> anonymous users, but to complete an order the user must authenticate 
>> himself (think something like an online shop where you can add what you 
>> want to the basket but to complete an order you have to log in).
>>
>> To accomplish this, in the wizard’s done() method, I redirect anonymous 
>> users to the login page with a ?next=/order-page/ parameter.
>> But this doesn’t work very well, because when a user logs in and gets 
>> redirected to the order page the wizard starts again from the beginning 
>> (loosing all the data inserted the first time).
>>
>> Can I keep/move the wizard session data from the anonymous user to the 
>> logged user?
>>
>> ---
>> Best regards,
>> e.p.
>> 
>>
>

-- 
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/feda2bb8-031f-4875-919a-a0f65fa23502%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Login at the end of form wizard

2014-02-13 Thread Thomas Leo
>> when a user logs in and gets redirected to the order page the wizard 
starts again from the beginning (loosing all the data inserted the first 
time).

The issue is that in WizardView, triggering the get function causes the session 
to 
reset.
 
I would suggest that you switch from using a plain SessionWizardView to 
a NamedUrlWizardView.

>> Can I keep/move the wizard session data from the anonymous user to the 
logged user?

I believe that session data is only cleaned when you log out, however when 
logging in you should not loose that data.

On Thursday, February 13, 2014 9:51:08 AM UTC-5, parnigot wrote:
>
> Hello fellow django users,
>
> I’m using a form wizard (a very basic SessionWizardView) to create a 
> simple “order page”.
> The four steps of the wizard must be accessible to both logged in and 
> anonymous users, but to complete an order the user must authenticate 
> himself (think something like an online shop where you can add what you 
> want to the basket but to complete an order you have to log in).
>
> To accomplish this, in the wizard’s done() method, I redirect anonymous 
> users to the login page with a ?next=/order-page/ parameter.
> But this doesn’t work very well, because when a user logs in and gets 
> redirected to the order page the wizard starts again from the beginning 
> (loosing all the data inserted the first time).
>
> Can I keep/move the wizard session data from the anonymous user to the 
> logged user?
>
> ---
> Best regards,
> e.p.
> 
>

-- 
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/ec968123-98f8-4905-b621-0aa93bd8cf4e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django application hosted on godaddy don't display the site models in admin page

2014-02-13 Thread Cal Leeming [Simplicity Media Ltd]
Glad you got it sorted out, and thanks for letting us know!

Cal


On Thu, Feb 13, 2014 at 10:26 AM, Mironiuc Sergiu wrote:

> I found the problem.
> I had an "extra" (non-necessary) folder admin, that should be in the
> static folder and not dirrectly in the project folder.
> That was a confusing thing for application.
> Thanks to all people who tried to help me.
> Regards!
>
> --
> 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/dd3a2e61-d320-4601-aa47-6d66be8351c8%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAHKQagErYOACsFigNpXVA9rCQhW8z9RT_Ax%2BvDXAU5ZM037tFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Login at the end of form wizard

2014-02-13 Thread parnigot
Hello fellow django users,

I'm using a form wizard (a very basic SessionWizardView) to create a simple 
"order page".
The four steps of the wizard must be accessible to both logged in and anonymous 
users, but to complete an order the user must authenticate himself (think 
something like an online shop where you can add what you want to the basket but 
to complete an order you have to log in).

To accomplish this, in the wizard's done() method, I redirect anonymous users 
to the login page with a ?next=/order-page/ parameter.
But this doesn't work very well, because when a user logs in and gets 
redirected to the order page the wizard starts again from the beginning 
(loosing all the data inserted the first time).

Can I keep/move the wizard session data from the anonymous user to the logged 
user?

---
Best regards,
e.p.

-- 
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/B22175ED-9DD9-4AC1-9CDA-34F396CB6D89%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Tutorial 5 - First Tests

2014-02-13 Thread Jonathan Baker
Are you running your tests on the command line using:

$ python manage.py test polls

...or are you trying to run them from a Python shell? It'd be helpful if
you could provide the internal link to the area of the page you linked to
that you're experiencing the failure at, as well as the output of the error
you're receiving and the command that causes it.

JDB


On Thu, Feb 13, 2014 at 3:19 AM, Paul Sermon wrote:

> This is the tutorial:
> https://docs.djangoproject.com/en/1.6/intro/tutorial05/
>
> I've followed the tutorials pretty much to the letter since tutorial one.
>
> Thanks for the help!
>
> -Paul
>
>
> On Wednesday, February 12, 2014 10:33:16 PM UTC, jondbaker wrote:
>
>> You're correct in thinking that tests use a test database that is
>> independent of your formally defined project database. Without knowing
>> exactly which Django tutorials you are referring to, I can only assume that
>> perhaps you:
>>
>> 1) Have defined initial_data.json fixtures
>> 2) Have defined other fixtures that your tests are referencing (likely in
>> their setUp method)
>>
>> If none of the items above are correct, feel free to provide a link to
>> the tutorial you're going through and I'll take a look.
>>
>> JDB
>>
>>
>> On Wed, Feb 12, 2014 at 2:33 PM, Paul Sermon wrote:
>>
>>> So I'm working my way through the Django tutorials, and have got as far
>>> as the view tests.  It seems that when running the test client, rather than
>>> returning data from an empty test database (is this what is meant to
>>> happen?) it is returning polls from the existing database, which has the
>>> polls created in the previous tutorials.  This means the tests that expect
>>> empty result sets fail.
>>>
>>> Any idea why it would be doing this?  Am I correct in thinking the test
>>> should create it's own empty database to test this?
>>>
>>> --
>>> 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/e1782c5f-d8e7-4fc6-93d8-88d01aafbd4f%
>>> 40googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>   --
> 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/4031d95b-7f80-4839-a25a-800649e33cf1%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

-- 
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/CAPMFOb7T4DpbwtMvtmiuzVfA2QsuoyJansjFLurDUPg2uKyD4g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Question about the send of file versus the django server

2014-02-13 Thread simone monteleone
Hi all,

I have to send a file (ex. csv file) to the Django server.

I think to use the requests python module.

Is this the best way?

Second question; Django can receive this file?

And also in this case, what it is the best way?

My goal is to load the csv file information in the dabatase handles by 
django,

My best regards.

Thanks in advice for the helpuful.

Simone Monteleone

-- 
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/526ea883-d5e2-4d60-b642-440a7796f811%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to make https work in django REST framework

2014-02-13 Thread Luca Corti

Il 2014-02-13 06:16 zhenwu he ha scritto:

Thanks for your help, Luca.

Could you elaborate a little bit? I am kind of new to this kind of
thing. What I am doing is that, I am using django to redirect all url
calls to python API to handle something and then return as response.
you want me to redirect this http call to where? and where do I setup
this redirect? in django? BTW, I am using manage.py run server 0:,
and it started listening to http port.


I'm guessing you have already setup your Django app behind a webserver 
(Apache, nginx + uwsgi, whatever).
I'm also assuming you have already set up an HTTPS virtualhost in your 
webserver to serve at least your REST API urls.


If I understand correctly, you want to avoid API access using standard 
HTTP. So what you can do is, when accessing any webservice URL, redirect 
the request via HTTP 301 to the equivalent HTTPS url.


With nginx you can easily do this in your HTTP virtualhost configuration 
with something like


...

location /your-REST-URL-endpoint {
rewrite ^(.*) https://www.example.com$1 permanent;
}

...

ciao

Luca

--
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/f19022d28180c5aafa0157b6688753b6%40mail.fantacast.it.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django application hosted on godaddy don't display the site models in admin page

2014-02-13 Thread Mironiuc Sergiu
I found the problem. 
I had an "extra" (non-necessary) folder admin, that should be in the static 
folder and not dirrectly in the project folder.
That was a confusing thing for application.
Thanks to all people who tried to help me.
Regards!

-- 
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/dd3a2e61-d320-4601-aa47-6d66be8351c8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: FieldError, But Only In Production

2014-02-13 Thread Vibhu Rishi
Seems to me somewhere in the code it is trying to put user into a field
instead of treating it as a table.
Basic sanity checks :
- is the djagno versions on both production and local same ?
- same for wsgi and apache ?
- syncdb worked fine ?

V.



On Thu, Feb 13, 2014 at 11:30 AM, Rich Jones  wrote:

> Hey guys!
>
> I've got a real stumper here. Pulling my hair out over this one, would
> really appreciate some options!
>
> Anywhere in my application that calls user.get_profile() causes a
> FieldError.. but only in production. I'm using WSGI and Apache.
>
> When I run locally with:
>
>  python manage.py runserver 0.0.0.0:
>
> it works just fine. However, running the exact same code and the exact
> same database with Apache, I get a 500 and find this in the logs:
>
>  [Wed Feb 12 21:23:21 2014] [error] [client] FieldError: Cannot
> resolve keyword 'user' into field. Choices are: about_me, about_me_mkd,
> etc..
>
> (Full traceback: http://pastebin.com/6141pHZ2)
>
> When I run sqlall, there is a users_id entry for the model:
>
> "user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id")
> DEFERRABLE INITIALLY DEFERRED
>
> What could possibly be happening here? What could the difference between
> devserver and Apache?
>
> (For reference, this is using Django-Userena 1.0, Django 1.3.7. and
> Postgres 8.4.)
>
> I've tried a few things I found on the internet:
>
>
> http://stackoverflow.com/questions/19145787/fielderror-cannot-resolve-keyword--into-field
>
> http://chase-seibert.github.io/blog/2010/04/30/django-manytomany-error-cannot-resolve-keyword-xxx-into-a-field.html
>
> Which both suggest that it has something to do with the order of the
> imports, but I haven't had any success with this approach.
>
> There is an extremely old Django bug seemingly related to this,
>
> https://code.djangoproject.com/ticket/1796
>
> but I don't know how relevant this is, as this is not a ManyToMany
> problem, because Userena uses a OneToOne field:
>
> user = models.OneToOneField(User,
> unique=True,
> verbose_name=_('user'),
> related_name='profile')
>
> Can anybody help me? I'm going nuts over here. I just don't know why the
> behavior would be different for runserver and Apache!
>
> Any ideas?
>
> Thanks so much!,
> Rich
>
>  --
> 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/41e0fdbe-520d-44a4-b3b5-ee4914d0e099%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
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/CAPiONw%3DwazFkycVy%3DAwoj99uq4RgqhFu%2B2iotZz712AKa0U%3DYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Tutorial 5 - First Tests

2014-02-13 Thread Paul Sermon
This is the 
tutorial: https://docs.djangoproject.com/en/1.6/intro/tutorial05/

I've followed the tutorials pretty much to the letter since tutorial one.

Thanks for the help!

-Paul

On Wednesday, February 12, 2014 10:33:16 PM UTC, jondbaker wrote:
>
> You're correct in thinking that tests use a test database that is 
> independent of your formally defined project database. Without knowing 
> exactly which Django tutorials you are referring to, I can only assume that 
> perhaps you:
>
> 1) Have defined initial_data.json fixtures
> 2) Have defined other fixtures that your tests are referencing (likely in 
> their setUp method)
>
> If none of the items above are correct, feel free to provide a link to the 
> tutorial you're going through and I'll take a look.
>
> JDB
>
>
> On Wed, Feb 12, 2014 at 2:33 PM, Paul Sermon 
>  > wrote:
>
>> So I'm working my way through the Django tutorials, and have got as far 
>> as the view tests.  It seems that when running the test client, rather than 
>> returning data from an empty test database (is this what is meant to 
>> happen?) it is returning polls from the existing database, which has the 
>> polls created in the previous tutorials.  This means the tests that expect 
>> empty result sets fail.
>>
>> Any idea why it would be doing this?  Am I correct in thinking the test 
>> should create it's own empty database to test this?
>>
>> -- 
>> 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/e1782c5f-d8e7-4fc6-93d8-88d01aafbd4f%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>  

-- 
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/4031d95b-7f80-4839-a25a-800649e33cf1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django application hosted on godaddy don't display the site models in admin page

2014-02-13 Thread Mironiuc Sergiu
I configured log. But in the log file I don't see any warning/errors about 
admin page.
Just some selects from database regarding users and groups.
But, another strange thing is that I don't have the "admin.pyc" file.
So, it looks like this file is not compiled...
May be that can be a suggestion...
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/1461155a-8379-4602-aae1-e3dcb628860b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to make https work in django REST framework

2014-02-13 Thread Erik Cederstrand
Den 13/02/2014 kl. 06.16 skrev zhenwu he :

> 
> Thanks for your help, Luca. 
> 
> Could you elaborate a little bit? I am kind of new to this kind of thing. 
> What I am doing is that, I am using django to redirect all url calls to 
> python API to handle something and then return as response. you want me to 
> redirect this http call to where? and where do I setup this redirect? in 
> django? BTW, I am using manage.py run server 0:, and it started listening 
> to http port.

runserver doesn't support HTTPS. You need to run a real webserver like Apache 
to start serving HTTPS requests, or at least install stunnel 
(http://stackoverflow.com/questions/8023126/how-can-i-test-https-connections-with-django-as-easily-as-i-can-non-https-connec).

To tell your users that you are now serving everything over HTTPS instead of 
HTTP, tell your webserver to redirect everything. This is for Apache:


[...]
ServerName example.com
RewriteEngine On
RewriteRule ^/(.*)$ https://example.com/$1 [R=301]



You could also do the redirection in Django by looking at 
HttpRequest.is_secure(), if your redirection logic is more complicated.


Erik

-- 
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/E44204D1-218F-4874-ABB3-BDB9860A1F42%40cederstrand.dk.
For more options, visit https://groups.google.com/groups/opt_out.