Re: TEMPLATE_CONTEXT_PROCESSORS missing in settings.py

2013-06-25 Thread Some Developer

On 22/06/2013 02:24, asax...@princeton.edu wrote:


# Make this unique, and don't share it with anybody.
SECRET_KEY = '8c(j)m3dm!m3gd_n#vjjfqdeuq!ltsj3+xii617dos1i@_pc7*'


You'll want to change your secret key now that you have posted it on a 
public mailing list if you are actually planning on deploying your 
application into production.


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




delete file in GridFS by its id

2013-06-25 Thread Hélio Miranda
Hi
I have a problem that is how to delete a file from GridFS by its id.
I am using django and mongoengine.
To delete files of a certain record I'm doing this:

*marmot = Animal.objects.get(id='51c80fb28774a715dc0481ae')*
*marmot.photo.delete()*

Now just to delete a file by its id, was trying like this:

*marmot = Animal.objects.get(id='51c86ae18774a70fec1a9fb7')*
*marmot.photo(id='51c86ae18774a70fec1a9fb5').delete()*

But it gives me the following error: *'GridFSProxy' object is not callable*
Someone can help me? What am I doing 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.




hi [django-users] How to do something after "return HttpResponse(html)"?

2013-06-25 Thread lx
hi all:
  I want to do someing after "return HttpResponse(html)".
for example
""
from django.http import HttpResponse
import datetime
def current_datetime(request):
  now = datetime.datetime.now()
  html = "It is now %s." % now
  return HttpResponse(html)
"

Actually, I have a question that I need first give a response to the
client, second I do something else.
How to solve this?

Thank you

-- 
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: delete file in GridFS by its id

2013-06-25 Thread Tom Christie
 

Hi Hélio,

  I see that you've posted this question separately on each of the `django 
users`, `mongoengine users`, and `mongoengine developers`.

Please don't cross post questions on mailing lists - pick one appropriate 
mailing list and use that.  If you cross post questions there's every 
chance that other community members will spend time trying to help you out, 
without realizing that you've already resolved the issue in another thread 
on another list.  Posting to a single list is also more helpful for anyone 
else having the same issue later, as they can follow the replies in a 
single thread.

Also please keep in mind when posting to the lists that hundreds or 
thousands of people are going to spend a little bit of time reading and 
considering your questions.  The open source community tends to be very 
generous with its time, but cross-posting to multiple lists means you're 
demanding lots of attention to your questions, when just choosing the right 
list would mean that a smaller number of people would be able to consider 
your question and help you out.

This question is probably most appropriate for `mongoengine users`, so in 
this case just post there.

Many thanks,

  Tom

On Tuesday, 25 June 2013 10:38:08 UTC+1, Hélio Miranda wrote:
>
> Hi
> I have a problem that is how to delete a file from GridFS by its id.
> I am using django and mongoengine.
> To delete files of a certain record I'm doing this:
>
> *marmot = Animal.objects.get(id='51c80fb28774a715dc0481ae')*
> *marmot.photo.delete()*
>
> Now just to delete a file by its id, was trying like this:
>
> *marmot = Animal.objects.get(id='51c86ae18774a70fec1a9fb7')*
> *marmot.photo(id='51c86ae18774a70fec1a9fb5').delete()*
>
> But it gives me the following error: *'GridFSProxy' object is not callable
> *
> Someone can help me? What am I doing 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.




Re: Background pattern files on S3 not being found while hosted on Heroku

2013-06-25 Thread Vincent Fulco
retried #3 without quotes and link works now.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Django Debug Toolbar inside Webkit DevTools

2013-06-25 Thread recamshak
I like Django Debug Toolbar, it's much more pleasant than looking at logs 
to quickly find out SQL requests that were executed to render a page.
But I was frustrated not being able to use it on AJAX requests. So I 
started a chrome DevTools 
extension
 and 
a Django application  that 
make the Debug Toolbar available inside a DevTools panel.
You can now look at all your AJAX requests (even non-HTML ones) with the 
Debug Toolbar.

Both are distributed under the BSD license.
Please try it, I would be very happy to get some feedback.

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

2013-06-25 Thread Harjot Mann
I have created a table in django templates but I want that the fields which 
are not filled from form should not be display in table not even the border 
and header of that field also. The headers are static while the data is 
coming from database. I  used if and for loop for this but whenever I am 
adding multiple row in a form it displays the table header equal to the 
number of rows added.
Code for this is as:

{% for test in st %}S.No
  {% ifnotequal test.Description "" %}Description{% 
endifnotequal %}
  {% ifnotequal test.Thickness "" %}Thickness{% endifnotequal 
%}
  {% ifnotequal test.Comp_Strength_MPa "" %}Compressive 
Strength(Mpa){% endifnotequal %}
{% endfor  %}
{% for test in st %}



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




Select2Multiple with list_filter :(

2013-06-25 Thread Jesús Lucas Flores
Hi i am looking for a thirth package for a usual funcinality : I want 
filter for multiple values with list_filter for django admin but I can't . 
( I search for something like Select2Multiple )

anybody can help me?

Thank you!
*Sorry about my english

-- 
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: hi [django-users] How to do something after "return HttpResponse(html)"?

2013-06-25 Thread Timster
You cannot do something after the "return" line. This is Python 
functionality. When you return, the function exits and does not process 
anything else.

What exactly are you trying to do? There is probably another way to 
accomplish it.

-- 
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 Related Objects in MODEL._meta.get_all_related_objects

2013-06-25 Thread Emil Stenström
On Thursday, 17 February 2011 17:09:26 UTC+1, Martin Siniawski wrote:
>
> Hey! 
>
> So we have a certain model which is related with many other models, by 
> ForeignKey fields set in those other models. 
>
> The setup is not particularly exotic, but for some reason, when 
> using ._meta.get_all_related_objects() on the model which has all the 
> ForeignKey fields pointing at it, some of the related objects that 
> should be returned are missing. 
>

This is an old thread, but since I solved a similar problem I thought I'd 
reply anyway.

What you are looking for is probably 
get_all_related_many_to_many_objects(). "get_all_related_objects" really 
just means "get_all_related_foreginkey_objects", so that could explain that 
some fields are missing.

/Emil

-- 
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: hi [django-users] How to do something after "return HttpResponse(html)"?

2013-06-25 Thread Sandro Dutra
The question is: What you're trying to do?

1. You can do any other process before the return line, the return will be
the same... for example:

from django.http import HttpResponse
from datetime import datetime
def current_datetime(request):
  now = datetime.now()
  html = "It is now %s." % now
  year = now.year()
  return HttpResponse(html)


2. You can use a conditional to have multiple returns:
from django.http import HttpResponse
from datetime import datetime
def current_datetime(request):
  now = datetime.now()
  html = "It is now %s." % now
  year = now.year()
  if year == 2013:
  return HttpResponse(html)
 else:
  return HttpResponse(Sorry it's not
2013.")


2013/6/25 Timster 

> You cannot do something after the "return" line. This is Python
> functionality. When you return, the function exits and does not process
> anything else.
>
> What exactly are you trying to do? There is probably another way to
> accomplish it.
>
>  --
> 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: hi [django-users] How to do something after "return HttpResponse(html)"?

2013-06-25 Thread lx
Thank you.

The real demand is:

1.
receive the xml file from client.

2.
if (the xml format is ERROR) == True:
return HttpResponse(ERROR FORMAT")
else:
return HttpResponse(RIGHT FORMAT")
#I must give a response first, And do other thing. Because the spend
time of do_something() may be long.
do_something(the xml file)






2013/6/25 Sandro Dutra 

> The question is: What you're trying to do?
>
> 1. You can do any other process before the return line, the return will be
> the same... for example:
>
> from django.http import HttpResponse
> from datetime import datetime
> def current_datetime(request):
>   now = datetime.now()
>   html = "It is now %s." % now
>   year = now.year()
>   return HttpResponse(html)
>
>
> 2. You can use a conditional to have multiple returns:
> from django.http import HttpResponse
> from datetime import datetime
> def current_datetime(request):
>   now = datetime.now()
>   html = "It is now %s." % now
>   year = now.year()
>   if year == 2013:
>   return HttpResponse(html)
>  else:
>   return HttpResponse(Sorry it's not
> 2013.")
>
>
> 2013/6/25 Timster 
>
>> You cannot do something after the "return" line. This is Python
>> functionality. When you return, the function exits and does not process
>> anything else.
>>
>> What exactly are you trying to do? There is probably another way to
>> accomplish it.
>>
>>  --
>> 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.




Hi..how to create seperate label next to sign up button in login page and direct user to new page using django?

2013-06-25 Thread Viji Venkatesan


-- 
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: File Path Question

2013-06-25 Thread Bill Freeman
Try using single forward slashes in MEDIA_ROOT (and in other paths in
settings.py).


On Sat, Jun 22, 2013 at 3:46 AM, Nigel Legg  wrote:

> MEDIA_ROOT = 'c:\\stats_portal\\myproject\\myproject\\media\\'
>
> doesn't work.  I've parsed the path to get this working for the time
> being, thanks for your help.
>
> Regards,
> Nigel Legg
> 07914 740972
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>
>
> On 21 June 2013 19:09, Jacky Tian  wrote:
>
>> Have you set your MEDIA_ROOT appropriately in settings.py? Since
>> fileview.py is where your original exception originated, can you post the
>> relevant parts of the source in that file (whatever function line 5 belongs
>> to). Did you get the exception under runserver or a "real" webserver?
>>
>> You shouldn't need to change the slashes in your path, Python handles
>> that for you.
>>
>> -Jacky Tian
>>
>> On Friday, June 21, 2013 11:34:16 AM UTC-4, Nigel Legg wrote:
>>
>>> In the path shown in my previous email, documents is a subdirectory of
>>> the media directory, which is set in settings.py.
>>>
>>> views.py:
>>> from myproject.myapp.forms import DocumentForm
>>>
>>> def list(request):
>>> # Handle file upload
>>> if request.method == 'POST':
>>> form = DocumentForm(request.POST, request.FILES)
>>> if form.is_valid():
>>> newdoc = Document(docfile = request.FILES['docfile'])
>>> newdoc.save()
>>>
>>> # Redirect to the document list after POST
>>> return HttpResponseRedirect(reverse('**
>>> myproject.myapp.views.list'))
>>> else:
>>> form = DocumentForm() # A empty, unbound form
>>>
>>> # Load documents for the list page
>>> documents = Document.objects.all()
>>>
>>> # Render list page with the documents and the form
>>> return render_to_response(
>>> 'myapp/list.html',
>>> {'documents': documents, 'form': form},
>>> context_instance=**RequestContext(request)
>>> )
>>>
>>> models.py:
>>> from django.db import models
>>>
>>> class Document(models.Model):
>>> docfile = models.FileField(upload_to='**documents/%Y/%m/%d')
>>>
>>> this section works fine - ie files yesterday were uploaded to
>>> c:\\\\myproject\\media\\**documents\\2013\\06\\20\\file.**csv.
>>>  I need now to be able to access them.  This error suggests I need to
>>> convert  documents/%Y/%m/%d' to documents\\2013\\06\\20\\ to be able to do
>>> so.  Is that correct?
>>>
>>> Regards,
>>> Nigel Legg
>>> 07914 740972
>>> http://twitter.com/nigellegg
>>> http://uk.linkedin.com/in/**nigellegg
>>>
>>>
>>>
>>> On 21 June 2013 16:25, Jacky Tian  wrote:
>>>
  What does your project directory tree look like? I suspect the error
 has to do with where your documents/ directory is located in relation to
 the working directory. Try loading the document using a path relative to
 your project root.

 -Jacky Tian



 On Friday, June 21, 2013 9:29:20 AM UTC-4, Nigel Legg wrote:
>
> New to Django(ish).  I'm not sure whether my error is coding or OS
> related:
> I am getting the following error message:
>
> IOError at /myapp/file_view/4/
>
> [Errno 2] No such file or directory: 
> 'documents/2013/06/20/**testdata**1.csv'
>
>  Request Method: GET  Request URL: http://127.0.0.1:8000/myapp/**fi**
> le_view/4/   Django Version:
> 1.5.1  Exception Type: IOError  Exception Value:
>
> [Errno 2] No such file or directory: 
> 'documents/2013/06/20/**testdata**1.csv'
>
>  Exception Location: 
> C:\stats_portal\myproject\**mypr**oject\myapp\fileview.py
> in filedata, line 5  Python Executable: c:\python27\python.exe  Python
> Version: 2.7.5  Python Path:
>
> ['C:\\stats_portal\\myproject',
>  
> 'c:\\python27\\lib\\site-**packa**ges\\python_dateutil-1.5-**py2.**7.egg',
>  
> 'c:\\python27\\lib\\site-**packa**ges\\django_directupload-**0.0.**11-py2.7.egg',
>  'C:\\windows\\system32\\**python**27.zip',
>  'c:\\python27\\DLLs',
>  'c:\\python27\\lib',
>  'c:\\python27\\lib\\plat-win',
>  'c:\\python27\\lib\\lib-tk',
>  'c:\\python27',
>  'c:\\python27\\lib\\site-**packa**ges']
>
>  Server time: Fri, 21 Jun 2013 14:09:20 +0100
> Is the file not found problem because the upload has recorded it as
> documents/2013/06/... even though I am working on Windows, so python /
> django should have ... documents\\2013\\06\\... etc? I am developing on
> Windows, but will deploy on Linux.
> Or have I made an error elsewhere?
>
>
> Regards,
> Nigel Legg
> 07914 740972
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/**nige**llegg
>
>   --
 You received this message because you are subscribed to the Google
 Groups "Django

Re: Hi..how to create seperate label next to sign up button in login page and direct user to new page using django?

2013-06-25 Thread Sergiy Khohlov
  add url to your code (at login page)  and   and this url  to url.py
 Dont forget to pass tutorials

Many thanks,

Serge


+380 636150445
skype: skhohlov


On Tue, Jun 25, 2013 at 4:19 PM, Viji Venkatesan  wrote:

>
>  --
> 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: hi [django-users] How to do something after "return HttpResponse(html)"?

2013-06-25 Thread Sandro Dutra
If the "do_something" will take a long time to finish, you've 2 options:
Find a better (optimized) way to "do_something" or inform your client the
application is doing something and he will have to wait a little.

So, I can't see any advantage to say to your client there's something was
ok if the application is not finish his work. If something goes wrong while
"do_something" is working, your client will think everything was ok, but
you'll an ocult error.


2013/6/25 lx 

> Thank you.
>
> The real demand is:
>
> 1.
> receive the xml file from client.
>
> 2.
> if (the xml format is ERROR) == True:
> return HttpResponse(ERROR FORMAT")
> else:
> return HttpResponse(RIGHT FORMAT")
> #I must give a response first, And do other thing. Because the spend
> time of do_something() may be long.
> do_something(the xml file)
>
>
>
>
>
>
> 2013/6/25 Sandro Dutra 
>
>> The question is: What you're trying to do?
>>
>> 1. You can do any other process before the return line, the return will
>> be the same... for example:
>>
>> from django.http import HttpResponse
>> from datetime import datetime
>> def current_datetime(request):
>>   now = datetime.now()
>>   html = "It is now %s." % now
>>   year = now.year()
>>   return HttpResponse(html)
>>
>>
>> 2. You can use a conditional to have multiple returns:
>> from django.http import HttpResponse
>> from datetime import datetime
>> def current_datetime(request):
>>   now = datetime.now()
>>   html = "It is now %s." % now
>>   year = now.year()
>>   if year == 2013:
>>   return HttpResponse(html)
>>  else:
>>   return HttpResponse(Sorry it's not
>> 2013.")
>>
>>
>> 2013/6/25 Timster 
>>
>>> You cannot do something after the "return" line. This is Python
>>> functionality. When you return, the function exits and does not process
>>> anything else.
>>>
>>> What exactly are you trying to do? There is probably another way to
>>> accomplish it.
>>>
>>>  --
>>> 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.
>
>
>

-- 
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: Writing your first Django app - Tutorial Question

2013-06-25 Thread Tony Guilin

>
>  you have missed 
>  from django.utils import timezone
>

That worked! Thanks.

P.S. I just copy and paste in Chrome (in Ubuntu)  and it picks up the 
formatting.

 

On Tuesday, June 4, 2013 4:10:23 PM UTC-7, Tony Guilin wrote:
>
> In the https://docs.djangoproject.com/en/1.5/intro/tutorial01/ tutorial 
> under the,
> Playing with the API
>
>
>
> section, I'm trying to go through the example in my python shell as 
> described.
>
>
> p = Poll(question="What's new?", pub_date=timezone.now())
>
> But I'm unable to get to next command "p.save()" because of the error 
> below.
>
>> tony@tonymachine:~/django_projects/mysite$ python manage.py shell
>> Python 2.7.3 (default, Aug 1 2012, 05:16:07)
>> [GCC 4.6.3] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> (InteractiveConsole)
>> >>> from polls.models import Poll, Choice
>> >>> Poll.objects.all()
>> []
>> >>> from django.utils import timezone
>> >>> p = Poll(question="What's new?", pub_date=timezone.now())
>> Traceback (most recent call last):
>>  File "", line 1, in 
>>  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
>> line 415, in __init__
>>  raise TypeError("'%s' is an invalid keyword argument for this function" 
>> % list(kwargs)[0])
>> TypeError: 'pub_date' is an invalid keyword argument for this function
>> >>>
>>
> Any guidance is appreciated.
>
>

-- 
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: hi [django-users] How to do something after "return HttpResponse(html)"?

2013-06-25 Thread Hector Armando Vela Santos
You can use Celery for that, I've done something similar, just with a CSV 
instead of a XML, check 
this http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

once installed and configured, its as simple as:

from celery import task

if (the xml format is ERROR) == True:
return HttpResponse(ERROR FORMAT")
else:
do_something.delay(the_xml_file)
return HttpResponse(RIGHT FORMAT")
#I must give a response first, And do other thing. Because the spend 
time of do_something() may be long.

@task(ignore_result=True)
def do_something(xml):
#do something time consuming


and the do_something function will be called in second plane, and the user 
will get an instant response, even if the parsing file process takes half 
an hour

On Tuesday, June 25, 2013 8:32:59 AM UTC-5, lx wrote:
>
> Thank you.
>
> The real demand is:
>
> 1.
> receive the xml file from client.
>
> 2.
> if (the xml format is ERROR) == True:
> return HttpResponse(ERROR FORMAT")
> else:
> return HttpResponse(RIGHT FORMAT")
> #I must give a response first, And do other thing. Because the spend 
> time of do_something() may be long.
> do_something(the xml file)
>
>
>
>
>
>
> 2013/6/25 Sandro Dutra >
>
>> The question is: What you're trying to do?
>>
>> 1. You can do any other process before the return line, the return will 
>> be the same... for example:
>>
>> from django.http import HttpResponse
>> from datetime import datetime
>> def current_datetime(request):
>>   now = datetime.now()
>>   html = "It is now %s." % now
>>   year = now.year()
>>   return HttpResponse(html)
>>
>>
>> 2. You can use a conditional to have multiple returns:
>> from django.http import HttpResponse
>> from datetime import datetime
>> def current_datetime(request):
>>   now = datetime.now()
>>   html = "It is now %s." % now
>>   year = now.year()
>>   if year == 2013:
>>   return HttpResponse(html)
>>  else:
>>   return HttpResponse(Sorry it's not 
>> 2013.")
>>
>>
>> 2013/6/25 Timster >
>>
>>> You cannot do something after the "return" line. This is Python 
>>> functionality. When you return, the function exits and does not process 
>>> anything else.
>>>
>>> What exactly are you trying to do? There is probably another way to 
>>> accomplish it.
>>>
>>>  -- 
>>> 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...@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: Select2Multiple with list_filter :(

2013-06-25 Thread carlos
Hi maybe help you try this snippets http://djangosnippets.org/snippets/1758/

Cheers


On Tue, Jun 25, 2013 at 6:21 AM, Jesús Lucas Flores wrote:

> Hi i am looking for a thirth package for a usual funcinality : I want
> filter for multiple values with list_filter for django admin but I can't .
> ( I search for something like Select2Multiple )
>
> anybody can help me?
>
> Thank you!
> *Sorry about my english
>
> --
> 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: Multi-DB read replica unit test raises TransactionManagementError

2013-06-25 Thread Michael
Bump! I'm experiencing the same issue.

On Friday, 3 May 2013 23:19:26 UTC+1, TTimo wrote:
>
> Hello,
>
> I started assessing multi-db support in Django 1.5.1, I'm interested in 
> having read replicas and a write master.
>
> I've figured out all the easy stuff: using TEST_MIRROR in the DATABASES 
> setting, writing a simple router that splits read and write traffic, all 
> according to the documentation. I can run a test server and issue some 
> calls manually, but I have not been able to run simple unit tests.
>
> The most simple test I can build fails during _pre_setup() with a 
> "TransactionManagementError: Transaction managed block ended with pending 
> COMMIT/ROLLBACK"
>
> My databases are MySQL EC2 RDS instances, the replication is working fine, 
> the tables are InnoDB etc.
>
> I know there is active development around transaction management code in 
> Django lately, so maybe I've stumbled on a bug? I'm attaching a simple test 
> setup that should make it easy to reproduce.
>
> Any advice would be greatly appreciated.
>
> Cheers,
> TTimo
>
> ./manage.py test readreplica
> Creating test database for alias 'default'...
> E
> ==
> ERROR: testTest (readreplica.tests.Test)
> --
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
> line 240, in __call__
> self._pre_setup()
>   File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
> line 462, in _pre_setup
> self._fixture_setup()
>   File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
> line 822, in _fixture_setup
> if not connections_support_transactions():
>   File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
> line 809, in connections_support_transactions
> for conn in connections.all())
>   File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
> line 809, in 
> for conn in connections.all())
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 
> 48, in __get__
> res = instance.__dict__[self.func.__name__] = self.func(instance)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", 
> line 627, in supports_transactions
> self.connection.leave_transaction_management()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", 
> line 319, in leave_transaction_management
> "Transaction managed block ended with pending COMMIT/ROLLBACK")
> TransactionManagementError: Transaction managed block ended with pending 
> COMMIT/ROLLBACK
>
> --
> Ran 0 tests in 0.084s
>
> FAILED (errors=1)
> Destroying test database for alias 'default'...
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Set up django-celery with mod_wsgi

2013-06-25 Thread no body
I have set up the django-celery in my local machine as the following
*
*
*#settings.py
import djcelery
djcelery.setup_loader()

BROKER_TRANSPORT = "django"
CELERY_ALWAYS_EAGER = True
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"*

In order to let the user set/modify the periodic task on the admin site
without reloading the server, I need to use django-supervisord  with the
following setup
*
*
*# supervisord.conf*
*[program:webserver]
command={{ PYTHON }} {{ PROJECT_DIR }}/manage.py runserver --noreload

[program:celeryd]
command={{ PYTHON }} {{ PROJECT_DIR }}/manage.py celerybeat


*
The local machine works great. Task are scheduled every 30 minutes.

Now I need to make it run on the client server. I used apache and mod_wsgi
to host and run my project. And this is my wsgi.py

*os.environ.setdefault("DJANGO_SETTINGS_MODULE", "abc.settings")
sys.path.append('/opt/a/wwwroot/b/')
sys.path.append('/opt/a/wwwroot/b/abc')

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
*
And this is httpd.conf

*   DirectoryIndex index.php

DocumentRoot /opt/a/wwwroot

Alias /static /opt/a/wwwroot/b/abc/abc/static

Order deny,allow
Allow from all


WSGIScriptAlias / /opt/a/wwwroot/b/abc/abc/wsgi.py



Order deny,allow
Allow from all

*

Project run well, except the period task. There is no complain of django on
the admin site when I added the task. I had *supervisord  *package
installed (pip install supervisord). How can I set up and make it run
normally on this server (I do not have the root access on this server,
though)

-- 
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: Set up django-celery with mod_wsgi

2013-06-25 Thread no body
I am trying to use

*echo_supervisord_conf  > schedule.conf *

then add the schedule.conf witth

*[program:celeryd]
command=python /opt/a/wwwroot/b/abc/manage.py celerybeat
*

and runt this command. Not sure whether this will work. Have to wait a bit
now

*supervisord  -c schedule.conf*


On Tue, Jun 25, 2013 at 11:18 PM, no body  wrote:

> I have set up the django-celery in my local machine as the following
> *
> *
> *#settings.py
> import djcelery
> djcelery.setup_loader()
>
> BROKER_TRANSPORT = "django"
> CELERY_ALWAYS_EAGER = True
> CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"*
>
> In order to let the user set/modify the periodic task on the admin site
> without reloading the server, I need to use django-supervisord  with the
> following setup
> *
> *
> *# supervisord.conf*
> *[program:webserver]
> command={{ PYTHON }} {{ PROJECT_DIR }}/manage.py runserver --noreload
>
> [program:celeryd]
> command={{ PYTHON }} {{ PROJECT_DIR }}/manage.py celerybeat
>
>
> *
> The local machine works great. Task are scheduled every 30 minutes.
>
> Now I need to make it run on the client server. I used apache and mod_wsgi
> to host and run my project. And this is my wsgi.py
>
> *os.environ.setdefault("DJANGO_SETTINGS_MODULE", "abc.settings")
> sys.path.append('/opt/a/wwwroot/b/')
> sys.path.append('/opt/a/wwwroot/b/abc')
>
> # This application object is used by any WSGI server configured to use this
> # file. This includes Django's development server, if the WSGI_APPLICATION
> # setting points here.
> from django.core.wsgi import get_wsgi_application
> application = get_wsgi_application()
> *
> And this is httpd.conf
>
> *   DirectoryIndex index.php
>
> DocumentRoot /opt/a/wwwroot
>
> Alias /static /opt/a/wwwroot/b/abc/abc/static
> 
> Order deny,allow
> Allow from all
> 
>
> WSGIScriptAlias / /opt/a/wwwroot/b/abc/abc/wsgi.py
>
> 
> 
> Order deny,allow
> Allow from all
> 
> *
>
> Project run well, except the period task. There is no complain of django
> on the admin site when I added the task. I had *supervisord  *package
> installed (pip install supervisord). How can I set up and make it run
> normally on this server (I do not have the root access on this server,
> though)
>

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




How to have two unicode methods in the models?

2013-06-25 Thread yeswanth nadella
This is what I currently have-

def __unicode__(self):
return u'%s %s %s %s %s %s' % (self.first_name, self.last_name, 
self.course, self.lab, self.start_time, self.end_time)

How do I add another unicode method so that it will return only first_name 
and last_name? I understand that unicode method is a constructor. So, is 
there an alternative for this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How can I have two unicode methods?

2013-06-25 Thread yeswanth nadella
In my models file, I have the following unicode method-

def __unicode__(self):
return u'%s %s %s %s %s %s' % (self.first_name, self.last_name, 
self.course, self.lab, self.start_time, self.end_time)

How can I have another unicode method which will return only first_name and 
last_name? I understand unicode is a constructor. So is there any 
alternative for this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How can I have two unicode methods?

2013-06-25 Thread Sithembewena Lloyd Dube
I have previously achieved this by using an if statement as follows:

if :
return 
else:
return 

What is your specific requirement, i.e. why do you need to implement this?


On Wed, Jun 26, 2013 at 3:47 AM, yeswanth nadella wrote:

> In my models file, I have the following unicode method-
>
> def __unicode__(self):
> return u'%s %s %s %s %s %s' % (self.first_name, self.last_name,
> self.course, self.lab, self.start_time, self.end_time)
>
> How can I have another unicode method which will return only first_name
> and last_name? I understand unicode is a constructor. So is there any
> alternative for this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> 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: How to have two unicode methods in the models?

2013-06-25 Thread Christophe Pettus

On Jun 25, 2013, at 6:54 PM, yeswanth nadella wrote:

> How do I add another unicode method so that it will return only first_name 
> and last_name?

You can have as many methods in a model class as you wish, of course, but you 
can only have one __unicode__, since that's what handles unicode() and str() 
calls.  In those situations, I just create a new method with an appropriate 
name.

--
-- Christophe Pettus
   x...@thebuild.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




hi [django-users]How to define the response?

2013-06-25 Thread lx
hi :
   I'm a new one. I want to fix a question.Like this:


from django.http import HttpResponse
import datetime
def current_datetime(request):
  now = datetime.datetime.now()
  if now == 2013:
  html = "It is now %s."
% now
  return HttpResponse(html)
  else:
 # giva a response first
 urllib.urlopen(message)
 # do something
 print 'not 2013'
 sys.exit(0)



How to use " urllib.urlopen(message)" instead of "HttpResponse()" ?

Thank you.

-- 
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: hi [django-users] How to do something after "return HttpResponse(html)"?

2013-06-25 Thread lx
Thank you.
But I want to fix it like this, because the time of "do something" is not
long.
###

from django.http import HttpResponseimport datetimedef
current_datetime(request):
  now = datetime.datetime.now()
  if now == 2013:
  html = "It is now %s." % now
  return HttpResponse(html)
  else:
 # giva a response first
 urllib.urlopen(message)
 # do something
 print 'not 2013'
 sys.exit(0)


###


2013/6/25 Hector Armando Vela Santos 

> You can use Celery for that, I've done something similar, just with a CSV
> instead of a XML, check this
> http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
>
> once installed and configured, its as simple as:
>
> from celery import task
>
> if (the xml format is ERROR) == True:
> return HttpResponse(ERROR FORMAT")
> else:
> do_something.delay(the_xml_file)
> return HttpResponse(RIGHT FORMAT")
> #I must give a response first, And do other thing. Because the spend
> time of do_something() may be long.
>
> @task(ignore_result=True)
> def do_something(xml):
> #do something time consuming
>
>
> and the do_something function will be called in second plane, and the user
> will get an instant response, even if the parsing file process takes half
> an hour
>
>
> On Tuesday, June 25, 2013 8:32:59 AM UTC-5, lx wrote:
>
>> Thank you.
>>
>> The real demand is:
>>
>> 1.
>> receive the xml file from client.
>>
>> 2.
>> if (the xml format is ERROR) == True:
>> return HttpResponse(ERROR FORMAT")
>> else:
>> return HttpResponse(RIGHT FORMAT")
>> #I must give a response first, And do other thing. Because the spend
>> time of do_something() may be long.
>> do_something(the xml file)
>>
>>
>>
>>
>>
>>
>> 2013/6/25 Sandro Dutra 
>>
>>> The question is: What you're trying to do?
>>>
>>> 1. You can do any other process before the return line, the return will
>>> be the same... for example:
>>>
>>> from django.http import HttpResponse
>>> from datetime import datetime
>>> def current_datetime(request):
>>>   now = datetime.now()
>>>   html = "It is now %s." % now
>>>   year = now.year()
>>>   return HttpResponse(html)
>>>
>>>
>>> 2. You can use a conditional to have multiple returns:
>>> from django.http import HttpResponse
>>> from datetime import datetime
>>> def current_datetime(request):
>>>   now = datetime.now()
>>>   html = "It is now %s." % now
>>>   year = now.year()
>>>   if year == 2013:
>>>   return HttpResponse(html)
>>>  else:
>>>   return HttpResponse(Sorry it's not
>>> 2013.")
>>>
>>>
>>> 2013/6/25 Timster 
>>>
 You cannot do something after the "return" line. This is Python
 functionality. When you return, the function exits and does not process
 anything else.

 What exactly are you trying to do? There is probably another way to
 accomplish it.

  --
 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...@**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..

How can I view in the templates the files that I stored by “models.FilePathField”?

2013-06-25 Thread Federico Erbea


I can't understand how to pass to the template a relative path rather than 
an absolute. Could you help me please...??!

here a class of my models.py :

class Brano( models.Model ):
titolo = models.CharField( max_length=39 )
testo = models.TextField( max_length=1000 )

locandina = models.FilePathField( path="C:/Users/Federico/Google 
Drive/Umore/apps/Database/static/Brani/Locandina", recursive=True )
copertina = models.FilePathField( path="C:/Users/Federico/Google 
Drive/Umore/apps/Database/static/Brani/Copertina", recursive=True )

data_inserimento = models.DateField( null=True, verbose_name="data 
d'inserimento" )
anno = models.ForeignKey( Anno )
durata = models.CharField( max_length=5 )
albums = models.ManyToManyField( Album )
artisti = models.ManyToManyField( Artista )
generi = models.ManyToManyField( Genere_Brano )
colonne_sonore = models.ManyToManyField( Film, blank=True )
def __unicode__(self):
return self.titolo
class Meta:
verbose_name_plural = "Brani"
ordering = ("-anno", )

here a def of my views.py :

def brano(request, id):
brano = get_object_or_404( Brano, pk=id )
return render_to_response('Brano.html', { 'brano': brano })

here part of my template :




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