Re: Admin - Auto Generate user_id on save

2008-12-18 Thread adnan
The save_model(..) in ModelAdmin is what you're looking for http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change On Nov 29, 6:25 pm, AJ wrote: > I have a simple model like so: > # models.py > class Announcement(models.Model): >    

Re: how to add more params in url

2008-12-18 Thread cschand
check this snippet http://www.djangosnippets.org/snippets/840/ Satheesh On Dec 19, 9:05 am, mono wrote: > I means if I have three param( I think it is very frequent ), the > style of writing method seem somehow inconvenient. > > eg; > > in code area which handle param1

Re: how to add more params in url

2008-12-18 Thread mono
I means if I have three param( I think it is very frequent ), the style of writing method seem somehow inconvenient. eg; in code area which handle param1 if ... url = ?param1=..=..=.. else url = ?param1=..=..=.. param2 if ... url = ?param1=..=..=.. else url = ?param1=..=..=..

Re: Security in AJAX POSTing

2008-12-18 Thread Taylor
Yay!! Now I can sleep tonight! So the docs say this about the CSRF middleware: "It may still be possible to use the middleware, provided you can find some way to get the CSRF token and ensure that is included when your form is submitted." Has anyone found that way, or can anyone point me in

Re: Security in AJAX POSTing

2008-12-18 Thread anb
> Each of my views use the @login_required decorator, is there anything > else I need to do to ensure that the user is logged in and active > (i.e. do I need to check user.is_active)? The meaning of is_active is an application decision. It's just a field on the model, you can do whatever you

Re: SQLite iexact problem with non-latin symbols

2008-12-18 Thread Karen Tracey
On Thu, Dec 18, 2008 at 4:53 PM, Eugene Mirotin wrote: > > Hello. > Consider I have a simple model > > class Team(models.Model): >name = models.CharField(max_length=200) > > Then I create some team and try to look for it with iexact match: > tt = Team(name='English') >

Validation error when uploading an image through admin interface

2008-12-18 Thread Michael Yoon
Hi all, I'm a Django newbie having some trouble getting image uploads to work. I've read the docs pretty carefully, I have PIL installed, and I've been googling without success for a while now. Hopefully, my dumb mistake will jump out at someone reading this... Anyway, here is my trivial model:

Re: Using Content Types With Test Databases

2008-12-18 Thread Russell Keith-Magee
On Mon, Dec 15, 2008 at 11:24 AM, Mark wrote: > > Hello, > > Are there any comments on the issue I describe below? > Aside from issue 7052 in the tracker: > > http://code.djangoproject.com/ticket/7052 > > I'm a new user of Django so I may be doing something >

output of XML serializer

2008-12-18 Thread Mr. T
response = serializers.serialize('xml', MySet.objects.all()) return HttpResponse(response , mimetype='text/xml;') The output has each member of "MySet" with an tag, and then within the object, a bunch of tags with each field. It seems sort of hard to parse this on the client side. Can anyone

Re: Security in AJAX POSTing

2008-12-18 Thread bruno desthuilliers
On 18 déc, 23:20, Taylor wrote: > I'm working on a game in Django where the majority of the interaction > comes through clicks that run JavaScript methods that use jQuery's > $.post() to post data to a url. To protect against cheaters and bots, > I must ensure that every post

Re: passing extra parameters with named urls

2008-12-18 Thread DragonSlayre
url(r'^register/$', register, {'extra_context' : {'currentmaintab' : 'account'}}, name='registration_register', ), It would have been nice if you could have told me straight up.

Re: passing extra parameters with named urls

2008-12-18 Thread Masklinn
On 18 Dec 2008, at 23:21 , DragonSlayre wrote: > > Hi, > > I'm currently working with django-registration, and have the following > url pattern (it's included from my other url pattern): > > url(r'^register/$', > register, >

RE: how to add more params in url

2008-12-18 Thread Wayper, Paul
> From: mono > Sent: Thursday, 18 December 2008 22:10 > To: Django users > Subject: Re: how to add more params in url > > > I don't know whether it is a good answer because only two > page links is here and the aim of is_extend flag is to show > entire or part of columns. > > so I could not

Re: inlineformset_factory with a custom widget for a field

2008-12-18 Thread Cortland Klein
Yep that works, adding that and the following to forms.py: > from django.forms import fields > from django.db import models On Thu, Dec 18, 2008 at 11:53 AM, panta wrote: > > noticing you have provided also models.py, here is a more complete > answer: > > def

Re: Custom form/formset for edit inline

2008-12-18 Thread Peter Shafer
It seems to be working now once I made the following changes to admin.py http://dpaste.com/100570/ On Dec 18, 1:56 pm, Peter Shafer wrote: > I'm also having the same problem as Emil.  I have pictures that belong > to galleries so I use inline forms to manage them.  I

passing extra parameters with named urls

2008-12-18 Thread DragonSlayre
Hi, I'm currently working with django-registration, and have the following url pattern (it's included from my other url pattern): url(r'^register/$', register, name='registration_register', ), This calls a view:

Security in AJAX POSTing

2008-12-18 Thread Taylor
I'm working on a game in Django where the majority of the interaction comes through clicks that run JavaScript methods that use jQuery's $.post() to post data to a url. To protect against cheaters and bots, I must ensure that every post is made by a logged-in user and protect against cross-site

Re: inlineformset_factory with a custom widget for a field

2008-12-18 Thread Daniel Roseman
On Dec 18, 7:18 pm, Cortland Klein wrote: > I'm using inlineformset_factory in one of my views, which is working   > great, except now I'd like to change the widget for one of the fields   > (in case anyone's curious, an AdminFileWidget). For clarification this   > is my own

SQLite iexact problem with non-latin symbols

2008-12-18 Thread Eugene Mirotin
Hello. Consider I have a simple model class Team(models.Model): name = models.CharField(max_length=200) Then I create some team and try to look for it with iexact match: tt = Team(name='English') tt.save() Team.objects.filter(name__iexact=tt.name.lower()) # this returns the list containing

Re: inlineformset_factory with a custom widget for a field

2008-12-18 Thread panta
noticing you have provided also models.py, here is a more complete answer: def my_formfield_cb(field): if isinstance(field, models.FileField) and field.name == 'file': return fields.FileField(widget = AdminFileWidget(attrs={'url': "/my/url/"})) return field.formfield()

Re: nested template problem

2008-12-18 Thread bruno desthuilliers
On 18 déc, 18:31, marco ghidinelli wrote: > hello. > > Does django template engine supports nested dictionary? Yes, indeed. > i'm trying to display a nested array with no luck. > > that's my tries: > > --- python manage.py shell --- > from

Re: inlineformset_factory with a custom widget for a field

2008-12-18 Thread panta
I've never used inlineformset_factory(), but I guess you can use the formfield_callback parameter. For example: def my_formfield_cb(field): if condition_on_field(field): return SuitableFormField(widget = MyCustomWidget()) return field.formfield() FileFormSet =

inlineformset_factory with a custom widget for a field

2008-12-18 Thread Cortland Klein
I'm using inlineformset_factory in one of my views, which is working great, except now I'd like to change the widget for one of the fields (in case anyone's curious, an AdminFileWidget). For clarification this is my own view and has nothing to do with contrib/admin. I see that

Re: Custom form/formset for edit inline

2008-12-18 Thread Peter Shafer
I'm also having the same problem as Emil. I have pictures that belong to galleries so I use inline forms to manage them. I also use the drag-drop script to order these images. Since images have so many attributes though, the size of the inline form becomes pretty unmanageable. Here is my

Re: Need Drop down menu code

2008-12-18 Thread Ana
Hello Dj, Yes, this is what I need. I just have to get it working and I will be on my way. Thanks, Ana On Dec 18, 10:35 am, "Dj Gilcrease" wrote: > Do you mean a select form item or a mouse over drop down menu? > > If you mean a select dropdown an

Re: Need Drop down menu code

2008-12-18 Thread Dj Gilcrease
Do you mean a select form item or a mouse over drop down menu? If you mean a select dropdown an example http://dpaste.com/hold/100463/ Dj Gilcrease OpenRPG Developer ~~http://www.openrpg.com --~--~-~--~~~---~--~~ You received this message because you are

Re: Need Drop down menu code

2008-12-18 Thread Ana
Hello Justin, This seems very complicated for a drop down menu. Will my travels through Django be this complex? I'm coming from a php environment and have been very impressed by Django admin page and inheritance of base.html, but now that I'm trying to write my own views and templates I'm

error at /accounts/register/ (10053, 'Software caused connection abort')

2008-12-18 Thread eldonp2
I am trying to get django-registration working. My PC is on a domain. When I am logged on to the domain, I cannot ping the Google smtp server. Even when I dial up, I get the error in the subject above. All my congifurations are correct, including the following in settings.py EMAIL_USE_TLS =

Re: Need Drop down menu code

2008-12-18 Thread Justin Myers
> How do I write the drop down menu on the index page to then > retrieve the value from the drop down menu.   Django itself won't generate the dropdowns for you--that's a template issue. What you'd want to do is generate the markup (i.e., a list within tags or something similar) with Django and

Need Drop down menu code

2008-12-18 Thread Ana
Hello, I have a table Technology: id technology What is the code to place in view.py to create a drop down menu on the index.html page, so a user can select a value from the technology list. How do I write the drop down menu on the index page to then retrieve the value from the drop down menu.

nested template problem

2008-12-18 Thread marco ghidinelli
hello. Does django template engine supports nested dictionary? i'm trying to display a nested array with no luck. that's my tries: --- python manage.py shell --- from django.template import Template, Context list_parts = { 'root': {'value': [{'tag':

Re: ANN: Softwarefabrica Django Utils (PRE-RELEASE)

2008-12-18 Thread panta
On Dec 18, 4:33 pm, "Marco Pantaleoni" wrote: > > Binary packages are available in the Cheeseshop (PyPI): > > http://pypi.python.org/softwarefabrica.django.utils errata corrige, the correct link is: http://pypi.python.org/pypi/softwarefabrica.django.utils Marco

ANN: Softwarefabrica Django Forms (PRE-RELEASE)

2008-12-18 Thread Marco Pantaleoni
Softwarefabrica Django Forms (sfforms) is a free, Open Source, forms library for Django, which aims at providing increased functionality and flexibility to the standard forms library ("newforms"). Its main features are: - a compatible replacement for the standard Form class, supporting

ANN: Softwarefabrica Django Utils (PRE-RELEASE)

2008-12-18 Thread Marco Pantaleoni
Softwarefabrica Django Utils (sfutils) is a free, Open Source, Django library providing useful functions and abstractions in day to day Django application development. This is the foundation library on which the other Softwarefabrica Open Source Django apps and libraries are built: Forms, CRUD

Re: two forms in the same view

2008-12-18 Thread Jorge Bastida
Or use prefix theform(request.POST,prefix='form1Prefix') theform2(request.POST,prefix='form2Prefix') 2008/12/18 Stefan Tunsch > > You simply have to avoid using the same field name in the two forms. > > On 12/18/08, Alfredo Alessandrini wrote: > > > >

Re: two forms in the same view

2008-12-18 Thread Stefan Tunsch
You simply have to avoid using the same field name in the two forms. On 12/18/08, Alfredo Alessandrini wrote: > > Hi, > > can I use two form in the same view function? > > if request.method == 'POST': > form = FORM_1(request.POST) > if form.is_valid(): >

Re: django and os.spawnvp method

2008-12-18 Thread Karen Tracey
On Thu, Dec 18, 2008 at 3:36 AM, Alan wrote: > Thanks Malcom, > I think I was not clear enough. I will try again. > > So I am at the "Submission Page" (submit.html), with a form where I set > some parameters and then I click "submit". This form is linked to action >

Re: Is this a bug in FormWizard?

2008-12-18 Thread Rajesh Dhawan
�� wrote: > On Dec 17, 7:49 am, Rajesh Dhawan wrote: > > On Dec 16, 2:31 am, $B wrote: > > > > > Theextra_contextinFormWizardis a class attribute so the new > > > request may get the context of the previous request. > > > I can prepend

Re: Is this a bug in FormWizard?

2008-12-18 Thread Rajesh Dhawan
朱穆穆 wrote: > On Dec 17, 7:49 am, Rajesh Dhawan wrote: > > On Dec 16, 2:31 am, $B wrote: > > > > > Theextra_contextinFormWizardis a class attribute so the new > > > request may get the context of the previous request. > > > I can prepend below to __call__ method to solved

Re: how to add more params in url

2008-12-18 Thread mono
maybe do it. is there a method like '+='? On Dec 18, 8:10 pm, "@@" wrote: > You can keep these information in session. > > On Thu, Dec 18, 2008 at 7:10 PM, mono wrote: > > > I don't know whether it is a good answer because only two page links > > is

Re: Multiple apps extending admin/change_list.html

2008-12-18 Thread Jeff Kowalczyk
Malcolm Tredinnick wrote: > So let's fall back to first principles: always construct the smallest > case possible that repeats the failure. This means start with a template > that includes nothing but the "extends" of the batchadmin template. If > that works, you can

modelForm with customised cleaned_data

2008-12-18 Thread Alan
Hi List, So I have this in models.py: class Job(models.Model): jname = models.CharField(max_length=255) title = models.CharField(max_length=255, null=True, blank=True) file = models.FileField(upload_to=".") class JobForm(ModelForm): class Meta: model = Job

two forms in the same view

2008-12-18 Thread Alfredo Alessandrini
Hi, can I use two form in the same view function? if request.method == 'POST': form = FORM_1(request.POST) if form.is_valid(): . form = FORM_2(request.POST) if form.is_valid(): . It's

Re: how to add more params in url

2008-12-18 Thread @@
You can keep these information in session. On Thu, Dec 18, 2008 at 7:10 PM, mono wrote: > > I don't know whether it is a good answer because only two page links > is here and the aim of is_extend flag is to show entire or part of > columns. > > so I could not tell a page

Re: how to add more params in url

2008-12-18 Thread mono
I don't know whether it is a good answer because only two page links is here and the aim of is_extend flag is to show entire or part of columns. so I could not tell a page linkto is_extend=shrink=next_page and is_extend=shrink=previous_page maybe I need more page links, like the first, the last

Re: populating a multi select list by passing in user obj to form

2008-12-18 Thread Chris
Thank you very much for the great advice. I found that it is: self.base_fields['accounts'].choices = but I am sure that was just an example. Thanks again. On Dec 18, 1:52 am, Daniel Roseman wrote: > On Dec 18, 9:41 am, Chris

Re: UserProfile matching query does not exist.

2008-12-18 Thread Daniel Roseman
On Dec 18, 9:30 am, "Arnoud Tijssen" wrote: > I`m a python newbie so bear with me > > I use the django framework and get the following error: > > DoesNotExist at / > UserProfile matching query does not exist. > > Since python is fairly new to me I don`t know where to start.

Re: Using the test client to verify form fields content

2008-12-18 Thread Daniel Roseman
On Dec 18, 6:16 am, sagi s wrote: > I'd like to use the test client to verify that when there's an error > in a form field, the input field in the > response is populated with the original input. > > So I'd like to do something like: > > iteration = 'bad data' > response =

Re: populating a multi select list by passing in user obj to form

2008-12-18 Thread Daniel Roseman
On Dec 18, 9:41 am, Chris wrote: > Hello all, > I am trying to popular a multi-select form field by passing in a user > object suchas request.user so that I can filter a table based on that > object. Below is what I came up with but it is still not working. > I get the

populating a multi select list by passing in user obj to form

2008-12-18 Thread Chris
Hello all, I am trying to popular a multi-select form field by passing in a user object suchas request.user so that I can filter a table based on that object. Below is what I came up with but it is still not working. I get the following error: 'ChoiceForm' object has no attribute 'accounts'

Re: double logging in unittest

2008-12-18 Thread Russell Keith-Magee
On Thu, Dec 18, 2008 at 5:05 PM, knight wrote: > > Hi, > > I have unittests in my django applications and I have a strange > behavior: > When I run the tests, I am getting each print-out to log from my > application twice. > I am using the standard python logging libraries.

UserProfile matching query does not exist.

2008-12-18 Thread Arnoud Tijssen
I`m a python newbie so bear with me I use the django framework and get the following error: DoesNotExist at / UserProfile matching query does not exist. Request Method: GET Request URL: http://surftracker.example.com/ Exception Type: DoesNotExist Exception Value: UserProfile matching query

Re: Strange error using modelformset_factory

2008-12-18 Thread marty3d
Ah I see. Thanks for the explanation! On Dec 18, 9:38 am, "alex.gay...@gmail.com" wrote: > The reason this occurs, even with valid data, is because is_valid() > triggers the validation procedures which set the cleaned_data > attribute. > > Alex > > On Dec 18, 2:33 am,

Re: Strange error using modelformset_factory

2008-12-18 Thread alex.gay...@gmail.com
The reason this occurs, even with valid data, is because is_valid() triggers the validation procedures which set the cleaned_data attribute. Alex On Dec 18, 2:33 am, marty3d wrote: > Thanks for the English lesson! :) > > As you both pointed out, the .is_valid()

Re: django and os.spawnvp method

2008-12-18 Thread Alan
Thanks Malcom, I think I was not clear enough. I will try again. So I am at the "Submission Page" (submit.html), with a form where I set some parameters and then I click "submit". This form is linked to action "run_aria" (run_aria.html) defined in views.py as: def run_aria(request): if not

Re: Strange error using modelformset_factory

2008-12-18 Thread marty3d
Thanks for the English lesson! :) As you both pointed out, the .is_valid() should be used here. I skipped that part because the data was indeed valid and still got the error message. It has been tried, sorry for not mentioning that. But actually, by trying it again, with the Werkzeug debugger

double logging in unittest

2008-12-18 Thread knight
Hi, I have unittests in my django applications and I have a strange behavior: When I run the tests, I am getting each print-out to log from my application twice. I am using the standard python logging libraries. Does anyone know this issue? Thanks, Arshavski Alexander.