Re: TemplateSyntaxError at /admin/

2011-01-07 Thread victorkendy
hi there hank23

to fix the problem you just need to send the queryset parameter to the
constructor of the ModelChoiceField

pollquestions = forms.ModelChoiceField(queryset=SomeModel, ...other
stuff...) works but

pollquestions = forms.ModelChoiceField(...other stuff without
queryset...) raises the exception you are getting

victor

On 7 jan, 20:28, hank23  wrote:
> I have coded a new form with a ModelChoiceField defined on it which is
> getting the following error:
>
> TemplateSyntaxError at /admin/
> Caught TypeError while rendering: __init__() takes at least 2
> arguments (6 given)Request Method: GET
> Request URL:http://127.0.0.1:8000/admin/
> Django Version: 1.2.4
> Exception Type: TemplateSyntaxError
> Exception Value: Caught TypeError while rendering: __init__() takes at
> least 2 arguments (6 given)
> Exception Location: C:\Users\hversemann\djangoprojects\mysite\polls
> \forms.py in AddChoiceForm, line 7
> Python Executable: C:\Python27\python.exe
> Python Version: 2.7.1
> Python Path: ['C:\\Users\\hversemann\\djangoprojects\\mysite', 'C:\
> \Python\\Lib', 'C:\\Python\\Lib\\site-packages', 'C:\\Users\\hversemann
> \\Desktop\\PythonSourceFiles', 'C:\\Users\\hversemann\\djangoprojects\
> \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs',
> 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\
> \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']
> Server time:
>
> and here's the new form code itself, which it apparently doesn't like:
>
> 1.from django import forms
> 2.
> 3.class AddChoiceForm(forms.Form):
> 4.    infomessage = forms.CharField(max_length=200)
> 5.    pollquestions = forms.ModelChoiceField(required=True,
> label='Poll Questions', initial='Please select a poll  question',
> help_text='Select a poll question.',
> 6.        error_messages={'required': 'Please select a poll
> question!', 'invalid_choice': 'Cannot select initial value!'},
> 7.        widget=forms.Select(attrs={'name': 'pollquestions',
> 'id':'pollquestions', 'size':'1', 'type':'select-one' })) ...
> 8.    confirmmessage = forms.CharField(max_length=200)9.    newchoice
> = forms.CharField(max_length=200)
>
> I think I all of the parameters for the ModelChoiceField are legal
> based on the documentation, unless I have a typo somewhere. Thanks for
> looking. The help is much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Curious 500 errors

2011-01-07 Thread Conor
Hello, I am new to Django and working on integrating it with
MailChimp. I am implementing call back handlers for their Web Hooks.
This should be just views.

Anyway, I am testing running the dev server and seeing that the views
are called just fine for GET requests, but for POST requests, all I
see is this:

[07/Jan/2011 18:12:01] "POST /newsletters/callback HTTP/1.1" 500 63243

Even though I am printing output in the view code which should be
logging. Any ideas why this should be resulting in such an error on
the dev server? Because it is not printing anything out for POSTs it
must be somehow circumventing the view code. Am I missing something.

Here is my handler code:

def handle_mailchimp_callback(request):
response =  http.HttpResponse()
response.status_code = 200
if request.POST:
print "POSTING"
else:
print "GETTTING"
return response

Here is the server console output for a GET request:

[07/Jan/2011 18:54:59] "GET /newsletters/callback HTTP/1.1" 301 0
GETTTING
[07/Jan/2011 18:54:59] "GET /newsletters/callback/ HTTP/1.1" 200 0


Thanks alot.

C.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



OSUOSL Looking for full-time developer

2011-01-07 Thread LH (Leslie Hawthorn)
Hello,

Oregon State University's Open Source Lab is seeking a full-time
developer with Django and Python programming skills. The Lab is
located in Corvallis, Oregon and employees are required to work on-
site. For more information, please see our job posting. [0]

[0] - http://osuosl.org/about/news/hiring-analyst-programmer

Best,
LH
--
Leslie Hawthorn
Open Source Outreach Manager

les...@osuosl.org

http://identi.ca/lh
http://twitter.com/lhawthorn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Serializing Objects with Reverse One-To-One Keys

2011-01-07 Thread Alec Story
I have an object which I want to serialize, which a modules with extra
information with a one-to-one key pointing to the main object.  I know
that I can do a lookup using select_related to get a cache of the
relation, but it seems that nothing I do will serialize (to json in my
case) these relations despite their being cached.  Is there a way to
do serialize the data, or do I have to do it manually?  I'd like to
have the object and all of its one-to-one (reverse) relations in one
piece of json.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



No module named contact.forms

2011-01-07 Thread marco
i'm reading the djangobook, and doing the example(s).
in chapter 7 (forms), when i try to run :

>>> from contact.forms import ContactForm

the shell gives me this error:

Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named contact.forms

can you help me to fix this?
thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



joining across databases

2011-01-07 Thread David
Strictly, joining across databases is usually impossible. However, I'm
looking at mechanisms to achieve that functionality and I just wanted
to get a sanity check to see that what I'm doing makes sense or if
there is a better way. I have one database in Postgres and a legacy
database in MSSql. I have a view in MSSql that I'd like to join with a
subset of a table in Postgres (a single VARCHAR column, actually).

This is essentially what I'm doing:

1. Use Django's ORM to get and filter data from Postgres
2. Create a temporary table in MSSql using raw SQL
3. Insert records into temporary table (we're talking order of 1k
records)
4. Use raw SQL to join the MSSql view against the temp table

Is there a better or smarter way to do what I'm doing?

While I'd like this to be fast, speed is not a big deal since this is
run periodically from a celery task. Mirroring is not an option. We're
talking on the order of 1B records in MSSql and 10M records in
Postgres and both of them change periodically and independently. An IN
clause with strings is not an option because MSSql has a limit on the
number of items in an IN clause (2300) and this number is sometimes
exceeded depending on the filter.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



how to integrate strace on mod_swgi

2011-01-07 Thread zodman
some know how can i integrate the
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Extracting_Python_Stack_Traces
but using the WSIHandler of django .. for show output like debuggingtechnique ?

-- 
Andres Vargas
www.zodman.com.mx

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



TemplateSyntaxError at /admin/

2011-01-07 Thread hank23
I have coded a new form with a ModelChoiceField defined on it which is
getting the following error:

TemplateSyntaxError at /admin/
Caught TypeError while rendering: __init__() takes at least 2
arguments (6 given)Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.2.4
Exception Type: TemplateSyntaxError
Exception Value: Caught TypeError while rendering: __init__() takes at
least 2 arguments (6 given)
Exception Location: C:\Users\hversemann\djangoprojects\mysite\polls
\forms.py in AddChoiceForm, line 7
Python Executable: C:\Python27\python.exe
Python Version: 2.7.1
Python Path: ['C:\\Users\\hversemann\\djangoprojects\\mysite', 'C:\
\Python\\Lib', 'C:\\Python\\Lib\\site-packages', 'C:\\Users\\hversemann
\\Desktop\\PythonSourceFiles', 'C:\\Users\\hversemann\\djangoprojects\
\mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs',
'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\
\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']
Server time:


and here's the new form code itself, which it apparently doesn't like:


1.from django import forms
2.
3.class AddChoiceForm(forms.Form):
4.infomessage = forms.CharField(max_length=200)
5.pollquestions = forms.ModelChoiceField(required=True,
label='Poll Questions', initial='Please select a poll  question',
help_text='Select a poll question.',
6.error_messages={'required': 'Please select a poll
question!', 'invalid_choice': 'Cannot select initial value!'},
7.widget=forms.Select(attrs={'name': 'pollquestions',
'id':'pollquestions', 'size':'1', 'type':'select-one' })) ...
8.confirmmessage = forms.CharField(max_length=200)9.newchoice
= forms.CharField(max_length=200)


I think I all of the parameters for the ModelChoiceField are legal
based on the documentation, unless I have a typo somewhere. Thanks for
looking. The help is much appreciated.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How do I Bind a Form choice Field?

2011-01-07 Thread hank23
Thanks for the help.

On Jan 7, 3:01 pm, Mike Seidle  wrote:
> Hank -
>
> Here's the answer you are looking for:
>
> http://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield
>
> Here's an example:
>
> stuff = forms.ModelChoiceField(queryset=Series.objects.values('whatever'),  
> empty_label="     ")
>
> Spend some serious time learning modelforms. Most of the time, they are the
> right answer.  Modelforms are different than regular forms... so you do have 
> to
> populate the choices differently.  The key with Django is to understand when
> you need a modelform, and when you need a regular form.
>
> modelform - Django builds forms from models.
> form - You design what you want, but have to do a lot more work to populate
> the form with data.
>
> There you go.
>
> On Friday, January 07, 2011 02:03:39 pm hank23 wrote:
>
>
>
> > So I can create a queryset and pass its variable in the choices
> > parameter to bind a modelchoicefield from a modelform to a particular
> > iterable object? So then does this work only with modelforms or with
> > any kind of form (one coded manually as well)? If I can do this with
> > any form then where do I code the choices parameter? The only examples
> > I've seen show it being coded using dictionaries containing hard-coded
> > values and being coded as part of the form in question.  Let me know
> > as soon as you can. Thanks for the help.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: OpenToken Spec & Single Sign On

2011-01-07 Thread Justin
Well that doesn't seem like much fun! But you're right, that's what
will eventually happen.

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How do I Bind a Form choice Field?

2011-01-07 Thread Mike Seidle
Hank -

Here's the answer you are looking for:

http://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield

Here's an example:

stuff = forms.ModelChoiceField(queryset=Series.objects.values('whatever'),  
empty_label=" ")

Spend some serious time learning modelforms. Most of the time, they are the 
right answer.  Modelforms are different than regular forms... so you do have to 
populate the choices differently.  The key with Django is to understand when 
you need a modelform, and when you need a regular form.

modelform - Django builds forms from models.
form - You design what you want, but have to do a lot more work to populate 
the form with data.



There you go.

On Friday, January 07, 2011 02:03:39 pm hank23 wrote:
> So I can create a queryset and pass its variable in the choices
> parameter to bind a modelchoicefield from a modelform to a particular
> iterable object? So then does this work only with modelforms or with
> any kind of form (one coded manually as well)? If I can do this with
> any form then where do I code the choices parameter? The only examples
> I've seen show it being coded using dictionaries containing hard-coded
> values and being coded as part of the form in question.  Let me know
> as soon as you can. Thanks for the help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: OpenToken Spec & Single Sign On

2011-01-07 Thread Matteius
Well since that is the case, why even use Django?  Why not just do
this conversion/forwarding using the existing Perl OpenToken library
and deploy it to a cgi-bin?

-Matteo

On Jan 7, 2:17 pm, Justin  wrote:
> Matteo,
>
> Thanks for the response. I wish I could just use the
> django.contrib.auth authentication mechanisms and be done with this.
> However, I am not looking to use OpenToken to authenticate users in
> Django, per se.
>
> I will be making a Django app that accepts an authentication assertion
> from another system, packages it into an OpenToken, and then forwards
> it on to another system. The target system only accepts OpenToken for
> SSO.
>
> My Django application doesn't need to store User information nor
> authenticate the user. It is just a translator between one identity
> assertion and the other. The end-user won't even know they hit my
> Django app as their HTTP requests will just pass right through via
> redirects. It's just magic to them.
>
> I am already porting the perl module to python but am running into
> issues with the KeyGenerator class. Luckily the original devs provided
> plenty of good tests so I know when I am on the right track. I hope to
> open source the code once I am done.
>
> Thanks,
> Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: OpenToken Spec & Single Sign On

2011-01-07 Thread Justin
Matteo,

Thanks for the response. I wish I could just use the
django.contrib.auth authentication mechanisms and be done with this.
However, I am not looking to use OpenToken to authenticate users in
Django, per se.

I will be making a Django app that accepts an authentication assertion
from another system, packages it into an OpenToken, and then forwards
it on to another system. The target system only accepts OpenToken for
SSO.

My Django application doesn't need to store User information nor
authenticate the user. It is just a translator between one identity
assertion and the other. The end-user won't even know they hit my
Django app as their HTTP requests will just pass right through via
redirects. It's just magic to them.

I am already porting the perl module to python but am running into
issues with the KeyGenerator class. Luckily the original devs provided
plenty of good tests so I know when I am on the right track. I hope to
open source the code once I am done.

Thanks,
Justin


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How do I Bind a Form choice Field?

2011-01-07 Thread hank23
So when I would code the queryset parameter in the form definition I
would just code something like this:

pollquestions =
forms.ModelChopiceField(queryset=Poll.objects.all(), ...)

when I define the pollquestions field of my form which is ultimately
to be rendered into the dropdown box on my form? And then also follow
that parameter with any other optional ones, like widget, etc.?

On Jan 7, 1:03 pm, hank23  wrote:
> So I can create a queryset and pass its variable in the choices
> parameter to bind a modelchoicefield from a modelform to a particular
> iterable object? So then does this work only with modelforms or with
> any kind of form (one coded manually as well)? If I can do this with
> any form then where do I code the choices parameter? The only examples
> I've seen show it being coded using dictionaries containing hard-coded
> values and being coded as part of the form in question.  Let me know
> as soon as you can. Thanks for the help.
>
> On Jan 7, 11:02 am, Daniel Roseman  wrote:
>
>
>
> > On Friday, January 7, 2011 4:47:43 PM UTC, ShawnMilo wrote:
>
> > > On 01/07/2011 11:33 AM, hank23 wrote:
> > > > I want to code a form which will have a choice field which I want to
> > > > have rendered as a dropdown box in my html file. How do I code the
> > > > choices parameter in the form definition to bind it to a column in one
> > > > of my data tables in my model? The documentation shows a few examples,
> > > > but nothing specifically for choice fields. Please explain. Thanks.
>
> > > You have to use a ModelForm for this.
>
> > > 
>
> > > Technically you can do it with a forms.Form, but you have to do the
> > > entire thing manually, which is a big waste.
>
> > > 
>
> > > Shawn
>
> > Er, no, both wrong. The source of choices for a field has nothing to do with
> > whether or not it's a modelform, and there is an easy built-in field class
> > for managing exactly what the OP requested: ModelChoiceField. This takes a
> > `queryset` parameter, which provides the data for the field choices. See the
> > docs:http://docs.djangoproject.com/en/1.2/ref/forms/fields/#modelchoicefield
> > --
> > DR.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



slugify override

2011-01-07 Thread galago
How can I override slugify function globally? I want to add some other 
letters actions especially form my language.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How do I Bind a Form choice Field?

2011-01-07 Thread hank23
So I can create a queryset and pass its variable in the choices
parameter to bind a modelchoicefield from a modelform to a particular
iterable object? So then does this work only with modelforms or with
any kind of form (one coded manually as well)? If I can do this with
any form then where do I code the choices parameter? The only examples
I've seen show it being coded using dictionaries containing hard-coded
values and being coded as part of the form in question.  Let me know
as soon as you can. Thanks for the help.

On Jan 7, 11:02 am, Daniel Roseman  wrote:
> On Friday, January 7, 2011 4:47:43 PM UTC, ShawnMilo wrote:
>
> > On 01/07/2011 11:33 AM, hank23 wrote:
> > > I want to code a form which will have a choice field which I want to
> > > have rendered as a dropdown box in my html file. How do I code the
> > > choices parameter in the form definition to bind it to a column in one
> > > of my data tables in my model? The documentation shows a few examples,
> > > but nothing specifically for choice fields. Please explain. Thanks.
>
> > You have to use a ModelForm for this.
>
> > 
>
> > Technically you can do it with a forms.Form, but you have to do the
> > entire thing manually, which is a big waste.
>
> > 
>
> > Shawn
>
> Er, no, both wrong. The source of choices for a field has nothing to do with
> whether or not it's a modelform, and there is an easy built-in field class
> for managing exactly what the OP requested: ModelChoiceField. This takes a
> `queryset` parameter, which provides the data for the field choices. See the
> docs:http://docs.djangoproject.com/en/1.2/ref/forms/fields/#modelchoicefield
> --
> DR.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: OpenToken Spec & Single Sign On

2011-01-07 Thread Matteius
I don't understand why you would need to use this for server-side
authentication in the Django environment?  So this OpenToken Single
Sign-on appears to be more similar to Django's own
django.contrib.auth, and django.contrib.sessions packages, and
possibly even less secure (and less documented) than Kerberos
authentication which is two way site-wide authentication protocol.  If
I were you, I'd use *django.contrib.auth* and
*django.contrib.sessions*.  The sessions application provides site
cookie for authenticating HTTP against, and auth provides User account
authentication for Single Sign-on using sha1 (default) or md5, or
crypt.

You could port the OenToken Perl module to Python easily, and remember
to target Pythong 2.6 and import hashlib for sha1 as the sha module is
now deprecated.

Beyond that, could you please provide more insight on why you would
want to use OpenToken specifically over the built in Django packages?
I read through the spec once and this is my conclusion is a much
bigger headache porting/integrating with OpenToken than using the
built in Django methods.

Regards,
Matteo

On Jan 6, 1:53 pm, Justin Murphy  wrote:
> Hello group,
>
> Does anybody have experience with the OpenToken specification? It is
> an authentication token that some (not many) applications use for SSO.
>
> I found existing Perl module that encrypts and decrypts the token but
> I need a Python version to use in a Django project. Not much luck
> finding one on Google, so I am asking this group to see if anybody has
> done this before so I don't need to re-create the wheel.
>
> Here is a link to the specification - website will automatically try
> and download PDF, sorry 
> :(http://www.pingidentity.com/support-and-downloads/download.cfm?item=1...
>
> OpenToken Perl module on GitHub:https://github.com/bleargh45/crypt-opentoken/
>
> I appreciate your help!
>
> Thanks,
> Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Generalizing functions in views.py?

2011-01-07 Thread Daniel Roseman
On Friday, January 7, 2011 5:19:10 PM UTC, Joe0418 wrote:
>
>
> Greetings!
>
> I've been spending the past few weeks learning django and love it!  I'm
> running into a snag though...
>
> I'm using just one template for all my toying right now, and it has a few
> sections in it that looks something like this:
>
> {% if user.username %}
> Welcome {{ user.username }}!
> {% else %}
> 
> Welcome anonymous user!
> Please  /login/ login 
> 
> {% endif %}
>
> -- and --
>
> {% for link in link_list %}
> {{ link.href }} {{ link.name }} 
> {% if not forloop.last %} 
> | 
> {% endif %}
> {% endfor %}
>
>
> I have around a dozen views, and I'm noticing that in each of my views I'm
> having to do something like:
>
> return render_to_response('base.html', {  #various logic
> 'link_list': link_list,
> 'user': request.user  })
>
> I have link_list defined in another file, so each function can handle that
> properly.  The problem creeps up on the 'user': request.user logic though. 
> Instead of having to have this line of code in EVERY return statement, I'd
> rather just define it once in a dictionary at the top of my views.py page 
> or
> in another file, with something like this:
>
> dictionary_of_variables = {'user': request.user, 'link_list': link_list,
> #various other global things}
>
> I'd also like to just return something like this in each of my functions:
>
> business_logic_variable = "some business logic"
> dictionary_of_variables['template_variable'] = business_logic_variable
> return render_to_response('base.html', dictionary_of_variables)
>
>
> HOWEVER: I can't do that because request.user is out of the scope of a
> 'request' that you would typically pass to a view function.  My specific
> error is: 
>
> name 'request' is not defined
>
>
> Is there a workaround for this sort of logic?  I don't mind returning it in
> my 10 or so functions that I have right now, but when my webpage grows to
> hundreds of functions & pages, it would be much better to globally define
> this variable.
>
> Thanks for your reply!
>

Context processors are what you need.
http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-context-requestcontext
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 admin - action on delete

2011-01-07 Thread Subhranath Chunder
When deleting from the admin interface, the delete is actually on the entire
QuerySet rather than on the object level. So if you need to perform some
object level modification on the delete action of the admin interface, you
can remove the default 'delete_selected' action, and go a custom delete
action. Like:

class SomeModelAdmin(admin.ModelAdmin):
actions = ['custom_delete']
 def custom_delete(self, request, queryset):
 for object in queryset:
perform_some_action(object)
object.delete()
custom_delete.short_description = "Delete selected items"

def get_actions(self, request):
actions = super(SomeModelAdmin, self).get_actions(request)
del actions['delete_selected']
return actions

Thanks,
Subhranath Chunder.

On Fri, Jan 7, 2011 at 8:52 PM, galago  wrote:

> I made what I wanted in
> def log_deletion(self, request, object, object_repr):
>
> It's not elegant, but in Django 1.3 there is a delete_model() function:)
> But now I'm using 1.2.4 :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



Generalizing functions in views.py?

2011-01-07 Thread Joe0418

Greetings!

I've been spending the past few weeks learning django and love it!  I'm
running into a snag though...

I'm using just one template for all my toying right now, and it has a few
sections in it that looks something like this:

{% if user.username %}
Welcome {{ user.username }}!
{% else %}

Welcome anonymous user!
Please  /login/ login 

{% endif %}

-- and --

{% for link in link_list %}
 {{ link.href }} {{ link.name }} 
{% if not forloop.last %} 
| 
{% endif %}
{% endfor %}


I have around a dozen views, and I'm noticing that in each of my views I'm
having to do something like:

return render_to_response('base.html', {  #various logic
'link_list': link_list,
'user': request.user  })

I have link_list defined in another file, so each function can handle that
properly.  The problem creeps up on the 'user': request.user logic though. 
Instead of having to have this line of code in EVERY return statement, I'd
rather just define it once in a dictionary at the top of my views.py page or
in another file, with something like this:

dictionary_of_variables = {'user': request.user, 'link_list': link_list,
#various other global things}

I'd also like to just return something like this in each of my functions:

business_logic_variable = "some business logic"
dictionary_of_variables['template_variable'] = business_logic_variable
return render_to_response('base.html', dictionary_of_variables)


HOWEVER: I can't do that because request.user is out of the scope of a
'request' that you would typically pass to a view function.  My specific
error is:   

name 'request' is not defined


Is there a workaround for this sort of logic?  I don't mind returning it in
my 10 or so functions that I have right now, but when my webpage grows to
hundreds of functions & pages, it would be much better to globally define
this variable.

Thanks for your reply!

-- 
View this message in context: 
http://old.nabble.com/Generalizing-functions-in-views.py--tp30616200p30616200.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Including subfolders

2011-01-07 Thread Subhranath Chunder
On Fri, Jan 7, 2011 at 10:32 PM, Mo Mughrabi  wrote:

> Hi,
>
> My project is getting quite large with so many apps, so i decided to create
> a folder for libs/shared and folder for apps in which libs/shared will
> contain all my generic libraries and apps will contain the project specific
> apps.
>
> I found the following
>
>
> http://solutions.treypiepmeier.com/2009/01/08/keep-your-django-applications-in-a-subfolder/
>
> and It did the job in enabling me to include apps. I just have to
> questions
>
> 1. How do create a tuple in my settings.py containing all the folders I
> need to include (in my case libs/shared and apps) and in manage.py include
> them without hard coding the folder names? It seems like the following
> function does not take tuples and only accept strings
>
> sys.path.insert(0, join(settings.PROJECT_ROOT, "apps"))
>

In your settings.py you can add:
sys.path.append(os.path.join(os.path.dirname(__file__), 'lib/shared'))
sys.path.append(os.path.join(os.path.dirname(__file__), 'app'))


> 2. Will my code works when I move it to production using mod_wsgi?
>

Yes.


>
> regards,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>

Thanks,
Subhranath Chunder.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: creating apps inside sub folders

2011-01-07 Thread Subhranath Chunder
You can simply append the path to your 'lib/shared' directory to your system
path in the settings.py file.

sys.path.append(os.path.join(os.path.dirname(__file__), 'lib/shared'))
This should do.

Thanks,
Subhranath Chunder.

On Fri, Jan 7, 2011 at 9:20 PM, Mo Mughrabi  wrote:

> Hi,
>
> am trying to organize some commonly used apps in my libs/shared folder
> inside my project.
>
> When I moved the file there, I just appended libs.shared.appname to the
> INSTALLED_APP and it worked. but the views are not working, i noticed the
> urls that needed to be appended as well. What else am missing?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: Designing a workflow engine on Django

2011-01-07 Thread Javier Guerra Giraldez
On Fri, Jan 7, 2011 at 11:57 AM, Mo Mughrabi  wrote:
> Any ideas of alternative solutions?

sure, a quick googling gives at least:

https://github.com/maaku/django-workflow
http://pypi.python.org/pypi/django-workflows

the last one at least seems quite active.  I haven't made up my mind
yet on which one to replace my own; when i get to that part of the
rewriting i'll do a deeper check on code style.

but in any case, if goFlow seemed cleaner, i wouldn't worry too much
about code age.  on small projects (like most portable apps), i tend
to copy them and take on maintenance.  that's why my choice is more
about code style and not API or 'freshness'

-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: render_to_response format using forms

2011-01-07 Thread Daniel Roseman
On Friday, January 7, 2011 4:05:27 PM UTC, hank23 wrote:
>
> Another question about forms. So the form name or names that I pass in 
> the dictionary to the response can also be named anything and aren't 
> required to be of a specific form name format right? 
>

Yes, that's correct. There's no name-based magic - it all follows the Python 
dictum "explicit is better than implicit". 
-- 
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How do I Bind a Form choice Field?

2011-01-07 Thread Daniel Roseman
On Friday, January 7, 2011 4:47:43 PM UTC, ShawnMilo wrote:
>
> On 01/07/2011 11:33 AM, hank23 wrote:
> > I want to code a form which will have a choice field which I want to
> > have rendered as a dropdown box in my html file. How do I code the
> > choices parameter in the form definition to bind it to a column in one
> > of my data tables in my model? The documentation shows a few examples,
> > but nothing specifically for choice fields. Please explain. Thanks.
> >
>
> You have to use a ModelForm for this.
>
> 
>
> Technically you can do it with a forms.Form, but you have to do the 
> entire thing manually, which is a big waste.
>
> 
>
> Shawn
>

Er, no, both wrong. The source of choices for a field has nothing to do with 
whether or not it's a modelform, and there is an easy built-in field class 
for managing exactly what the OP requested: ModelChoiceField. This takes a 
`queryset` parameter, which provides the data for the field choices. See the 
docs:
http://docs.djangoproject.com/en/1.2/ref/forms/fields/#modelchoicefield
-- 
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Including subfolders

2011-01-07 Thread Mo Mughrabi
Hi,

My project is getting quite large with so many apps, so i decided to create
a folder for libs/shared and folder for apps in which libs/shared will
contain all my generic libraries and apps will contain the project specific
apps.

I found the following

http://solutions.treypiepmeier.com/2009/01/08/keep-your-django-applications-in-a-subfolder/

and It did the job in enabling me to include apps. I just have to questions

1. How do create a tuple in my settings.py containing all the folders I need
to include (in my case libs/shared and apps) and in manage.py include them
without hard coding the folder names? It seems like the following function
does not take tuples and only accept strings

sys.path.insert(0, join(settings.PROJECT_ROOT, "apps"))

2. Will my code works when I move it to production using mod_wsgi?

regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Designing a workflow engine on Django

2011-01-07 Thread Mo Mughrabi
Hi Javier,

yeah I saw goFlow, it looks pretty nice. My only concern is the update, if
you go to

http://code.google.com/p/goflow/downloads/list

you notice it has not been
updated since 2008 and that is worrying. I don't know if anyone is still
maintaining the code, if it will work with 1.2 django..

Any ideas of alternative solutions?


Regards,

On Fri, Jan 7, 2011 at 7:01 PM, Javier Guerra Giraldez
wrote:

> On Fri, Jan 7, 2011 at 10:09 AM, Mo Mughrabi 
> wrote:
> > If am reinventing the wheel and if there is such thing that has been
> > developed already, any one can suggest, I would be more than happy to go
> > through it.
>
> yes, there are a few ones around there.  (as i found after realizing
> that what i had just programmed was a workflow engine :-))
>
> one that seems ok is GoFlow (http://code.google.com/p/goflow/).  i
> haven't used it but read the API and code and plan to (soon?) replace
> my own with it.
>
>
> --
> Javier
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: How do I Bind a Form choice Field?

2011-01-07 Thread Shawn Milochik

On 01/07/2011 11:33 AM, hank23 wrote:

I want to code a form which will have a choice field which I want to
have rendered as a dropdown box in my html file. How do I code the
choices parameter in the form definition to bind it to a column in one
of my data tables in my model? The documentation shows a few examples,
but nothing specifically for choice fields. Please explain. Thanks.



You have to use a ModelForm for this.

class SomeForm(forms.ModelForm):

class Meta:
model = YourModel #Done!


Technically you can do it with a forms.Form, but you have to do the 
entire thing manually, which is a big waste.


class ManualFormNotWorthTheTrouble(forms.Form):

my_dropdown = forms.ChoiceField()

def __init__(self, *args, **kwargs):

#do normal __init__
super(ManualFormNotWorthTheTrouble, self).__init__(*args, **kwargs)

	self.fields['my_dropdown'].choices = [x.id, x.name for x in 
YourMode.objects.all()]



Shawn



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.



How do I Bind a Form choice Field?

2011-01-07 Thread hank23
I want to code a form which will have a choice field which I want to
have rendered as a dropdown box in my html file. How do I code the
choices parameter in the form definition to bind it to a column in one
of my data tables in my model? The documentation shows a few examples,
but nothing specifically for choice fields. Please explain. Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: render_to_response format using forms

2011-01-07 Thread hank23
Another question about forms. So the form name or names that I pass in
the dictionary to the response can also be named anything and aren't
required to be of a specific form name format right?


On Jan 7, 9:57 am, hank23  wrote:
> I see. So then I would code it something like this then:
>
> return render_to_response('contact.html',
>     { my_data_dictionary(including an entry for 'form': form) },
>     context_instance=RequestContext(request))
>
> On Jan 7, 9:42 am, Daniel Roseman  wrote:
>
>
>
> > On Friday, January 7, 2011 3:38:10 PM UTC, hank23 wrote:
>
> > > So then when using a form do I code it something like this then:
>
> > > return render_to_response('contact.html', {
> > >      'form': form,
> > >      my_data_dictionary,
> > >      context_instance=RequestContext(request))
>
> > > })
>
> > > I ask because it's confusing me when using a form for how to code the
> > > form reference while still including the dictionary and context
> > > references. The dictionary reference almost seems redundant since when
> > > I go to create my form and assign it the name form I use the data
> > > dictionary in the constructor of my form. Please clarify.
>
> > No, for some reason you're thinking of the form as something special. It's
> > not - it's simply part of the context, just like anything else you pass to
> > the template. So the form just goes inside `my_data_dictionary` along with
> > any other data you want there.
> > --
> > DR.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Designing a workflow engine on Django

2011-01-07 Thread Javier Guerra Giraldez
On Fri, Jan 7, 2011 at 10:09 AM, Mo Mughrabi  wrote:
> If am reinventing the wheel and if there is such thing that has been
> developed already, any one can suggest, I would be more than happy to go
> through it.

yes, there are a few ones around there.  (as i found after realizing
that what i had just programmed was a workflow engine :-))

one that seems ok is GoFlow (http://code.google.com/p/goflow/).  i
haven't used it but read the API and code and plan to (soon?) replace
my own with it.


-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: render_to_response format using forms

2011-01-07 Thread hank23
I see. So then I would code it something like this then:

return render_to_response('contact.html',
{ my_data_dictionary(including an entry for 'form': form) },
context_instance=RequestContext(request))




On Jan 7, 9:42 am, Daniel Roseman  wrote:
> On Friday, January 7, 2011 3:38:10 PM UTC, hank23 wrote:
>
> > So then when using a form do I code it something like this then:
>
> > return render_to_response('contact.html', {
> >      'form': form,
> >      my_data_dictionary,
> >      context_instance=RequestContext(request))
>
> > })
>
> > I ask because it's confusing me when using a form for how to code the
> > form reference while still including the dictionary and context
> > references. The dictionary reference almost seems redundant since when
> > I go to create my form and assign it the name form I use the data
> > dictionary in the constructor of my form. Please clarify.
>
> No, for some reason you're thinking of the form as something special. It's
> not - it's simply part of the context, just like anything else you pass to
> the template. So the form just goes inside `my_data_dictionary` along with
> any other data you want there.
> --
> DR.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 version control solutions

2011-01-07 Thread Pēteris Brūns

Thanks!

Some basic use case.
Possibility to add remark about created change importance.
a) Perfect if possible to build it semiautomatic, some model field value 
change is important and we can add automatic some importance level for 
version.
b) Also possibility by user set created change importance and add some 
comment.


From documentation looks that some part from my case can be solved 
using version metadata.

--
pb

On 2011.01.07. 17:33, PeteDK wrote:

Hi.

I use Django-Reversion and i absolutely love it! :)

But I guess it depends on how you're planning on using it?


pete

On 7 Jan., 16:24, Pēteris Brūns  wrote:

Hi,
I'm seeking for version control solution in django. The most suitable
looks django-reversion all other seems dead. Has anybody experience with
django-reversion and can comment how successful is this solution, exists
other good options to look on? Which from existing solutions is the most
easy maintainable and with good admin integration. And very important
thing - has no symptoms that maintenance and development will die in
near future.

Thanks for advice!

--
pb


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.



creating apps inside sub folders

2011-01-07 Thread Mo Mughrabi
Hi,

am trying to organize some commonly used apps in my libs/shared folder
inside my project.

When I moved the file there, I just appended libs.shared.appname to the
INSTALLED_APP and it worked. but the views are not working, i noticed the
urls that needed to be appended as well. What else am missing?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: render_to_response format using forms

2011-01-07 Thread Daniel Roseman
On Friday, January 7, 2011 3:38:10 PM UTC, hank23 wrote:
>
> So then when using a form do I code it something like this then: 
>
>
> return render_to_response('contact.html', { 
>  'form': form, 
>  my_data_dictionary, 
>  context_instance=RequestContext(request)) 
>
> }) 
>
>
> I ask because it's confusing me when using a form for how to code the 
> form reference while still including the dictionary and context 
> references. The dictionary reference almost seems redundant since when 
> I go to create my form and assign it the name form I use the data 
> dictionary in the constructor of my form. Please clarify. 
>
 

No, for some reason you're thinking of the form as something special. It's 
not - it's simply part of the context, just like anything else you pass to 
the template. So the form just goes inside `my_data_dictionary` along with 
any other data you want there.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: render_to_response format using forms

2011-01-07 Thread hank23
So then when using a form do I code it something like this then:


return render_to_response('contact.html', {
 'form': form,
 my_data_dictionary,
 context_instance=RequestContext(request))

})


I ask because it's confusing me when using a form for how to code the
form reference while still including the dictionary and context
references. The dictionary reference almost seems redundant since when
I go to create my form and assign it the name form I use the data
dictionary in the constructor of my form. Please clarify.


On Jan 7, 9:27 am, Daniel Roseman  wrote:
> On Friday, January 7, 2011 3:15:33 PM UTC, hank23 wrote:
>
> > In the topics forms documentation there's an example of using a form
> > in a view which shows a return statement using a render_to_respone
> > shortcut like this:
>
> > return render_to_response('contact.html', {
> >      'form': form,
> > })
>
> > but in the shortcuts documentation it shows an example of using
> > render_to_response not using forms and coded like this:
>
> > return render_to_response('my_template.html',
> >                                        my_data_dictionary,
>
> > context_instance=RequestContect(request))
>
> > So if I want to use a form when coding a view how do I merge or
> > reconcile these two different examples so that my render_to_repsonse
> > will work properly? Please advise. Thanks.
>
> These are not substantially different, and the minor differences have
> nothing to do with forms. The only difference is that one is using the
> additional context_instance argument, for which see 
> here:http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-c...
> but as I say, this has nothing to do with forms. Apart from using a literal
> dictionary instead of a variable containing a dictionary, there is no other
> difference between the two examples.
> --
> DR.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 version control solutions

2011-01-07 Thread PeteDK
Hi.

I use Django-Reversion and i absolutely love it! :)

But I guess it depends on how you're planning on using it?


pete

On 7 Jan., 16:24, Pēteris Brūns  wrote:
> Hi,
> I'm seeking for version control solution in django. The most suitable
> looks django-reversion all other seems dead. Has anybody experience with
> django-reversion and can comment how successful is this solution, exists
> other good options to look on? Which from existing solutions is the most
> easy maintainable and with good admin integration. And very important
> thing - has no symptoms that maintenance and development will die in
> near future.
>
> Thanks for advice!
>
> --
> pb

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: render_to_response format using forms

2011-01-07 Thread Daniel Roseman
On Friday, January 7, 2011 3:15:33 PM UTC, hank23 wrote:
>
> In the topics forms documentation there's an example of using a form 
> in a view which shows a return statement using a render_to_respone 
> shortcut like this: 
>
> return render_to_response('contact.html', { 
>  'form': form, 
> }) 
>
> but in the shortcuts documentation it shows an example of using 
> render_to_response not using forms and coded like this: 
>
> return render_to_response('my_template.html', 
>my_data_dictionary, 
>   
> context_instance=RequestContect(request)) 
>
> So if I want to use a form when coding a view how do I merge or 
> reconcile these two different examples so that my render_to_repsonse 
> will work properly? Please advise. Thanks.


These are not substantially different, and the minor differences have 
nothing to do with forms. The only difference is that one is using the 
additional context_instance argument, for which see here:
http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-context-requestcontext
but as I say, this has nothing to do with forms. Apart from using a literal 
dictionary instead of a variable containing a dictionary, there is no other 
difference between the two examples.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: i18n django models

2011-01-07 Thread Marcos Moyano
I've worked on/with this app
https://github.com/Anue/django-polyglot/

Hope it helps.
Rgds,
Marcos

On Fri, Jan 7, 2011 at 12:20 PM, Mo Mughrabi  wrote:

> Hello,
>
> in my design there are some models where I need to store certain fields in
> different languages. I was wondering if anyone has done it before? I saw
> some django modules that help do model translations but some of them did not
> work properly.
>
> Any best practices out there? below is my code
>
> *my model.py*
>
> class Lookup_I18n(models.Model):
> i18n_code = models.CharField(max_length=5,
> default=settings.LANGUAGE_CODE)
> value = models.CharField(max_length=300)
>
> class Lookup(models.Model):
>
> purpose = models.CharField(max_length=10)
> key = models.CharField(max_length=10)
> value_i18n = models.ForeignKey(Lookup_I18n)
> value = models.Field()
>
> class Meta:
> unique_together = (('purpose', 'key'),)
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>



-- 
Some people, when confronted with a problem, think “I know, I'll use regular
expressions.” Now they have two problems.

Jamie Zawinski, in comp.emacs.xemacs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Django version control solutions

2011-01-07 Thread Pēteris Brūns

Hi,
I'm seeking for version control solution in django. The most suitable 
looks django-reversion all other seems dead. Has anybody experience with 
django-reversion and can comment how successful is this solution, exists 
other good options to look on? Which from existing solutions is the most 
easy maintainable and with good admin integration. And very important 
thing - has no symptoms that maintenance and development will die in 
near future.


Thanks for advice!

--
pb

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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 admin - action on delete

2011-01-07 Thread galago
I made what I wanted in
def log_deletion(self, request, object, object_repr):

It's not elegant, but in Django 1.3 there is a delete_model() function:)
But now I'm using 1.2.4 :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



i18n django models

2011-01-07 Thread Mo Mughrabi
Hello,

in my design there are some models where I need to store certain fields in
different languages. I was wondering if anyone has done it before? I saw
some django modules that help do model translations but some of them did not
work properly.

Any best practices out there? below is my code

*my model.py*

class Lookup_I18n(models.Model):
i18n_code = models.CharField(max_length=5,
default=settings.LANGUAGE_CODE)
value = models.CharField(max_length=300)

class Lookup(models.Model):

purpose = models.CharField(max_length=10)
key = models.CharField(max_length=10)
value_i18n = models.ForeignKey(Lookup_I18n)
value = models.Field()

class Meta:
unique_together = (('purpose', 'key'),)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



render_to_response format using forms

2011-01-07 Thread hank23
In the topics forms documentation there's an example of using a form
in a view which shows a return statement using a render_to_respone
shortcut like this:

return render_to_response('contact.html', {
 'form': form,
})

but in the shortcuts documentation it shows an example of using
render_to_response not using forms and coded like this:

return render_to_response('my_template.html',
   my_data_dictionary,
 
context_instance=RequestContect(request))

So if I want to use a form when coding a view how do I merge or
reconcile these two different examples so that my render_to_repsonse
will work properly? Please advise. Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 admin - action on delete

2011-01-07 Thread Mark (Nosrednakram)
There is a warning in on overriding delete, maybe not a concern for
you but worth knowing about.:

http://docs.djangoproject.com/en/dev/topics/db/models/

Note that the delete() method for an object is not necessarily called
when deleting objects in bulk using a QuerySet. To ensure customized
delete logic gets executed, you can use pre_delete and/or post_delete
signals.

On Jan 7, 4:18 am, robos85  wrote:
> What action is initialized when delete link is clicked?
> I user save_model() to override default save action, but can't find action
> to override delete procedures. I need 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-us...@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: Can I add custom field to ModelForm?

2011-01-07 Thread satyandra babu
Hi, i think form choice will work in this case.

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

class AuthorForm(forms.Form):
name = forms.CharField(max_length=100)
title = forms.CharField(max_length=3,
widget=forms.Select(choices=TITLE_CHOICES))
birth_date = forms.DateField(required=False)

like here in title, choices=TITLE_CHOICES you can always validate with
clean methods.

I hope it will solve your problem.


On Fri, Jan 7, 2011 at 8:25 PM, robos85  wrote:

> Is it possible to add field (I want it to be visible in generated form and
> after post) to form which is not included in Model? I need it to make a
> check after form.is_valid(), but this field won't go to DB.
>
> If yes - how can I do that?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



Can I add custom field to ModelForm?

2011-01-07 Thread robos85
Is it possible to add field (I want it to be visible in generated form and 
after post) to form which is not included in Model? I need it to make a 
check after form.is_valid(), but this field won't go to DB.

If yes - how can I do that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: A few beginner questions

2011-01-07 Thread derek
Re: " I would like to read about some best practices about midsize and
large Django projects."

I would recommend first implementing a small-ish but meaningful (i.e.
something that addresses a Real World problem, and that you will
actually use) project; that way you will see the overall structure and
shape of a typical project.  Trying to "brute force" PHP concepts into
a Python -based framework is a certain recipe for frustration... and
just reading about them will not help change your world view.  (My
2c)  I started with The Django Book - it starts very simply, with the
basic concepts, and someone with your skills should be able to work
through this fairly quickly.

On Jan 5, 12:06 am, Ondřej Mirtes  wrote:
> Hello,
> I am experienced PHP developer (and by PHP I mean advanced programming
> with MVC frameworks, TDD, ORM libraries, design patterns and such, so
> no scoffing please :)) and I would like to try something new. I've
> chosen Python and Django and I am building my bachelor thesis project
> with it.
>
> I dived directly into django-nonrel fork, because I am building the
> project on App Engine. However, I have few basic questions that
> concern basic relational Django as well.
>
> 1) Since Python has no object encapsulation, I have no idea how to
> implement computed columns in its models. E. g. I want to save forum
> post rating in the "posts" table even if I have related table with all
> the related post votes because it's faster and no joins are required
> to get the rating value.
>
> 2) I would like to perform some integrity checking before saving
> object to the database. I found here (http://docs.djangoproject.com/en/
> 1.2/topics/db/models/#overriding-predefined-model-methods) that I can
> override entity save method and stop it's execution before calling
> parent implementation. However, this didn't work for me for two
> reasons - it somehow caused 500 error on App Engine (because the app
> does not know that the object was not saved?) and it does not meet my
> needs - I would like to "attach" some error message to this
> application state and I would like this message to bubble up to the
> form errors (in case it happens when a form is submitted) in a way
> compatible with Django admin, so the user can fix the problem.
>
> 3) I would like to read about some best practices about midsize and
> large Django projects. How to organize the code, what directory
> structure to choose etc. Are there any additional layers between model
> and views widely used? Where should I put my code that is not directly
> related to model and is used in more than one view? Can you recommend
> me some articles about this topic?
>
> 4) What about dependency injection? From what I saw so far it seems
> like Django is full of singletons, static attributes and methods and
> hidden dependencies, which are considered as bad practice. For example
> how can I use two connections to two different databases to load and
> save model entities? Are there any "inversion of control" concepts?
>
> Thank you very much! And you can expect more questions to come in this
> thread :)
>
> Ondřej Mirtes from Prague, Czech Republic

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Error on Production Server (TemplateSyntaxError: Caught ImportError while rendering: No module named testapp)

2011-01-07 Thread Thomas M
I have to correct myself:

It still doesnt find "testapp", so nothing has changed :(

On 7 Jan., 14:53, Thomas M  wrote:
> Ok, I've called the sittings file with "bellcher.settings" and moved
> it into the projects root folder.
> Now there are no Error Mesages anymore but django still wont work.
>
> If I access the server's IP I am getting a "500 - Internal Server
> Error"
> I've posted my Server Configuration above. Do you have any Ideas?
>
> BTW: the testapp doesnt do very much, it just returns a HttpResponse
> so I can test the server.
>
> Thanks, Thomas
>
> On 7 Jan., 14:39, Tonton  wrote:
>
>
>
> > hello i am not sure if i can help you but from my config
> > use
>
> > os.environ["DJANGO_SETTINGS_MODULE"] = "bellcher.settings"  (like in
> > installed apps)
>
> > or mv django.wsgi in /Bellcher
> > WSGIScriptAlias / /www/django/bellcher/django.wsgi
>
> > regards
>
> > On Fri, Jan 7, 2011 at 2:26 PM, Thomas M  wrote:
> > > Hi,
>
> > > I've just set up a server with apache2 and mod_wsgi.
> > > Now I want to run django on this Server but it crashes with this error
> > > message:
> > > "TemplateSyntaxError: Caught ImportError while rendering: No module
> > > named testapp"
>
> > > I've configured the Server this way:
> > > My django code is in:
>
> > > /www/django/bellcher/
>
> > > so the app "testapp" is in /www/django/bellcher/testapp and has an
> > > __init__.py
>
> > > My WSGI Script:
>
> > > #!/usr/local/bin/python
> > > import os, sys
> > > sys.path.append("/www/django/")
> > > sys.path.append("/www/django/bellcher/")
> > > os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
> > > os.environ["PYTHON_EGG_CACHE"] = "/tmp"
>
> > > import django.core.handlers.wsgi
>
> > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > And my Apache configuration:
>
> > > 
> > >        Order deny,allow
> > >        Allow from all
> > > 
>
> > > 
> > >        AllowOverride All
> > >        Order deny,allow
> > >        Allow from all
> > > 
>
> > > Alias /media/ /www/django/bellcher/media/
> > > ServerAdmin t...@gmx.de
> > > ErrorLog "/var/log/apache2/django_error.log"
> > > CustomLog "/var/log/apache2/django_access.log" common
>
> > > WSGIScriptAlias / /www/django/bellcher/apache/django.wsgi
>
> > > I dont think that my server configuration causes the problem, because
> > > I've tried configuring the server with the help of several tutorials.
> > > And every try ended up with this error.
>
> > > Can somebody please help me with this issue?
>
> > > Much thanks in advance,
> > > Thomas M
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@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-us...@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: A few beginner questions

2011-01-07 Thread derek
Re:  "inversion of control" in Python - look at:

http://plope.com/control_inversion
http://code.activestate.com/recipes/413268-dependency-injection-the-python-way/
http://blog.code.zaubersoftware.com/2009/04/controlfreak-python-inversion-of.html

On Jan 5, 12:06 am, Ondřej Mirtes  wrote:
> Hello,
> I am experienced PHP developer (and by PHP I mean advanced programming
> with MVC frameworks, TDD, ORM libraries, design patterns and such, so
> no scoffing please :)) and I would like to try something new. I've
> chosen Python and Django and I am building my bachelor thesis project
> with it.
>
> I dived directly into django-nonrel fork, because I am building the
> project on App Engine. However, I have few basic questions that
> concern basic relational Django as well.
>
> 1) Since Python has no object encapsulation, I have no idea how to
> implement computed columns in its models. E. g. I want to save forum
> post rating in the "posts" table even if I have related table with all
> the related post votes because it's faster and no joins are required
> to get the rating value.
>
> 2) I would like to perform some integrity checking before saving
> object to the database. I found here (http://docs.djangoproject.com/en/
> 1.2/topics/db/models/#overriding-predefined-model-methods) that I can
> override entity save method and stop it's execution before calling
> parent implementation. However, this didn't work for me for two
> reasons - it somehow caused 500 error on App Engine (because the app
> does not know that the object was not saved?) and it does not meet my
> needs - I would like to "attach" some error message to this
> application state and I would like this message to bubble up to the
> form errors (in case it happens when a form is submitted) in a way
> compatible with Django admin, so the user can fix the problem.
>
> 3) I would like to read about some best practices about midsize and
> large Django projects. How to organize the code, what directory
> structure to choose etc. Are there any additional layers between model
> and views widely used? Where should I put my code that is not directly
> related to model and is used in more than one view? Can you recommend
> me some articles about this topic?
>
> 4) What about dependency injection? From what I saw so far it seems
> like Django is full of singletons, static attributes and methods and
> hidden dependencies, which are considered as bad practice. For example
> how can I use two connections to two different databases to load and
> save model entities? Are there any "inversion of control" concepts?
>
> Thank you very much! And you can expect more questions to come in this
> thread :)
>
> Ondřej Mirtes from Prague, Czech Republic

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Custom queryset on a ModelForm field

2011-01-07 Thread derek
Re: "why isn't there a proper API documentation on django like
doxygen? I  find the django documentation full of content but awful
structure! "

Have a look at:
http://docs.djangoproject.com/en/dev/internals/documentation/

I am curious as to what specific problems you have?  I have read the
docs for many open source (and closed source) projects over the last
dozen years and rate Django's docs as some of the best I have seen.

In addition, bear in mind this is a open source project: if there are
demonstrably significant improvements you can make, I am sure they
will be appreciated!

On Jan 4, 9:42 pm, Simon W  wrote:
> Hi,
>
> I have a 'project' model
>
> class Project(models.Model):
>     title = models.CharField(max_length=100)
>     links = models.ManyToManyField('Link', related_name='link')
>
> and a 'link' model
>
> class Link(models.Model):
>     label = models.CharField(max_length=50)
>     url = models.URLField(max_length=100)
>     project = models.ForeignKey(Project)
>
> I want the user to edit his project properties. I'm using ModelForm class
> and a UpdateView to put everything together. But I have a problems:
>
> I want the form to only show those *link*s who are owned by the project in
> the MultipleChoisesWidget, hence the ForeignKey in the Link model.
>
> Any help on how to achieve this? Thanks!
>
> P.S why isn't there a proper API documentation on django like doxygen? I
> find the django documentation full of content but awful structure!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server

2011-01-07 Thread DaithiF
Hi,
you only have 1 forward slash after the ftp: protocol string, you need two:
'ftp:*/*/16.168.250.14:2189/RTVE/VIDEOS/Thisisit.wmv'



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server

2011-01-07 Thread Scott Hebert (slaptijack)
>         file = 'ftp:/16.168.250.14:2189/RTVE/VIDEOS/Thisisit.wmv'

Looks like you are missing a second slash before the IP address there.

file = 'ftp://16.168.250.14:2189/RTVE/VIDEOS/Thisisit.wmv'

--
Scott Hebert
http://slaptijack.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Accessing the corresponding object for a form instance

2011-01-07 Thread Sithembewena Lloyd Dube
Dan and Chris, thanks! That was exactly what I needed.

@Chris, sorry about the double-post.

On Fri, Jan 7, 2011 at 2:55 PM, Dan Fairs  wrote:

> >
> > the, in views.py:
> > form = PersonForm(request.POST)
> > form.save() # how to return person's id here?
>
> instance = form.save()
> print instance.id
>
> Cheers,
> Dan
> --
> Dan Fairs | dan.fa...@gmail.com | www.fezconsulting.com
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Error on Production Server (TemplateSyntaxError: Caught ImportError while rendering: No module named testapp)

2011-01-07 Thread Thomas M
Ok, I've called the sittings file with "bellcher.settings" and moved
it into the projects root folder.
Now there are no Error Mesages anymore but django still wont work.

If I access the server's IP I am getting a "500 - Internal Server
Error"
I've posted my Server Configuration above. Do you have any Ideas?

BTW: the testapp doesnt do very much, it just returns a HttpResponse
so I can test the server.

Thanks, Thomas

On 7 Jan., 14:39, Tonton  wrote:
> hello i am not sure if i can help you but from my config
> use
>
> os.environ["DJANGO_SETTINGS_MODULE"] = "bellcher.settings"  (like in
> installed apps)
>
> or mv django.wsgi in /Bellcher
> WSGIScriptAlias / /www/django/bellcher/django.wsgi
>
> regards
>
>
>
> On Fri, Jan 7, 2011 at 2:26 PM, Thomas M  wrote:
> > Hi,
>
> > I've just set up a server with apache2 and mod_wsgi.
> > Now I want to run django on this Server but it crashes with this error
> > message:
> > "TemplateSyntaxError: Caught ImportError while rendering: No module
> > named testapp"
>
> > I've configured the Server this way:
> > My django code is in:
>
> > /www/django/bellcher/
>
> > so the app "testapp" is in /www/django/bellcher/testapp and has an
> > __init__.py
>
> > My WSGI Script:
>
> > #!/usr/local/bin/python
> > import os, sys
> > sys.path.append("/www/django/")
> > sys.path.append("/www/django/bellcher/")
> > os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
> > os.environ["PYTHON_EGG_CACHE"] = "/tmp"
>
> > import django.core.handlers.wsgi
>
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > And my Apache configuration:
>
> > 
> >        Order deny,allow
> >        Allow from all
> > 
>
> > 
> >        AllowOverride All
> >        Order deny,allow
> >        Allow from all
> > 
>
> > Alias /media/ /www/django/bellcher/media/
> > ServerAdmin t...@gmx.de
> > ErrorLog "/var/log/apache2/django_error.log"
> > CustomLog "/var/log/apache2/django_access.log" common
>
> > WSGIScriptAlias / /www/django/bellcher/apache/django.wsgi
>
> > I dont think that my server configuration causes the problem, because
> > I've tried configuring the server with the help of several tutorials.
> > And every try ended up with this error.
>
> > Can somebody please help me with this issue?
>
> > Much thanks in advance,
> > Thomas M
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@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-us...@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 admin - action on delete

2011-01-07 Thread Scott Hebert (slaptijack)
On Jan 7, 5:18 am, robos85  wrote:
> What action is initialized when delete link is clicked?
> I user save_model() to override default save action, but can't find action
> to override delete procedures. I need it:/

Every model has a delete() method. You should be able to override it.

http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.delete

--
Scott Hebert
http://slaptijack.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Can't use dumpdata and loaddata to migrate non-ASCII data between databases

2011-01-07 Thread derek
Maybe Google for this?  e.g.

http://www.codesmell.org/blog/2009/03/migrate-data-from-postgres-to-mysql/


On Jan 4, 1:49 am, Eric Chamberlain  wrote:
> Or is there a better way to migrate a database from postgres to MySQL?
>
> On Jan 3, 2011, at 6:35 PM, Eric Chamberlain wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > We are trying to migrate between databases and we are running into a 
> > problem while trying to use dumpdata.  We've tried:
>
> >    ./manage.py dumpdata --natural --indent 2 > dump.json
>
> > and:
>
> >    ./manage.py dumpdata --natural --format xml --indent 2 > dump.xml
>
> > Both return the following error:
>
> >    Error: Unable to serialize database: 'ascii' codec can't encode 
> > character u'\xe9' in position 18: ordinal not in range(128)
>
> > Is there a way to dump and load non-ASCII data?
>
> > --
> > Eric Chamberlain, Founder
> > RF.com -http://RF.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Massive insertion of records

2011-01-07 Thread Thomas Weholt
On Fri, Jan 7, 2011 at 2:31 PM, Derek  wrote:
> Thomas
> That looks potentially useful - can you please give an example (on the
> webpage) of how to do a multi-row insertion?  I typically need to add
> thousands of rows from existing spreadsheets - am using xlrd to read the
> data, but if DSE could speed up the write-to-database operation, that would
> be incredibly useful.
> Thanks!


A quick example:

Given a model foo, defined as:

class foo(models.Model):
name = models.CharField(max_length = 200)
age = models.IntegerField()

you can insert 5000 records very easily like so:

   dex = dse.ModelDelayedExecutor(foo)
   for i in range(0, 5000):
   dex.addItem({'name': 'Person%s' % i, 'age': i})
   dex.close()

The thing is that while you`re adding items nothing happens SQL-wise
until you reach a specific limit, the default limit is 1000, then dse
executes a cursor.executemany(list of cached elements).
Another thing is the significant overhead of creating objects using
the django ORM and that slows things down as well.

The biggest performance gain is when you want to do inserts and
updates on a bunch of elements, like this:


   dex = dse.ModelDelayedExecutor(foo)
   for item in dex.getItems(): # will iterate over all records in
the foo-table
   item['name'] = '%s Doe' % item['name] # changing name here,
would probably alter a calculated value, something not possible using
SQL alone.
   dex.addItem(item)
   dex.close()

Regards,
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ReportLab and Django - templates? ; FK object has no attribute split

2011-01-07 Thread Sells, Fred
Depending on what you need to do
You could shell down and run FOP from Apache foundation which is xml,
xslt to pdf
Or if you are filling in a form, you can use Adobe LiveCycle to define a
form and use code like below to fill in the form

def getPDFContent(id):
values = getAllValues(id)
code = values['CODE']
completedfdf = getCompletedForm(values)
pdffilename = PDFTemplateMapper.get(code, None)
if pdffilename==None:
raise "No PDF Template defined for %s" % code
pdfpath = os.path.join(ThisDirectory, 'forms')
pdfpath = os.path.join(pdfpath, pdffilename)
pdftk = ["/usr/bin/pdftk" ,'pdftk'][os.name=='nt']
cmd = '%s %s fill_form - output - flatten' % (pdftk, pdfpath)
proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE,
shell=True, bufsize=1)
cmdout,cmderr = proc.communicate(completedfdf)
if cmderr != '':
raise cmderr
return cmdout

-Original Message-
From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of Jirka Vejrazka
Sent: Thursday, November 18, 2010 4:14 AM
To: django-users@googlegroups.com
Subject: Re: ReportLab and Django - templates? ; FK object has no
attribute split

Hi Victor,

  It really depends on complexity of your PDF. I needed to do
something similar some time ago and used ReportLab addon called "pisa"
and used standard Django template language to define the PDF contents.

  You might want to take a look, it worked well enough for simple PDF
pages.

  Cheers

Jirka

On 18/11/2010, Victor Hooi  wrote:
> Hi,
>
> I'm trying to use ReportLab to produce a PDF output for one of my
> views.
>
> My first question is - at the moment, I'm building up the PDF inside
> my view. Is this really the recommended way of doing it? It's like
> I've got presentation code inside my view (controller). Isn't there a
> cleaner way of doing it, or going from a template to PDF somehow? (I
> know ReportLab offers a commercial package using RML templates,
> however I was hoping for an opensource/free method).
>
> Second question, I have a model with several FK fields. E.g.
>
> class Article(models.Model):
> category = models.ForeignKey(Category)
> subject = models.ForeignKey(Subject)
>
> Both the category and subject classes have fields called "name", and
> __unicode__ methods defined which return name.
>
> I'm trying to refer to these fields in my PDF output. I have a list of
> items in article_list (i.e. queryset):
>
> for item in article_list:
> text = item.category
> category = Paragraph(text, styles['Heading2'])
> story.append(category)
>
> text = '%s' % item.subject
> subject = Paragraph(text, styles['Heading3'])
> story.append(subject)
>
> When I try to run this code, I get:
>
> 'Category' object has no attribute 'split'
>
> and the same error with subject, obviously, once it gets to that bit
> of the code.
>
> Any idea why this might be, or how to fix it? Any help is much
> appreciated.
>
> Cheers,
> Victor
>
> --
> You received this message because you are subscribed to the Google
Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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-us...@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: Error on Production Server (TemplateSyntaxError: Caught ImportError while rendering: No module named testapp)

2011-01-07 Thread Tonton
hello i am not sure if i can help you but from my config
use

os.environ["DJANGO_SETTINGS_MODULE"] = "bellcher.settings"  (like in
installed apps)

or mv django.wsgi in /Bellcher
WSGIScriptAlias / /www/django/bellcher/django.wsgi

regards

On Fri, Jan 7, 2011 at 2:26 PM, Thomas M  wrote:

> Hi,
>
> I've just set up a server with apache2 and mod_wsgi.
> Now I want to run django on this Server but it crashes with this error
> message:
> "TemplateSyntaxError: Caught ImportError while rendering: No module
> named testapp"
>
> I've configured the Server this way:
> My django code is in:
>
> /www/django/bellcher/
>
> so the app "testapp" is in /www/django/bellcher/testapp and has an
> __init__.py
>
> My WSGI Script:
>
> #!/usr/local/bin/python
> import os, sys
> sys.path.append("/www/django/")
> sys.path.append("/www/django/bellcher/")
> os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
> os.environ["PYTHON_EGG_CACHE"] = "/tmp"
>
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
>
> And my Apache configuration:
>
> 
>Order deny,allow
>Allow from all
> 
>
> 
>AllowOverride All
>Order deny,allow
>Allow from all
> 
>
> Alias /media/ /www/django/bellcher/media/
> ServerAdmin t...@gmx.de
> ErrorLog "/var/log/apache2/django_error.log"
> CustomLog "/var/log/apache2/django_access.log" common
>
> WSGIScriptAlias / /www/django/bellcher/apache/django.wsgi
>
>
> I dont think that my server configuration causes the problem, because
> I've tried configuring the server with the help of several tutorials.
> And every try ended up with this error.
>
> Can somebody please help me with this issue?
>
> Much thanks in advance,
> Thomas M
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: Massive insertion of records

2011-01-07 Thread Derek
Thomas

That looks potentially useful - can you please give an example (on the
webpage) of how to do a multi-row insertion?  I typically need to add
thousands of rows from existing spreadsheets - am using xlrd to read the
data, but if DSE could speed up the write-to-database operation, that would
be incredibly useful.

Thanks!

On 6 January 2011 17:20, Thomas Weholt  wrote:

> Just want to mention DSE which is especially made to solve problems
> with mass insert and/updates in django:
>
> http://pypi.python.org/pypi/dse/0.3.0
>
> Regards,
> Thomas
>
> On Wed, Dec 29, 2010 at 1:22 PM, Derek  wrote:
> > Thanks Craig - that explains it very clearly indeed ("textbook answer"!)
> >
> > On 27 December 2010 16:50, W. Craig Trader 
> wrote:
> >>
> >> Derek ...
> >>
> >> Quoting from
> http://docs.djangoproject.com/en/1.2/topics/db/transactions/:
> >>>
> >>> Django’s default behavior is to run with an open transaction which it
> >>> commits automatically when any built-in, data-altering model function
> is
> >>> called. For example, if you call model.save() or model.delete(), the
> change
> >>> will be committed immediately.
> >>>
> >>> This is much like the auto-commit setting for most databases. As soon
> as
> >>> you perform an action that needs to write to the database, Django
> produces
> >>> the INSERT/UPDATE/DELETE statements and then does the COMMIT. There’s
> no
> >>> implicit ROLLBACK.
> >>
> >> Using the Django transaction API, you can manually control transactions.
> >> In this case, Silva must be doing something like this:
> >>
> >> from django.db import transaction
> >>
> >> @transaction.commit_manually
> >> def viewfunc(request):
> >>
> >>
> >>
> >> ...
> >> # You can commit/rollback however and whenever you want
> >> i = 0
> >> for x in data:
> >> ... save something ...
> >> i += 1
> >> if i % 1000:
> >>
> >> transaction.commit()
> >>
> >> # One last commit to persist the last batch of saves
> >> transaction.commit()
> >>
> >>
> >>
> >>
> >> I will also note that the transaction API can be (and should be) used
> when
> >> you're writing management commands.
> >>
> >>  - Craig -
> >>
> >> On Mon, Dec 27, 2010 at 05:29, derek  wrote:
> >>>
> >>> Can you explain what you mean by "manual commitments" (preferably with
> >>> a code example)?
> >>>
> >>> Thanks
> >>> Derek
> >>>
> >>> On Dec 26, 4:38 am, Silva Paulo  wrote:
> >>> > OK. I found a "solution".
> >>> > Using manual commitments after lots of insertions (ex. >1000) makes
> the
> >>> > massive insertion very fast (at least for my needs).
> >>> >
> >>> > Thanks to all who answered.
> >>> >
> >>> > --- On Fri, 12/24/10, Silva Paulo  wrote:
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > > From: Silva Paulo 
> >>> > > Subject: Massive insertion of records
> >>> > > To: "newbie" 
> >>> > > Date: Friday, December 24, 2010, 6:26 PM
> >>> > > I need to do a massive insertion of
> >>> > > records in two tables "connectd" by "foreignkey". Is there a
> >>> > > way, using the Django db API, to do it. e=Foo(...);e.save()
> >>> > > seems too slow.
> >>> >
> >>> > > Thanks
> >>> >
> >>> > >
> >>> >
> >>> > > --
> >>> > > 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
> >>> > > athttp://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-us...@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-us...@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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > 

Error on Production Server (TemplateSyntaxError: Caught ImportError while rendering: No module named testapp)

2011-01-07 Thread Thomas M
Hi,

I've just set up a server with apache2 and mod_wsgi.
Now I want to run django on this Server but it crashes with this error
message:
"TemplateSyntaxError: Caught ImportError while rendering: No module
named testapp"

I've configured the Server this way:
My django code is in:

/www/django/bellcher/

so the app "testapp" is in /www/django/bellcher/testapp and has an
__init__.py

My WSGI Script:

#!/usr/local/bin/python
import os, sys
sys.path.append("/www/django/")
sys.path.append("/www/django/bellcher/")
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
os.environ["PYTHON_EGG_CACHE"] = "/tmp"

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

And my Apache configuration:


Order deny,allow
Allow from all



AllowOverride All
Order deny,allow
Allow from all


Alias /media/ /www/django/bellcher/media/
ServerAdmin t...@gmx.de
ErrorLog "/var/log/apache2/django_error.log"
CustomLog "/var/log/apache2/django_access.log" common

WSGIScriptAlias / /www/django/bellcher/apache/django.wsgi


I dont think that my server configuration causes the problem, because
I've tried configuring the server with the help of several tutorials.
And every try ended up with this error.

Can somebody please help me with this issue?

Much thanks in advance,
Thomas M

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Accessing the corresponding object for a form instance

2011-01-07 Thread Dan Fairs
> 
> the, in views.py:
> form = PersonForm(request.POST)
> form.save() # how to return person's id here?

instance = form.save()
print instance.id

Cheers,
Dan
--
Dan Fairs | dan.fa...@gmail.com | www.fezconsulting.com


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Accessing the corresponding object for a form instance

2011-01-07 Thread Sithembewena Lloyd Dube
Hi all,

I have a form which inherits ModelForm and is attached to a model via a Meta
class.

I wish to find out if/ how I could access the return object (model) for a
form instance after calling save() on the form. I need to access the id of
the newly saved return object e.g:

*in models.py:*
class Person(models.Model):
 name =   models.CharField(max_length=50)

*in forms.py:*
class PersonForm(ModelForm):
 class Meta:
  model = Person
 name =
forms.CharField(widget=forms.TextInput(attrs={'size':'50'}))

*the, in views.py:*
form = PersonForm(request.POST)
form.save()* # how to return person's id here?*

Thanks.

-- 
Regards,
Sithembewena Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Changing a constraint with live data

2011-01-07 Thread Sithembewena Lloyd Dube
Thanks Shawn. Great to note that someone has thought of this before.

On Wed, Jan 5, 2011 at 5:24 PM, Shawn Milochik  wrote:

>
> On Jan 5, 2011, at 4:44 AM, Sithembewena Lloyd Dube wrote:
>
> Thomas and Shawn, thanks for responding.
>
> South looks pretty useful - I hope that it could be included in the
> standard Django distribution.
>
>
> This has been discussed quite a bit, and a plan has been made to do this --
> in a way. South itself won't be integrated into Django, but the South
> project will be divided into two separate pieces. One will be built into
> Django, and will allow users to make their own migration front-end. The
> other will be the third-party South app which you can use to take advantage
> of the built-in backend.
>
> http://www.aeracode.org/2010/6/2/django-and-migrations/
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>



-- 
Regards,
Sithembewena Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: list of lists in template

2011-01-07 Thread Chris Matthews
{%  for Ltarp in  smth.3 %}
SHOULD BE 
{%  for Ltarp in  smth.2 %}
'cos Lans only has 3 elements and Ltarp is Lans[2].

Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of gintare
Sent: 07 January 2011 08:52
To: Django users
Subject: list of lists in template


in view.py
...
Ltarp.append([item.Wordword, item.WordTranslEn, item.WordNotesGram,
item.WordConcl])
..
Lans.append([sen.Sent, sen.SentTransl, Ltarp ] )

in template.html
{% if Lans %}

{%  for smth in Lans %}

  {{smth.0}} 

{%  for Ltarp in  smth.3 %}

 {{Ltarp.0}} 


{% endfor %}


{% endfor %}

{% endif %}

###

the rows from smth.0 are shown
the rows from  Ltarp in  smth.3, i.e. {{Ltarp.0}} are not shown.

I tried also:Ltarp, Ltarp[0], smth.Ltarp.0

nothing works in the second for cycle where i need to get items from
list built in third item of list in the first for cycle.

Could you please help with syntax, when i need to dislay item from
list in another list in template

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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-us...@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.



Dynamically Generating a Tuple for use within Settings.py

2011-01-07 Thread bdunlay
Hi everyone -- I'd like to dynamically generate a tuple of users in a
tuple from my UserProfile model and assign it to a variable within my
settings file. Do you have any suggestions for accomplishing this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Django admin - action on delete

2011-01-07 Thread robos85
What action is initialized when delete link is clicked?
I user save_model() to override default save action, but can't find action 
to override delete procedures. I need 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-us...@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: ANN: dse 0.3.0 DSE - Delayed SQL Executor

2011-01-07 Thread bruno desthuilliers
On 7 jan, 10:00, Thomas Weholt  wrote:
> On Fri, Jan 7, 2011 at 9:40 AM, bruno desthuilliers
>
>  wrote:
>
> > On 6 jan, 15:49, Thomas Weholt  wrote:
> >> Just released a new version of DSE for django and would like to get
> >> comments, flames, whatever.
>
> >>http://pypi.python.org/pypi/dse/0.3.0
>
> > Ok, just browsed the project page, but there's already something that
> > bugs me : mixedCaps method names instead of PEP08 compliant all_lower.
>
> Yes, I agree completly - use of mixedCaps or all_lower should at least
> be consistent throughout the code. So the code is still messy, but
> what about the concept?

Deathmarch here so I can't dig further but it might be of interest.
I'll try to spend a bit more time on it ASAP.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ANN: dse 0.3.0 DSE - Delayed SQL Executor

2011-01-07 Thread Thomas Weholt
On Fri, Jan 7, 2011 at 9:45 AM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Do you have any performance comparisons? Would be interested to see them.
> Cheers
> Cal

These tests were all done using an in-memory SQLite database:

Lots of inserts using dse:

dex = dse.ModelDelayedExecutor(foo)
for i in range(0, 5000):
dex.addItem({'name': 'Person%s' % i, 'age': i})
dex.close()

Takes about  0.107000112534 seconds.

Same thing, using the orm:

for i in range(0, 5000):
foo(name = 'Person%s' % i, age = i).save()

Takes 0.99009537 seconds. Not that big difference.

But if you want to update a bunch of records, for instance to change a
calculated value ( I`m not doing that here, just changing the name ):

dex = dse.ModelDelayedExecutor(foo)
try:
for item in dex.getItems():
item['name'] = "%s Doe" % item['name']
dex.addItem(item)
finally:
dex.close()

It takes 0.1220654 seconds. Using orm:

for item in foo.objects.all():
item.name = "%s Doe" % item.name
item.save()

it takes 9.6017057 seconds. It shows that the overhead of using
the orm is significant ( we all knew that allready ).

Regards,
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ANN: dse 0.3.0 DSE - Delayed SQL Executor

2011-01-07 Thread Thomas Weholt
On Fri, Jan 7, 2011 at 9:40 AM, bruno desthuilliers
 wrote:
>
>
> On 6 jan, 15:49, Thomas Weholt  wrote:
>> Just released a new version of DSE for django and would like to get
>> comments, flames, whatever.
>>
>> http://pypi.python.org/pypi/dse/0.3.0
>>
>
> Ok, just browsed the project page, but there's already something that
> bugs me : mixedCaps method names instead of PEP08 compliant all_lower.

Yes, I agree completly - use of mixedCaps or all_lower should at least
be consistent throughout the code. So the code is still messy, but
what about the concept?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ANN: dse 0.3.0 DSE - Delayed SQL Executor

2011-01-07 Thread Cal Leeming [Simplicity Media Ltd]
Do you have any performance comparisons? Would be interested to see them.

Cheers

Cal

On Fri, Jan 7, 2011 at 8:40 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On 6 jan, 15:49, Thomas Weholt  wrote:
> > Just released a new version of DSE for django and would like to get
> > comments, flames, whatever.
> >
> > http://pypi.python.org/pypi/dse/0.3.0
> >
>
> Ok, just browsed the project page, but there's already something that
> bugs me : mixedCaps method names instead of PEP08 compliant all_lower.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: ANN: dse 0.3.0 DSE - Delayed SQL Executor

2011-01-07 Thread bruno desthuilliers


On 6 jan, 15:49, Thomas Weholt  wrote:
> Just released a new version of DSE for django and would like to get
> comments, flames, whatever.
>
> http://pypi.python.org/pypi/dse/0.3.0
>

Ok, just browsed the project page, but there's already something that
bugs me : mixedCaps method names instead of PEP08 compliant all_lower.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.