TypeError: direct_to_template() got multiple values for keyword argument 'template'

2008-09-15 Thread Cortland Klein

Hi. I'm getting a TypeError on my direct_to_template url:

direct_to_template() got multiple values for keyword argument 'template'

urls.py:
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
> (r'^$', 'redacted.redacted.views.sessionform'),
> (r'^success(.*)$',  
> 'django.views.generic.simple.direct_to_template', {'template':  
> 'success.html'}),
>
> )
>


-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040

Alumni, Business Management <[EMAIL PROTECTED]>
San José State University

Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED] 
 >
http://e-society.org/

Q&A Techie, Silicon Valley Mac User Group
http://svmug.org/

Member, Silicon Valley Google Technology User Group
http://sv-gtug.org/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TypeError: direct_to_template() got multiple values for keyword argument 'template'

2008-09-15 Thread Cortland Klein

Oh whoops, my bad.

I forgot about positional arguments; thanks for the reminder.

On Sep 15, 2008, at 4:04 PM, Malcolm Tredinnick wrote:

> This URL pattern says to capture everything after "success" and that  
> is
> then passed as the first positional argument to the view. That  
> argument
> is also the template keyword argument. That's why Django is giving you
> the error, because it's receiving two values for the first argument  
> for
> direct_to_template(): one via "template =..." and one via the captured
> group in the pattern reg-exp.
>
> It's unclear what you're trying to do, but you aren't going to achieve
> it with an unnamed capturing group in the URL pattern there.
>
> Regards,
> Malcolm

-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040

Alumni, Business Management <[EMAIL PROTECTED]>
San José State University

Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED] 
 >
http://e-society.org/

Q&A Techie, Silicon Valley Mac User Group
http://svmug.org/

Member, Silicon Valley Google Technology User Group
http://sv-gtug.org/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Google Analytics Cookies invalidating Caching Middleware

2008-09-29 Thread Cortland Klein

I've enabled caching via UpdateCacheMiddleware and  
FetchFromCacheMiddleware, placed at the beginning and end of  
middleware, respectively.

When loading a URL, I'm getting a Vary: Accept-Encodinge.

Problem is, each page load Google Analytics keeps changing  
__utm(a,b,c,z) cookies, apparently invalidating cache.

I'm using SSL on Apache with FastCGI.

settings.py:
> CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
>
> ...
>
> MIDDLEWARE_CLASSES = (
> 'django.middleware.cache.UpdateCacheMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.middleware.doc.XViewMiddleware',
>   'django.middleware.locale.LocaleMiddleware',
>   'django.middleware.http.ConditionalGetMiddleware',
>   'django.middleware.gzip.GZipMiddleware',
> 'django.middleware.cache.FetchFromCacheMiddleware',
>   #'debug_toolbar.middleware.DebugToolbarMiddleware',
> )
>
> CACHE_MIDDLEWARE_SECONDS = 300 # 5 Minutes = 300
> CACHE_MIDDLEWARE_KEY_PREFIX = ""


Response Headers:
> Cache-Control: max-age=300
> Connection: Keep-Alive
> Content-Encoding: gzip
> Content-Language: en
> Content-Length: 2119
> Content-Type: text/html; charset=utf-8
> Date: Mon, 29 Sep 2008 23:27:53 GMT
> Etag: "936d0ad516a45ffed5a34baa32d10f66"
> Expires: Mon, 29 Sep 2008 23:32:53 GMT
> Keep-Alive: timeout=15, max=500
> Last-Modified: Mon, 29 Sep 2008 23:27:53 GMT
> Ms-Author-Via: DAV
> Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l PHP/5.2.6  
> mod_fastcgi/2.4.2
> Vary: Accept-Encoding,Accept-Language,Cookie


-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
Web Developer, Media and Technology
Apple Retail Training and Development
1 Infinite Loop, MS 49-SM
Cupertino, CA 95014
http://apple.com/retail/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



filter on doubly-spanned relationship failing

2008-10-13 Thread Cortland Klein

In one of my views, I've got an answers =  
Answer 
.objects 
.select_related 
(depth=2).filter(question__promotion__slug__exact=promotion) .

Answer has a ForeignKey to Question, which in turn has a ForeignKey to  
Promotion, which has a SlugField.

When I run this query from the shell and call response['answertest'] =  
answers[0].correct , I get a proper True/False.

However, when run from the view's request, I get the traceback below.

When changing the query to answers =  
Answer.objects.select_related(depth=2).all() I don't get this problem,  
however that defeats the purpose of filtering.

My current theory is that there's something wrong with filtering  
across doubly-spanned relationships, however it does work when run  
from the shell.

The reason I'm trying to do this is because currently I have some  
nested loops in my promotion view that cause tons of SQL queries on  
the inner loops between Questions and Answers. I'm going to use  
instead a {% regroup answers by question as questions %} in my  
template code; which works with the all() query so I know the regroup  
isn't the problem.

Traceback:
> Environment:
>
> Request Method: GET
> Request URL: http://localhost:8000/us/product/whatsnew/test/
> Django Version: 1.0-final-SVN-unknown
> Python Version: 2.5.1
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'retailu.learn',
>  'retailu.product',
>  'retailu.storytime',
>  'retailu.stattrack',
>  'retailu.index',
>  'retailu.whatevermap',
>  'retailu.plano',
>  'retailu.assettracker',
>  'django.contrib.admin',
>  'django.contrib.admindocs',
>  'django.contrib.databrowse',
>  'django.contrib.markup',
>  'mobileadmin',
>  'django_evolution',
>  'rosetta',
>  'debug_toolbar']
> Installed Middleware:
> ('django.middleware.cache.UpdateCacheMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.doc.XViewMiddleware',
>  'django.middleware.locale.LocaleMiddleware',
>  'django.middleware.http.ConditionalGetMiddleware',
>  'django.middleware.gzip.GZipMiddleware',
>  'django.middleware.cache.FetchFromCacheMiddleware')
>
>
> Traceback:
> File "/Library/Python/2.5/site-packages/django/core/handlers/ 
> base.py" in get_response
>   86. response = callback(request, *callback_args,  
> **callback_kwargs)
> File "/Library/WebServer/retailu/../retailu/product/views.py" in  
> promotion
>   45. response['answertest'] = answers[0].correct
> File "/Library/Python/2.5/site-packages/django/db/models/query.py"  
> in __getitem__
>   232. return list(qs)[0]
> File "/Library/Python/2.5/site-packages/django/db/models/query.py"  
> in __len__
>   156. self._result_cache.extend(list(self._iter))
> File "/Library/Python/2.5/site-packages/django/db/models/query.py"  
> in iterator
>   269. for row in self.query.results_iter():
> File "/Library/Python/2.5/site-packages/django/db/models/sql/ 
> query.py" in results_iter
>   206. for rows in self.execute_sql(MULTI):
> File "/Library/Python/2.5/site-packages/django/db/models/sql/ 
> query.py" in execute_sql
>   1700. cursor.execute(sql, params)
> File "/Library/Python/2.5/site-packages/django/db/backends/util.py"  
> in execute
>   19. return self.cursor.execute(sql, params)
> File "/Library/Python/2.5/site-packages/django/db/backends/sqlite3/ 
> base.py" in execute
>   167. return Database.Cursor.execute(self, query, params)
>
> Exception Type: InterfaceError at /us/product/whatsnew/test/
> Exception Value: Error binding parameter 0 - probably unsupported  
> type.
>


-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best practice to build a multilingual site

2008-10-13 Thread Cortland Klein

It depends on if a particular News is shared across languages, or if  
each language has its own news.

For me, one of my projects has translations of objects where each  
object should have all translations. Thus, I have something like a  
News and then NewsTranslations with ForeignKey back to News. Then I  
just do News.objects.filter(newstranslations__lang=lang) or whatever.

In admin I'd then have NewsAdmin inline a NewsTranslationsInline or  
something.

On Oct 13, 2008, at 8:48 AM, Alex Rades wrote:

> Hi,
> if we have a model like:
>
> class News(models.Model):
>title = models.CharField(..)
>content = models.TextField(...)
>
> Imagine i want to work with different language (this means adding
> multilingual content via admin and retrieving it from views/templates)
> What is the best way to develop this kind of multi language support?
> (Of course I dont want to add title_en title_es... )
>
> Thank  you

-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: filter on doubly-spanned relationship failing

2008-10-13 Thread Cortland Klein

Never mind; I was clashing variables. Thanks, #django IRC!


On Oct 13, 12:05 pm, Cortland Klein <[EMAIL PROTECTED]> wrote:
> In one of my views, I've got an answers =  
> Answer
> .objects
> .select_related
> (depth=2).filter(question__promotion__slug__exact=promotion) .
>
> Answer has a ForeignKey to Question, which in turn has a ForeignKey to  
> Promotion, which has a SlugField.
>
> When I run this query from the shell and call response['answertest'] =  
> answers[0].correct , I get a proper True/False.
>
> However, when run from the view's request, I get the traceback below.
>
> When changing the query to answers =  
> Answer.objects.select_related(depth=2).all() I don't get this problem,  
> however that defeats the purpose of filtering.
>
> My current theory is that there's something wrong with filtering  
> across doubly-spanned relationships, however it does work when run  
> from the shell.
>
> The reason I'm trying to do this is because currently I have some  
> nested loops in my promotion view that cause tons of SQL queries on  
> the inner loops between Questions and Answers. I'm going to use  
> instead a {% regroup answers by question as questions %} in my  
> template code; which works with the all() query so I know the regroup  
> isn't the problem.
>
>
> --
> Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791http://pixelcort.com/
> 2260 California Street #13
> Mountain View, CA, USA 94040
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 inlineformset_factory has something for fields, but I'm not  
sure what to pass to it to override a field's widget:

# django/forms/models.py
> def inlineformset_factory(parent_model, model, form=ModelForm,
>   formset=BaseInlineFormSet, fk_name=None,
>   fields=None, exclude=None,
>   extra=3, can_order=False, can_delete=True,  
> max_num=0,
>   formfield_callback=lambda f: f.formfield()):

 From my app:

# models.py
> class Version(models.Model):
>   number = models.FloatField(_("Number"))
>
> class File(models.Model):
>   file   = models.FileField(_("File"), upload_to="materials/file/ 
> %Y/%m/%d") # I want to eventually make this an AdminFileWidget
>   version = models.ForeignKey(Version)

# forms.py
> from models import Version, File
> from django.forms.models import inlineformset_factory
> from django.contrib.admin.widgets import AdminFileWidget # Not sure  
> how to get this into FileFormSet
>
> FileFormSet = inlineformset_factory(Version, File, extra=1)

# views.py
> from forms import FileFormSet
> from django.shortcuts import render_to_response
> from django.template import RequestContext
>
> def version(request, curriculum, version):
>   response = {}
>   if request.method == 'POST':
>   response['fileformset']= FileFormSet(request.POST,  
> request.FILES, prefix="file", instance=response['version'])
>   if response['fileformset'].is_valid():
>   response['fileformset'].save()
>   else:
>   response['fileformset']= FileFormSet(prefix="file",  
> instance=response['version'])
>   return render_to_response('redacted/version.html', response,  
> RequestContext(request))

Any ideas?

-- 
Cortland Klein  +1 408 506 9791
Web Developer, Media and Technology
Apple Retail Training and Development
1 Infinite Loop, MS 49-SM
Cupertino, CA 95014
http://apple.com/retail/


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



Re: 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 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()
>
> FileFormSet = inlineformset_factory(Version, File, extra=1,
> formfield_callback = my_formfield_cb)
> formSet = FileFormSet()
>
> Marco
>
> On Dec 18, 8: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 view and has nothing to do with contrib/admin.
>>
>> I see that inlineformset_factory has something for fields, but I'm not
>> sure what to pass to it to override a field's widget:
>>
>> # django/forms/models.py
>>
>> > def inlineformset_factory(parent_model, model, form=ModelForm,
>> >   formset=BaseInlineFormSet, fk_name=None,
>> >   fields=None, exclude=None,
>> >   extra=3, can_order=False, can_delete=True,
>> > max_num=0,
>> >   formfield_callback=lambda f: f.formfield()):
>>
>>  From my app:
>>
>> # models.py
>>
>> > class Version(models.Model):
>> >number = models.FloatField(_("Number"))
>>
>> > class File(models.Model):
>> >file   = models.FileField(_("File"), upload_to="materials/file/
>> > %Y/%m/%d") # I want to eventually make this an AdminFileWidget
>> >version = models.ForeignKey(Version)
>>
>> # forms.py
>>
>> > from models import Version, File
>> > from django.forms.models import inlineformset_factory
>> > from django.contrib.admin.widgets import AdminFileWidget # Not sure
>> > how to get this into FileFormSet
>>
>> > FileFormSet = inlineformset_factory(Version, File, extra=1)
>>
>> # views.py
>>
>>
>>
>> > from forms import FileFormSet
>> > from django.shortcuts import render_to_response
>> > from django.template import RequestContext
>>
>> > def version(request, curriculum, version):
>> >response = {}
>> >if request.method == 'POST':
>> >response['fileformset']= FileFormSet(request.POST,
>> > request.FILES, prefix="file", instance=response['version'])
>> >    if response['fileformset'].is_valid():
>> >response['fileformset'].save()
>> >else:
>> >response['fileformset']= FileFormSet(prefix="file",
>> > instance=response['version'])
>> >return render_to_response('redacted/version.html', response,
>> > RequestContext(request))
>>
>> Any ideas?
>>
>> --
>> Cortland Klein  +1 408 506 9791
>> Web Developer, Media and Technology
>> Apple Retail Training and Development
>> 1 Infinite Loop, MS 49-SM
>> Cupertino, CA 95014http://apple.com/retail/
> >
>



-- 
-- 
Cortland Klein  +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040

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



Extending Group for a GroupProfile

2009-01-08 Thread Cortland Klein

Hi. I'm planning on extending Group for a GroupProfile. I noticed that  
the recommended way to extend User is to create a UserProfile with a  
ForeignKey(User, unique=True) instead of a OneToOneField[a].

1. Why is it recommended to use a ForeignKey(unique=True) from a  
UserProfile to User instead of a OneToOneField or subclassing User for  
multi-table inheritance?
2. As I'm planning on extending Group with GroupProfile, should I use  
a ForeignKey(Group, unique=True), a OneToOneField(Group), or have  
GroupProfile subclass Group to use Multi-table interitence? Does it  
even matter since Group currently has no get_profile() function anyways?



a: http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/

-- 
Cortland Klein 
Work: +1 408 862 3775
Mobile: +1 408 506 9791
Web Developer, Media and Technology
Retail Training & Development
MS 49-SM
https://retailu.apple.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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ValidationError in a ModelForm with a DateTimeField in the Model

2009-01-12 Thread Cortland Klein

Hi. I'm getting the following ValidationError in a ModelForm that's  
returning True for the form's is_valid() function but is throwing this  
ValidationError when the form's save() function is being called.  
Running save(commit=False).save() has no effect.

This view is used to both create new Versions and edit existing  
Versions. The ValidationError only happens when  
response['versionform'] represents a Version that's not yet in the  
database. Editing an existing Version works fine.

I created a second test case with just a DateTimeField and that's  
working, so it's probably something in my code.

Trackback: http://dpaste.com/108336/

views.py: http://dpaste.com/108337/
Lines: 105, 110
In Line 105, is_valid() returns True. In Line 110, I get the  
ValidationError.

models.py: http://dpaste.com/108340/
Line: 33
Here is where the DateTimeField is being defined.

forms.py: http://dpaste.com/108341/
Lines: 10-13
Here is the form for Version.

urls.py: http://dpaste.com/108343/
Lines: 5, 7
Here are the patterns which cause the failure.

Any thoughts?

-- 
Cortland Klein  +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040




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



Re: ValidationError in a ModelForm with a DateTimeField in the Model

2009-01-12 Thread Cortland Klein
Update: It looks like it's a DateTimeField (lastsenttotranslation) that's
not included in the form, hence the form is_valid() but the actual save()
fails. But I'm still confused why...

In models.py, its defined as:

> lastsenttotranslation = models.DateTimeField(_("Last sent to Translation"),
> blank=True, default="")
>

Do I need to set this to null=True instead?

-- 
Cortland Klein  +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040

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



Re: ValidationError in a ModelForm with a DateTimeField in the Model

2009-01-13 Thread Cortland Klein

Got it.

Should be models.DateTimeField(blank=True, null=True, default=None)

I shouldn't use default = "" on a DateTimeField.

On Jan 12, 9:29 pm, "Cortland Klein"  wrote:
> Update: It looks like it's a DateTimeField (lastsenttotranslation) that's
> not included in the form, hence the form is_valid() but the actual save()
> fails. But I'm still confused why...
>
> In models.py, its defined as:
>
> > lastsenttotranslation = models.DateTimeField(_("Last sent to Translation"),
> > blank=True, default="")
>
> Do I need to set this to null=True instead?

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



Re: import of mysql in settings.py

2008-08-21 Thread Cortland Klein

I just had the same problem. It has something to do with MySQLdb not  
being included.

For me, I think it's because Mac OS X 10.5.4 doesn't have this python  
thing installed. The documentation and tutorial should mention this,  
IMO.

http://code.djangoproject.com/ticket/5531#comment:12

On Aug 21, 2008, at 2:52 PM, mpls wrote:

> I've edited the DATABASE_ENGINE = 'mysql' in settings.py along with
> specifying a database name and user account info. But I get the
> following error:
>
> ImportError: No module named mysql.base
>
> How can I fix this problem. Any help is appreciated.

-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
529 Water Witch Way
San Jose, CA, USA

Alumni, Business Management <[EMAIL PROTECTED]>
San José State University

Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED] 
 >
http://e-society.org/

Q&A Techie, Silicon Valley Mac User Group
http://svmug.org/







--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Random ordering in Templates

2008-09-03 Thread Cortland Klein

I've got the following in my template:
> {% for question in event.question_set.order_by('?') %}

And am getting the error "Could not parse the remainder: '('?')'".

I'm trying to randomly iterate through these objects.

Should I implement a custom filter, or is there an easier way to  
accomplish this?

-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040

Alumni, Business Management <[EMAIL PROTECTED]>
San José State University

Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED] 
 >
http://e-society.org/

Q&A Techie, Silicon Valley Mac User Group
http://svmug.org/

Member, Silicon Valley Google Technology User Group
http://sv-gtug.org/





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Random ordering in Templates

2008-09-03 Thread Cortland Klein

Can I do that with a Generic View?

I'm using date_based.archive_index on an Event model which has many  
Questions.

On Sep 3, 2008, at 11:40 AM, Karen Tracey wrote:

> Why not just create the randomized list in the view and pass the  
> already-randomized list into the template?

-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040

Alumni, Business Management <[EMAIL PROTECTED]>
San José State University

Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED] 
 >
http://e-society.org/

Q&A Techie, Silicon Valley Mac User Group
http://svmug.org/

Member, Silicon Valley Google Technology User Group
http://sv-gtug.org/





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Random ordering in Templates

2008-09-03 Thread Cortland Klein

Yes, but I don't want to randomize he Events, but the Questions that  
belong to the events.

On Sep 3, 2008, at 12:07 PM, Ludwig wrote:

> There is nothing to stop you putting the order_by clause into a  
> generic view, like so:
>
> event_info = {
> 'queryset' : Events.objects.order_by('?'),
> }
>

-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040

Alumni, Business Management <[EMAIL PROTECTED]>
San José State University

Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED] 
 >
http://e-society.org/

Q&A Techie, Silicon Valley Mac User Group
http://svmug.org/

Member, Silicon Valley Google Technology User Group
http://sv-gtug.org/





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Random ordering in Templates

2008-09-03 Thread Cortland Klein
That looks like that should work!

Thank you; I'll try this out when I get back from lunch.

Sent from my iPhone

On Sep 3, 2008, at 12:23 PM, Ludwig <[EMAIL PROTECTED]> wrote:

> Am I right that you have a one-to-many relationship between events  
> and questions, with questions having a foreign key to events?
> Then you could add a method to your Event model class that returns  
> you a random list of questions:
>
> class Event (model.Models):
> ...
> def questions(self):
> questions = self.question_set.all().order_by('?')
> return questions
> 
>
> You can then call the questions method inside your template when you  
> have an event:
>
> {% for question in event.questions %}
> question
> {% endfor %}
>
> Ludwig
>
>
> 2008/9/3 Cortland Klein <[EMAIL PROTECTED]>
>
> Yes, but I don't want to randomize he Events, but the Questions that
> belong to the events.
>
> On Sep 3, 2008, at 12:07 PM, Ludwig wrote:
>
> > There is nothing to stop you putting the order_by clause into a
> > generic view, like so:
> >
> > event_info = {
> > 'queryset' : Events.objects.order_by('?'),
> > }
> >
>
> --
> Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
> http://pixelcort.com/
> 2260 California Street #13
> Mountain View, CA, USA 94040
>
> Alumni, Business Management <[EMAIL PROTECTED]>
> San José State University
>
> Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED]
>  >
> http://e-society.org/
>
> Q&A Techie, Silicon Valley Mac User Group
> http://svmug.org/
>
> Member, Silicon Valley Google Technology User Group
> http://sv-gtug.org/
>
>
>
>
>
>
>
>
> >

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



View not passing MEDIA_URL to Template

2008-09-04 Thread Cortland Klein

I have two templates, one called via a Generic View and one via my own  
View. They both extend a base.html view that has {{MEDIA_URL}} in it.

When the generic view is hit, the base.html template gets it's value, 
http://rtdev.apple.com/media/ 
  , but when my own View hits MEDIA_URL blanks.

I tried to get MEDIA_URL in my views.py to pass it in to my  
render_to_response but it seems from there that global isn't defined.

views.py:
> from django.shortcuts import render_to_response, get_object_or_404
>
> from models import Event
>
> def results(request):
>   event = get_object_or_404(Event, pk=request.REQUEST['event'])
>   response = {}
>   response['correct_answers'] = 0
>   response['total_questions'] = 0
>   response['passed'] = 0
>   response['name'] = request.REQUEST['name']
>   
>   # ...
>
>   return render_to_response('whatsnew/results.html', response)


-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
http://pixelcort.com/
2260 California Street #13
Mountain View, CA, USA 94040

Alumni, Business Management <[EMAIL PROTECTED]>
San José State University

Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED] 
 >
http://e-society.org/

Q&A Techie, Silicon Valley Mac User Group
http://svmug.org/

Member, Silicon Valley Google Technology User Group
http://sv-gtug.org/
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Nokia Guys

2008-09-08 Thread Cortland Klein

At DjangoCon, I met two guys from Nokia, but did not get their cards.

If you're out there, let me know; I'd like to get in touch with you.

Thanks!

-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
Web Developer, Retail Training
Apple Inc.
10101 Bubb Rd.
Cupertino, CA 95014
http://apple.com/retail/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Nesting inlines with django-admin

2008-09-10 Thread Cortland Klein

I'm having the same need for nested inlines.

I have Events with many Questions, which have many Answers.

I'd like to show inline the answers in the inline of the questions.

Also as an aside has anyone done any AJAX work with inlines; getting a  
dynamic '+' to add extra rows could be very useful.

On Aug 31, 2008, at 9:25 AM, Bojan Mihelac wrote:

> Is it possible to nest inlines with django-admin? Using this type of
> models for example:
>
> Poll
> PollTranslation (this is inline)
> PollAnswer (this is inline)
> PollAnswerTranslation (this should be inline of PollAnswer)
>
> PollAnswerTranslation objects should be editable on same page.
>
> Any hint or solution would be helpful.


-- 
Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791
Web Developer, Retail Training
Apple Inc.
10101 Bubb Rd.
Cupertino, CA 95014
http://apple.com/retail/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---