IOError, Permission Denied using Amazon s3 w/ django-storage?

2012-12-08 Thread easypie
I encountered an error where whenever I go to upload a file, it tells me 
that a folder doesn't have enough permission. What kind of permission do we 
give these folders? I use Apache server. Do I change the whole project 
folder to group www-data? Then set chmod to 775 to the project folder and 
all files in the project recursively? Here is my traceback error log: 
http://dpaste.org/5KUMf/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/eQd9aDbaZxcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Model method versus overriding save()

2012-12-08 Thread Thomas Lockhart

On 12/8/12 5:37 AM, Derek wrote:
Rather than use a trigger (which is DB-specific and also hard to debug 
because not part of your code base), suggest you use signals[1].
Hmm. Triggers have advantages over application-level code where they can 
be used. They are likely more efficient (no data needs to be transferred 
to the client) and are more likely to ensure data integrity (by 
operating within a database transaction in an atomic fashion, and 
without application-level edge case failures). For cases like this one, 
debugging should be pretty easy because one can add or increment values 
in a table and watch the trigger do the additional work.


That's not to say that signals aren't a great feature, just that compact 
trigger code can have advantages and, well, that code is part of the 
code base too.


  - Tom



Derek

[1] https://docs.djangoproject.com/en/dev/topics/signals/

On Saturday, 8 December 2012 04:27:50 UTC+2, Chris Cogdon wrote:

It's a simple performance vs storage question.

Storing a calculatable field also risks it getting out of sync
with reality, but if you're doing the query on that _so_ much,
then its usualyl worth it.

Also, with the right database and a trigger, that's something the
database can ensure for you. Ie, a field that the database updates
for you.


On Friday, December 7, 2012 5:54:37 PM UTC-8, Victor Hooi wrote:

Hi,

I have a "ranking" field for an item that returns an integer
between 1 to 10 based on a number of criteria of each item.

My question is - what are the pros and cons of using a model
method to return this, versus overriding the save() method and
saving it directly into a normal IntegerField on that item?

I understand that model methods *won't* let me use them within
QuerySet filters on that item - is there any way around that?

If I just override the model's save() method to get it
recalculate and save that field each time, I can use it within
QuerySet filters. Any cons with that approach?

What do you guys tend to use in your projects?

Cheers,
Victor

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/G7fp5OLkapgJ.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Internal Error after chaning SITE domain name and modifying html file...?

2012-12-08 Thread Ramiro Morales
On Fri, Dec 7, 2012 at 6:21 PM, easypie  wrote:
> Here's my wsgi.py file located in my project: http://dpaste.org/dBRqQ/
>

Sorry I miesread the traceback. In,oine 4 of wsgi.py you import settings
and the one reporting the about about /etc/apache2/https is settings.py

Is it possible that you somehow are importing/including/referencing
/etc/apache2/https from settings.py?

-- 
Ramiro Morales

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Internal Error after chaning SITE domain name and modifying html file...?

2012-12-08 Thread Ramiro Morales
On Fri, Dec 7, 2012 at 6:16 PM, easypie  wrote:
> Here's my apache log. I know this is outside of django but this might help
> find the cause: http://dpaste.org/V9ONE/  thanks for the helps.

>From the traceback you attached to the first message I'd say you need
to review or post the /home/easyi/.virtualenvs/tomw/project/tomw/wsgi.py
file.

According to the traceback it has in line 4 a reference to a
/etc/apache2/https or /etc/apache2/https: file that doesn't exist.

-- 
Ramiro Morales

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Using X-editable with Django?

2012-12-08 Thread Steven L
 I am trying to get 
X-Editable inline 
editing of a model in Django. I am simply trying to change attributes of a 
model instance (in this case, the name of a Dataset object). Whenever I try 
to make the inline edit, I get an error that says that there is no CSRF 
protection. How can I add this this?

Also, I am not sure how to write the view so that it correctly captures the 
information from the ajax request:

POST /datasets/9/update_name/{
pk:3//primary key (record id)
value: 'The Updated Name' //new value}

Then save the new name to the Dataset object.

urls.py

# ex: /datasets/3/update_name
url(r'^(?P\d+)/update_name/$', update_name ,
name='update_name'),

detail.html


  {{ dataset.name }}
// using jQueryfunction getCookie(name) {
  var cookieValue = null;
  if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
  var cookie = jQuery.trim(cookies[i]);
  // Does this cookie string begin with the name we want?
  if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
  }
}
  }
  return cookieValue;
}
var csrftoken = getCookie('csrftoken');

function csrfSafeMethod(method) {
  // these HTTP methods do not require CSRF protection
  return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));}
$.ajaxSetup({ 
 beforeSend: function(xhr, settings) {
   function getCookie(name) {
 var cookieValue = null;
 if (document.cookie && document.cookie != '') {
   var cookies = document.cookie.split(';');
   for (var i = 0; i < cookies.length; i++) {
 var cookie = jQuery.trim(cookies[i]);
   // Does this cookie string begin with the name we want?
   if (cookie.substring(0, name.length + 1) == (name + '=')) {
 cookieValue = 
decodeURIComponent(cookie.substring(name.length + 1));
 break;
   }
 }
   }
   return cookieValue;
 }
 if (!(/^http:.*/.test(settings.url) || 
/^https:.*/.test(settings.url))) {
   // Only send the token to relative URLs i.e. locally.
   xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
 }
   } 
 });
$('#datasetName').editable({
  type: 'text',
  pk: {{ dataset.pk }},
  url: '{% url 'datasets:update_name' dataset.pk %}',
  title: 'Edit dataset name',});

views.py

def update_name(request, dataset_id):   
# ... Update Dataset object ...
json = simplejson.dumps(request.POST)
return HttpResponse(json, mimetype='application/json') 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/S0b-lgcqgxwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Using etags for backend caching

2012-12-08 Thread Tom Eastman

Hey guys,

My project makes pretty heavy use of etags for browser-level caching, 
but I'd like to go one step further and be able to cache pages on the 
backend keyed by the page's etag.


As far as I can tell, none of the current built-in caching 
middleware/decorators or conditional processing does this, but I don't 
think it will be terribly hard to implement.


The logic would look something like this:

etag = calculate_etag(request)
if etag in cache:
return cache.get(etag)
else:
response = view(request, ...)
cache.set(etag, response)
return response

Does this seem feasible? Are there any major problems I'm missing? Has 
someone already done it?


If no-one's done it before, and you think it sounds super useful, should 
I write a generic enough version that I can put online for people to use?


Thanks for any input you can give.

Cheers!

Tom


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Scripting for Django-related Android apps?

2012-12-08 Thread Timothy Makobu
The book definitely helps. The phone app can interact with the django app
via REST.


On Sat, Dec 8, 2012 at 4:05 PM, Derek  wrote:

> Hi
>
> Can anyone share  any experience on writing Android apps with Python (
> via SL4A) that interact with Django;  and does the book "Pro Android
> Python with SL4A"  (http://www.apress.com/9781430235699) help at all
> in this process?
>
> Thanks
> Derek
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django gracefully shutdown

2012-12-08 Thread Odagi

Thank you for all comments, hints and suggestions. I'll dive a bit more in 
uWSGI signals and documentations. Gunicorn seems to be a good option too, 
thanks!


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/anv-CjTAC0EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Model method versus overriding save()

2012-12-08 Thread Derek
Rather than use a trigger (which is DB-specific and also hard to debug 
because not part of your code base), suggest you use signals[1].

Derek

[1] https://docs.djangoproject.com/en/dev/topics/signals/

On Saturday, 8 December 2012 04:27:50 UTC+2, Chris Cogdon wrote:
>
> It's a simple performance vs storage question.
>
> Storing a calculatable field also risks it getting out of sync with 
> reality, but if you're doing the query on that _so_ much, then its usualyl 
> worth it.
>
> Also, with the right database and a trigger, that's something the database 
> can ensure for you. Ie, a field that the database updates for you.
>
>
> On Friday, December 7, 2012 5:54:37 PM UTC-8, Victor Hooi wrote:
>>
>> Hi,
>>
>> I have a "ranking" field for an item that returns an integer between 1 to 
>> 10 based on a number of criteria of each item.
>>
>> My question is - what are the pros and cons of using a model method to 
>> return this, versus overriding the save() method and saving it directly 
>> into a normal IntegerField on that item?
>>
>> I understand that model methods *won't* let me use them within QuerySet 
>> filters on that item - is there any way around that?
>>
>> If I just override the model's save() method to get it recalculate and 
>> save that field each time, I can use it within QuerySet filters. Any cons 
>> with that approach?
>>
>> What do you guys tend to use in your projects?
>>
>> Cheers,
>> Victor
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/G7fp5OLkapgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django gracefully shutdown

2012-12-08 Thread fuxter fuxter
I found this solution pretty easy and to my likings:

$ uwsgi ... --touch-reload /var/run/any_file_actually.pid ... # launching 
uwsgi
$ touch /var/run/any_file_actually.pid # anytime i want to reload all the 
python code

I'm using using uWSGI in master mode with handfull of small sites and this 
approach reloads all workers, so it might not be for everybody.

On Saturday, December 8, 2012 12:25:55 AM UTC+4, Odagi wrote:
>
>
> Hello! 
>
> After lot of work I'm ready to deploy my site on production. I'll use 
> Nginx with uWSGI or fastCGI (not sure yet), and my doubt is how can I 
> shutdown my production Django app gracefully (for make changes for 
> example). Of course I can kill django-python-fcgi processes and restart 
> everything again but is that correct? Can someone give me some hints please?
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/NrvEne4WdJwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django gracefully shutdown

2012-12-08 Thread Roberto De Ioris

>
> Hello!
>
> After lot of work I'm ready to deploy my site on production. I'll use
> Nginx
> with uWSGI or fastCGI (not sure yet), and my doubt is how can I shutdown
> my
> production Django app gracefully (for make changes for example). Of course
> I can kill django-python-fcgi processes and restart everything again but
> is
> that correct? Can someone give me some hints please?
>
> Thanks!
>

There are various way to accomplish that in uWSGI. As always there is no
'one fit for all' solution so you have to evaluate yourself.

For example lot of people are satisfied with simple 'binary-patching'
approach (sending SIGHUP to the master) where the sockets are not closed
between reloads.

Other people (generally the ones with very high-loaded sites) cannot
tolerate the slowdown of the application during the reload, so they prefer
to spawn a whole new stack (with the new code) and simply move the
connections to the new one as soon as the new app is ready (and eventually
move back to the old instance if something is wrong)

This second approach requires a bit of effort (compared to the simple
SIGHUP approach) but is fore sure the most versatile.

Regarding fastcgi (read: flup, as fastcgi is only a communication
protocol) i do not think it is still "on par" with more modern solutions
like uWSGI, gunicorn and mod_wsgi.

Again, if you want a simple pure-python application server, gunicorn is a
better solution than flup (IMHO)

-- 
Roberto De Ioris
http://unbit.it

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.