Re: Two projects fail to import the same main app when I turn on both in Apache

2015-05-07 Thread Thomas Levine
It turns out that my two inquiries from the past three days were more
related than I had thought. I have finally resolved both.

Let's first review what was going on. Here was my original problem,
titled "Two projects fail to import the same main app when I turn on
both in Apache".

On Tue, May 5, 2015 at 10:32 AM, Thomas Levine <_...@thomaslevine.com> wrote:
> I have two sites that I want to host on the same computer.
> I have root access on this computer. The two sites are called
> "dadaportal", which is on https://thomaslevine.com, and "scott",
> which is on http://scott.dada.pink.
>
> ...
>
> Both sites work fine if I disable the other. Here is what its
> configuration looks like.
>
> I have problem when I try to run both at the same time.

Tom gave me something that seemed to work.

On 05 May 13:49, Tom Evans wrote:
> You're missing the process-group argument from WSGIScriptAlias so it
> tries to run both of them in the default process group.
> 
> https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/#using-mod-wsgi-daemon-mode

After setting the process groups, I stumbled upon another problem,
which I titled "How do I debug 400 errors that arise from turning off
debug mode?"

On 07 May 13:43, Thomas Levine wrote:
> Hi,
> 
> Every page on my site returns a status code of 400 when I set
> `debug = False` in my settings file, and this doesn't happen
> if I switch it to `True`. How can I determine what is going wrong?
> 
> ...
> 
> I believe that neither the `settings.py` nor even `wsgi.py` files
> are being run, as adding the following lines to their tops did not
> produce `settings.pyabc` nor `wsgi.pyabc`, respectively.
> 
> with open(__file__ + 'abc', 'w') as fp:
> fp.write('abc')

I eventually managed to debug it somewhat.

On 07 May 18:11, Thomas Levine wrote:
> Well this is neat. Following the advice of Collin Anderson,
> https://groups.google.com/d/msg/django-users/d_aWdw_AhH0/424ABkRajaoJ
> 
> I removed the LOGGING stuff, which wasn't that interesting anyway.
> And then the exception emails started appearing!
> 
> I got this,
> 
> > Invalid HTTP_HOST header: 'localhost:8000'. You may need to add
> > 'localhost' to ALLOWED_HOSTS.
> 
> which was a surprise to me because I already had 'localhost:*' in
> my settings, but I switched it and it indeed worked on the development
> server. For example, this returned the admin login page.
> 
> curl 'http://localhost:8000/admin/login/?next=/admin/'
> 
> But it still didn't work with the Apache server. ('scott.dada.pink',
> the host that Apache watches for, had always been in ALLOWED_HOSTS.)
> So I removed 'localhost' from ALLOWED_HOSTS and tried this.
> 
> curl -H 'host: scott.dada.pink' 
> 'http://localhost:8000/admin/login/?next=/admin/'
> 
> It returned the same web page, even though the host was not in
> ALLOWED_HOSTS. I guess the development server does not care about
> ALLOWED_HOSTS?
> 
> curl -H 'host: scott.dada.pink' 
> 'http://localhost:8000/admin/login/?next=/admin/'
> 
> Unfortunately, while email works with the development server,
> it does not work on the production server, and I have yet to figure
> out why.

Then I looked at the scott2-error.log log again and noticed this.

[Fri May 08 05:14:05.295576 2015] [wsgi:info] [pid 16576] [remote 
81.234.202.247:15414] mod_wsgi (pid=16576, process='thomaslevine.com', 
application='scott.dada.pink|'): Loading WSGI script 
'/srv/dadaportal/dadaportal/wsgi.py'.

Scott2 is running in the "thomaslevine.com" process group even though
its Apache configuration contains this.

WSGIScriptAlias / /srv/scott2/scott2/wsgi.py process-group=scott.dada.pink

But now I saw the problem! The two sites' configuration files had the
WSGI configuration lines outside of the virtual host,

WSGIScriptAlias / /srv/scott2/scott2/wsgi.py process-group=scott.dada.pink
WSGIDaemonProcess scott.dada.pink python-path=/srv/scott2
WSGIProcessGroup scott.dada.pink


ServerName scott.dada.pink
# ...


making them global. They needed to be inside the virtual host.


WSGIScriptAlias / /srv/scott2/scott2/wsgi.py 
process-group=scott.dada.pink
WSGIDaemonProcess scott.dada.pink python-path=/srv/scott2
WSGIProcessGroup scott.dada.pink

ServerName scott.dada.pink
# ...


When I switch even just one of them to be local, both sites work.
This makes sense to me, as that's how name spaces are.

Before I had done this, Dadaportal was working, and Scott2 wasn't.
I think the reason for this is that Dadaportal's configuration file
has a name (010-dadaportal) that is lower in alphabetical order than
Scott2's configuration file (015-scott), but I have not tested this
hunch.

In response to my second question, about how to debug: I think I was
doing everything that I could have done.

And the information was in the Django errors for the development server,
but my custom logging setup apparently interfered with the standard

Re: django 1.8 and wsgi_mod

2015-05-07 Thread Luis Zárate
Your server log said this (loading my.wsgi)
Exception occurred processing WSGI script
'/code/projects/my_web/wsgi/my.wsgi'.


But your structure said that wsgi file is called different (idrac.wsgi).

Other thing, call core your app is not a good idea, do it if you understand
well how python import work, otherwise it is a pain in the ask



El jueves, 7 de mayo de 2015, Abhaya Agarwal 
escribió:
> On Tue, Apr 28, 2015 at 9:40 PM, dk  wrote:
>>
>> I check the apache httpd log  and do get this
>>
>> [Tue Apr 28 10:33:49.982311 2015] [:error] [pid 18060] [client
10.35.0.91:61408] from django.apps import apps
>> [Tue Apr 28 10:33:49.982336 2015] [:error] [pid 18060] [client
10.35.0.91:61408] ImportError: No module named apps
>> [Tue Apr 28 10:33:52.595973 2015] [:error] [pid 18061] [client
10.35.0.91:61410] mod_wsgi (pid=18061):
>> Target WSGI script '/code/projects/my_web/wsgi/my.wsgi' cannot be loaded
as Python module.
>> [Tue Apr 28 10:33:52.596033 2015] [:error] [pid 18061] [client
10.35.0.91:61410] mod_wsgi (pid=18061):
>> Exception occurred processing WSGI script
'/code/projects/my_web/wsgi/my.wsgi'.
>>
>> I think is the No module named apps is causing this =(
>
> It certainly is. It is hard to say anything more without looking at the
actual code/setup. But since runserver works, perhaps your production
environment is pointing to an older version of Django?
> Regards,
> Abhaya
>
> --
> 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/CAFPF63SGNtRKwaWThd%2BS47dz9joGxqfg%3D%2BXuB4UOfKr0g0Erbw%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyPU-J3LjPYsVGXYHWTxDo_0zUWZLcspETmuADP80ojQYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django code of conduct - last line

2015-05-07 Thread Lachlan Musicman
To my mind it means something along the lines of:

if someone says something sexist, instead of jumping on them and
eviscerating them publicly, we take them aside and explain that that type
of language is against the CoC, is inappropriate, and ask them to not do it
again. Even so far as to offer supplementary  readings/texts/opportunities
to discuss.

Then, if the behaviour is repeated in a non accidental manner
(reconstruction is hard, mistakes are made!), we probably warn or ask them
to leave the space.

That would be my reading.

cheers
L.

--
let's build quiet armies friends, let's march on their glass towers...let's
build fallen cathedrals and make impractical plans

- GYBE

On 8 May 2015 at 12:51, Graham Oliver  wrote:

> Hello all
> Just reading the code of conduct https://www.djangoproject.com/conduct/
> The last line goes like this
>
> 'Don’t forget that it is human to err and blaming each other doesn’t get
> us anywhere, rather offer to help resolving issues and to help learn from
> mistakes.'
>
> I don't really understand the 'rather offer to help resolving issues and
> to help learn from mistakes.'
>
> Anyone got a view on what this means and/or a better way to express it?
>
> Cheers
> g
>
> --
> 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/31e23634-80d0-4d5e-8a26-8cbc99d12a71%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django code of conduct - last line

2015-05-07 Thread m1chael
I think if you change the word 'resolving' to 'resolve', it may make
more sense..



On Thu, May 7, 2015 at 10:51 PM, Graham Oliver
 wrote:
> Hello all
> Just reading the code of conduct https://www.djangoproject.com/conduct/
> The last line goes like this
>
> 'Don’t forget that it is human to err and blaming each other doesn’t get us
> anywhere, rather offer to help resolving issues and to help learn from
> mistakes.'
>
> I don't really understand the 'rather offer to help resolving issues and to
> help learn from mistakes.'
>
> Anyone got a view on what this means and/or a better way to express it?
>
> Cheers
> g
>
> --
> 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/31e23634-80d0-4d5e-8a26-8cbc99d12a71%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Django code of conduct - last line

2015-05-07 Thread Graham Oliver
Hello all
Just reading the code of conduct https://www.djangoproject.com/conduct/
The last line goes like this

'Don’t forget that it is human to err and blaming each other doesn’t get us 
anywhere, rather offer to help resolving issues and to help learn from 
mistakes.'

I don't really understand the 'rather offer to help resolving issues and to 
help learn from mistakes.'

Anyone got a view on what this means and/or a better way to express it?

Cheers
g

-- 
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/31e23634-80d0-4d5e-8a26-8cbc99d12a71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: create comment programmatically from CommentForm embedded in another form

2015-05-07 Thread Martin Beroiz
I just found out the CommentForm actually requires to set target_object for 
initialization.

It should've been
commForm = CommentForm(target_object = myobj, data=request.POST)

Sorry for the noise on the list!


On Thursday, 7 May 2015 18:05:09 UTC-5, Martin Beroiz wrote:
>
> Hello, 
>
> I'm rather new to Django and I'm trying to include django_comments form in 
> another form a user can choose. 
> Basically, the user will fill a custom form (of mine) and possibly leave a 
> comment with a form generated with django_comments. 
> In a nutshell, I want to save a comment programmatically from my custom 
> view/form.
>
> A minimal version of my 'rank' view and template is:
>
> from django_comments.forms import CommentForm
> @login_required
> def rank(request):
> if request.method == "POST":
> rankForm = RankingForm(data=request.POST)
> commForm = CommentForm(data=request.POST)
>
> if form.is_valid() and commForm.is_valid():
> r = rankForm.save()
> commForm.save()
>
> else:
> rankForm = RankingForm()
> return render(request, 'rank.html', {'form': rankForm, 'tc_id': '1', 
> ... other stuff })
>
>
> and in the template:
>
>  enctype="multipart/form-data">
> {% csrf_token %}
> {{ rankForm.as_p }}
>  {% get_comment_form for my_app.my_model tc_id as comment_form %}
>
> {{ comment_form.comment }}
> {{ comment_form.honeypot }}
> {{ comment_form.content_type }}
> {{ comment_form.object_pk }}
> {{ comment_form.timestamp }}
> {{ comment_form.security_hash }}
> 
> 
>
>
>
> Django throws an error on this line: commForm = 
> CommentForm(data=request.POST)
> TypeError  __init__() takes at least 2 arguments (2 given)
>
> I don't know how to initialize a comment object with the data supplied on 
> the form and save it using the provided methods from django_comments.
> I did in the past create a whole Comment() instance from scratch and 
> filled it all with the correct data, but it seemed to me like a hack, 
> bypassing all the security checks built-in in the comment package.
>
> How would I go about to save a comment programmatically from my custom 
> view/form?
>
> Thanks,
> Martin.
>

-- 
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/869179b2-0320-480b-8dbf-cdbb9e8d9013%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Errno 13 when uploading pictures

2015-05-07 Thread R.N. George
I'm trying to upload a picture through my admin page and keep getting Errno 
13.I have no clue what is going wrong, any help would be great.

Here are the lines of code from my model, 

   
 image_object = models.ImageField(db_column='IMAGE_OBJECT',upload_to = 
"/media/", blank=True) # Field name made lowercase.


setting, 

ENV_PATH = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
MEDIA_ROOT = os.path.join(ENV_PATH, '/media/')
MEDIA_URL = "/media/"


and httpd.conf files

Alias /media /path_to_media_folder/media/


Require all granted


I have already used chmod 777 on the media file fyi

-- 
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/7702c5b7-a6ea-44f3-995b-43e6bd1094dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


create comment programmatically from CommentForm embedded in another form

2015-05-07 Thread Martin Beroiz
Hello, 

I'm rather new to Django and I'm trying to include django_comments form in 
another form a user can choose. 
Basically, the user will fill a custom form (of mine) and possibly leave a 
comment with a form generated with django_comments. 
In a nutshell, I want to save a comment programmatically from my custom 
view/form.

A minimal version of my 'rank' view and template is:

from django_comments.forms import CommentForm
@login_required
def rank(request):
if request.method == "POST":
rankForm = RankingForm(data=request.POST)
commForm = CommentForm(data=request.POST)

if form.is_valid() and commForm.is_valid():
r = rankForm.save()
commForm.save()

else:
rankForm = RankingForm()
return render(request, 'rank.html', {'form': rankForm, 'tc_id': '1', 
... other stuff })


and in the template:


{% csrf_token %}
{{ rankForm.as_p }}
 {% get_comment_form for my_app.my_model tc_id as comment_form %}

{{ comment_form.comment }}
{{ comment_form.honeypot }}
{{ comment_form.content_type }}
{{ comment_form.object_pk }}
{{ comment_form.timestamp }}
{{ comment_form.security_hash }}





Django throws an error on this line: commForm = 
CommentForm(data=request.POST)
TypeError  __init__() takes at least 2 arguments (2 given)

I don't know how to initialize a comment object with the data supplied on 
the form and save it using the provided methods from django_comments.
I did in the past create a whole Comment() instance from scratch and filled 
it all with the correct data, but it seemed to me like a hack, bypassing 
all the security checks built-in in the comment package.

How would I go about to save a comment programmatically from my custom 
view/form?

Thanks,
Martin.

-- 
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/c2133f7d-8d5b-4460-a0c9-38c1f05c6290%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: JSON data

2015-05-07 Thread Tim Chase
On 2015-05-07 22:32, Thorsten Sanders wrote:
> Am 07.05.2015 17:37, schrieb Tim Chase:
>> Can you provide sample JSON data that others can use
>> for testing?  Which version of Python are you using and which
>> Python JSON library are you using?
>
> The version of python can make quite a big difference, years ago
> with python 2.6 I had the problem that decoding several megabyte of
> json data took over 1 minute with the integrated one, simplejson
> fixed that (only took a few hundred ms) and since 2.7 it works fine
> with the integrated one as well.

I remember there being various JSON libraries over time, and that
there were some performance issues in some of them (thus that bit of
my line of questioning) but didn't remember the particulars. Thanks
for filling in the details.

-tkc



-- 
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/20150507154248.5cd89434%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Re: JSON data

2015-05-07 Thread Thorsten Sanders

Am 07.05.2015 17:37, schrieb Tim Chase:

On 2015-05-07 13:56, palansh agarwal wrote:

processing of json is slow. It takes considerable amount of time to
process data after calling the API.

You seem fairly confident in this.  Do you have the timing
statistics?  Can you provide sample JSON data that others can use
for testing?  Which version of Python are you using and which Python
JSON library are you using?

-tkc



The version of python can make quite a big difference, years ago with 
python 2.6 I had the problem that decoding several megabyte of json data 
took over 1 minute with the integrated one, simplejson fixed that (only 
took a few hundred ms) and since 2.7 it works fine with the integrated 
one as well.


--
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/554BCBCB.2000703%40gmx.net.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.8 and wsgi_mod

2015-05-07 Thread Abhaya Agarwal
On Tue, Apr 28, 2015 at 9:40 PM, dk  wrote:

> I check the apache httpd log  and do get this
>
> [Tue Apr 28 10:33:49.982311 2015] [:error] [pid 18060] [client
> 10.35.0.91:61408] from django.apps import apps
> [Tue Apr 28 10:33:49.982336 2015] [:error] [pid 18060] [client
> 10.35.0.91:61408] ImportError: No module named apps
> [Tue Apr 28 10:33:52.595973 2015] [:error] [pid 18061] [client
> 10.35.0.91:61410] mod_wsgi (pid=18061):
> Target WSGI script '/code/projects/my_web/wsgi/my.wsgi' cannot be loaded
> as Python module.
> [Tue Apr 28 10:33:52.596033 2015] [:error] [pid 18061] [client
> 10.35.0.91:61410] mod_wsgi (pid=18061):
> Exception occurred processing WSGI script
> '/code/projects/my_web/wsgi/my.wsgi'.
>
> I think is the No module named apps is causing this =(
>
It certainly is. It is hard to say anything more without looking at the
actual code/setup. But since runserver works, perhaps your production
environment is pointing to an older version of Django?

Regards,
Abhaya

-- 
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/CAFPF63SGNtRKwaWThd%2BS47dz9joGxqfg%3D%2BXuB4UOfKr0g0Erbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I debug 400 errors that arise from turning off debug mode?

2015-05-07 Thread Thomas Levine
Well this is neat. Following the advice of Collin Anderson,
https://groups.google.com/d/msg/django-users/d_aWdw_AhH0/424ABkRajaoJ

I removed the LOGGING stuff, which wasn't that interesting anyway.
And then the exception emails started appearing!

I got this,

> Invalid HTTP_HOST header: 'localhost:8000'. You may need to add
> 'localhost' to ALLOWED_HOSTS.

which was a surprise to me because I already had 'localhost:*' in
my settings, but I switched it and it indeed worked on the development
server. For example, this returned the admin login page.

curl 'http://localhost:8000/admin/login/?next=/admin/'

But it still didn't work with the Apache server. ('scott.dada.pink',
the host that Apache watches for, had always been in ALLOWED_HOSTS.)
So I removed 'localhost' from ALLOWED_HOSTS and tried this.

curl -H 'host: scott.dada.pink' 
'http://localhost:8000/admin/login/?next=/admin/'

It returned the same web page, even though the host was not in
ALLOWED_HOSTS. I guess the development server does not care about
ALLOWED_HOSTS?

curl -H 'host: scott.dada.pink' 
'http://localhost:8000/admin/login/?next=/admin/'

Unfortunately, while email works with the development server,
it does not work on the production server, and I have yet to figure
out why.

On 07 May 13:43, Thomas Levine wrote:
> Hi,
> 
> Every page on my site returns a status code of 400 when I set
> `debug = False` in my settings file, and this doesn't happen
> if I switch it to `True`. How can I determine what is going wrong?
> 
> I have not managed to find it in the Django loggers (through email
> or through a custom logging facility), the console output of the
> development server, nor the logs of the production server (Apache).
> Well I do see it in the development server output, but only as this:
> 
> [07/May/2015 13:38:38]"GET /admin/ HTTP/1.0" 400 0
> 
> In case I should be able to find the issue in those places and I
> am just doing something wrong, here are my settings.
> http://dada.pink/scott2/scott2/settings.py
> 
> I believe that neither the `settings.py` nor even `wsgi.py` files
> are being run, as adding the following lines to their tops did not
> produce `settings.pyabc` nor `wsgi.pyabc`, respectively.
> 
> with open(__file__ + 'abc', 'w') as fp:
> fp.write('abc')
> 
> Thanks
> 
> 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/20150507134350.GA25982%40d1stkfactory.
> For more options, visit https://groups.google.com/d/optout.

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


Re: JSON data

2015-05-07 Thread Tim Chase
On 2015-05-07 13:56, palansh agarwal wrote:
> processing of json is slow. It takes considerable amount of time to
> process data after calling the API.

You seem fairly confident in this.  Do you have the timing
statistics?  Can you provide sample JSON data that others can use
for testing?  Which version of Python are you using and which Python
JSON library are you using?

-tkc



-- 
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/20150507103749.042807d9%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Re: Admin site in Django 1.8 tutorial giving CSRF errors

2015-05-07 Thread David Riddle
No I have not made any changes to the admin templates. I simply
followed the instructions in the tutorial. I am using Django's
runserver per the tutorial instructions. I am totally stumped.

David

On Thu, May 7, 2015 at 3:04 AM, aRkadeFR  wrote:
> Hey,
>
> You shouldn't see these errors since the templates with the form
> and so the CSRF token are generated from the contrib app admin.
>
> Could you provide us more details of the error? Did you override
> the admin templates?
>
> Thanks,
>
> aRkadeFR
>
>
> On 05/06/2015 10:03 PM, David Riddle wrote:
>>
>> Hi,
>>
>> I am working through the Django 1.8 tutorial. I finished part one and
>> am starting on part 2. I created an admin user but when I login to the
>> /admin page I receive a 403 Error because CSRF verification failed.
>>
>> https://docs.djangoproject.com/en/1.8/intro/tutorial02/
>>
>> Any idea what the problem is?
>>
>> Thanks,
>>
>> David R.
>>
>
> --
> aRkadeFR
>
> --
> 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/554B1CA7.2090800%40arkade.info.
> For more options, visit https://groups.google.com/d/optout.



-- 
Always code as if the (person) who ends up maintaining your code will
be a violent psychopath who knows where you live.
 - M. Golding

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


Re: Sending Data from client side(another computer) to Django(my computer) using Socket library

2015-05-07 Thread Thomas Levine
On 07 May 16:00, steve malise wrote:
> The error comes when i runserver and send data from another computer to
> django,then i get this "code 400, message Bad request syntax ( data from
> another computer)"

This is because

On 07 May 11:42, Tom Evans wrote:
> Eurgh. Your hand-crafted HTTP request is not a valid request. Use one
> of the http libraries built in to python:

You can find here some directions on forming the request validly, 
http://www.w3.org/Protocols/Specs.html

as you apparently don't want to use any of the libraries below.

On 07 May 16:00, steve malise wrote:
> urllib2:
> https://docs.python.org/2/howto/urllib2.html#data
> 
> httplib:
> https://docs.python.org/2/library/httplib.html#examples
> 
> or use a 3rd party library that wraps those in a more pleasing interface:
> 
> requests:
> http://docs.python-requests.org/en/latest/

Using one of the above-listed libraries would still accomplish what you
are trying to do, as you described here,

On 07 May 16:00, steve malise wrote:
> What i am trying to do is run python script(client side) on another
> computer which is on same network with my computer,then receive data from
> another computer with the django(which is running on my computer(server
> side)).i am using built-in "runserver".

so I suspect that you are doing something more that we missed. Perhaps
you could tell us why you want to do 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+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/20150507141332.GA27942%40d1stkfactory.
For more options, visit https://groups.google.com/d/optout.


Re: Sending Data from client side(another computer) to Django(my computer) using Socket library

2015-05-07 Thread steve malise
What i am trying to do is run python script(client side) on another
computer which is on same network with my computer,then receive data from
another computer with the django(which is running on my computer(server
side)).i am using built-in "runserver".

The error comes when i runserver and send data from another computer to
django,then i get this "code 400, message Bad request syntax ( data from
another computer)"



On Thu, May 7, 2015 at 3:28 PM, Tom Evans  wrote:

> On Thu, May 7, 2015 at 12:48 PM, steve malise 
> wrote:
> > where can i write web server?
> >
>
> Why do you want to?
>
> Django is a web application, it is hosted inside webservers, typically
> using WSGI. Typically, you would use one of the many webservers that
> can host wsgi applications - nginx, apache+mod_wsgi, uwsgi, chaussette
> and many many others. You can also use the built-in "runserver"
> webserver for development.
>
> If you want to write your own webserver for your own edification, the
> wsgiref library is built in to python to provide a reference
> implementation.
>
> 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/CAFHbX1LKc_%2BBW_8JakpFLPOiZ%2BM07YwemFTZ1AH%2Bmk_TH8j42g%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Sending Data from client side(another computer) to Django(my computer) using Socket library

2015-05-07 Thread Tom Evans
On Thu, May 7, 2015 at 3:00 PM, steve malise  wrote:
> What i am trying to do is run python script(client side) on another computer
> which is on same network with my computer,then receive data from another
> computer with the django(which is running on my computer(server side)).i am
> using built-in "runserver".
>
> The error comes when i runserver and send data from another computer to
> django,then i get this "code 400, message Bad request syntax ( data from
> another computer)"
>

Write a simple django view like this:

  def myview(request):
return HttpResponse(request.raw_post_data)

In your client python script, use one of the libraries I mentioned, eg requests:

  import requests
  req = requests.post('http://hostname/url', data='hello world')
  print req.text

Go from there..

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/CAFHbX1K0Heb94TcrWRo-yEsf%2BM04bMWRKH-rLRasreWrJEr21A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Little trouble with migration.

2015-05-07 Thread Markus Holtermann
No need to apologize. If you think there is anything we can / should add to 
Django's documentation that would have either helped you to figure out the 
issue or that had prevented you from running into the issue in the first 
place, please go ahead and open an issue at https://code.djangoproject.com/ 

/Markus

On Thursday, May 7, 2015 at 3:24:47 PM UTC+2, Алексей Широков wrote:
>
> Oh thank you very much for the clarification. 
> I understood in what there was a mistake. And I apologize for my 
> carelessness.
>
> 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/a642c938-df53-4001-ba1f-0594a93376fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Does loaddata script supports loading data from JSON files to Cassandra database?

2015-05-07 Thread aravind pogu
I have a requirement to load data into cassandra db from my JSON file using 
Django framework. As far as I know, "manage.py loaddata" only works for 
relational databases but not for NoSQL class databases. Is there any script 
similar to loaddata and dumpdata for loading and dumping data from/to 
cassandra DB from/to JSON files using django framework?

-- 
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/425f5df3-4613-4755-9c97-04f44f5820ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: JSON data

2015-05-07 Thread Thomas Levine
> which part is slow?  the API, the processing of the JSON, or the
> display?

And here's how you can check that. Insert the following line between
the different steps that Tim itemized,

print(time.perf_counter())

subtract the numbers that get printed, and then determine which step
is slow.

Alternatively, if your code is written very cleanly, you can use timeit.
https://docs.python.org/3/library/timeit.html

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/20150507135234.GA27152%40d1stkfactory.
For more options, visit https://groups.google.com/d/optout.


How do I debug 400 errors that arise from turning off debug mode?

2015-05-07 Thread Thomas Levine
Hi,

Every page on my site returns a status code of 400 when I set
`debug = False` in my settings file, and this doesn't happen
if I switch it to `True`. How can I determine what is going wrong?

I have not managed to find it in the Django loggers (through email
or through a custom logging facility), the console output of the
development server, nor the logs of the production server (Apache).
Well I do see it in the development server output, but only as this:

[07/May/2015 13:38:38]"GET /admin/ HTTP/1.0" 400 0

In case I should be able to find the issue in those places and I
am just doing something wrong, here are my settings.
http://dada.pink/scott2/scott2/settings.py

I believe that neither the `settings.py` nor even `wsgi.py` files
are being run, as adding the following lines to their tops did not
produce `settings.pyabc` nor `wsgi.pyabc`, respectively.

with open(__file__ + 'abc', 'w') as fp:
fp.write('abc')

Thanks

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/20150507134350.GA25982%40d1stkfactory.
For more options, visit https://groups.google.com/d/optout.


Re: Sending Data from client side(another computer) to Django(my computer) using Socket library

2015-05-07 Thread Tom Evans
On Thu, May 7, 2015 at 12:48 PM, steve malise  wrote:
> where can i write web server?
>

Why do you want to?

Django is a web application, it is hosted inside webservers, typically
using WSGI. Typically, you would use one of the many webservers that
can host wsgi applications - nginx, apache+mod_wsgi, uwsgi, chaussette
and many many others. You can also use the built-in "runserver"
webserver for development.

If you want to write your own webserver for your own edification, the
wsgiref library is built in to python to provide a reference
implementation.

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/CAFHbX1LKc_%2BBW_8JakpFLPOiZ%2BM07YwemFTZ1AH%2Bmk_TH8j42g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Little trouble with migration.

2015-05-07 Thread Алексей Широков
Oh thank you very much for the clarification. 
I understood in what there was a mistake. And I apologize for my 
carelessness.

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/62b63cf0-6d1a-4929-b3e2-a3b7e82af582%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Little trouble with migration.

2015-05-07 Thread Markus Holtermann
Hey there,

app labels (i.e. what you specify in your AppConfig or in AUTH_USER_MODEL) 
are case sensitive. Thus either change AccountConfig.label to "account" 
(this affects all migrations that depend on your account app) or 
AUTH_USER_MODEL to "Account.User". I'd recommend to use lower case app 
labels

/Markus

On Thursday, May 7, 2015 at 11:39:16 AM UTC+2, Алексей Широков wrote:
>
> I have custom user model.
>
> settings.py
> ---
> ...
> AUTH_USER_MODEL = 'account.User'
> ...
>
>
> also I have following AppConfig
>
> account/apps.py
> ---
>
> class AccountConfig(AppConfig):
> name = 'isar.account'
> *label = 'Account'*
> verbose_name = 'Аккаунт'
>
>
> and when I call command migrate I get the following exception:
>
> ...
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 120, in call_command
>   return command.execute(*args, **defaults)
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 441, in execute
>   output = self.handle(*args, **options)
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>  
> line 93, in handle
>   executor = MigrationExecutor(connection, 
> self.migration_progress_callback)
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/executor.py",
>  
> line 19, in __init__
>   self.loader = MigrationLoader(self.connection)
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
>  
> line 47, in __init__
>   self.build_graph()
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
>  
> line 287, in build_graph
>   parent = self.check_key(parent, key[0])
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
>  
> line 165, in check_key
>   raise ValueError("Dependency on unknown app: %s" % key[0])
> ValueError: Dependency on unknown app: account
>
> I think that the problem here 
> https://github.com/django/django/blob/stable/1.8.x/django/db/migrations/migration.py#L178
>

-- 
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/200c62a7-7c59-4962-bd02-5a4a0b65051a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Two projects fail to import the same main app when I turn on both in Apache

2015-05-07 Thread Thomas Levine
Indeed! Thanks

Tom

On 05 May 13:49, Tom Evans wrote:
> On Tue, May 5, 2015 at 10:32 AM, Thomas Levine <_...@thomaslevine.com> wrote:
> > Hi,
> >
> > For like the first time ever I want to make complicated websites,
> > so using Django finally seems like a good idea. And it is! All the
> > small building blocks that I had never thought of are already here.
> > Anyway, the part that's relevant to my present concern is that I
> > haven't deployed Django many times before and thus don't really know
> > what I'm doing.
> >
> > I have two sites that I want to host on the same computer.
> > I have root access on this computer. The two sites are called
> > "dadaportal", which is on https://thomaslevine.com, and "scott",
> > which is on http://scott.dada.pink.
> >
> > I also have a bunch of other sites configured in Apache, but
> > none of those uses wsgi or even Python.
> >
> > Both sites work fine if I disable the other. Here is what its
> > configuration looks like.
> > http://big.dada.pink/010-dadaportal.conf
> > http://dada.pink/dadaportal/dadaportal/wsgi.py
> > http://dada.pink/dadaportal/dadaportal/settings.py
> >
> > And here is the other.
> > http://big.dada.pink/015-scott.conf
> > http://dada.pink/scott2/scott2/wsgi.py
> > http://dada.pink/scott2/scott2/settings.py
> >
> > I have problem when I try to run both at the same time.
> 
> You're missing the process-group argument from WSGIScriptAlias so it
> tries to run both of them in the default process group.
> 
> https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/#using-mod-wsgi-daemon-mode
> 
> 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/CAFHbX1%2B7ag9RiJrQ6dUPzADOss5dN2zWxrmpH3zHkF%2BsCP-eNQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Sending Data from client side(another computer) to Django(my computer) using Socket library

2015-05-07 Thread steve malise
where can i write web server?


On Thu, May 7, 2015 at 12:42 PM, Tom Evans  wrote:

> On Thu, May 7, 2015 at 9:24 AM, steve malise  wrote:
> >
> > client side code:
> > data = "message"
> > try:
> > clsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > clsocket.connect(('192.168.2.2', 8000))
> > print("Connection has been Made")
> > clsocket.send("POST / HTTP/1.1 "+ data)
> > clsocket.close()
> > except:
> > print("ERROR:Connection is not established")
>
> Eurgh. Your hand-crafted HTTP request is not a valid request. Use one
> of the http libraries built in to python:
>
> urllib2:
> https://docs.python.org/2/howto/urllib2.html#data
>
> httplib:
> https://docs.python.org/2/library/httplib.html#examples
>
> or use a 3rd party library that wraps those in a more pleasing interface:
>
> requests:
> http://docs.python-requests.org/en/latest/
>
> >
> > Django code(view.py)
> >
> > def RandomValues(request):
> >
> > template = get_template('TIME TABLE.html')
> > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> > try:
> > s.bind(('192.168.2.2',8000))
> > s.listen(5)
> > socketList.append(s)
> > except:
> > return HttpResponse("Unable to bind ")
> >
> >
> >
> > while 1:
> > readyToread,readyTowrite,inError =
> select.select(socketList,[],[],1)
> > for sock in readyToread:
> >
> >  if sock == s:
> >   sockfd, addr = s.accept()
> >socketList.append(sockfd)
> >   else:
> >data = sock.recv(4096)
> >message = data.decode("utf-8")
> >
> > return HttpResponse(message)
>
> ?
>
> Why are you writing a webserver inside a view?
>
> 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/CAFHbX1%2BS_w9zCk_Af5wMXZABFM%3D6k40nRWfp9P1gonsT5BNDFQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Little trouble with migration.

2015-05-07 Thread Алексей Широков
Oh, sure!

INSTALLED_APPS = [
  ...
  'isar.account',
  'isar.account.auth',
  ...
]

-- 
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/dddfd204-1fed-470f-a568-8a565e9c5bd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Little trouble with migration.

2015-05-07 Thread SK
you have added to the installed_apps?

четверг, 7 мая 2015 г., 12:39:16 UTC+3 пользователь Алексей Широков написал:
>
> I have custom user model.
>
> settings.py
> ---
> ...
> AUTH_USER_MODEL = 'account.User'
> ...
>
>
> also I have following AppConfig
>
> account/apps.py
> ---
>
> class AccountConfig(AppConfig):
> name = 'isar.account'
> *label = 'Account'*
> verbose_name = 'Аккаунт'
>
>
> and when I call command migrate I get the following exception:
>
> ...
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 120, in call_command
>   return command.execute(*args, **defaults)
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 441, in execute
>   output = self.handle(*args, **options)
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>  
> line 93, in handle
>   executor = MigrationExecutor(connection, 
> self.migration_progress_callback)
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/executor.py",
>  
> line 19, in __init__
>   self.loader = MigrationLoader(self.connection)
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
>  
> line 47, in __init__
>   self.build_graph()
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
>  
> line 287, in build_graph
>   parent = self.check_key(parent, key[0])
> File 
> "/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
>  
> line 165, in check_key
>   raise ValueError("Dependency on unknown app: %s" % key[0])
> ValueError: Dependency on unknown app: account
>
> I think that the problem here 
> https://github.com/django/django/blob/stable/1.8.x/django/db/migrations/migration.py#L178
>

-- 
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/f6beb232-0bf5-44ed-8499-43ab267aacb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sending Data from client side(another computer) to Django(my computer) using Socket library

2015-05-07 Thread Tom Evans
On Thu, May 7, 2015 at 9:24 AM, steve malise  wrote:
>
> client side code:
> data = "message"
> try:
> clsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> clsocket.connect(('192.168.2.2', 8000))
> print("Connection has been Made")
> clsocket.send("POST / HTTP/1.1 "+ data)
> clsocket.close()
> except:
> print("ERROR:Connection is not established")

Eurgh. Your hand-crafted HTTP request is not a valid request. Use one
of the http libraries built in to python:

urllib2:
https://docs.python.org/2/howto/urllib2.html#data

httplib:
https://docs.python.org/2/library/httplib.html#examples

or use a 3rd party library that wraps those in a more pleasing interface:

requests:
http://docs.python-requests.org/en/latest/

>
> Django code(view.py)
>
> def RandomValues(request):
>
> template = get_template('TIME TABLE.html')
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> try:
> s.bind(('192.168.2.2',8000))
> s.listen(5)
> socketList.append(s)
> except:
> return HttpResponse("Unable to bind ")
>
>
>
> while 1:
> readyToread,readyTowrite,inError = select.select(socketList,[],[],1)
> for sock in readyToread:
>
>  if sock == s:
>   sockfd, addr = s.accept()
>socketList.append(sockfd)
>   else:
>data = sock.recv(4096)
>message = data.decode("utf-8")
>
> return HttpResponse(message)

?

Why are you writing a webserver inside a view?

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/CAFHbX1%2BS_w9zCk_Af5wMXZABFM%3D6k40nRWfp9P1gonsT5BNDFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Sending Data from client side(another computer) to Django(my computer) using Socket library

2015-05-07 Thread steve malise

client side code:
data = "message"
try:
clsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clsocket.connect(('192.168.2.2', 8000))
print("Connection has been Made")
clsocket.send("POST / HTTP/1.1 "+ data)
clsocket.close()   
except:
print("ERROR:Connection is not established")

Django code(view.py)

def RandomValues(request):

template = get_template('TIME TABLE.html')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
s.bind(('192.168.2.2',8000))
s.listen(5)
socketList.append(s)
except:
return HttpResponse("Unable to bind ")



while 1:
readyToread,readyTowrite,inError = select.select(socketList,[],[],1)
for sock in readyToread:
  
 if sock == s:
  sockfd, addr = s.accept()
   socketList.append(sockfd)
  else:
   data = sock.recv(4096)
   message = data.decode("utf-8")

return HttpResponse(message)

On my command prompt it says:
[07/May/2015 10:06:21]code 400, message Bad request syntax ('POST / 
HTTP/1.1 message')
[07/May/2015 10:06:21]"POST / HTTP/1.1 message" 400 -

Even if i remove "POST / HTTP/1.1",i still get this error 

please help i am new to 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/12ab40fa-b80f-4f35-ab5a-75530e9eca03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Little trouble with migration.

2015-05-07 Thread Алексей Широков
I have custom user model.

settings.py
---
...
AUTH_USER_MODEL = 'account.User'
...


also I have following AppConfig

account/apps.py
---

class AccountConfig(AppConfig):
name = 'isar.account'
*label = 'Account'*
verbose_name = 'Аккаунт'


and when I call command migrate I get the following exception:

...
File 
"/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 120, in call_command
  return command.execute(*args, **defaults)
File 
"/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 441, in execute
  output = self.handle(*args, **options)
File 
"/var/venvs/isar-future/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
 
line 93, in handle
  executor = MigrationExecutor(connection, self.migration_progress_callback)
File 
"/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 19, in __init__
  self.loader = MigrationLoader(self.connection)
File 
"/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
 
line 47, in __init__
  self.build_graph()
File 
"/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
 
line 287, in build_graph
  parent = self.check_key(parent, key[0])
File 
"/var/venvs/isar-future/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
 
line 165, in check_key
  raise ValueError("Dependency on unknown app: %s" % key[0])
ValueError: Dependency on unknown app: account

I think that the problem here 
https://github.com/django/django/blob/stable/1.8.x/django/db/migrations/migration.py#L178

-- 
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/82ddf759-57f0-418d-9e3f-959a87f88491%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Tasty pie reutrns 401 unauthorized even when i commented out authorization and authentication

2015-05-07 Thread Anubhav Kaushik
i added 
v1_api.register(ArtistResource()) 
in my main url 


and this is the code in meta class 

 class Meta:
queryset = Artist.objects.all()
resource_name = 'artist'
#authentication = Authentication()
   # authorization = Authorization()
excludes = ['rating', 'override_rating', 'force_inclusion']
allowed_methods = ['get','post']
aklogger.info(Artist.objects.all)

-- 
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/36a8ccd7-f136-4baa-bff3-d80b6db4898c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at /polls/1/results/

2015-05-07 Thread James Schneider
I'm guessing the issue is actually in your template if you are following
along that page. None of the code in your views would generate that error
from what I can see.

The error indicates that you are trying to reverse('polls:detail') and not
providing any arguments for the URL resolver (or are passing an
empty/missing variable). In the template, this would probably look
something like {% url 'polls:detail' %}. I would guess that you are
forgetting question.id after the view name, assuming you are using the same
variable names as the tutorial.

Check near the bottom of the stack trace on the page, I bet it has a {% url
%} tag highlighted as the culprit.

-James
On May 7, 2015 12:09 AM, "H M"  wrote:

> I am on part 4 django tutorial. The tutorial is very good and I easily get
> on part 4 but
>
> I get error: Reverse for 'detail' with arguments '('',)' and keyword
> arguments '{}' not found. 1 pattern(s) tried:
> [u'polls/(?P\\d+)/$']
>
> Am I missing something?
>
> My code is following:
>
> urlpatterns = patterns('',
>> url(r'^$', views.index, name='index'),
>> url(r'^(?P\d+)/$', views.detail, name='detail'),
>> url(r'^(?P\d+)/results/$',views.results, name='results'),
>> url(r'^(?P\d+)/vote/$', views.vote, name='vote'),
>>
>
>
> views.py:
>
> from django.shortcuts import get_object_or_404, render
>> from django.http import HttpResponseRedirect, HttpResponse
>> from django.template import RequestContext, loader
>> from polls.models import Question, Choice
>> from django.http import Http404
>> from django.core.urlresolvers import reverse
>>
>>
>> def index(request):
>> latest_question_list =  Question.objects.order_by('-pub_date')[:5]
>> template = loader.get_template('polls/index.html')
>> context = RequestContext(request, {'latest_question_list' :
>> latest_question_list, })
>> return HttpResponse(template.render(context))
>>
>> def detail(request, question_id):
>> try:
>> question = Question.objects.get(pk = question_id)
>> except Question.DoesNotExist:
>> raise Http404("Question ne postoji")
>> return render(request, 'polls/detail.html', {'question': question})
>>
>> def results(request, question_id):
>> question = get_object_or_404(Question, pk = question_id)
>> return render(request, 'polls/results.html', {'guestion': question})
>>
>>
>> def vote(request, question_id):
>> p = get_object_or_404(Question, pk=question_id)
>> try:
>> selected_choice  = p.choice_set.get(pk=request.POST['choice'])
>> except (KeyError, Choice.DoesNotExist):
>> return render(request, 'polls/detail.html', {
>> 'question': p,
>> 'error_message': "Nijesi izabrao pitanje.",
>>  })
>> else:
>> selected_choice.votes += 1
>> selected_choice.save()
>> return HttpResponseRedirect(reverse('polls:results', args=(p.id
>> ,)))
>>
>
>
>
>
>
>  --
> 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/2e2320f1-6813-4e01-8b32-76694dbd22f8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Admin site in Django 1.8 tutorial giving CSRF errors

2015-05-07 Thread aRkadeFR

Hey,

You shouldn't see these errors since the templates with the form
and so the CSRF token are generated from the contrib app admin.

Could you provide us more details of the error? Did you override
the admin templates?

Thanks,

aRkadeFR

On 05/06/2015 10:03 PM, David Riddle wrote:

Hi,

I am working through the Django 1.8 tutorial. I finished part one and
am starting on part 2. I created an admin user but when I login to the
/admin page I receive a 403 Error because CSRF verification failed.

https://docs.djangoproject.com/en/1.8/intro/tutorial02/

Any idea what the problem is?

Thanks,

David R.



--
aRkadeFR

--
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/554B1CA7.2090800%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Choosing an auth module: Login via Facebook, Google, ...

2015-05-07 Thread guettli

I guess I will try django-allauth. Looks like it is easier to integrate.

thank you for reply.
  Thomas Güttler


Am Mittwoch, 6. Mai 2015 13:23:30 UTC+2 schrieb Filipe Ximenes:
>
> I have some experience with python-social-auth. 
> https://github.com/omab/python-social-auth
> It's a very good tool, well maintained, and with good support. The problem 
> with it, is that it's a generic package, it works with a lot of frameworks 
> and ORM configurations and this turns it a bit complicated to get started. 
> But also because of this, it's very customisable. 
> If you are willing to spend some time studying the lib, this is a very 
> good and powerful choice.
>
> On Wed, May 6, 2015 at 3:45 AM, rush  
> wrote:
>
>> Hi,
>>  
>> What kind of issues do you have?
>>
>> It should support 1.8 now. You can even check that support request for 
>> 1.8 is already closed at github (
>> https://github.com/pennersr/django-allauth/issues/858).
>>  
>> -- 
>> wbr,
>> rush.
>>  
>>  
>>  
>> 06.05.2015, 09:17, "guettli" :
>>
>> I need a library to let users loging via Facebook, Google, ...
>>
>> I looked at this page:
>>
>> https://www.djangopackages.com/grids/g/authentication/
>>
>> It's hard for me to decide which one to use.
>>
>> I have no special requirements except the end user experience should be 
>> good.
>> The login for new users should be as simple as possible.
>>
>> Can you give me an advice?
>>
>> I tried django-all-auth, but it has issues with Django 1.8
>>
>>
>>  
>> -- 
>> 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/f365689f-73a2-4934-b64b-7963f9671bc6%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/5628571430894754%40web12j.yandex.ru
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>   
>
> *Filipe Ximenes*+55 (81) 8245-9204
>
> *Vinta Software Studio*http://www.vinta.com.br
>  

-- 
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/6f0a8b3e-ca84-4bc2-ba92-3472ce47a562%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


NoReverseMatch at /polls/1/results/

2015-05-07 Thread H M
I am on part 4 django tutorial. The tutorial is very good and I easily get 
on part 4 but

I get error: Reverse for 'detail' with arguments '('',)' and keyword 
arguments '{}' not found. 1 pattern(s) tried: 
[u'polls/(?P\\d+)/$']

Am I missing something?

My code is following:

urlpatterns = patterns('',
> url(r'^$', views.index, name='index'),
> url(r'^(?P\d+)/$', views.detail, name='detail'),
> url(r'^(?P\d+)/results/$',views.results, name='results'),
> url(r'^(?P\d+)/vote/$', views.vote, name='vote'),
>


views.py:

from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponseRedirect, HttpResponse 
> from django.template import RequestContext, loader
> from polls.models import Question, Choice
> from django.http import Http404
> from django.core.urlresolvers import reverse
>
>
> def index(request):
> latest_question_list =  Question.objects.order_by('-pub_date')[:5]
> template = loader.get_template('polls/index.html') 
> context = RequestContext(request, {'latest_question_list' : 
> latest_question_list, })
> return HttpResponse(template.render(context))
>
> def detail(request, question_id):
> try:
> question = Question.objects.get(pk = question_id)
> except Question.DoesNotExist:
> raise Http404("Question ne postoji") 
> return render(request, 'polls/detail.html', {'question': question})
>
> def results(request, question_id):
> question = get_object_or_404(Question, pk = question_id) 
> return render(request, 'polls/results.html', {'guestion': question})
>
>
> def vote(request, question_id):
> p = get_object_or_404(Question, pk=question_id)
> try:
> selected_choice  = p.choice_set.get(pk=request.POST['choice'])
> except (KeyError, Choice.DoesNotExist):
> return render(request, 'polls/detail.html', {
> 'question': p,
> 'error_message': "Nijesi izabrao pitanje.",
>  })
> else:
> selected_choice.votes += 1
> selected_choice.save()
> return HttpResponseRedirect(reverse('polls:results', args=(p.id,)))
>





-- 
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/2e2320f1-6813-4e01-8b32-76694dbd22f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.