Problem with staticfiles

2013-07-03 Thread Andreas Kuhne
Hi all,

I am trying to CachedStaticFilesStorage to work in our environment. I have
been able to configure all of the settings, and am able to copy all static
files (we have alot of them) to the correct location. However when the
postprocessing starts and the MD5 hashes are being calculated it fails with
an exception:
ValueError: The file
'extjs/resources/css/images/default/editor/tb-sprite.gif' could not be
found with .

This is because it is going through the css files trying to rewrite the url
parts to add the MD5 hash. I have looked in the CSS files and all of the
url calls are using relative paths, but it seems as though the rewrite
process is forgetting to add the "../" part. The path that is in the error
is a concatenation of the path where the CSS resides (extjs/resources/css)
and the url (../images/default/editor), but it seems that the ../ is being
omitted somehow. I have checked and tested the code for traversing the css
files in a python shell and it works there. But it fails both on my
development machine and the staging server.

Has anyone had the same issues and knows what to do?

Regards,

Andréas

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




Re: Integrating Django with Trac

2013-07-03 Thread saintger
Le mardi 2 juillet 2013 18:37:27 UTC+2, sain...@gmail.com a écrit :
>
> Hello,
>
> I would like to make a website with Django and manage the issues with Trac.
> I can see that the Django website currently do the same (so it must be a 
> good idea !).
>
> I've found the following thread:
> https://groups.google.com/d/topic/django-users/OD3rP_iAUc0/discussion
>
> But I would like to know what is the current best approach to manage the 
> authentication and to have a unified beautiful website (i.e same visual and 
> look and feel for the website part and the issue tracking part).
>
> It seems that using twod.wsgi (http://pythonhosted.org/twod.wsgi/) may be 
> a good approach ?
>
> So basically I would like to know how the Django website manage to 
> integrate Trac and if their way to do that is the current best way ! ;-)
>
>
Answering my own question: it seems that Djangoproject doesn't manage the 
login but just redirect to a Trac instance (code.djangoproject.com) which 
manage the login. So Trac is not really "integrated" into Djangoproject.

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




Form validation vs. DRY

2013-07-03 Thread Roman Klesel
Hello,

I'm programming a database front end. In many cases I want to
constrain the data written to the database. Therefore I implement some
checks either through real database constraints or trough some logic
in the model, so it will throw an exception when the constraints are
not met.

e.g.: unique constraint on a database column.

Now, when I write my form validation, I have to implement the same
logic again, since form validation takes place before a save() is even
considered. Like this:

>>> if form.is_valid():
>>>form.save()

Is there a better way to do it? Is there a good way to avoid this
duplicate logic?

Regards
  Roman

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




Re: Form validation vs. DRY

2013-07-03 Thread Tomas Ehrlich
Hi Roman,
you can use model validation
https://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects

It works similar to form validation. After, when you create ModelForm,
it will take validation rules from model.

All these validations should be called outside save()


Cheers,
  Tom

Dne Wed, 3 Jul 2013 10:21:51 +0200
Roman Klesel  napsal(a):

> Hello,
> 
> I'm programming a database front end. In many cases I want to
> constrain the data written to the database. Therefore I implement some
> checks either through real database constraints or trough some logic
> in the model, so it will throw an exception when the constraints are
> not met.
> 
> e.g.: unique constraint on a database column.
> 
> Now, when I write my form validation, I have to implement the same
> logic again, since form validation takes place before a save() is even
> considered. Like this:
> 
> >>> if form.is_valid():
> >>>form.save()
> 
> Is there a better way to do it? Is there a good way to avoid this
> duplicate logic?
> 
> Regards
>   Roman
> 

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




Re: Form validation vs. DRY

2013-07-03 Thread Roman Klesel
2013/7/3 Tomas Ehrlich :

> you can use model validation
> https://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects


This sounds very good! :-)

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




Re: nginx and apache

2013-07-03 Thread Kakar Arunachal Service
Thanks Rafael!


On Wed, Jul 3, 2013 at 12:08 AM, Rafael E. Ferrero  wrote:

> https://code.djangoproject.com/wiki/DjangoAndNginx
> http://wiki.nginx.org/DjangoFastCGI
>
> its a start. ;)
>
>
> 2013/7/2 Kakar Arunachal Service 
>
>> Can you please suggest any good tutorial regarding this. And i'm on
>> windows. :(
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Rafael E. Ferrero
> Claro: (03562) 15514856
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Exception Value: Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not found.

2013-07-03 Thread Pepsodent Cola
I just double checked.  A month ago I followed the Django Polls tutorial to 
the point and all of the above worked.

But the second time I followed the Polls tutorial I used different Model 
names such as *"class Citizen_voice(models.Model)"* instead of the 
tutorials table name.

class Poll(models.Model):


Will my underscore table naming convention cause problems with *"Generic 
views"* usage?







On Wednesday, July 3, 2013 12:37:50 AM UTC+2, Pepsodent Cola wrote:
>
> Hi,
>
> 1.)
> When following the Django 1.5 poll tutorial everything works ok.  Until I 
> try to implement the *"Generic views"* to use less code in the poll, then 
> the poll app breaks.
>
> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#use-generic-views-less-code-is-better
>
>
> 2.)
> When go to this link in my web browser, then I get the following error 
> message.
> http://localhost:8000/polls/specifics/2/
>
> Exception Value: 
>
> Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not 
> found.
>
>
>
> 3.)
> *Error during template rendering*
> /mysite/polls/templates/polls/detail.html, *error at line 6*
>
> http://pastebin.com/4HSt1VyS
>
>
>{{ poll.question }}
> 
>{% if error_message %}{{ error_message }}{% 
>endif %}
> 
>**
>**
>{% csrf_token %}
>{% for choice in poll.choice_set.all %}
>="{{ choice.id }}" />
>{{ choice.choice_text }}<
>/label>
>{% endfor %}
>
>
>
>
> 4.)
> Which files do I need to edit when refactoring the old working code to the 
> "Generic views" code?
>
> I have already edited *"polls/urls.py"*.
> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-urlconf
>
> And I have edited *"polls/views.py"*
> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-views
>
> And I tried to edit *"detail.html"* template file as described at point 
> 3.) but I still get the same error message.
> *Error during template rendering*
> /mysite/polls/templates/polls/detail.html, *error at line 6*
> *
> *
>

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




Re: can we pass objects in template tags

2013-07-03 Thread Christian Erhardt
Maybe this will help you? 

http://stackoverflow.com/questions/6400557/how-can-i-pass-objects-to-a-custom-django-template-tag-i-figured-out-a-way-but

A Filter will support objects, don't use template tags.

Am Mittwoch, 3. Juli 2013 00:24:55 UTC+2 schrieb surya:
>
> I would like to pass object into template tag, then process it.. Is it 
> possible
>
> def my_tag(parser, token):
>return Node()
>
> The token object seems to be a string!! but how to get some objects??
>
>

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




Custom Authentication

2013-07-03 Thread adroit . goose
Hello,

I am a newbie to Django and would wish to know if it possible to use the 
authentication scheme(from django.contrib import auth) on a custom made 
'Company_user' table.
I don't want to use the default User object provided by Django admin as the 
fields in the custom table are different. How should I go about it?.

Thanks,
Goose.
  

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




Extending Django Admin functionality

2013-07-03 Thread adroit . goose

   
   Hello,
   


   I am a newbie to Django and would like to know if the functionality of 
   Django admin can be extended to my own needs.
   If it is possible, is it a good idea extend the functionality or start 
   from 
   scratch. Is there any good documentation for the same?.
   Thanks for your time.

   --
   Goose.

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




Re: can we pass objects in template tags

2013-07-03 Thread Tom Evans
On Tue, Jul 2, 2013 at 11:24 PM, surya  wrote:
> I would like to pass object into template tag, then process it.. Is it
> possible
>
> def my_tag(parser, token):
>return Node()
>
> The token object seems to be a string!! but how to get some objects??
>

https://docs.djangoproject.com/en/1.5/howto/custom-template-tags/#passing-template-variables-to-the-tag

Docs
  -> "The Template Layer"
-> "Custom template tags and filters"
  -> "Passing template variables to the tag"

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




Error when loading application server

2013-07-03 Thread Hélio Miranda
Hi
I have a Django application, I am using the tastypie too.
What happens when meth is my application server, I get this error on a page:

*"error_message": "invalid literal for int() with base 10: ''"*


Someone can explain me why?

What do I fix?

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




django-simple-multitenant

2013-07-03 Thread Nigel Legg
I am building an app to, among other things, allow people to upload data
files and carry out various analyses online.  I would like each user to
only see the datafiles that they or members of their team (company,
research team, etc) have uploaded.
It seems that 
django-simple-multitenantwould
be appropriate for this.  Are there any problems in using this, or
other apps that would be easier to implement?
Cheers N//

Regards,
Nigel Legg
07914 740972
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg

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




Django, python, MYSQL, Eclipse3.7

2013-07-03 Thread Vamsi Popuri
I have 2 projects. They are* project 1* and *project 2*.

 *Project 2* has 
*models.py*
 class Address(models.Model):
Street = models.CharField(max_length=50)   
pin = models.CharField(max_length=20)

*forms.py *
 class Address(forms.Form):
   ..

My question is, In *project 1* i wanna access Address model in the *project 
2*Is it possible, then please let me know how to do ..

Thanks for advance

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




Re: Error when loading application server

2013-07-03 Thread Tom Christie
Hi Helio,

  Something somewhere is expecting an integer but receiving an empty string 
instead.
This could be the result of a missing component in the URL eg 
`http://example.com/users//`,
or a field in a JSON or form data request that's missing a value, eg:

{
  "score": ""
  ...
}

Hope that helps.

  Tom

On Wednesday, 3 July 2013 13:13:35 UTC+1, Hélio Miranda wrote:
>
> Hi
> I have a Django application, I am using the tastypie too.
> What happens when meth is my application server, I get this error on a 
> page:
>
> *"error_message": "invalid literal for int() with base 10: ''"*
>
>
> Someone can explain me why?
>
> What do I fix?
>

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




Re: Custom Authentication

2013-07-03 Thread Sandro Dutra
You can extend the User Model:
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model


2013/7/3 

> Hello,
>
> I am a newbie to Django and would wish to know if it possible to use the
> authentication scheme(from django.contrib import auth) on a custom made
> 'Company_user' table.
> I don't want to use the default User object provided by Django admin as
> the fields in the custom table are different. How should I go about it?.
>
> Thanks,
> Goose.
>
>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django dynamic template tag

2013-07-03 Thread Fred Stluka

Fadi,

You need to {% load %} the file that defines the tags.

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 7/2/13 8:11 PM, Fadi Samara wrote:


I try to build a plugins based application, I have created tags and 
registered them for each plugin.


I have a table stores each page plugins, and need to render any stored 
plugin in the template accordingly as inclusion tag.


Now for the template i use this:

|{%  block slider_region%}
{%  for  pagecontentin  pagecontents%}
 {%  pagecontent.plugin%}
{%  endfor%}
{%  endblock%}|

But this returns:

|Invalid  block tag:  'pagecontent.plugin',  expected'empty'  or  'endfor'

|

My question, how can I pass the plugin as a tag from view query to a 
template and be rendered as inclusion tag.


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




Re: Django, python, MYSQL, Eclipse3.7

2013-07-03 Thread Branko Majic
On Wed, 3 Jul 2013 05:03:35 -0700 (PDT)
Vamsi Popuri  wrote:

> I have 2 projects. They are* project 1* and *project 2*.
> 
>  *Project 2* has 
> *models.py*
>  class Address(models.Model):
> Street = models.CharField(max_length=50)   
> pin = models.CharField(max_length=20)
> 
> *forms.py *
>  class Address(forms.Form):
>..
> 
> My question is, In *project 1* i wanna access Address model in the *project 
> 2*Is it possible, then please let me know how to do ..
> 
> Thanks for advance
> 

Are you trying to access the _data_ (in database) from project 1, or do
you want to reuse the model definition in project 2 (where project 2
would have its own data independent from project 1)?

Best regards

-- 
Branko Majic
Jabber: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.


signature.asc
Description: PGP signature


Re: Returning data from view to ajax call

2013-07-03 Thread Larry Martell
On Tue, Jul 2, 2013 at 5:39 PM, Larry Martell  wrote:
> On Tue, Jul 2, 2013 at 5:24 PM, Sanjay Bhangar  
> wrote:
>> On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell 
>> wrote:
>>>
>>> On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar 
>>> wrote:
>>> > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell 
>>> > wrote:
>>> >>
>>> >> 
>>> >>
>>> >> In the browser the response has this:
>>> >>
>>> >> HTTP/1.0 200 OK
>>> >> Date: Tue, 02 Jul 2013 22:53:47 GMT
>>> >> Server: WSGIServer/0.1 Python/2.7.2
>>> >> Vary: Cookie
>>> >> Content-Type: text/plain
>>> >>
>>> >> No content. But I verified from pdb that the python code is sending
>>> >> something in the content when it does this:
>>> >>
>>> >> return HttpResponse(content=data, content_type="text/plain",
>>> >> status=200)
>>> >>
>>> > try:
>>> >   return HttpResponse(data, content_type="text/plain", status=200)
>>> >
>>> > (no content= ... )
>>>
>>> No difference - still no content.
>>>
>> Can you navigate to the page just in the browser (not making an AJAX
>> request) ? Do you get a response then? What if you substitute data with
>> "some random string" ?
>
> Yes, I get back the data I expect.

I just tried setting an always function and that is called and I can
get my response. So I guess I'll go with that. But I wonder why the
success function is not called.

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




Re: Exception Value: Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not found.

2013-07-03 Thread Pepsodent Cola
I changed everything related to Model "class Citizen_voice" back to "class 
Poll" and now everything works with "Generic views" usage.
Don't understand why my detail.html template will only accept the variable 
"poll.id"?




On Wednesday, July 3, 2013 12:39:18 PM UTC+2, Pepsodent Cola wrote:
>
> I just double checked.  A month ago I followed the Django Polls tutorial 
> to the point and all of the above worked.
>
> But the second time I followed the Polls tutorial I used different Model 
> names such as *"class Citizen_voice(models.Model)"* instead of the 
> tutorials table name.
>
> class Poll(models.Model):
>
>
> Will my underscore table naming convention cause problems with *"Generic 
> views"* usage?
>
>
>
>
>
>
>
> On Wednesday, July 3, 2013 12:37:50 AM UTC+2, Pepsodent Cola wrote:
>>
>> Hi,
>>
>> 1.)
>> When following the Django 1.5 poll tutorial everything works ok.  Until I 
>> try to implement the *"Generic views"* to use less code in the poll, 
>> then the poll app breaks.
>>
>> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#use-generic-views-less-code-is-better
>>
>>
>> 2.)
>> When go to this link in my web browser, then I get the following error 
>> message.
>> http://localhost:8000/polls/specifics/2/
>>
>> Exception Value: 
>>
>> Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not 
>> found.
>>
>>
>>
>> 3.)
>> *Error during template rendering*
>> /mysite/polls/templates/polls/detail.html, *error at line 6*
>>
>> http://pastebin.com/4HSt1VyS
>>
>>
>>{{ poll.question }}
>> 
>>{% if error_message %}{{ error_message }}{% 
>>endif %}
>> 
>>**
>>**
>>{% csrf_token %}
>>{% for choice in poll.choice_set.all %}
>>>="{{ choice.id }}" />
>>{{ choice.choice_text }}<
>>/label>
>>{% endfor %}
>>
>>
>>
>>
>> 4.)
>> Which files do I need to edit when refactoring the old working code to 
>> the "Generic views" code?
>>
>> I have already edited *"polls/urls.py"*.
>> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-urlconf
>>
>> And I have edited *"polls/views.py"*
>> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-views
>>
>> And I tried to edit *"detail.html"* template file as described at point 
>> 3.) but I still get the same error message.
>> *Error during template rendering*
>> /mysite/polls/templates/polls/detail.html, *error at line 6*
>> *
>> *
>>
>

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




Re: Error when loading application server

2013-07-03 Thread Hélio Miranda
my url is:
http://onpitch-dev.life-emotions.local/onpitch/api/v1/Game

and my class is like this:
*class Game(mongoengine.Document):*
*result = StringField()*
*date = DateTimeField()*
*hour = DateTimeField()*
*stops = IntField()*
*total_time = IntField()*
*lost_time = IntField()*
*num_spectators = IntField()*
*club = fields.ListField(fields.ReferenceField(Club,*
*reverse_delete_rule=CASCADE, dbref=False))*
*journey = fields.ReferenceField(Journey, reverse_delete_rule=CASCADE, 
dbref=False)*
*competition = fields.ReferenceField(Competition, 
reverse_delete_rule=CASCADE, dbref=False)*
*
*
I'm having trouble figuring out what is wrong ...

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




Writing Form Tests

2013-07-03 Thread Cody Scott


I am trying to extend the polls tutorial code to use a django form with tests.


I created this form, but ran into some issues when trying to test it. When 
looking up how to test it, I found this form from 
http://toastdriven.com/blog/2011/apr/17/guide-to-testing-in-django-2/ It also 
had tests.


When I try to run those tests on my form I get the error

"_VoteForm is not callable"

"AttributeError: '_VoteForm' object has no attribute 'instance'"


Which form is preferred? How can I write similar tests for _VoteForm

#my form

def vote_form_class(poll):
choices = [(i.id, _(i.choice_text)) for i in poll.choices.all()]

class _VoteForm(forms.Form):
vote = forms.ChoiceField(choices=choices, widget=forms.RadioSelect())

def save(self):
if not self.is_valid():
raise forms.ValidationError("Poll Form was not validated before 
.save()")

data = self.cleaned_data
choice_id = data['vote']
choice = Choice.objects.get(id=choice_id)
choice.record_vote()

return _VoteForm



#form with tests

class PollForm(forms.Form):
def __init__(self, *args, **kwargs):
# We require an ``instance`` parameter.
self.instance = kwargs.pop('instance')

# We call ``super`` (without the ``instance`` param) to finish
# off the setup.
super(PollForm, self).__init__(*args, **kwargs)

# We add on a ``choice`` field based on the instance we've got.
# This has to be done here (instead of declaratively) because the
# ``Poll`` instance will change from request to request.
self.fields['choice'] = 
forms.ModelChoiceField(queryset=Choice.objects.filter(poll=self.instance.pk), 
empty_label=None, widget=forms.RadioSelect)



def save(self):
if not self.is_valid():
raise forms.ValidationError("PollForm was not validated first 
before trying to call 'save'.")

choice = self.cleaned_data['choice']
choice.record_vote()
return choice




class PollFormTestCase(TestCase):
fixtures = ['polls_forms_testdata.json']

def setUp(self):
super(PollFormTestCase, self).setUp()
self.poll_1 = Poll.objects.get(pk=1)
self.poll_2 = Poll.objects.get(pk=2)

def test_init(self):
# Test successful init without data.
form = PollForm(instance=self.poll_1)
self.assertTrue(isinstance(form.instance, Poll))
self.assertEqual(form.instance.pk, self.poll_1.pk)
self.assertEqual([c for c in form.fields['choice'].choices], [(1, 
u'Yes'), (2, u'No')])

# Test successful init with data.
form = PollForm({'choice': 3}, instance=self.poll_2)
self.assertTrue(isinstance(form.instance, Poll))
self.assertEqual(form.instance.pk, self.poll_2.pk)
self.assertEqual([c for c in form.fields['choice'].choices], [(3, 
u'Alright.'), (4, u'Meh.'), (5, u'Not so good.')])

# Test a failed init without data.
self.assertRaises(KeyError, PollForm)

# Test a failed init with data.
self.assertRaises(KeyError, PollForm, {})



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




Re: Exception Value: Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not found.

2013-07-03 Thread Bill Freeman
Are you sure that you changed *everything*, including the database tables?


On Wed, Jul 3, 2013 at 9:21 AM, Pepsodent Cola wrote:

> I changed everything related to Model "class Citizen_voice" back to "class
> Poll" and now everything works with "Generic views" usage.
> Don't understand why my detail.html template will only accept the variable
> "poll.id"?
>
>
>
>
> On Wednesday, July 3, 2013 12:39:18 PM UTC+2, Pepsodent Cola wrote:
>>
>> I just double checked.  A month ago I followed the Django Polls tutorial
>> to the point and all of the above worked.
>>
>> But the second time I followed the Polls tutorial I used different Model
>> names such as *"class Citizen_voice(models.Model)"* instead of the
>> tutorials table name.
>>
>> class Poll(models.Model):
>>
>>
>> Will my underscore table naming convention cause problems with *"Generic 
>> views"* usage?
>>
>>
>>
>>
>>
>>
>>
>> On Wednesday, July 3, 2013 12:37:50 AM UTC+2, Pepsodent Cola wrote:
>>>
>>> Hi,
>>>
>>> 1.)
>>> When following the Django 1.5 poll tutorial everything works ok.  Until
>>> I try to implement the *"Generic views"* to use less code in the poll,
>>> then the poll app breaks.
>>> https://docs.djangoproject.**com/en/1.5/intro/tutorial04/#**
>>> use-generic-views-less-code-**is-better
>>>
>>>
>>> 2.)
>>> When go to this link in my web browser, then I get the following error
>>> message.
>>> http://localhost:8000/polls/**specifics/2/
>>>
>>> Exception Value:
>>>
>>> Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not 
>>> found.
>>>
>>>
>>>
>>> 3.)
>>> *Error during template rendering*
>>> /mysite/polls/templates/polls/**detail.html, *error at line 6*
>>>
>>> http://pastebin.com/4HSt1VyS
>>>
>>>
>>>{{ poll.question }}
>>>
>>>{% if error_message %}{{ error_message }}{%
>>>endif %}
>>>
>>>**
>>>**
>>>{% csrf_token %}
>>>{% for choice in poll.choice_set.all %}
>>>
>>>{{ choice.choice_text }}
>>>
>>>{% endfor %}
>>>
>>>
>>>
>>>
>>> 4.)
>>> Which files do I need to edit when refactoring the old working code to
>>> the "Generic views" code?
>>>
>>> I have already edited *"polls/urls.py"*.
>>> https://docs.djangoproject.**com/en/1.5/intro/tutorial04/#**
>>> amend-urlconf
>>>
>>> And I have edited *"polls/views.py"*
>>> https://docs.djangoproject.**com/en/1.5/intro/tutorial04/#**amend-views
>>>
>>> And I tried to edit *"detail.html"* template file as described at point
>>> 3.) but I still get the same error message.
>>> *Error during template rendering*
>>> /mysite/polls/templates/polls/**detail.html, *error at line 6*
>>> *
>>> *
>>>
>>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




PyCon APAC CFP

2013-07-03 Thread Ian Lewis
Hey Django users!

I wanted to get the word out that we are accepting talks for this year's
PyCon APAC in Tokyo Japan. If you have ever wanted to visit Tokyo and you
have a Python topic you are passionate about then this is your chance!

The conference is formatted into 4 tracks, 2 Japanese and 2 English tracks.
We are especially looking for English speakers to give talks so be sure
submit a talk proposal. I was a bit late getting the word out to the U.S.
mailing lists so there is only a week left to submit proposals. Don't sit
on it!
http://apac-2013.pycon.jp/speakers/cfp.html

More info about PyCon APAC

The conference is being held on Sept. 14th-15th with tutorials on the 13th
and development sprints being held on the 16th. We are hoping to have up to
500 participants this year (PyCon JP sold out at 400 last year). George
Brandl (@birkenfeld) is our first keynote speaker. We have another really
exciting keynote speaker lined up.

You can find out more about the conference details on the about page:
http://apac-2013.pycon.jp/about/index.html

The conference venue is the Kogakuin University Shinjuku Campus in the
heart of Tokyo. Anyone coming to the conference won't be at a loss for
things to do :)
http://apac-2013.pycon.jp/venue/index.html

...Or if you would just like to come and participate we welcome that too!
Conference registration is currently open:

Early Bird Registration: http://connpass.com/event/2703/
Patron Sponsor Registration: http://connpass.com/event/2704/

Thanks! If anyone has questions I'll do my best to answer them.
Hope to see you in Tokyo!

-- 
Ian

http://www.ianlewis.org/

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




Re: Custom Authentication

2013-07-03 Thread adroit . goose
Thank you :-)

On Wednesday, July 3, 2013 2:47:15 PM UTC+2, Odin wrote:
>
> You can extend the User Model: 
> https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model
>
>
> 2013/7/3 >
>
>> Hello,
>>
>> I am a newbie to Django and would wish to know if it possible to use the 
>> authentication scheme(from django.contrib import auth) on a custom made 
>> 'Company_user' table.
>> I don't want to use the default User object provided by Django admin as 
>> the fields in the custom table are different. How should I go about it?.
>>
>> Thanks,
>> Goose.
>>   
>>
>>  -- 
>> 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.
>> 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.
For more options, visit https://groups.google.com/groups/opt_out.




alternate to gunicorn

2013-07-03 Thread Kakar Arunachal Service
Hi,
If i was to use nginx in windows, is ther any alternate to Gunicorn for
windows environment.

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




Re: Missing peice before best practises

2013-07-03 Thread Amirouche Boubekki
2013/7/1 Sayth Renshaw 

>
>
> On Monday, July 1, 2013, Tom Evans wrote:
>
>> On Mon, Jul 1, 2013 at 11:37 AM, Sayth Renshaw 
>> wrote:
>> > Is that good though?
>> >
>> > Barring 2 scoops there is no new material to recognise and guide users
>> to
>> > the new features of Django and to get beginner Django developers on
>> board
>> > quicker.
>> >
>> > It leads to bits of info for each python framework but nothing
>> > comprehensive.
>> >
>> > Sayth
>> >
>>
>> Virtualenv, pip etc are not features of Django, they are features of
>> python. It is right that Django mentions them in places, it is doubly
>> right that it does not attempt to duplicate the fine documentation
>> that pip and virtualenv possess themselves.
>>
>> Cheers
>>
>> Tom
>>
>>
> Agreed good tutorials would show steps and then point to resources for
> further reading,
>
> At this point though it appears there is a scarcity of good tutorials for
> current Django.
>

pip+virtualenv[wrapper] is a pratice not something that will allow you to
build a skyrocket as-is, you can live without it.

The documentation is good, and overall ecosystem alive and active, what do
you need more ? They are several CMS and admin apps, blog solutions etc...
They are still improvements and stabilisation to be done on many (utility)
apps... Everything I want to say is that outside the django tutorial, and
anybooks you read, the best way to improve your skills it to [re]build
something...

Time to time, I think about writring a set of tutorial about a CMS or
Social Network from scratch, but experience says that except the actual
code, the remaining issues are solved and well documented outside this
virtual project, so this would, I think, have little value.




HTH,

Amirouche

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




Re: Embedded documents doubts

2013-07-03 Thread Amirouche Boubekki
This is a mongodb database design issue, please forward your question to
mongodb user mailling list.

AFAIK, it only makes sens if the contact is used nowhere else.


2013/7/2 Hélio Miranda 

> Hi
> I have an application in Django-Tastypie and MongoDB, where I have to
> enter a club, that club can have multiple contacts.
> So I was thinking for the document within the document contact club is the
> best option?
>
> I was trying something like this:
>
> *class ClubContact (mongoengine.EmbeddedDocument):*
> * name = Stringfield ()*
> * IntField phone = ()*
> *
> *
> *Club class (mongoengine.Document):*
> * name = Stringfield ()*
> * Stringfield address = ()*
> * email = EmailField ()*
> * phone = ListField (EmbeddedDocumentField (ClubContact))*
>
> Does it make sense?
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Returning data from view to ajax call

2013-07-03 Thread C. Kirby
An HttpResponse includes http headers and will blow up an ajax call.
You want to use a render_to_string method and pass either json or a 
rendered template (render to string bypasses the headers, render to 
response will include them)

On Wednesday, July 3, 2013 8:14:06 AM UTC-5, larry@gmail.com wrote:
>
> On Tue, Jul 2, 2013 at 5:39 PM, Larry Martell 
> > 
> wrote: 
> > On Tue, Jul 2, 2013 at 5:24 PM, Sanjay Bhangar 
> > > 
> wrote: 
> >> On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell 
> >> > 
>
> >> wrote: 
> >>> 
> >>> On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar 
> >>> > 
>
> >>> wrote: 
> >>> > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell 
> >>> > > 
>
> >>> > wrote: 
> >>> >> 
> >>> >>  
> >>> >> 
> >>> >> In the browser the response has this: 
> >>> >> 
> >>> >> HTTP/1.0 200 OK 
> >>> >> Date: Tue, 02 Jul 2013 22:53:47 GMT 
> >>> >> Server: WSGIServer/0.1 Python/2.7.2 
> >>> >> Vary: Cookie 
> >>> >> Content-Type: text/plain 
> >>> >> 
> >>> >> No content. But I verified from pdb that the python code is sending 
> >>> >> something in the content when it does this: 
> >>> >> 
> >>> >> return HttpResponse(content=data, content_type="text/plain", 
> >>> >> status=200) 
> >>> >> 
> >>> > try: 
> >>> >   return HttpResponse(data, content_type="text/plain", status=200) 
> >>> > 
> >>> > (no content= ... ) 
> >>> 
> >>> No difference - still no content. 
> >>> 
> >> Can you navigate to the page just in the browser (not making an AJAX 
> >> request) ? Do you get a response then? What if you substitute data with 
> >> "some random string" ? 
> > 
> > Yes, I get back the data I expect. 
>
> I just tried setting an always function and that is called and I can 
> get my response. So I guess I'll go with that. But I wonder why the 
> success function is not called. 
>

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




Re: Returning data from view to ajax call

2013-07-03 Thread Larry Martell
On Wed, Jul 3, 2013 at 9:30 AM, C. Kirby  wrote:
> An HttpResponse includes http headers and will blow up an ajax call.
> You want to use a render_to_string method and pass either json or a rendered
> template (render to string bypasses the headers, render to response will
> include them)

I don't want to return a template, just some data. I tried this:

return render_to_string(simplejson.dumps(data))

But it blows up with template not found.

> On Wednesday, July 3, 2013 8:14:06 AM UTC-5, larry@gmail.com wrote:
>>
>> On Tue, Jul 2, 2013 at 5:39 PM, Larry Martell  wrote:
>> > On Tue, Jul 2, 2013 at 5:24 PM, Sanjay Bhangar 
>> > wrote:
>> >> On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell 
>> >> wrote:
>> >>>
>> >>> On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar 
>> >>> wrote:
>> >>> > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell 
>> >>> > wrote:
>> >>> >>
>> >>> >> 
>> >>> >>
>> >>> >> In the browser the response has this:
>> >>> >>
>> >>> >> HTTP/1.0 200 OK
>> >>> >> Date: Tue, 02 Jul 2013 22:53:47 GMT
>> >>> >> Server: WSGIServer/0.1 Python/2.7.2
>> >>> >> Vary: Cookie
>> >>> >> Content-Type: text/plain
>> >>> >>
>> >>> >> No content. But I verified from pdb that the python code is sending
>> >>> >> something in the content when it does this:
>> >>> >>
>> >>> >> return HttpResponse(content=data, content_type="text/plain",
>> >>> >> status=200)
>> >>> >>
>> >>> > try:
>> >>> >   return HttpResponse(data, content_type="text/plain", status=200)
>> >>> >
>> >>> > (no content= ... )
>> >>>
>> >>> No difference - still no content.
>> >>>
>> >> Can you navigate to the page just in the browser (not making an AJAX
>> >> request) ? Do you get a response then? What if you substitute data with
>> >> "some random string" ?
>> >
>> > Yes, I get back the data I expect.
>>
>> I just tried setting an always function and that is called and I can
>> get my response. So I guess I'll go with that. But I wonder why the
>> success function is not called.
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Returning data from view to ajax call

2013-07-03 Thread C. Kirby
I'm sorry, I was typing without thinking.
render_to_string() if you want to use a template without headers
render_to_response() includes headers

HttpResponse(json.dumps(data_object)) should be what you want.

It would also be helpful to see the code for your view. It looks like you 
already put the template code concerning the ajax call in this thread.

On Wednesday, July 3, 2013 10:47:38 AM UTC-5, larry@gmail.com wrote:
>
> On Wed, Jul 3, 2013 at 9:30 AM, C. Kirby > 
> wrote: 
> > An HttpResponse includes http headers and will blow up an ajax call. 
> > You want to use a render_to_string method and pass either json or a 
> rendered 
> > template (render to string bypasses the headers, render to response will 
> > include them) 
>
> I don't want to return a template, just some data. I tried this: 
>
> return render_to_string(simplejson.dumps(data)) 
>
> But it blows up with template not found. 
>
> > On Wednesday, July 3, 2013 8:14:06 AM UTC-5, larry@gmail.com wrote: 
> >> 
> >> On Tue, Jul 2, 2013 at 5:39 PM, Larry Martell  
> wrote: 
> >> > On Tue, Jul 2, 2013 at 5:24 PM, Sanjay Bhangar  
> >> > wrote: 
> >> >> On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell  
> >> >> wrote: 
> >> >>> 
> >> >>> On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar  
>
> >> >>> wrote: 
> >> >>> > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell <
> larry@gmail.com> 
> >> >>> > wrote: 
> >> >>> >> 
> >> >>> >>  
> >> >>> >> 
> >> >>> >> In the browser the response has this: 
> >> >>> >> 
> >> >>> >> HTTP/1.0 200 OK 
> >> >>> >> Date: Tue, 02 Jul 2013 22:53:47 GMT 
> >> >>> >> Server: WSGIServer/0.1 Python/2.7.2 
> >> >>> >> Vary: Cookie 
> >> >>> >> Content-Type: text/plain 
> >> >>> >> 
> >> >>> >> No content. But I verified from pdb that the python code is 
> sending 
> >> >>> >> something in the content when it does this: 
> >> >>> >> 
> >> >>> >> return HttpResponse(content=data, content_type="text/plain", 
> >> >>> >> status=200) 
> >> >>> >> 
> >> >>> > try: 
> >> >>> >   return HttpResponse(data, content_type="text/plain", 
> status=200) 
> >> >>> > 
> >> >>> > (no content= ... ) 
> >> >>> 
> >> >>> No difference - still no content. 
> >> >>> 
> >> >> Can you navigate to the page just in the browser (not making an AJAX 
> >> >> request) ? Do you get a response then? What if you substitute data 
> with 
> >> >> "some random string" ? 
> >> > 
> >> > Yes, I get back the data I expect. 
> >> 
> >> I just tried setting an always function and that is called and I can 
> >> get my response. So I guess I'll go with that. But I wonder why the 
> >> success function is not called. 
> > 
> > -- 
> > 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. 
> > 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Returning data from view to ajax call

2013-07-03 Thread Larry Martell
On Wed, Jul 3, 2013 at 10:01 AM, C. Kirby  wrote:
> I'm sorry, I was typing without thinking.
> render_to_string() if you want to use a template without headers
> render_to_response() includes headers
>
> HttpResponse(json.dumps(data_object)) should be what you want.
>
> It would also be helpful to see the code for your view. It looks like you
> already put the template code concerning the ajax call in this thread.

The view is very simple. It does some stuff and ends up with a single
short string that I am returning like this:

return HttpResponse(data, content_type="application/json", status=200)

I can pick up the string in an always function from data.responseText
so I'm going to go with that, declare victory and move on. Thanks to
everyone for the help.


>
> On Wednesday, July 3, 2013 10:47:38 AM UTC-5, larry@gmail.com wrote:
>>
>> On Wed, Jul 3, 2013 at 9:30 AM, C. Kirby  wrote:
>> > An HttpResponse includes http headers and will blow up an ajax call.
>> > You want to use a render_to_string method and pass either json or a
>> > rendered
>> > template (render to string bypasses the headers, render to response will
>> > include them)
>>
>> I don't want to return a template, just some data. I tried this:
>>
>> return render_to_string(simplejson.dumps(data))
>>
>> But it blows up with template not found.
>>
>> > On Wednesday, July 3, 2013 8:14:06 AM UTC-5, larry@gmail.com wrote:
>> >>
>> >> On Tue, Jul 2, 2013 at 5:39 PM, Larry Martell 
>> >> wrote:
>> >> > On Tue, Jul 2, 2013 at 5:24 PM, Sanjay Bhangar 
>> >> > wrote:
>> >> >> On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell 
>> >> >> wrote:
>> >> >>>
>> >> >>> On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar
>> >> >>> 
>> >> >>> wrote:
>> >> >>> > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell
>> >> >>> > 
>> >> >>> > wrote:
>> >> >>> >>
>> >> >>> >> 
>> >> >>> >>
>> >> >>> >> In the browser the response has this:
>> >> >>> >>
>> >> >>> >> HTTP/1.0 200 OK
>> >> >>> >> Date: Tue, 02 Jul 2013 22:53:47 GMT
>> >> >>> >> Server: WSGIServer/0.1 Python/2.7.2
>> >> >>> >> Vary: Cookie
>> >> >>> >> Content-Type: text/plain
>> >> >>> >>
>> >> >>> >> No content. But I verified from pdb that the python code is
>> >> >>> >> sending
>> >> >>> >> something in the content when it does this:
>> >> >>> >>
>> >> >>> >> return HttpResponse(content=data, content_type="text/plain",
>> >> >>> >> status=200)
>> >> >>> >>
>> >> >>> > try:
>> >> >>> >   return HttpResponse(data, content_type="text/plain",
>> >> >>> > status=200)
>> >> >>> >
>> >> >>> > (no content= ... )
>> >> >>>
>> >> >>> No difference - still no content.
>> >> >>>
>> >> >> Can you navigate to the page just in the browser (not making an AJAX
>> >> >> request) ? Do you get a response then? What if you substitute data
>> >> >> with
>> >> >> "some random string" ?
>> >> >
>> >> > Yes, I get back the data I expect.
>> >>
>> >> I just tried setting an always function and that is called and I can
>> >> get my response. So I guess I'll go with that. But I wonder why the
>> >> success function is not called.
>> >
>> > --
>> > 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.
>> > 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django, python, MYSQL, Eclipse3.7

2013-07-03 Thread Rafael E. Ferrero
just import one model into another using import statement.


2013/7/3 Branko Majic 

> On Wed, 3 Jul 2013 05:03:35 -0700 (PDT)
> Vamsi Popuri  wrote:
>
> > I have 2 projects. They are* project 1* and *project 2*.
> >
> >  *Project 2* has
> > *models.py*
> >  class Address(models.Model):
> > Street = models.CharField(max_length=50)
> > pin = models.CharField(max_length=20)
> >
> > *forms.py *
> >  class Address(forms.Form):
> >..
> >
> > My question is, In *project 1* i wanna access Address model in the
> *project
> > 2*Is it possible, then please let me know how to do ..
> >
> > Thanks for advance
> >
>
> Are you trying to access the _data_ (in database) from project 1, or do
> you want to reuse the model definition in project 2 (where project 2
> would have its own data independent from project 1)?
>
> Best regards
>
> --
> Branko Majic
> Jabber: bra...@majic.rs
> Please use only Free formats when sending attachments to me.
>
> Бранко Мајић
> Џабер: bra...@majic.rs
> Молим вас да додатке шаљете искључиво у слободним форматима.
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

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




Inserting String from Visual Basic Express 2010 to Django SQLite3 Database

2013-07-03 Thread hiQ
I've been able to configure my Visual Basic Express 2010 to read strings 
from certain measurement equipment. I also found a very cool youtube video 
(http://youtu.be/Z3j-7309ITc ) which shows how data can be added to 
Microsoft SQL table. Problem is I am stubborn and refuse to use Microsoft 
proprietary stuff that's going to screw me over in 2-3 years with a 
re-write.

Can this be done using Visual Studio Express 2010 and the SQLite3 table 
which Django uses?

Currently I can read and display the string information within the VB 
application. My end goal is to:

1. Read the string (which is currently working OK)
2. Write the string into the SQL table (which I have no idea how to do)
3. Plot the data line using Django Chartit (Also have no idea how to do)

Thanks for any guidance or references.



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




django create_without_commit method

2013-07-03 Thread surya
We just found a small bug regarding Django Transactions.
Our code were using objects.create_without_commit() method!!

I just added missing Transactions middleware and it all seems to work 
amazing now without actually editing the way models work..
Is this a known method? used in transactions and previous developer just 
forgot to add middleware?

He used django 1.3 (but our site seems to work perfect on 1.4 too)

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




Re: Inserting String from Visual Basic Express 2010 to Django SQLite3 Database

2013-07-03 Thread Nikolas Stevenson-Molnar
This might be helpful: http://zetcode.com/db/sqlitevb/

_Nik

On 7/3/2013 12:08 PM, hiQ wrote:
> I've been able to configure my Visual Basic Express 2010 to read
> strings from certain measurement equipment. I also found a very cool
> youtube video (http://youtu.be/Z3j-7309ITc ) which shows how data can
> be added to Microsoft SQL table. Problem is I am stubborn and refuse
> to use Microsoft proprietary stuff that's going to screw me over in
> 2-3 years with a re-write.
>
> Can this be done using Visual Studio Express 2010 and the SQLite3
> table which Django uses?
>
> Currently I can read and display the string information within the VB
> application. My end goal is to:
>
> 1. Read the string (which is currently working OK)
> 2. Write the string into the SQL table (which I have no idea how to do)
> 3. Plot the data line using Django Chartit (Also have no idea how to do)
>
> Thanks for any guidance or references.
>
>
>
> -- 
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Advice on creating an SFTP frontend in Django

2013-07-03 Thread Paul Hudson
Hi,

I have successfully used django-storages (
http://django-storages.readthedocs.org/en/latest/index.html)  and paramiko 
directly to log into an SFTP server and list a directory.  My end goal is 
to make a simple Client Area that allows the downloading of files hosted on 
SFTP.  I am open to any advice.  But here are a few specific questions:


   1. How should I handle authentication?  Use django's built in 
   authentication and pass the usr/pwd onto the SFTP? (is that possible in a 
   secure way?)  Authenticate directly against SFTP server in a secure way?
   2. Are files going to be transferred twice?  Once from SFTP to temp area 
   on Django server.  And then downloaded via client's web browser...  Am I 
   just better off hosting the files on the web server to begin with?  (The 
   files need to be available on SFTP and via web browser.  Maybe instead of 
   direct access to SFTP via Django, I should focus on a simple way to post 
   the original files to both places???)
   3. Are they any Django Projects/Plugins/Components for File Explorer/FTP 
   Client type GUIs that you would recommend using or referencing?



Thanks for any and all input!
-Paul

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




Does django have something similar to resource in rails?

2013-07-03 Thread gabby gabriel
I just started learning django. I was a rails developer before that. I was 
wondering if there is anything similar to resource in rails in django? Or 
do I have to make different urls and corresponding views for those urls? 
Thanks in advance!

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




Re: Does django have something similar to resource in rails?

2013-07-03 Thread Nick Apostolakis
Check out the Rest apis (tastypie etc )  they should be what you are
looking for
Στις 03 Ιουλ 2013 11:03 μ.μ., ο χρήστης "gabby gabriel" <
gabbyha...@gmail.com> έγραψε:

> I just started learning django. I was a rails developer before that. I was
> wondering if there is anything similar to resource in rails in django? Or
> do I have to make different urls and corresponding views for those urls?
> Thanks in advance!
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: django-otp and friends: one-time passwords and trusted agents

2013-07-03 Thread Peter Sagerson
I took part of this conversation offline to spare the list from the gory 
details, but the upshot was that verifying an OTP is logically a mutating 
operation on the verifying device, and thus is not really valid on an unsaved 
model object. I posted an update to the documentation to clarify.

There were a couple of other questions down there that got lost, but they're 
more interesting to Django in general. Managing a heterogenous collection of 
model objects is indeed a little tricky, although it's definitely a solved 
problem: this is precisely what the admin interface does. Technically, it 
should be easy to derive an AdminSite that allows a user to manage their own 
devices, although integrating that cleanly into a broader site design is 
probably more trouble than it's worth. I suspect that your approach using 
ContentTypes is a good one--that's pretty much what they're for.

When I first embarked on this project, I actually thought that device 
management was one of the primary goals. Initially, writing a plugin required 
not just a model class, but a collection of forms that could be used to create 
and manage that device. Eventually I decided that there were several good 
reasons not to go down this road. To take one example, a TOTPDevice is fairly 
generic and could be paired with any number of real-world provers. Google 
Authenticator is the main one I know about, but there are others out there and 
more will emerge. Each prover may have a unique setup flow with different 
required TOTP parameters, some of which can't be anticipated in advance. For 
that reason alone, I think that integrating any kind of management UI directly 
into the device definition is a dangerous layer violation.

I'll back up for a minute and point out that--true to the open-source 
ethic--one reason I haven't published any generic device management code is 
that I haven't myself needed it. I currently have django-otp deployed in two 
places. One is only for internal users ("staff" in Django parlance), so it just 
uses the management interface. The other is targeted at competent but not 
necessarily technical users, so it's fairly directed. For example, I require 
that these users register and confirm an SMS device before I issue backup codes 
and a Google Authenticator key. This all uses device-specific UI, so no need to 
be generic.

This gets at the larger issue, which is designing policies for two-factor 
authentication. The policy that you're proposing is essentially to support as 
many kinds of OTP devices as you can and let users manage their own security. I 
think that model has a lot of merits and I'd be happy to see more sites adopt 
it where appropriate. Of course, the downside to being too casual about 
two-factor policies is account recovery. I recently read an article in which 
Google cited this as their Achilles heel in their push for two-factor 
everywhere. Hence the not-uncommon policy of requiring an SMS backup before 
allowing more volatile options.

What this all comes down to is that I think there's plenty of room for code 
that facilitates different kinds of two-factor authentication policies in 
Django apps. django-otp itself shouldn't include any of them, of course, 
because it's just the framework that provides the underlying mechanisms. I can 
easily imagine a django-otp-authenticator app which has tools for generating 
Google-Authenticator-compatible TOTPDevice objects, rendering QR codes, 
confirming, etc. Or, at a higher level, django-otp-devices, with views that 
allow a user to manage their own heterogenous collection of devices. The 
problem space is quite large and I'm not sure how it all shakes out in the end.

On the decorator question, it occurred to me that I actually use the 
otp-required-if-configured pattern as well, although I had it implemented 
directly in a view hierarchy. There seems to be a bit of incoherence in recent 
Django versions between the decorated-view pattern and the view-as-class 
pattern. In any case, I expanded the otp_required decorator to take an 
if_configured argument. New versions of django-otp and django-otp-agents are 
available.

Thanks so much for your feedback. Do keep in touch either here or privately to 
let me know how it works out.

Peter


On Jul 2, 2013, at 4:42 PM, Jason Arnst-Goodrich  wrote:

> I think I found one more nicety to add.
> 
> The following is the verify_token method for TOTPDevice:
> 
> def verify_token(self, token):
> OTP_TOTP_SYNC = getattr(settings, 'OTP_TOTP_SYNC', True)
> 
> try:
> token = int(token)
> except StandardError:
> verified = False
> else:
> key = self.bin_key
> 
> for offset in range(-self.tolerance, self.tolerance + 1):
> if totp(key, self.step, self.t0, self.digits, self.drift + 
> offset) == token:
> if (offset != 0) and OTP_TOTP_SYNC:
> self.drift += offset
>   

Re: Advice on creating an SFTP frontend in Django

2013-07-03 Thread Adnan Sadzak
Hi Paul,

does all users have/need their own SFTP account on server?
If not, You can mount remote SFTP folder on web server and control access
to folders via django.

Cheers,
Adnan


On Wed, Jul 3, 2013 at 9:43 PM, Paul Hudson  wrote:

> Hi,
>
> I have successfully used django-storages (
> http://django-storages.readthedocs.org/en/latest/index.html)  and
> paramiko directly to log into an SFTP server and list a directory.  My end
> goal is to make a simple Client Area that allows the downloading of files
> hosted on SFTP.  I am open to any advice.  But here are a few specific
> questions:
>
>
>1. How should I handle authentication?  Use django's built in
>authentication and pass the usr/pwd onto the SFTP? (is that possible in a
>secure way?)  Authenticate directly against SFTP server in a secure way?
>2. Are files going to be transferred twice?  Once from SFTP to temp
>area on Django server.  And then downloaded via client's web browser...  Am
>I just better off hosting the files on the web server to begin with?  (The
>files need to be available on SFTP and via web browser.  Maybe instead of
>direct access to SFTP via Django, I should focus on a simple way to post
>the original files to both places???)
>3. Are they any Django Projects/Plugins/Components for File
>Explorer/FTP Client type GUIs that you would recommend using or 
> referencing?
>
>
>
> Thanks for any and all input!
> -Paul
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Python Fabric manage.py problem

2013-07-03 Thread Sithembewena Lloyd Dube
I had a similar issue - running manage.py through Fabric simply didn't pan
out - even after following the Fabric documentation. Also tried the
--noinput switch with no luck? I do not have a ready answer right now, but
I do intend to look into this. I am sure it has (and is being) done plenty
times with good result.


On Mon, Jul 1, 2013 at 8:28 AM, Eduardo Basílio <
eduardoafonsobasi...@gmail.com> wrote:

> I use Python Fabric to deploy. Works great for accessing the remote
> server, install dependencies, run linux commands, etc..
>
> But when I try to run *file commands manage.py Django*, NOT work!
>
>
> Example of my fabfile.py:
>
> with prefix ('source/home/user/env/bin/activate'):
>
> with cd ('path/to/your/project/django'):
>
> *run ('python manage.py help --settings=path.for.settings')*
>
>
> Fatal error: runstrong text() received nonzero return code while executing
> one!
>
>
> I've tried putting a --noinput but the error remains:
>
> *run ('python manage.py help --settings=caminho.para.settings --noinput')*
>
> Does anyone know how to solve?
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Regards,
Sithu Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Exception Value: Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not found.

2013-07-03 Thread Pepsodent Cola
1.)
Well I took the working *"class Poll"* version and changed much into *"class 
Polly_bird"* instead to see if the underscore business was indeed causing 
me this problem.


2.)
So I deleted the database.


3.)
And edited this file *"/mysite/polls/urls.py"*.

urlpatterns = patterns('',
...
...
# ex: /polls/5/
url(r'^(?P\d+)/$', views.DetailView.as_view(), name='detail'),

# ex: /polls/5/vote/
url(r'^(?P\d+)/vote/$', views.vote, name='vote'),
)



4.)
And edited this file *"/mysite/polls/admin.py"*.

from polls.models import Polly_bird, Choice
...
...
class Polly_birdAdmin(admin.ModelAdmin):
...
...
admin.site.register(Polly_bird, Polly_birdAdmin)



5.)
And edited this file *"/mysite/polls/models.py"*.

class Polly_bird(models.Model):
...
...
class Choice(models.Model):
PollChoice = models.ForeignKey(Polly_bird)
...
...



6.)
And edited this file *"/mysite/polls/views.py"*.

from polls.models import Polly_bird, Choice

class IndexView(generic.ListView):
...
...
return Polly_bird.objects.order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
model = Polly_bird
...
...

def vote(request, polly_bird_id):
p = get_object_or_404(Polly_bird, pk=polly_bird_id)
...
...

class ResultsView(generic.DetailView):
model = Polly_bird
...
...



7.)
Then I ran "python manage.py syncdb" to create the database tables from 
scratch.  After that I restarted the runserver.


8.)
Then I got the original error again, what line of code have I missed and in 
which files?
Or why doesn't Django like it when I use underscore table naming convention?

http://localhost:8000/polls/1/

Exception Value: 

Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not found.


Error during template rendering
/mysite/polls/templates/polls/*detail.html*, error at line *5*

...
...

5

...
...












On Wednesday, July 3, 2013 3:51:50 PM UTC+2, ke1g wrote:
>
> Are you sure that you changed *everything*, including the database tables?
>
>
> On Wed, Jul 3, 2013 at 9:21 AM, Pepsodent Cola 
> 
> > wrote:
>
>> I changed everything related to Model "class Citizen_voice" back to 
>> "class Poll" and now everything works with "Generic views" usage.
>> Don't understand why my detail.html template will only accept the 
>> variable "poll.id"?
>>
>>
>>
>>
>> On Wednesday, July 3, 2013 12:39:18 PM UTC+2, Pepsodent Cola wrote:
>>>
>>> I just double checked.  A month ago I followed the Django Polls tutorial 
>>> to the point and all of the above worked.
>>>
>>> But the second time I followed the Polls tutorial I used different Model 
>>> names such as *"class Citizen_voice(models.Model)"* instead of the 
>>> tutorials table name.
>>>
>>> class Poll(models.Model):
>>>
>>>
>>>
>>> Will my underscore table naming convention cause problems with *"Generic 
>>> views"* usage?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, July 3, 2013 12:37:50 AM UTC+2, Pepsodent Cola wrote:

 Hi,

 1.)
 When following the Django 1.5 poll tutorial everything works ok.  Until 
 I try to implement the *"Generic views"* to use less code in the poll, 
 then the poll app breaks.
 https://docs.djangoproject.**com/en/1.5/intro/tutorial04/#**
 use-generic-views-less-code-**is-better


 2.)
 When go to this link in my web browser, then I get the following error 
 message.
 http://localhost:8000/polls/**specifics/2/

 Exception Value: 

 Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not 
 found.



 3.)
 *Error during template rendering*
 /mysite/polls/templates/polls/**detail.html, *error at line 6*

 http://pastebin.com/4HSt1VyS


{{ poll.question }}
 
{% if error_message %}{{ error_message }}{% 
endif %}
 
**
**
{% csrf_token %}
{% for choice in poll.choice_set.all %}

{{ choice.choice_text }
}
{% endfor %}




 4.)
 Which files do I need to edit when refactoring the old working code to 
 the "Generic views" code?

 I have already edited *"polls/urls.py"*.
 https://docs.djangoproject.**com/en/1.5/intro/tutorial04/#**
 amend-urlconf

 And I have edited *"polls/views.py"*
 https://docs.djangoproject.**com/en/1.5/intro/tutorial04/#**amend-views

 And I tried to edit *"detail.html"* template file as described at 
 point 3.) but I still get the same error message.
 *Error during template rendering*
 /mysite/polls/templates/polls/**detail.html, *error at line 6*
 *
 *

>>>  -- 
>> You received this messa

Re: Exception Value: Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not found.

2013-07-03 Thread Pepsodent Cola
I think I know what the problem is with the Django 1.5 tutorial.
https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-views

Both these classes are missing the "context_object_name" thingy, which 
links to the templates.

class DetailView(generic.DetailView):
class ResultsView(generic.DetailView):
model = Birdy
template_name = 'polls/detail.html'
template_name = 'polls/results.html'
*context_object_name = 'poll'*

Now my Poll application is working without having to use Poll as Model. 
 Also it's now working using the "Generic views".

[ Problem solved... ]





On Thursday, July 4, 2013 12:25:31 AM UTC+2, Pepsodent Cola wrote:
>
> 1.)
> Well I took the working *"class Poll"* version and changed much into *"class 
> Polly_bird"* instead to see if the underscore business was indeed causing 
> me this problem.
>
>
> 2.)
> So I deleted the database.
>
>
> 3.)
> And edited this file *"/mysite/polls/urls.py"*.
>
> urlpatterns = patterns('',
> ...
> ...
> # ex: /polls/5/
> url(r'^(?P\d+)/$', views.DetailView.as_view(), name='detail'),
>
> # ex: /polls/5/vote/
> url(r'^(?P\d+)/vote/$', views.vote, name='vote'),
> )
>
>
>
> 4.)
> And edited this file *"/mysite/polls/admin.py"*.
>
> from polls.models import Polly_bird, Choice
> ...
> ...
> class Polly_birdAdmin(admin.ModelAdmin):
> ...
> ...
> admin.site.register(Polly_bird, Polly_birdAdmin)
>
>
>
> 5.)
> And edited this file *"/mysite/polls/models.py"*.
>
> class Polly_bird(models.Model):
> ...
> ...
> class Choice(models.Model):
> PollChoice = models.ForeignKey(Polly_bird)
> ...
> ...
>
>
>
> 6.)
> And edited this file *"/mysite/polls/views.py"*.
>
> from polls.models import Polly_bird, Choice
>
> class IndexView(generic.ListView):
> ...
> ...
> return Polly_bird.objects.order_by('-pub_date')[:5]
>
> class DetailView(generic.DetailView):
> model = Polly_bird
> ...
> ...
>
> def vote(request, polly_bird_id):
> p = get_object_or_404(Polly_bird, pk=polly_bird_id)
> ...
> ...
>
> class ResultsView(generic.DetailView):
> model = Polly_bird
> ...
> ...
>
>
>
> 7.)
> Then I ran "python manage.py syncdb" to create the database tables from 
> scratch.  After that I restarted the runserver.
>
>
> 8.)
> Then I got the original error again, what line of code have I missed and 
> in which files?
> Or why doesn't Django like it when I use underscore table naming 
> convention?
>
> http://localhost:8000/polls/1/
>
> Exception Value: 
>
> Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not 
> found.
>
>
> Error during template rendering
> /mysite/polls/templates/polls/*detail.html*, error at line *5*
>
> ...
> ...
>
> 5
>
> ...
> ...
>
>
>
>
>
>
>
>
>
>
>
>
> On Wednesday, July 3, 2013 3:51:50 PM UTC+2, ke1g wrote:
>>
>> Are you sure that you changed *everything*, including the database tables?
>>
>>
>> On Wed, Jul 3, 2013 at 9:21 AM, Pepsodent Cola wrote:
>>
>>> I changed everything related to Model "class Citizen_voice" back to 
>>> "class Poll" and now everything works with "Generic views" usage.
>>> Don't understand why my detail.html template will only accept the 
>>> variable "poll.id"?
>>>
>>>
>>>
>>>
>>> On Wednesday, July 3, 2013 12:39:18 PM UTC+2, Pepsodent Cola wrote:

 I just double checked.  A month ago I followed the Django Polls 
 tutorial to the point and all of the above worked.

 But the second time I followed the Polls tutorial I used different 
 Model names such as *"class Citizen_voice(models.Model)"* instead of 
 the tutorials table name.

 class Poll(models.Model):



 Will my underscore table naming convention cause problems with *"Generic 
 views"* usage?







 On Wednesday, July 3, 2013 12:37:50 AM UTC+2, Pepsodent Cola wrote:
>
> Hi,
>
> 1.)
> When following the Django 1.5 poll tutorial everything works ok. 
>  Until I try to implement the *"Generic views"* to use less code in 
> the poll, then the poll app breaks.
> https://docs.djangoproject.**com/en/1.5/intro/tutorial04/#**
> use-generic-views-less-code-**is-better
>
>
> 2.)
> When go to this link in my web browser, then I get the following error 
> message.
> http://localhost:8000/polls/**specifics/2/
>
> Exception Value: 
>
> Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not 
> found.
>
>
>
> 3.)
> *Error during template rendering*
> /mysite/polls/templates/polls/**detail.html, *error at line 6*
>
> http://pastebin.com/4HSt1VyS
>
>
>{{ poll.question }}
> 
>{% if error_message %}{{ error_message }}{% 
>endif %}
> 
>**
>**
>{% csrf_token %}
>{% for choice in poll.choice_set.all

Re: django-simple-multitenant

2013-07-03 Thread Mario Gudelj
Depends what you need. Do you want to have users access data via
www.domain.com/user_acccount/ or http://user_account.domain.com? If it's
www.domain.com/user_acccount/ just foreign key your models to user model
and in your queries always include user as a filter. The other option is
somewhat harder.

Cheers,

_M


On 3 July 2013 22:20, Nigel Legg  wrote:

> I am building an app to, among other things, allow people to upload data
> files and carry out various analyses online.  I would like each user to
> only see the datafiles that they or members of their team (company,
> research team, etc) have uploaded.
> It seems that 
> django-simple-multitenantwould
>  be appropriate for this.  Are there any problems in using this, or
> other apps that would be easier to implement?
> Cheers N//
>
> Regards,
> Nigel Legg
> 07914 740972
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Django 1.5 runserver hangs in Chrome

2013-07-03 Thread Nikolas Stevenson-Molnar
I've just updated to Django 1.5 and am running into a problem when using
Chrome with the Django devlopment server (and staticfiles). One
particular page which loads a lot of static content /consistently/ hangs
in Chrome (works fine in Firefox). This seems similar to two resolved
issues: https://code.djangoproject.com/ticket/16099 and
https://code.djangoproject.com/ticket/18336. Except that I've waited
several minutes and the resources haven't finished loading. I've
increased request_queue_size as suggested in the second issue (first to
10, then 20, then 50) with no change.

I'd chalk this up entirely as a Chrome problem, except that if I switch
back to Django 1.4 (changing nothing else), everything goes back to
working fine. So what changed about runserver in Django 1.5 that might
cause this? And more importantly, how do I get around it? I'm running
everything on Windows 7 with Django 1.5.1 and the latest version of Chrome.

Thanks,
_Nik

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




Re: Django 1.5 runserver hangs in Chrome

2013-07-03 Thread Nikolas Stevenson-Molnar
Also, while Chrome is spinning, I can open Firefox and load pages
(including the problem page) just fine. So it's not that the server is
overloaded or anything like that...

_Nik

On 7/3/2013 5:39 PM, Nikolas Stevenson-Molnar wrote:
> I've just updated to Django 1.5 and am running into a problem when
> using Chrome with the Django devlopment server (and staticfiles). One
> particular page which loads a lot of static content /consistently/
> hangs in Chrome (works fine in Firefox). This seems similar to two
> resolved issues: https://code.djangoproject.com/ticket/16099 and
> https://code.djangoproject.com/ticket/18336. Except that I've waited
> several minutes and the resources haven't finished loading. I've
> increased request_queue_size as suggested in the second issue (first
> to 10, then 20, then 50) with no change.
>
> I'd chalk this up entirely as a Chrome problem, except that if I
> switch back to Django 1.4 (changing nothing else), everything goes
> back to working fine. So what changed about runserver in Django 1.5
> that might cause this? And more importantly, how do I get around it?
> I'm running everything on Windows 7 with Django 1.5.1 and the latest
> version of Chrome.
>
> Thanks,
> _Nik

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




Re: django dynamic template tag

2013-07-03 Thread Fadi Samara
its already included at the start of the template to load all plugin tags
{% load slider ...%}


Regards,
Fadi Samara.


On Wed, Jul 3, 2013 at 11:00 PM, Fred Stluka  wrote:

>  Fadi,
>
> You need to {% load %} the file that defines the tags.
>
> --Fred
> --
> Fred Stluka -- mailto:f...@bristle.com  --
> http://bristle.com/~fred/
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
> Open Source: Without walls and fences, we need no Windows or Gates.
> --
>
> On 7/2/13 8:11 PM, Fadi Samara wrote:
>
>  I try to build a plugins based application, I have created tags and
> registered them for each plugin.
>
> I have a table stores each page plugins, and need to render any stored
> plugin in the template accordingly as inclusion tag.
>
> Now for the template i use this:
>
> {% block slider_region %}{% for pagecontent in pagecontents %}
> {% pagecontent.plugin %}{% endfor %}{% endblock %}
>
>  But this returns:
>
> Invalid block tag: 'pagecontent.plugin', expected 'empty' or 'endfor'
>
> My question, how can I pass the plugin as a tag from view query to a
> template and be rendered as inclusion tag.
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>  --
> 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/AukAEPmgq_A/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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django dynamic template tag

2013-07-03 Thread Fadi Samara
Hi Fred,

its already included at the start of the template to load all plugin tags 
{% load slider ...%}

Thanks,


On Wednesday, July 3, 2013 11:00:31 PM UTC+10, Fred Stluka wrote:
>
>  Fadi,
>
> You need to {% load %} the file that defines the tags.
>
> --Fred 
> --
> Fred Stluka -- mailt...@bristle.com  -- 
> http://bristle.com/~fred/ 
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! 
> Open Source: Without walls and fences, we need no Windows or Gates. 
> --
>  
> On 7/2/13 8:11 PM, Fadi Samara wrote: 
>
>  I try to build a plugins based application, I have created tags and 
> registered them for each plugin.
>
> I have a table stores each page plugins, and need to render any stored 
> plugin in the template accordingly as inclusion tag.
>
> Now for the template i use this:
>
> {% block slider_region %}{% for pagecontent in pagecontents %}
> {% pagecontent.plugin %}{% endfor %}{% endblock %}
>
>  But this returns:
>
> Invalid block tag: 'pagecontent.plugin', expected 'empty' or 'endfor'
>
> My question, how can I pass the plugin as a tag from view query to a 
> template and be rendered as inclusion tag.
>  -- 
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Python Fabric manage.py problem

2013-07-03 Thread Roger Barnes
It looks like you may be missing a space after the word "source".

My fabfile has these helpers, given an env.virtualenv and env.app_dir 
setting...

def ve_run(command, func=run, base_dir=None, *args, **kwargs):

base_dir = base_dir or env.app_dirwith cd(base_dir):with 
prefix("source /opt/virtualenvs/%s/bin/activate" % env.virtualenv):
return func(command, *args, **kwargs)


def manage(*args):return ve_run("python manage.py " + ' '.join(args))


I've had problems with custom settings (with Django 1.3 FWIW) which meant I had 
to use django-admin.py, so if the above doesn't work, this might:


def manage(*args):
return _ve_run("django-admin.py " + ' '.join(args) + " --pythonpath . 
--settings %s%s" % (env.settings,))


Hope that helps,

- Roger


On Monday, 1 July 2013 16:28:21 UTC+10, Eduardo Basílio wrote:
>
> I use Python Fabric to deploy. Works great for accessing the remote 
> server, install dependencies, run linux commands, etc..
>
> But when I try to run *file commands manage.py Django*, NOT work!
>
>
> Example of my fabfile.py:
>
> with prefix ('source/home/user/env/bin/activate'):
>
> with cd ('path/to/your/project/django'):
>
> *run ('python manage.py help --settings=path.for.settings')*
>
>
> Fatal error: runstrong text() received nonzero return code while executing 
> one!
>
>
> I've tried putting a --noinput but the error remains:
>
> *run ('python manage.py help --settings=caminho.para.settings --noinput')*
>
> Does anyone know how to solve?
>

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




Django admin automatically adding slash to a URL field after update

2013-07-03 Thread ecasbas
Hi,

I have this issue wit the admin interface:

I try edit manually a register, I change some values and when I save the 
data, the URL field, which I have no modifed, 
become automatically with a slash append at the end. This issue is causing 
inconsistencies due to I normalize each
URL before save to BBDD, but when I modify manually some register, then the 
problem.

I tried the advice from: 
https://docs.djangoproject.com/en/dev/ref/middleware/
APPEND_SLASH = False

but without success, any hints?

TIA
Emilio

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




Re: django-simple-multitenant

2013-07-03 Thread Nigel Legg
Mario, I am not sure what you mean here.  I want users to be able to upload
data to the site, and do various things with it. I want each user to only
see the data they have uploaded.  Whether this is domain.com/uer_account or
user_account.domain.com I don't know, so long as it provides the
functionality I need. If I use the domain,com/user_account, can I do that
with the standard django auth system?

Regards,
Nigel Legg
07914 740972
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 4 July 2013 00:36, Mario Gudelj  wrote:

> Depends what you need. Do you want to have users access data via
> www.domain.com/user_acccount/ or http://user_account.domain.com? If it's
> www.domain.com/user_acccount/ just foreign key your models to user model
> and in your queries always include user as a filter. The other option is
> somewhat harder.
>
> Cheers,
>
> _M
>
>
> On 3 July 2013 22:20, Nigel Legg  wrote:
>
>> I am building an app to, among other things, allow people to upload data
>> files and carry out various analyses online.  I would like each user to
>> only see the datafiles that they or members of their team (company,
>> research team, etc) have uploaded.
>> It seems that 
>> django-simple-multitenantwould
>>  be appropriate for this.  Are there any problems in using this, or
>> other apps that would be easier to implement?
>> Cheers N//
>>
>> Regards,
>> Nigel Legg
>> 07914 740972
>> http://twitter.com/nigellegg
>> http://uk.linkedin.com/in/nigellegg
>>
>>  --
>> 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.
>> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.