django-registration ImportError

2013-07-20 Thread Mike
I just updated django-registration to 1.0 (from 0.8) and now I get an 
ImportError:

ImportError: cannot import name activate

/Users/mike/sieve-django/SIEVEENV/lib/python2.7/site-packages/registration_email/backends/default/urls.py
 in 

   1. 
   
   from registration.views import activate, register
   
   

Has anyone else had this problem? For now I'll revert to 0.8.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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: CSRF in javascript

2013-07-20 Thread Fred Stluka

Karl,

You are calling render_to_response() wrong.  See the docs at:

https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response


Instead of:

variables = RequestContext(request, {
'bookmarks':[bookmark],
'show_edit':True,
'show_tags':True
})
return render_to_response('bookmark_list.html', variables)

try:

variables = {
'bookmarks':[bookmark],
'show_edit':True,
'show_tags':True
}
return render_to_response('bookmark_list.html', 
variables, RequestContext(request))


--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/20/13 3:39 PM, Karl Arunachal wrote:
I am sorry, i am really new to this things. Could you please point me 
out as to where I should add it.


_js file:

_function bookmark_edit() {
var item = $(this).parent();
var url = item.find(".title").attr("href");
item.load("/save/?ajax=" + escape(url), null, function () {
$("#save-form").submit(bookmark_save);
});
return false;
}

$(document).ready(function () {
$("ul.bookmarks .edit").click(bookmark_edit);
});

function bookmark_save() {
var item = $(this).parent();
var data = {
url: item.find("#id_url").val(),
title: item.find("#id_title").val(),
tags: item.find("#id_tags").val()
};
$.post("/save/?ajax", data, function (result) {
if (result != "failure") {
item.before($("li", result).get(0));
item.remove();
$("ul.bookmarks .edit").click(bookmark_edit);
}
else {
alert("Failed to validate bookmark before saving.");
}
})
return false;
}

_save_form.html:

_
{% csrf_token %}
{{form.as_p}}





_user_page.html:_

{% extends "base.html" %}
{% block external %}


{% endblock %}
{% block title %} {{username}} {% endblock %}
{% block head %} Bookmarks for {{username}} {% endblock %}
{% block content %}
{% include "bookmark_list.html" %}
{% endblock %}


_views.py:_

@login_required(login_url='/login/')
def bookmark_save_page(request):
ajax = request.GET.has_key('ajax')
if request.method == 'POST':
form = BookmarkSaveForm(request.POST)
if form.is_valid():
bookmark = _bookmark_save(request, form)
if ajax:
variables = RequestContext(request, {
'bookmarks':[bookmark],
'show_edit':True,
'show_tags':True
})
return render_to_response('bookmark_list.html', variables)
else:
return HttpResponseRedirect('/user/%s/' % 
request.user.username

)
else:
if ajax:
return HttpResponseRedirect('failure')
elif request.GET.has_key('url'):
url = request.GET['url']
title = ''
tags = ''

try:
link = Link.objects.get(url=url)
bookmark = Bookmark.objects.get(
link=link,
user = request.user
)
title = bookmark.title
tags = ' '.join(
tag.name  for tag in bookmark.tag_set.all()
)
except ObjectDoesNotExist:
pass
form = BookmarkSaveForm({
'url':url,
'title':title,
'tags':tags
})
else:
form = BookmarkSaveForm()

variables = RequestContext(request, {
'form': form
})
if ajax:
return render_to_response(
'bookmark_save_form.html',
variables
)
else:
return render_to_response('bookmark_save.html',variables)

Please help me out. Thank you.


On Sun, Jul 21, 2013 at 12:53 AM, Fred Stluka > wrote:


Karl,

Since you already have a form, and are already submitting it
as an Ajax request via JavaScript, the easiest way is to just
put the {% csrf_token %} in the Django template for the page.
We do that for our Ajax forms.

If you are not using a Django template to generate the form,
there are lots of other convenient options.  See:
- https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
and especially:
- https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax

Also, you can find tons of working examples by Googling:
django csrf ajax

--Fred

django-admin.py startproject mysite error

2013-07-20 Thread Jay Lozier
Using openSUSE 12.3
python 2.7.3
django 1.5.1 installed manually and verified

When I enter "django-admin.py startproject mysite" at the command prompt I 
get the following traceback:

Traceback (most recent call last):
File "/usr/bin/django-admin.py", line 5, in 
management.execute_from_command_line()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 453, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 77, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, 
in import_module
__import__(name)
File 
"/usr/lib/python2.7/site-packages/django/core/management/commands/startproject.py",
 
line 2, in 
from django.core.management.templates import TemplateCommand
File 
"/usr/lib/python2.7/site-packages/django/core/management/templates.py", 
line 20, in 
from django.template import Template, Context
File "/usr/lib/python2.7/site-packages/django/template/__init__.py", line 
53, in 
from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
File "/usr/lib/python2.7/site-packages/django/template/base.py", line 18, 
in 
from django.utils.formats import localize
File "/usr/lib/python2.7/site-packages/django/utils/formats.py", line 5, in 

from django.utils import dateformat, numberformat, datetime_safe
File "/usr/lib/python2.7/site-packages/django/utils/dateformat.py", line 
25, in 
from django.utils.timezone import is_aware, is_naive
File "/usr/lib/python2.7/site-packages/django/utils/timezone.py", line 11, 
in 
import pytz
File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 35, in 

from pkg_resources import resource_stream
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 

add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 709, in 
subscribe
callback(dist)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 

add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2465, in 
activate
map(declare_namespace, self._get_metadata('namespace_packages.txt'))
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2045, in 
declare_namespace
_handle_ns(packageName, path_item)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2010, in 
_handle_ns
raise TypeError("Not a package:", packageName)
TypeError: ('Not a package:', 'cgi')

How do I fix 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: File Log vs. Database Log

2013-07-20 Thread Javier Guerra Giraldez
On Sat, Jul 20, 2013 at 9:52 AM, Parin Porecha  wrote:
> My question is - Should I do it via file storage, or should I save it in
> database ?

neither.  syslog is a great tool, often overlooked, but built
specifically for this.  not only it works right out of the box, but
it's very customizable "from the outside" without changing your code
when your needs change, and believe it or not, it does scale very


--
Javier

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




Re: CSRF in javascript

2013-07-20 Thread Karl Arunachal
I am sorry, i am really new to this things. Could you please point me out
as to where I should add it.

*js file:

*function bookmark_edit() {
var item = $(this).parent();
var url = item.find(".title").attr("href");
item.load("/save/?ajax=" + escape(url), null, function () {
$("#save-form").submit(bookmark_save);
});
return false;
}

$(document).ready(function () {
$("ul.bookmarks .edit").click(bookmark_edit);
});

function bookmark_save() {
var item = $(this).parent();
var data = {
url: item.find("#id_url").val(),
title: item.find("#id_title").val(),
tags: item.find("#id_tags").val()
};
$.post("/save/?ajax", data, function (result) {
if (result != "failure") {
item.before($("li", result).get(0));
item.remove();
$("ul.bookmarks .edit").click(bookmark_edit);
}
else {
alert("Failed to validate bookmark before saving.");
}
})
return false;
}

*save_form.html:

*
{% csrf_token %}
{{form.as_p}}





*user_page.html:*

{% extends "base.html" %}
{% block external %}

{% endblock %}
{% block title %} {{username}} {% endblock %}
{% block head %} Bookmarks for {{username}} {% endblock %}
{% block content %}
{% include "bookmark_list.html" %}
{% endblock %}


*views.py:*

@login_required(login_url='/login/')
def bookmark_save_page(request):
ajax = request.GET.has_key('ajax')
if request.method == 'POST':
form = BookmarkSaveForm(request.POST)
if form.is_valid():
bookmark = _bookmark_save(request, form)
if ajax:
variables = RequestContext(request, {
'bookmarks':[bookmark],
'show_edit':True,
'show_tags':True
})
return render_to_response('bookmark_list.html', variables)
else:
return HttpResponseRedirect('/user/%s/' %
request.user.username
)
else:
if ajax:
return HttpResponseRedirect('failure')
elif request.GET.has_key('url'):
url = request.GET['url']
title = ''
tags = ''

try:
link = Link.objects.get(url=url)
bookmark = Bookmark.objects.get(
link=link,
user = request.user
)
title = bookmark.title
tags = ' '.join(
tag.name for tag in bookmark.tag_set.all()
)
except ObjectDoesNotExist:
pass
form = BookmarkSaveForm({
'url':url,
'title':title,
'tags':tags
})
else:
form = BookmarkSaveForm()

variables = RequestContext(request, {
'form': form
})
if ajax:
return render_to_response(
'bookmark_save_form.html',
variables
)
else:
return render_to_response('bookmark_save.html',variables)

Please help me out. Thank you.


On Sun, Jul 21, 2013 at 12:53 AM, Fred Stluka  wrote:

>  Karl,
>
> Since you already have a form, and are already submitting it
> as an Ajax request via JavaScript, the easiest way is to just
> put the {% csrf_token %} in the Django template for the page.
> We do that for our Ajax forms.
>
> If you are not using a Django template to generate the form,
> there are lots of other convenient options.  See:
> - https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
> and especially:
> - https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
>
> Also, you can find tons of working examples by Googling:
> django csrf ajax
>
> --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/20/13 3:05 PM, Karl Arunachal wrote:
>
>   Hi,
>  In my users page, i have in place editing with ajax. And when i click
> edit, it works fine. But when i submit the form, it don't do anything. When
> i checked, this is the error:
>
> CSRF verification failed. Request aborted.
>
>  So, how do I place {% csrf_token %} in my javascript? Please advice.
>
>  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.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" 

Re: CSRF in javascript

2013-07-20 Thread Fred Stluka

Karl,

Since you already have a form, and are already submitting it
as an Ajax request via JavaScript, the easiest way is to just
put the {% csrf_token %} in the Django template for the page.
We do that for our Ajax forms.

If you are not using a Django template to generate the form,
there are lots of other convenient options.  See:
- https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
and especially:
- https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax

Also, you can find tons of working examples by Googling:
django csrf ajax

--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/20/13 3:05 PM, Karl Arunachal wrote:

Hi,
In my users page, i have in place editing with ajax. And when i click 
edit, it works fine. But when i submit the form, it don't do anything. 
When i checked, this is the error:

|CSRF verification failed. Request aborted.|
So, how do I place {% csrf_token %} in my javascript? Please advice.

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.




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




CSRF in javascript

2013-07-20 Thread Karl Arunachal
Hi,
In my users page, i have in place editing with ajax. And when i click edit,
it works fine. But when i submit the form, it don't do anything. When i
checked, this is the error:

CSRF verification failed. Request aborted.

So, how do I place {% csrf_token %} in my javascript? Please advice.

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: Testing django views: RequestFactory and CSRF protection

2013-07-20 Thread Vladimir Ignatev
Well, looks like I've found workaround. At first we should test if a view 
have CSRF protection: 
def test_csrf_protected(self):
request = RequestFactory().post('', data={})
response = views.register_form(request)
self.assertEqual(response.status_code, 403)

(fix me, it is very weak test for example purpose)

Then we actually test view, providing request._dont_enforce_csrf_checks = 
True. And voila. Remember that you shouldn't test Django library, so it's 
obsolete to test "CSRF bypassing + view" chain. Test your view only and 
that it is protected with @csrf_protect is absolutely enough.

четверг, 18 июля 2013 г., 11:35:00 UTC+2 пользователь Vladimir Ignatev 
написал:
>
> I need using RequestFactory instead of Client to test one of my views. So 
> the question is how to generate proper CSRF token to provide it to my 
> @csrf_protect'ed view? At this moment I get 403 error when generating POST 
> request. 
> I've read similar topic in this group dated 2011 year, but that topic 
> observed solution of the problem using Client class and it's parameter 
> enforce_csrf. 
>
>

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




passing extra arguments formset save

2013-07-20 Thread Clement Poh
I have a bunch of inline formsets, which are related to two models. In this 
case I want to have a bunch of "Dealings" associated with a "Report" and a 
"Question".

So I can associate them to one fairly easily.

DealingFormset = inlineformset_factory(Report, Dealing, form = DealingForm)


So to associate the Dealing with the Question I do it when I save the form. 

> 104 dealings = formset.save(commit = False)
> 105 for deal in dealings:
> 106 deal.question = question
> 107 deal.save()


I wanted to move the second snippet to a method on the DealingForm. 
However, when I try to override the save on the form, I get an exception 
saying that the formset received an unexpected argument.

Is there a way to either at the beginning, associate an inlineformset with 
2 models? Or, is there a way to override the formset save method to accept 
my new argument?

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: File Log vs. Database Log

2013-07-20 Thread Valder Gallo
:D

http://django-audit-log.readthedocs.org/en/latest/usage.html


On Sat, Jul 20, 2013 at 1:16 PM, Parin Porecha wrote:

> django-logtailer looks a great app, but the last commit was 2 years ago.
> Also, it's focused on admins.
> Maybe the term 'logs' is confusing. So, I'll change it to 'audit-data' (
> stackoverflow suggestion ).
> I need audit data not system logs.
>
> Thanks Valder
>
>
> On Sat, Jul 20, 2013 at 9:02 PM, Valder Gallo wrote:
>
>> Do you know django-logtailer ?
>> https://github.com/fireantology/django-logtailer
>>
>> If you don't need search or modify the data.
>>
>> +1 for file storage
>>
>> :D
>>
>>
>> On Sat, Jul 20, 2013 at 11:52 AM, Parin Porecha 
>> wrote:
>>
>>> Hi,
>>>
>>> I have a to-do list app ( using Django 1.5 and MySQL ) in which a task
>>> can be shared with another user. Thus, a user can have personal tasks and
>>> shared tasks. Shared tasks will be a fraction ( i guess around 30% of total
>>> tasks of a user )
>>>
>>> For shared tasks, I want to keep a log so that users connected to the
>>> task can know who has done which changes.
>>> For this, I'm thinking of keeping a log file for every shared task.
>>> Whenever any user makes a change, it'll be appended to that file.
>>>
>>> My question is - *Should I do it via file storage, or should I save it
>>> in database ?*
>>>
>>> Please note these points -
>>> - Log will not be accessed frequently ( A file's log may be read 5-10
>>> times max in an hour. )
>>> - In an hour, there may be total >500 writes ( but for different files.
>>> So for a file there may be 10-50 max writes in an hour. So, concurrency is
>>> not a major issue. )
>>> - I won't need to search or modify the data anyway after reading it.
>>>
>>> Thanks in advance !
>>>
>>> --
>>> Regards,
>>> Parin Porecha
>>>
>>> say Kifflom!  and look
>>> forward to 17.09.13 !
>>>
>>> --
>>> 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.
>>>
>>>
>>>
>>
>>
>>
>> --
>> Valder Gallo
>> +55 11 9949 2911
>> +55 11 2532 2911
>> Skype: valdergallo
>> @valdergallo
>> www.valdergallo.com.br
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Regards,
> Parin Porecha
>
> say Kifflom!  and look forward
> to 17.09.13 !
>
> --
> 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.
>
>
>



-- 
Valder Gallo
+55 11 9949 2911
+55 11 2532 2911
Skype: valdergallo
@valdergallo
www.valdergallo.com.br

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




Re: Search from database

2013-07-20 Thread Satinderpal Singh
On Sat, Jul 20, 2013 at 8:48 AM, Kamal Kaur  wrote:
> Can we have a search module in django that can suggest resembling
> spellings from mysql database?
>
I am not getting you, please expalin.


--
Satinderpal Singh

-- 
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 Log vs. Database Log

2013-07-20 Thread Parin Porecha
django-logtailer looks a great app, but the last commit was 2 years ago.
Also, it's focused on admins.
Maybe the term 'logs' is confusing. So, I'll change it to 'audit-data' (
stackoverflow suggestion ).
I need audit data not system logs.

Thanks Valder


On Sat, Jul 20, 2013 at 9:02 PM, Valder Gallo  wrote:

> Do you know django-logtailer ?
> https://github.com/fireantology/django-logtailer
>
> If you don't need search or modify the data.
>
> +1 for file storage
>
> :D
>
>
> On Sat, Jul 20, 2013 at 11:52 AM, Parin Porecha wrote:
>
>> Hi,
>>
>> I have a to-do list app ( using Django 1.5 and MySQL ) in which a task
>> can be shared with another user. Thus, a user can have personal tasks and
>> shared tasks. Shared tasks will be a fraction ( i guess around 30% of total
>> tasks of a user )
>>
>> For shared tasks, I want to keep a log so that users connected to the
>> task can know who has done which changes.
>> For this, I'm thinking of keeping a log file for every shared task.
>> Whenever any user makes a change, it'll be appended to that file.
>>
>> My question is - *Should I do it via file storage, or should I save it
>> in database ?*
>>
>> Please note these points -
>> - Log will not be accessed frequently ( A file's log may be read 5-10
>> times max in an hour. )
>> - In an hour, there may be total >500 writes ( but for different files.
>> So for a file there may be 10-50 max writes in an hour. So, concurrency is
>> not a major issue. )
>> - I won't need to search or modify the data anyway after reading it.
>>
>> Thanks in advance !
>>
>> --
>> Regards,
>> Parin Porecha
>>
>> say Kifflom!  and look
>> forward to 17.09.13 !
>>
>> --
>> 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.
>>
>>
>>
>
>
>
> --
> Valder Gallo
> +55 11 9949 2911
> +55 11 2532 2911
> Skype: valdergallo
> @valdergallo
> www.valdergallo.com.br
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Regards,
Parin Porecha

say Kifflom!  and look forward
to 17.09.13 !

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




Project template for django 1.4+

2013-07-20 Thread Allisson
Here: https://github.com/allisson/django-project-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.




Re: File Log vs. Database Log

2013-07-20 Thread Valder Gallo
Do you know django-logtailer ?
https://github.com/fireantology/django-logtailer

If you don't need search or modify the data.

+1 for file storage

:D


On Sat, Jul 20, 2013 at 11:52 AM, Parin Porecha wrote:

> Hi,
>
> I have a to-do list app ( using Django 1.5 and MySQL ) in which a task can
> be shared with another user. Thus, a user can have personal tasks and
> shared tasks. Shared tasks will be a fraction ( i guess around 30% of total
> tasks of a user )
>
> For shared tasks, I want to keep a log so that users connected to the task
> can know who has done which changes.
> For this, I'm thinking of keeping a log file for every shared task.
> Whenever any user makes a change, it'll be appended to that file.
>
> My question is - *Should I do it via file storage, or should I save it in
> database ?*
>
> Please note these points -
> - Log will not be accessed frequently ( A file's log may be read 5-10
> times max in an hour. )
> - In an hour, there may be total >500 writes ( but for different files. So
> for a file there may be 10-50 max writes in an hour. So, concurrency is not
> a major issue. )
> - I won't need to search or modify the data anyway after reading it.
>
> Thanks in advance !
>
> --
> Regards,
> Parin Porecha
>
> say Kifflom!  and look forward
> to 17.09.13 !
>
> --
> 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.
>
>
>



-- 
Valder Gallo
+55 11 9949 2911
+55 11 2532 2911
Skype: valdergallo
@valdergallo
www.valdergallo.com.br

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




Re: create random string for username

2013-07-20 Thread Randy Baxley
The Django tutorial is not quite making it for me.  This is a very
complicated language and all the pieces seem to not match up for me.  This
I think is my fault and most of it seems to be in the use of the r hat for
root and exactly how that points to views, models and dbs.  I may get there
but it is not easy without someone to be a sort of guide.  Each time though
I go into settings or one of the other files they get a perception of being
more familiar and thus shorter.  While doing some of those I say a key set
to fals for allow profanity but not sure what all that filter has passed
through it.


On Sat, Jul 20, 2013 at 8:20 AM, Tim Chase
wrote:

> On 2013-07-18 20:53, Sivaram R wrote:
> >   While saving these forms instance,is it possible to create a
> > random string for username field.How to do this,any sample would be
> > great choice.
>
> You can.  Assigning random usernames isn't usually considered a very
> nice thing to do to users, but assuming you have a valid use-case
> for it, it's just simple Python:
>
>   import random
>   import string
>   def random_username(characters=string.ascii_lowercase, length=10):
> return ''.join(
>   random.choice(characters)
>   for _ in range(length)
>   )
>
> You might also want to post-process to check for profanity in it, as
> you you don't (usually) want to assign profanity as a username:
>
>   BAD_WORDS = [ ... ] # all in uppercase
>   while True:
> username = random_username()
> normalized_username = random_username.upper()
> for word in BAD_WORDS:
>   if word in normalized_username:
> break
> else: # note this is at the indentation level of the "for", not "if"
>   break
>   print "Username:", username
>
> It's not a perfect check, but it will eliminate the obviously
> problematic ones based on your black-list
>
> -tkc
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> 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.




Overriding the formset save method/ Inlineformsets with 2 related Models

2013-07-20 Thread Clement Poh
I have a bunch of inline formsets, which are related to two models. In this 
case I want to have a bunch of "Dealings" associated with a "Report" and a 
"Question".

So I can associate them to one fairly easily.

DealingFormset = inlineformset_factory(Report, Dealing, form = DealingForm)


So to associate the Dealing with the Question I do it when I save the form. 

> 104 dealings = formset.save(commit = False)
> 105 for deal in dealings:
> 106 deal.question = question
> 107 deal.save()


I wanted to move the second snippet to a method on the DealingForm. 
However, when I try to override the save on the form, I get an exception 
saying that the formset received an unexpected argument.

Is there a way to either at the beginning, associate an inlineformset with 
2 models? Or, is there a way to override the formset save method to accept 
my new argument?

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.




File Log vs. Database Log

2013-07-20 Thread Parin Porecha
Hi,

I have a to-do list app ( using Django 1.5 and MySQL ) in which a task can
be shared with another user. Thus, a user can have personal tasks and
shared tasks. Shared tasks will be a fraction ( i guess around 30% of total
tasks of a user )

For shared tasks, I want to keep a log so that users connected to the task
can know who has done which changes.
For this, I'm thinking of keeping a log file for every shared task.
Whenever any user makes a change, it'll be appended to that file.

My question is - *Should I do it via file storage, or should I save it in
database ?*

Please note these points -
- Log will not be accessed frequently ( A file's log may be read 5-10 times
max in an hour. )
- In an hour, there may be total >500 writes ( but for different files. So
for a file there may be 10-50 max writes in an hour. So, concurrency is not
a major issue. )
- I won't need to search or modify the data anyway after reading it.

Thanks in advance !

-- 
Regards,
Parin Porecha

say Kifflom!  and look forward
to 17.09.13 !

-- 
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: create random string for username

2013-07-20 Thread Tim Chase
On 2013-07-18 20:53, Sivaram R wrote:
>   While saving these forms instance,is it possible to create a
> random string for username field.How to do this,any sample would be
> great choice.

You can.  Assigning random usernames isn't usually considered a very
nice thing to do to users, but assuming you have a valid use-case
for it, it's just simple Python:

  import random
  import string
  def random_username(characters=string.ascii_lowercase, length=10):
return ''.join(
  random.choice(characters)
  for _ in range(length)
  )

You might also want to post-process to check for profanity in it, as
you you don't (usually) want to assign profanity as a username:

  BAD_WORDS = [ ... ] # all in uppercase
  while True:
username = random_username()
normalized_username = random_username.upper()
for word in BAD_WORDS:
  if word in normalized_username:
break
else: # note this is at the indentation level of the "for", not "if"
  break
  print "Username:", username

It's not a perfect check, but it will eliminate the obviously
problematic ones based on your black-list

-tkc


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