Re: Template html works when double clicked but empty when accessed through server

2011-08-16 Thread Adam Zedan
So what do u suggest ?? will that also solve the firefox security
issue.
currenty i am just using the following html code





Demo







On Aug 16, 11:58 am, Adam Zedan  wrote:
> Thanks.. that what i just came across.
> It seems firefox doesnt let u load static 
> fileshttp://rubenlaguna.com/wp/2007/04/20/firefox-and-file-windows-unc-paths/
>
> On Tue, Aug 16, 2011 at 11:43 AM, Jani Tiainen  wrote:
> > Hi,
>
> > You can't (and you shouldn't) use file urls in your original source but
> > should let the Django handle urls to them for you.
>
> > There is dedicated part about static file serving in documentation [1][2].
>
> > And if you really think that you're deploying your project to somewhere you
> > really expect everyone to have same directory structure on their machines as
> > you do? And even more, you think people really would appreciate browser to
> > load arbitrary files from a filesystem? :)
>
> > [1]https://docs.djangoproject.**com/en/1.3/howto/static-files/
> > [2]https://docs.djangoproject.**com/en/1.3/ref/contrib/**staticfiles/
>
> > --
>
> > Jani Tiainen
>
> > On 08/16/2011 09:23 AM, Adam Zedan wrote:
>
> >> okay going to error ansole of firefox here is what i got
>
> >> Error: Slick is not defined
> >> Source File:http://127.0.0.1:8000/db/
> >> Line: 37
>
> >> which is : grid = new Slick.Grid("#myGrid", data, columns, options);
>
> >> and the warnings are
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/slick.grid.js.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/slick.core.js.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/lib/jquery.**
> >> event.drag-2.0.min.js.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/lib/jquery-1.4.**
> >> 3.min.js.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/slick.grid.js.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/slick.core.js.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/lib/jquery.**
> >> event.drag-2.0.min.js.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/lib/jquery-1.4.**
> >> 3.min.js.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/examples/**
> >> examples.css.
> >> Security Error: Content athttp://127.0.0.1:8000/db/may not load or
> >> link to file:///D:/Django-1.3/django/**bin/SlickGrid/css/smoothness/**
> >> jquery-ui-1.8.5.custom.css.
>
> >> I think it cant link to those files when rendered or something... not
> >> sure though ?? what do u guys think??
>
> >> On Aug 16, 11:01 am, Landy 
> >> Chapman>
> >>  wrote:
>
> >>>  From what I can tell it's not your fault. have a look at:
> >>>  http://code.google.com/p/**slickgrid/issues/detail?id=19
>
> >>> fix might be here
> >>>    
> >>> http://drupal.org/node/**1094054#comment-4825024
>
> > --
> > 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+unsubscribe@**
> > 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-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: Weird hyperlink issue with Office and Django authentication

2011-08-16 Thread Michel30
Addidtionally I found this kb article that I believe describes what is
going on:
http://support.microsoft.com/kb/899927/en-us


On Aug 16, 8:59 am, Michel30  wrote:
> I have made a CMS-like application to store and retrieve documents
> using Django 1.3, mysql and Apache.
>
> One requirement was that only authenticated users could use it and
> that after closing the browser the session should be expired.
> So, I implemented an LDAP authentication backend, set the
> "SESSION_EXPIRE_AT_BROWSER_CLOSE" to True and added an @login_required
> decorator to functions that need it.
> And it is working great, just like it should.
>
> Until using one feature that involves clicking on a hyperlink that is
> supposed to open a document within the application in a browser.
> This again works perfectly with every browser (firefix, chrome, IE) in
> several flavors of versions.
> With working I mean the document view opens, and this is important, as
> long as the user was already logged in to the application he/she
> doesn't have to log in again.
>
> It is working until trying this from any office (2000/2003)
> application. Then suddenly logging in is required every time
> regardless if an session exists or not.
> I did some investigating and found that clicking a hyperlink in an
> Office application triggers three requests, and it looks like the
> first one is missing the session cookie.
> Apache log for a hyperlink in Open office:
>
>     172.16.3.51 - - [15/Aug/2011:11:27:29 +0200] "GET /cgi-bin/DocDB/
> ShowDocument?docid=20916&version=8 HTTP/1.1" 200 3603 "-" "Mozilla/5.0
> (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
>
> and the same document from Word:
>
>     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /cgi-bin/DocDB/
> ShowDocument?docid=20916&version=8 HTTP/1.1" 302 496 "-" "Mozilla/4.0
> (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR
> 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> 3.5.30729; .NET4.0C; .NET4.0E)"
>
>     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /login/?next=/
> cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> 3269 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/
> 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> 3.5.30729; .NET4.0C; .NET4.0E)"
>
>     172.16.3.51 - - [15/Aug/2011:11:26:10 +0200] "GET /login/?next=/
> cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> 3278 "-" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/
> 5.0"
>
> Note the different status '200 = OK'  for OO and '302 Found' for Word.
> Also the length of the first returned object differ: 496 vs 3603.
>
> I am not sure where to point the finger to, or how to proceed and
> resolve it... So I'd appreciate some help a lot.
> Thanks,
> Michel

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



model save question

2011-08-16 Thread Mike Dewhirst

When using save() in a model, what is the difference between ...

save(self, force_insert=False, force_update=False) or
save(self, force_insert=False, force_update=False, **kwargs)
# whatever
super(Xyz, self).save(force_insert, force_update) or
super(Xyz, self).save(force_insert, force_update, **kwargs)

and

save(self, *arg, **kwargs)
# whatever
super(Xyz, self).save(*args, **kwargs)

I see the former in a fair bit of django example code around the place 
and the latter in the docs here


https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods

Thanks for any insights

Mike

--
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: Template html works when double clicked but empty when accessed through server

2011-08-16 Thread Landy Chapman
 Jani Tiainen  is right
> > You can't (and you shouldn't) use file urls in your original source but
> > should let the Django handle urls to them for you.

..or hard-code relative links in your templates.
I was thinking about the file:/// un your urls; not the best idea but
they are absolute and will work on your local machine.

We know your template is rendering because
> Yes the title changes but my table does not appear. It only appear if i
> double click it ... :(

Were you using firefox before?  If yes, that security error should
have nothing to do with it.  My reasoning is
some, if not all of your file:/// urls are being used by FF -- since
the double-click event is being handled, and then the table appears.


-- 
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: Weird hyperlink issue with Office and Django authentication

2011-08-16 Thread Michel30
Hmm the workaround MS suggests actually works, so I have a
workaround :-)

But understanding why Django's authentication backend doesn't support
this would be good

On Aug 16, 9:10 am, Michel30  wrote:
> Addidtionally I found this kb article that I believe describes what is
> going on:http://support.microsoft.com/kb/899927/en-us
>
> On Aug 16, 8:59 am, Michel30  wrote:
>
>
>
>
>
>
>
> > I have made a CMS-like application to store and retrieve documents
> > using Django 1.3, mysql and Apache.
>
> > One requirement was that only authenticated users could use it and
> > that after closing the browser the session should be expired.
> > So, I implemented an LDAP authentication backend, set the
> > "SESSION_EXPIRE_AT_BROWSER_CLOSE" to True and added an @login_required
> > decorator to functions that need it.
> > And it is working great, just like it should.
>
> > Until using one feature that involves clicking on a hyperlink that is
> > supposed to open a document within the application in a browser.
> > This again works perfectly with every browser (firefix, chrome, IE) in
> > several flavors of versions.
> > With working I mean the document view opens, and this is important, as
> > long as the user was already logged in to the application he/she
> > doesn't have to log in again.
>
> > It is working until trying this from any office (2000/2003)
> > application. Then suddenly logging in is required every time
> > regardless if an session exists or not.
> > I did some investigating and found that clicking a hyperlink in an
> > Office application triggers three requests, and it looks like the
> > first one is missing the session cookie.
> > Apache log for a hyperlink in Open office:
>
> >     172.16.3.51 - - [15/Aug/2011:11:27:29 +0200] "GET /cgi-bin/DocDB/
> > ShowDocument?docid=20916&version=8 HTTP/1.1" 200 3603 "-" "Mozilla/5.0
> > (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
>
> > and the same document from Word:
>
> >     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /cgi-bin/DocDB/
> > ShowDocument?docid=20916&version=8 HTTP/1.1" 302 496 "-" "Mozilla/4.0
> > (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR
> > 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> > 3.5.30729; .NET4.0C; .NET4.0E)"
>
> >     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /login/?next=/
> > cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> > 3269 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/
> > 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> > 3.5.30729; .NET4.0C; .NET4.0E)"
>
> >     172.16.3.51 - - [15/Aug/2011:11:26:10 +0200] "GET /login/?next=/
> > cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> > 3278 "-" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/
> > 5.0"
>
> > Note the different status '200 = OK'  for OO and '302 Found' for Word.
> > Also the length of the first returned object differ: 496 vs 3603.
>
> > I am not sure where to point the finger to, or how to proceed and
> > resolve it... So I'd appreciate some help a lot.
> > Thanks,
> > Michel

-- 
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: model save question

2011-08-16 Thread Daniel Roseman
On Tuesday, 16 August 2011 08:21:24 UTC+1, Mike Dewhirst wrote:
>
> When using save() in a model, what is the difference between ...
>
> save(self, force_insert=False, force_update=False) or
> save(self, force_insert=False, force_update=False, **kwargs)
>  # whatever
>  super(Xyz, self).save(force_insert, force_update) or
>  super(Xyz, self).save(force_insert, force_update, **kwargs)
>
> and
>
> save(self, *arg, **kwargs)
>  # whatever
>  super(Xyz, self).save(*args, **kwargs)
>
> I see the former in a fair bit of django example code around the place 
> and the latter in the docs here
>
>
> https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods
>
> Thanks for any insights
>
> Mike
>

There's no practical difference right now. The main reason for the (*args, 
**kwargs) format is for forwards compatibility: if Django introduces a new 
argument to `save` in future versions, your code might stop working if 
you've hard-coded the function to only pass two parameters.
--
DR.

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



Re: model save question

2011-08-16 Thread Mike Dewhirst

Thanks DR

Mike

On 16/08/2011 6:10pm, Daniel Roseman wrote:

On Tuesday, 16 August 2011 08:21:24 UTC+1, Mike Dewhirst wrote:

When using save() in a model, what is the difference between ...

save(self, force_insert=False, force_update=False) or
save(self, force_insert=False, force_update=False, **kwargs)
 # whatever
 super(Xyz, self).save(force_insert, force_update) or
 super(Xyz, self).save(force_insert, force_update, **kwargs)

and

save(self, *arg, **kwargs)
 # whatever
 super(Xyz, self).save(*args, **kwargs)

I see the former in a fair bit of django example code around the
place
and the latter in the docs here


https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods



Thanks for any insights

Mike


There's no practical difference right now. The main reason for the 
(*args, **kwargs) format is for forwards compatibility: if Django 
introduces a new argument to `save` in future versions, your code 
might stop working if you've hard-coded the function to only pass two 
parameters.

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

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


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



[ANN]: FeinCMS v1.4.1 final

2011-08-16 Thread Matthias Kestenholz
Hello everyone

I failed big time when creating the v1.4.0 release and created the
package from the wrong version...

Anyway, we're back on track now. v1.4.1 is available at the usual
places with the contents v1.4.0 should have had.

I'm sorry for any problems caused by this blunder.


Best regards
Matthias

-- 
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: Using {% url somenamedview %} in a custom page extending admin templates

2011-08-16 Thread Tom Evans
On Mon, Aug 15, 2011 at 8:37 PM, Thomas Weholt  wrote:
> My urls.py for my app:
>
> urlpatterns = patterns('',
>    url(r'^geocoding/$', geocoding, name='geocoding'),
> )
>
> I've extended the change_list.html template based on the standard
> change_list.html and added this piece :
>
> {% block content %}
>  
>    {% block object-tools %}
>      {% if has_add_permission %}
>        
>            
>              From geocoding
>            
>
> where {% url geocoding %} is the problem. When rendered it says:
>
> TemplateSyntaxError at /admin/locationbase/location/
> Caught NoReverseMatch while rendering: Reverse for '' with arguments
> '()' and keyword arguments '{}' not found.
>
> So the question is; how can I use the url template tag in templates
> extending the standard admin templates and refer to a view defined in
> my app by name?
>
> What am I now seeing here?
>

So, you don't state your django version.

I think either your template, or perhaps some combination of your
template and the admin templates, is loading the future version of the
url tag. The future version does not interpret a constant as the view
name, but as a context variable which it then resolves. I guess
'geocoding' doesn't correspond to a context variable, and hence the
error message.

Does it work if you quote the view name? Eg:

{% url "geocoding" %}

Cheers

Tom

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



Re: Convert dictionaries to django model (recursively)

2011-08-16 Thread Masklinn
On 2011-08-15, at 18:11 , Jacco77 wrote:
> 
> How can I get django to understand that I want it to convert my
> dictionary recursively? Then I want to full save it (the whole blob)
> recursively, that is fields that are pointing to other models should
> be saved first.
The only piece of Django I can think of which would do that sort of
things is the serialization framework.

While it does not (as far as I know) expose any interface to
serializing objects as Python dicts and arrays, it does support
serializing to JSON (although the structure is a bit more complex
than what you show here as it stores the instance's model at a
higher level of the structure than the raw field values), it should
be a good start towards vivifying simple dicts into complete object
structures.

Therefore, I would recommend looking into serializers and how they're
coded, and maybe just rework your dict structure a bit and add a new
serializer to/from python dicts (I'm not sure how pluggable django's
serializers are, but considering there's a SERIALIZATION_MODULES[0]
settings key I'm guessing you can add pretty much anything you want,
and some googling leads me to think it's even possible to replace
the built-in serializers[1]).

See also: 
http://readthedocs.org/docs/django-testing-docs/en/latest/serialization.html

[0] https://docs.djangoproject.com/en/dev/ref/settings/#serialization-modules
[1] http://pypi.python.org/pypi/wadofstuff-django-serializers

-- 
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: showing an attribute of a foreign key in admin

2011-08-16 Thread i...@webbricks.co.uk
thanks tracy, i'd tried something very similar to Daniels method and
failed, but your code worked first time.

On Aug 15, 12:36 pm, Karen Tracey  wrote:
> On Mon, Aug 15, 2011 at 4:51 AM, i...@webbricks.co.uk
> wrote:
>
>
>
>
>
>
>
>
>
>
>
> > I want to display the Level of the Category that the product belongs
> > to, in the admin page for the Product. snipped a lot of the
> > unimportant fields out of the display below.
>
> > class Category(models.Model):
> >    name = models.CharField(max_length=50, default=False)
> >    level = models.IntegerField(help_text="1, 2 ,3 or 4")
>
> > class Product(models.Model):
> >    category = models.ForeignKey(Category)
> >    name = models.CharField(max_length=100)
>
> >    prepopulated_fields = {'slug': ('name',)}
> >    fieldsets = [
> >        ('Product Info',{'fields': ['name',
> > 'slug','partno','description']}),
> >        ('Categorisation',{'fields': ['brand','category']}),
>
> > You can do this so long as you only want to display the level, and not
>
> change it from the Product edit page. Admin was not designed to allowed
> editing of related-model attributes so you cannot do that. But with readonly
> fields you can easily display information:
>
> 1 - Define a method on Product that returns the information you want, eg:
>
>     def category_level(self):
>         try:
>             return u'%s' % self.category.level
>         except Category.DoesNotExist:
>             return u'No Category'
>
> (You need to allow for Category not existing since it will not exist on an
> add page.)
>
> 2 - Include that method in readonly_fields and wherever you want it in your
> fieldsets, eg:
>
> class ProductAdmin(admin.ModelAdmin):
>    readonly_fields = ['category_level']
>    fieldsets = [
>        ('Product Info',{'fields': ['name', etc etc etc ]}),
>        ('Categorisation',{'fields': ['category', 'category_level']}),
>     ]
>
> Karen
> --http://tracey.org/kmt/

-- 
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: Use object (User and custom object) in a form

2011-08-16 Thread nicolas HERSOG
Oh I see,

I've just modified my code with new import but i still have problem to
submit my form. I don t have any errors but i can't pass the
form.is_valid().
It's my first form so i don t know how to do it. Can you (again) help me ?

Here it's my forms.py :

from django import forms
from django.contrib.auth.models import User
from myApp.models import Article

class CommentForms (forms.Form):
cf_comment = forms.CharField()
cf_writer = User()
cf_date = forms.DateField()
cf_video = Article()

my template :
(...)
 {% csrf_token %}






(...)

and my view.py :

def article(request, id):
article = Article.objects.get(id=id)
commentaires = Commentaire.objects.filter(video=video.id
).order_by("-dateComment")
#dateTime
date = datetime.datetime.now()

c = Context({
'article' : article,
'commentaires' : commentaires,
'now' : date,
})
 # preparation du formulaire de commentaire
if request.method == 'POST':
form = CommentForms(request.POST)
if form.is_valid(): #validation
cf_comment = form.cleaned_data['commentaire']
cf_date = form.cleaned_date['time']
cf_writer = form.cleaned_data['user']
cf_article = form.cleaned_date['article']
print 'IF'
else :
form = CommentForms()
print 'ELSE'


return render_to_response('myApp/article.html', c,
context_instance=RequestContext(request))


When i submit my form i can see via the python console that i m only in the
ELSE of the form.is_valid, and when i inspect via firebug what i submit in
my form i have :
commentaire test commentaire a2
csrfmiddlewaretoken c25f76451eba14ebb762bb4ed4795274
time 16
user username
vod Final

any idea ?
Great thx for your help :)

On Sat, Aug 13, 2011 at 5:53 AM, Landy Chapman wrote:

> copy/paste typo, sorry.  It should have read/been:
>
> def formView(request, which_form=None):
>if request.method == 'POST':
>if not [1, 2].__contains__(which_form):
>pass #  <--- iNone or nvalid form specified
>else:
> if which_form==1:
>  form = form1(request.POST)
>   redirect_url='/thanksForm1/'#was typo
>  if which_form==2:
>  form = form2(request.POST)
>  redirect_url='/thanksForm2/'
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Template html works when double clicked but empty when accessed through server

2011-08-16 Thread Konstantin Sushenko
you do not see anything because the style on your root element is set
to "display:none" and the browser does not run scripts because they
are loaded from local URLs. as it says: it is a insecure to execute
scripts from local URLs. suppose you publish this page on your
production server, where would your visitors get there scripts? they
are not on their machines in "d:/django-1.3...". basically, it is
unclear to me what you are trying to achieve.

konstantin

-- 
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: Use object (User and custom object) in a form

2011-08-16 Thread Tom Evans
On Tue, Aug 16, 2011 at 12:39 PM, nicolas HERSOG  wrote:
> Oh I see,
> I've just modified my code with new import but i still have problem to
> submit my form. I don t have any errors but i can't pass the
> form.is_valid().
> It's my first form so i don t know how to do it. Can you (again) help me ?
> Here it's my forms.py :
> from django import forms
> from django.contrib.auth.models import User
> from myApp.models import Article
> class CommentForms (forms.Form):
>     cf_comment = forms.CharField()
>     cf_writer = User()
>     cf_date = forms.DateField()
>     cf_video = Article()

OK

> my template :
> (...)
>  {% csrf_token %}
> 
> 
> 
> 
> 
> 

You aren't rendering your Form, you are manually outputting a form.
For one thing, this means you won't see the validation messages from
your form.

> (...)
> and my view.py :
> def article(request, id):
> article = Article.objects.get(id=id)
> commentaires =
> Commentaire.objects.filter(video=video.id).order_by("-dateComment")
> #dateTime
> date = datetime.datetime.now()
> c = Context({
> 'article' : article,
> 'commentaires' : commentaires,
> 'now' : date,
> })
> # preparation du formulaire de commentaire
> if request.method == 'POST':
> form = CommentForms(request.POST)
> if form.is_valid(): #validation
> cf_comment = form.cleaned_data['commentaire']
> cf_date = form.cleaned_date['time']
> cf_writer = form.cleaned_data['user']
> cf_article = form.cleaned_date['article']
> print 'IF'
> else :
> form = CommentForms()
> print 'ELSE'
>
> return render_to_response('myApp/article.html', c,
> context_instance=RequestContext(request))
>

If request.method != 'POST' then you don't create the Form object
(which might explain why you were rendering by hand).

> When i submit my form i can see via the python console that i m only in the
> ELSE of the form.is_valid, and when i inspect via firebug what i submit in
> my form i have :
> commentaire test commentaire a2
> csrfmiddlewaretoken c25f76451eba14ebb762bb4ed4795274
> time 16
> user username
> vod Final
> any idea ?
> Great thx for your help :)

Find out why the form validation fails and fix it.

Look at the how the manual describes how to create a form, use it in a
view, and render it in a template. Compare and contrast this with your
view, and how you handle and render your form.

https://docs.djangoproject.com/en/1.3/topics/forms/#using-a-form-in-a-view
https://docs.djangoproject.com/en/1.3/topics/forms/#displaying-a-form-using-a-template

Cheers

Tom

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



Re: Weird hyperlink issue with Office and Django authentication

2011-08-16 Thread Konstantin Sushenko
as the article says, their sessions are independent of these used by
the web server. the cookies are not shared between office sessions and
web sessions. I think django has nothing to do with it.

On Aug 16, 4:04 am, Michel30  wrote:
> Hmm the workaround MS suggests actually works, so I have a
> workaround :-)
>
> But understanding why Django's authentication backend doesn't support
> this would be good
>
> On Aug 16, 9:10 am, Michel30  wrote:
>
>
>
>
>
>
>
> > Addidtionally I found this kb article that I believe describes what is
> > going on:http://support.microsoft.com/kb/899927/en-us
>
> > On Aug 16, 8:59 am, Michel30  wrote:
>
> > > I have made a CMS-like application to store and retrieve documents
> > > using Django 1.3, mysql and Apache.
>
> > > One requirement was that only authenticated users could use it and
> > > that after closing the browser the session should be expired.
> > > So, I implemented an LDAP authentication backend, set the
> > > "SESSION_EXPIRE_AT_BROWSER_CLOSE" to True and added an @login_required
> > > decorator to functions that need it.
> > > And it is working great, just like it should.
>
> > > Until using one feature that involves clicking on a hyperlink that is
> > > supposed to open a document within the application in a browser.
> > > This again works perfectly with every browser (firefix, chrome, IE) in
> > > several flavors of versions.
> > > With working I mean the document view opens, and this is important, as
> > > long as the user was already logged in to the application he/she
> > > doesn't have to log in again.
>
> > > It is working until trying this from any office (2000/2003)
> > > application. Then suddenly logging in is required every time
> > > regardless if an session exists or not.
> > > I did some investigating and found that clicking a hyperlink in an
> > > Office application triggers three requests, and it looks like the
> > > first one is missing the session cookie.
> > > Apache log for a hyperlink in Open office:
>
> > >     172.16.3.51 - - [15/Aug/2011:11:27:29 +0200] "GET /cgi-bin/DocDB/
> > > ShowDocument?docid=20916&version=8 HTTP/1.1" 200 3603 "-" "Mozilla/5.0
> > > (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
>
> > > and the same document from Word:
>
> > >     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /cgi-bin/DocDB/
> > > ShowDocument?docid=20916&version=8 HTTP/1.1" 302 496 "-" "Mozilla/4.0
> > > (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR
> > > 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> > > 3.5.30729; .NET4.0C; .NET4.0E)"
>
> > >     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /login/?next=/
> > > cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> > > 3269 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/
> > > 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> > > 3.5.30729; .NET4.0C; .NET4.0E)"
>
> > >     172.16.3.51 - - [15/Aug/2011:11:26:10 +0200] "GET /login/?next=/
> > > cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> > > 3278 "-" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/
> > > 5.0"
>
> > > Note the different status '200 = OK'  for OO and '302 Found' for Word.
> > > Also the length of the first returned object differ: 496 vs 3603.
>
> > > I am not sure where to point the finger to, or how to proceed and
> > > resolve it... So I'd appreciate some help a lot.
> > > Thanks,
> > > Michel

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



M2M with self throught int. table, how to access related items?

2011-08-16 Thread Yaşar Arabacı
Hi,

I am not a django guru (yet) and I am having what I would guess a
trivial django question. Here is my table setup stripped:

class Post(models.Model):

relevancy =
models.ManyToManyField("self",through="Traffic",symmetrical=False,related_name="relevant",blank=True)

class Traffic(models.Model):
tfrom = models.ForeignKey(Post,related_name="tfrom")
tto = models.ForeignKey(Post,related_name="tto")
count = models.PositiveIntegerField(default=0)

This is to be a simple visitor tendency tool, which I keep records of
which link clicked on which post. I am confused about, getting related
items. For example, given a post, how to get set of posts which have
traffic from the post (post.tfrom_set ? ), or how to get post with a
max "count" which is trafficked to the post
( post.tto_set.max("count") ? ) etc.

PS: English is not my main language. Sorry if I wasn't clear

-- 
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: model save question

2011-08-16 Thread Yaşar Arabacı
Absence of **kwargs would cause problems if for example save method is
called with "using" keyword argument. You could either list all the
available keyword arguments or use **kwargs.

By the way, is there any other kwarg for save?

2011/8/16 Mike Dewhirst 

> When using save() in a model, what is the difference between ...
>
> save(self, force_insert=False, force_update=False) or
> save(self, force_insert=False, force_update=False, **kwargs)
># whatever
>super(Xyz, self).save(force_insert, force_update) or
>super(Xyz, self).save(force_insert, force_update, **kwargs)
>
> and
>
> save(self, *arg, **kwargs)
># whatever
>super(Xyz, self).save(*args, **kwargs)
>
> I see the former in a fair bit of django example code around the place and
> the latter in the docs here
>
>
> https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods
>
> Thanks for any insights
>
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



search with a optional value

2011-08-16 Thread john
hi,
i have a form with few fields as optional,i.e can be left blank,
i want to search my db for values i receive from this form, how should
i go on about writing my filters when some of values can be " ".
any reference is kindly 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-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: Weird hyperlink issue with Office and Django authentication

2011-08-16 Thread Michel30
Yes I agree, but if I understand it right then the article suggests
that the issue originates from the single sign-on mechanism, in this
case the Django authentication backend. This should be smart enough to
handle the multiple sessions.

Anyway I had a hard time finding anything related on the web including
a fix.
So for future reference, here it is.

On Aug 16, 2:35 pm, Konstantin Sushenko  wrote:
> as the article says, their sessions are independent of these used by
> the web server. the cookies are not shared between office sessions and
> web sessions. I think django has nothing to do with it.
>
> On Aug 16, 4:04 am, Michel30  wrote:
>
>
>
>
>
>
>
> > Hmm the workaround MS suggests actually works, so I have a
> > workaround :-)
>
> > But understanding why Django's authentication backend doesn't support
> > this would be good
>
> > On Aug 16, 9:10 am, Michel30  wrote:
>
> > > Addidtionally I found this kb article that I believe describes what is
> > > going on:http://support.microsoft.com/kb/899927/en-us
>
> > > On Aug 16, 8:59 am, Michel30  wrote:
>
> > > > I have made a CMS-like application to store and retrieve documents
> > > > using Django 1.3, mysql and Apache.
>
> > > > One requirement was that only authenticated users could use it and
> > > > that after closing the browser the session should be expired.
> > > > So, I implemented an LDAP authentication backend, set the
> > > > "SESSION_EXPIRE_AT_BROWSER_CLOSE" to True and added an @login_required
> > > > decorator to functions that need it.
> > > > And it is working great, just like it should.
>
> > > > Until using one feature that involves clicking on a hyperlink that is
> > > > supposed to open a document within the application in a browser.
> > > > This again works perfectly with every browser (firefix, chrome, IE) in
> > > > several flavors of versions.
> > > > With working I mean the document view opens, and this is important, as
> > > > long as the user was already logged in to the application he/she
> > > > doesn't have to log in again.
>
> > > > It is working until trying this from any office (2000/2003)
> > > > application. Then suddenly logging in is required every time
> > > > regardless if an session exists or not.
> > > > I did some investigating and found that clicking a hyperlink in an
> > > > Office application triggers three requests, and it looks like the
> > > > first one is missing the session cookie.
> > > > Apache log for a hyperlink in Open office:
>
> > > >     172.16.3.51 - - [15/Aug/2011:11:27:29 +0200] "GET /cgi-bin/DocDB/
> > > > ShowDocument?docid=20916&version=8 HTTP/1.1" 200 3603 "-" "Mozilla/5.0
> > > > (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
>
> > > > and the same document from Word:
>
> > > >     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /cgi-bin/DocDB/
> > > > ShowDocument?docid=20916&version=8 HTTP/1.1" 302 496 "-" "Mozilla/4.0
> > > > (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR
> > > > 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> > > > 3.5.30729; .NET4.0C; .NET4.0E)"
>
> > > >     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /login/?next=/
> > > > cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> > > > 3269 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/
> > > > 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> > > > 3.5.30729; .NET4.0C; .NET4.0E)"
>
> > > >     172.16.3.51 - - [15/Aug/2011:11:26:10 +0200] "GET /login/?next=/
> > > > cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> > > > 3278 "-" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/
> > > > 5.0"
>
> > > > Note the different status '200 = OK'  for OO and '302 Found' for Word.
> > > > Also the length of the first returned object differ: 496 vs 3603.
>
> > > > I am not sure where to point the finger to, or how to proceed and
> > > > resolve it... So I'd appreciate some help a lot.
> > > > Thanks,
> > > > Michel

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



httpresponse creates file in /tmp

2011-08-16 Thread sebastiaan
Hi,

currently I'm working on an application that serves PDF files using
HttpResponse:

f = open( pdfFileName, 'r' )

response = http.HttpResponse( f.read(), mimetype='application/
pdf' )
response['Content-Disposition'] = 'attachment; filename=%s' %
pdfFileName

f.close()

return response

Problem is that HttpResponse creates the served file in /tmp which is
not desirable.

Anyone have a suggestion?

PS: I've also tried with StringIO, same result.

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



Re: Django-Registration, How can a beginner work with this 3rd party App?

2011-08-16 Thread shacker
See also:

django-profiles: The Missing Manual
http://birdhouse.org/blog/2009/06/27/django-profiles/

(django-profiles and django-registration are close cousins; I always
use them in combination with one another).

./s

-- 
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: httpresponse creates file in /tmp

2011-08-16 Thread Tom Evans
On Tue, Aug 16, 2011 at 3:58 PM, sebastiaan  wrote:
> Hi,
>
> currently I'm working on an application that serves PDF files using
> HttpResponse:
>
>        f = open( pdfFileName, 'r' )
>
>        response = http.HttpResponse( f.read(), mimetype='application/
> pdf' )
>        response['Content-Disposition'] = 'attachment; filename=%s' %
> pdfFileName
>
>        f.close()
>
>        return response
>
> Problem is that HttpResponse creates the served file in /tmp which is
> not desirable.
>
> Anyone have a suggestion?
>
> PS: I've also tried with StringIO, same result.
>

I wasn't aware django buffered responses into TMPDIR, however...

HttpResponse either takes a string or a file-like object. When you
pass it a file-like object it reads it in chunks and outputs it in
chunks. You're passing it a string, but you could just pass it the
file handle, in which case it would output it in chunks*.

Cheers

Tom

* Certain middleware breaks with chunked style responses, particularly
caching. See [1] for details.

[1] https://code.djangoproject.com/ticket/6527

-- 
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: help error in form usage

2011-08-16 Thread Phang Mulianto
hi anyone can help me...

On Mon, Aug 15, 2011 at 12:39 PM, Phang Mulianto wrote:

> Hi Daniel,
>
> i change it to instance, but still got other errors :
>
>
> def myadmin_change_post(request,
> template_name='blog/admin/change_post.html'):
> try:
> id= request.GET.get('id','4')
> except ValueError:
> id=1
> #post = get_object_or_404(Post,pk=id)
> post = Post.objects.get(pk=id)
> form = AdminPostForm(instance=post)
>
> return render_to_response(template_name,locals(),context_instance =
> RequestContext(request) )
>
> the form :
>
> class AdminPostForm(forms.Form):
>
>
> cat_choices = [('private','private')]
>
> title =
> forms.CharField(widget=forms.TextInput(attrs={'size':'20','value':'','class':''}),label='Title')
> content=
> forms.CharField(widget=forms.Textarea(attrs={'cols':'40','rows':'5'}),label='Content')
> slug =
> forms.CharField(widget=forms.TextInput(attrs={'size':'20','class':''}),label='Slug')
> is_publish = forms.BooleanField(label='Publish')
> categories = forms.ChoiceField(choices=cat_choices)
> created_at =
> forms.DateTimeField(widget=forms.DateTimeInput(),label='Created at')
> modified_at =
> forms.DateTimeField(widget=forms.DateTimeInput(),label='Modified at')
>
> any clue where the error migh be..
> TypeError at /article/change/
>
> __init__() got an unexpected keyword argument 'instance'
>
>  Request Method: GET  Request URL:
> http://127.0.0.1:8000/article/change/?id=2  Django Version: 1.3  Exception
> Type: TypeError  Exception Value:
>
> __init__() got an unexpected keyword argument 'instance'
>
>  Exception Location: 
> C:\Users\mulianto\workspace\myblog\src\myblog\..\myblog\article\views.py
> in myadmin_change_post, line 132  Python Executable:
> c:\python27\python.exe  Python Version: 2.7.2  Python Path:
>
> ['C:\\Users\\mulianto\\workspace\\myblog\\src\\myblog',
>  'c:\\python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
>  'c:\\python27\\lib\\site-packages\\simplejson-2.1.6-py2.7.egg',
>
>  'c:\\python27\\lib\\site-packages\\pyasn1-0.0.13-py2.7.egg',
>  'c:\\python27\\lib\\site-packages\\pymongo-1.11-py2.7-win32.egg',
>  'c:\\python27\\lib\\site-packages\\mongoengine-0.4-py2.7.egg',
>
>  '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',
>
>
>  'c:\\python27\\lib\\site-packages\\PIL']
>
>  Server time: Mon, 15 Aug 2011 12:32:23 +0800
>
> Traceback Switch to copy-and-paste 
> view
>
>- c:\python27\lib\site-packages\django\core\handlers\base.py in
>get_response
>1.
>
>   for middleware_method in self._view_middleware:
>
>   2.
>
>   response = middleware_method(request, callback, 
> callback_args, callback_kwargs)
>
>   3.
>
>   if response:
>
>   4.
>
>   break
>
>   5.
>   6.
>
>   if response is None:
>
>   7.
>
>   try:
>
>1.
>
>   response = callback(request, *callback_args, 
> **callback_kwargs)
>
>   ...
>1.
>
>   except Exception, e:
>
>   2.
>
>   # If the view raised an exception, run it 
> through exception
>
>   3.
>
>   # middleware, and if the exception middleware 
> returns a
>
>   4.
>
>   # response, use that. Otherwise, reraise the 
> exception.
>
>   5.
>
>   for middleware_method in 
> self._exception_middleware:
>
>   6.
>
>   response = middleware_method(request, e)
>
>▶ Local vars 
>  Variable Value   exceptions
>
> 'c:\python27\lib\site-packages\django\core\exceptions.pyc'>
>
> e
>
>TypeError("__init__() got an unexpected keyword argument 'instance'",)
>
> callback_args
>
>()
>
> receivers
>
>[(, None)]
>
> middleware_method
>
> >
>
> self
>
>
>
> settings
>
>
>
> request
>
>GET:,
>POST:,
>COOKIES:{'csrftoken': '5fbc1b8cf0e31318c4f7a1904df1b5c2',
> 'sessionid': 'ee90c4ad05c1512cc424c7117f1320c9'},
>META:{'ALLUSERSPROFILE': 'C:\\ProgramData',
> 'APACHE2TRIAD_DIR': 'd:\\apache2triad',
> 'APPDATA': 'C:\\Users\\mulianto\\AppData\\Roaming',
> 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files',
> 'COMPUTERNAME': 'MULIANTO-PC',
> 'COMSPEC': 'C:\\Windows\\system32\\cmd.exe',
> 'CONTENT_LENGTH': '',
> 'CONTENT_TYPE': 'text/plain',
> 'CSRF_COOKIE': '5fbc1b8cf0e31318c4f7a1904df1b5c2',
> 'DJANGO_SETTINGS_MODULE': 'myblog.settings',
> 'FP_NO_HOST_CHECK': 'NO',
> 'GATEWAY_INTERFACE': 'C

Re: help error in form usage

2011-08-16 Thread Tom Evans
Your form is not a model form, and so you cannot pass instance=post.
Since it is just a regular form, you should pass a dictionary of
values, with the keys of the dictionary being the names of the fields.

If the form is representing a model, you should be using a model form.

https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/

Cheers

Tom

On Tue, Aug 16, 2011 at 4:47 PM, Phang Mulianto  wrote:
>
> hi anyone can help me...
>
> On Mon, Aug 15, 2011 at 12:39 PM, Phang Mulianto  wrote:
>>
>> Hi Daniel,
>>
>> i change it to instance, but still got other errors :
>>
>> def myadmin_change_post(request, 
>> template_name='blog/admin/change_post.html'):
>>     try:
>>     id= request.GET.get('id','4')
>>     except ValueError:
>>     id=1
>>     #post = get_object_or_404(Post,pk=id)
>>     post = Post.objects.get(pk=id)
>>     form = AdminPostForm(instance=post)
>>     return render_to_response(template_name,locals(),context_instance = 
>> RequestContext(request) )
>>
>> the form :
>>
>> class AdminPostForm(forms.Form):
>>
>>
>>     cat_choices = [('private','private')]
>>
>>     title = 
>> forms.CharField(widget=forms.TextInput(attrs={'size':'20','value':'','class':''}),label='Title')
>>     content= 
>> forms.CharField(widget=forms.Textarea(attrs={'cols':'40','rows':'5'}),label='Content')
>>     slug = 
>> forms.CharField(widget=forms.TextInput(attrs={'size':'20','class':''}),label='Slug')
>>     is_publish = forms.BooleanField(label='Publish')
>>     categories = forms.ChoiceField(choices=cat_choices)
>>     created_at = 
>> forms.DateTimeField(widget=forms.DateTimeInput(),label='Created at')
>>     modified_at = 
>> forms.DateTimeField(widget=forms.DateTimeInput(),label='Modified at')
>>
>> any clue where the error migh be..
>>
>> TypeError at /article/change/
>>
>> __init__() got an unexpected keyword argument 'instance'
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/article/change/?id=2
>> Django Version: 1.3
>> Exception Type: TypeError
>> Exception Value:
>>
>> __init__() got an unexpected keyword argument 'instance'
>>
>> Exception Location: 
>> C:\Users\mulianto\workspace\myblog\src\myblog\..\myblog\article\views.py in 
>> myadmin_change_post, line 132
>> Python Executable: c:\python27\python.exe
>> Python Version: 2.7.2
>> Python Path:
>>
>> ['C:\\Users\\mulianto\\workspace\\myblog\\src\\myblog',
>>  'c:\\python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
>>  'c:\\python27\\lib\\site-packages\\simplejson-2.1.6-py2.7.egg',
>>
>>
>>  'c:\\python27\\lib\\site-packages\\pyasn1-0.0.13-py2.7.egg',
>>  'c:\\python27\\lib\\site-packages\\pymongo-1.11-py2.7-win32.egg',
>>  'c:\\python27\\lib\\site-packages\\mongoengine-0.4-py2.7.egg',
>>
>>
>>  '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',
>>
>>
>>  'c:\\python27\\lib\\site-packages\\PIL']
>>
>> Server time: Mon, 15 Aug 2011 12:32:23 +0800
>>
>> Traceback Switch to copy-and-paste view
>>
>> c:\python27\lib\site-packages\django\core\handlers\base.py in get_response
>>
>> for middleware_method in self._view_middleware:
>>
>> response = middleware_method(request, callback, 
>> callback_args, callback_kwargs)
>>
>> if response:
>>
>> break
>>
>> if response is None:
>>
>> try:
>>
>> response = callback(request, *callback_args, 
>> **callback_kwargs)
>>
>> ...
>>
>> except Exception, e:
>>
>> # If the view raised an exception, run it through 
>> exception
>>
>> # middleware, and if the exception middleware 
>> returns a
>>
>> # response, use that. Otherwise, reraise the 
>> exception.
>>
>> for middleware_method in self._exception_middleware:
>>
>> response = middleware_method(request, e)
>>
>> ▶ Local vars
>> Variable Value
>> exceptions
>>
>> > 'c:\python27\lib\site-packages\django\core\exceptions.pyc'>
>>
>> e
>>
>> TypeError("__init__() got an unexpected keyword argument 'instance'",)
>>
>> callback_args
>>
>> ()
>>
>> receivers
>>
>> [(, None)]
>>
>> middleware_method
>>
>> > >
>>
>> self
>>
>> 
>>
>> settings
>>
>> 
>>
>> request
>>
>> > GET:,
>> POST:,
>> COOKIES:{'csrftoken': '5fbc1b8cf0e31318c4f7a1904df1b5c2',
>>  'sessionid': 'ee90c4ad05c1512cc424c7117f1320c9'},
>> META:{'ALLUSERSPROFILE': 'C:\\ProgramData',
>>  'APACHE2TRIAD_DIR': 'd:\\apache2triad',
>>  'APPDATA': 'C:\\Users\\mulianto\\AppData\\Roaming',
>>  'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files',
>>  'COMPUTERNAME': 'MULIANTO-PC',
>>  'COMSPEC': 'C:\\Windows\\system32\\cmd.exe',
>>  'CONTENT_LENGTH': '',
>>  'CONTENT_TYPE': 'text/plain',
>>  'CSRF_COOKIE': '5fbc1b8cf0e313

Re: help error in form usage

2011-08-16 Thread Phang Mulianto
Oh i see..

i read the manual, the django book, no such information about that..
oh my..better update the manual there..

thanks for your quick explanation then, i think not a good way to manualy
assign a dictionarry to the form, not like in the documentation / book of
django. now i get it.

Thanks

Mulianto

On Tue, Aug 16, 2011 at 11:58 PM, Tom Evans wrote:

> Your form is not a model form, and so you cannot pass instance=post.
> Since it is just a regular form, you should pass a dictionary of
> values, with the keys of the dictionary being the names of the fields.
>
> If the form is representing a model, you should be using a model form.
>
> https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/
>
> Cheers
>
> Tom
>
> On Tue, Aug 16, 2011 at 4:47 PM, Phang Mulianto 
> wrote:
> >
> > hi anyone can help me...
> >
> > On Mon, Aug 15, 2011 at 12:39 PM, Phang Mulianto 
> wrote:
> >>
> >> Hi Daniel,
> >>
> >> i change it to instance, but still got other errors :
> >>
> >> def myadmin_change_post(request,
> template_name='blog/admin/change_post.html'):
> >> try:
> >> id= request.GET.get('id','4')
> >> except ValueError:
> >> id=1
> >> #post = get_object_or_404(Post,pk=id)
> >> post = Post.objects.get(pk=id)
> >> form = AdminPostForm(instance=post)
> >> return render_to_response(template_name,locals(),context_instance =
> RequestContext(request) )
> >>
> >> the form :
> >>
> >> class AdminPostForm(forms.Form):
> >>
> >>
> >> cat_choices = [('private','private')]
> >>
> >> title =
> forms.CharField(widget=forms.TextInput(attrs={'size':'20','value':'','class':''}),label='Title')
> >> content=
> forms.CharField(widget=forms.Textarea(attrs={'cols':'40','rows':'5'}),label='Content')
> >> slug =
> forms.CharField(widget=forms.TextInput(attrs={'size':'20','class':''}),label='Slug')
> >> is_publish = forms.BooleanField(label='Publish')
> >> categories = forms.ChoiceField(choices=cat_choices)
> >> created_at =
> forms.DateTimeField(widget=forms.DateTimeInput(),label='Created at')
> >> modified_at =
> forms.DateTimeField(widget=forms.DateTimeInput(),label='Modified at')
> >>
> >> any clue where the error migh be..
> >>
> >> TypeError at /article/change/
> >>
> >> __init__() got an unexpected keyword argument 'instance'
> >>
> >> Request Method: GET
> >> Request URL: http://127.0.0.1:8000/article/change/?id=2
> >> Django Version: 1.3
> >> Exception Type: TypeError
> >> Exception Value:
> >>
> >> __init__() got an unexpected keyword argument 'instance'
> >>
> >> Exception Location:
> C:\Users\mulianto\workspace\myblog\src\myblog\..\myblog\article\views.py in
> myadmin_change_post, line 132
> >> Python Executable: c:\python27\python.exe
> >> Python Version: 2.7.2
> >> Python Path:
> >>
> >> ['C:\\Users\\mulianto\\workspace\\myblog\\src\\myblog',
> >>  'c:\\python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
> >>  'c:\\python27\\lib\\site-packages\\simplejson-2.1.6-py2.7.egg',
> >>
> >>
> >>  'c:\\python27\\lib\\site-packages\\pyasn1-0.0.13-py2.7.egg',
> >>  'c:\\python27\\lib\\site-packages\\pymongo-1.11-py2.7-win32.egg',
> >>  'c:\\python27\\lib\\site-packages\\mongoengine-0.4-py2.7.egg',
> >>
> >>
> >>  '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',
> >>
> >>
> >>  'c:\\python27\\lib\\site-packages\\PIL']
> >>
> >> Server time: Mon, 15 Aug 2011 12:32:23 +0800
> >>
> >> Traceback Switch to copy-and-paste view
> >>
> >> c:\python27\lib\site-packages\django\core\handlers\base.py in
> get_response
> >>
> >> for middleware_method in self._view_middleware:
> >>
> >> response = middleware_method(request, callback,
> callback_args, callback_kwargs)
> >>
> >> if response:
> >>
> >> break
> >>
> >> if response is None:
> >>
> >> try:
> >>
> >> response = callback(request, *callback_args,
> **callback_kwargs)
> >>
> >> ...
> >>
> >> except Exception, e:
> >>
> >> # If the view raised an exception, run it
> through exception
> >>
> >> # middleware, and if the exception middleware
> returns a
> >>
> >> # response, use that. Otherwise, reraise the
> exception.
> >>
> >> for middleware_method in
> self._exception_middleware:
> >>
> >> response = middleware_method(request, e)
> >>
> >> ▶ Local vars
> >> Variable Value
> >> exceptions
> >>
> >>  'c:\python27\lib\site-packages\django\core\exceptions.pyc'>
> >>
> >> e
> >>
> >> TypeError("__init__() got an unexpected keyword argument 'instance'",)
> >>
> >> callback_args
> >>
> >> ()
> >>
> >> receivers
> >>
> >> [(, Non

Re: httpresponse creates file in /tmp

2011-08-16 Thread Landy Chapman
The example here:
https://docs.djangoproject.com/en/1.3/howto/outputting-pdf/

does not use a file; it uses the a file-like object: HttpResponse.
That is how my code does it. When I get back I will check if my pdf
report also creates a file in /tmp

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



How to Layout a Django Application?

2011-08-16 Thread Andre Lopes
Hi, another question from a Django beginner.

I have played with views and templates a little bit, but now I want to
make a real layout(Header, Side Column and Footer). There are any
guides on layouts that I should follow? There are Apps that will help
me with that task?

Please le me know.

Best 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django-Registration, How can a beginner work with this 3rd party App?

2011-08-16 Thread Andre Lopes
Thanks for your reply. I will follow this tutorial.

Best Regards,

On Tue, Aug 16, 2011 at 4:36 PM, shacker  wrote:
> See also:
>
> django-profiles: The Missing Manual
> http://birdhouse.org/blog/2009/06/27/django-profiles/
>
> (django-profiles and django-registration are close cousins; I always
> use them in combination with one another).
>
> ./s
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Json serialization help

2011-08-16 Thread Nate
Thank you for the suggestion.
I actually ended up extending Django's json serializer.  Here is the
code in case you or someone else needs to do something like this.

from django.core.serializers.json import Serializer as JsonSerializer
from django.utils.encoding import is_protected_type
class DisplayNameJsonSerializer(JsonSerializer):

def handle_field(self, obj, field):
value = field._get_val_from_obj(obj)

#If the object has a get_field_display() method, use it.
display_method = "get_%s_display" % field.name
if hasattr(obj, display_method):
self._current[field.name] = getattr(obj, display_method)()

# Protected types (i.e., primitives like None, numbers, dates,
# and Decimals) are passed through as is. All other values are
# converted to string first.
elif is_protected_type(value):
self._current[field.name] = value
else:
self._current[field.name] = field.value_to_string(obj)

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



M2M with self throught int. table, how to access related items?

2011-08-16 Thread Yaşar Arabacı
Hi,

I have tried to sent this e-mail before, but I guess it didn't make its way
to the groups so I am trying to resent it, if this is a double post, I am
sorry. I am having trouble understanding m2m relation to self with a
intermediary table. Here is my table setup stripped:

   class Post(models.Model):

   relevancy =
models.ManyToManyField("self",
through="Traffic",symmetrical=False,related_name="relevant",blank=True)

   class Traffic(models.Model):
   tfrom = models.ForeignKey(Post,related_name="tfrom")
   tto = models.ForeignKey(Post,related_name="tto")
   count = models.PositiveIntegerField(default=0)

This is to be a simple visitor tendency tool, which I keep records of
which link clicked on which post. I am confused about, getting related
items. For example, given a post, how to get set of posts which have
traffic from the post (post.tfrom_set ? ), or how to get post with a
max "count" which is trafficked to the post
( post.tto_set.max("count") ? ) etc.

And also, what is the recommended way of getting, for example, given a post,
which is the post with max "count" value from this post. Like, get a list of
traffics where tfrom is given post, and get a Traffic object with max
"count" and get tto post of that traffic.

PS: English is not my main language. Sorry if I wasn't clear

-- 
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: For loop problem in template..Is this correct

2011-08-16 Thread victorkendy
Hi

The for tag iterates over the elements of the list you are using so
your code should be

$(function() {
var data = [];
var i = something();
   {% for x in content %}
data[i] =
{
roll_no: {{x.roll_no}},
cell_no: {{x.cell_no}},
nationality:{{x.nationality}},
e_mail:{{x.e_mail}}
};
{% endfor %}

grid = new Slick.Grid("#myGrid", data, columns, options);

$("#myGrid").show();
})

On Aug 15, 8:45 pm, Adam Zedan  wrote:
> Hi i am getting a problem with my for loop which i used in my template.Could
> you kindly let me know what is going wrong in here.
> The for loop is in a jquery function
>
> $(function() {
>             var data = [];
>
>                {% for x in range(len(content)) %}
>                 data[i] =
>                 {
>                     roll_no: {{content[x].roll_no}},
>                     cell_no: {{content[x].cell_no}},
>                     nationality:{{content[x].nationality}},
>                     e_mail:{{content[x].e_mail}}
>
>                 };
>                 {% endfor %}
>
>             grid = new Slick.Grid("#myGrid", data, columns, options);
>
>             $("#myGrid").show();
>         })

-- 
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: search with a optional value

2011-08-16 Thread Nan

Filters can be applied in multiple statements, and querysets are
evaluated lazily, so the following would work and would only run a
single query, when you finally output or otherwise check the contents
of the results variable:

def get_results(...):
...
results =
MyThing.objects.filter(required_field=somevalue).filter(other_required_field=othervalue)
if optional_value_submitted:
results = results.filter(optional_field=optional_value)
if other_optional_value:
results =
results.filter(other_optional_field=other_optional_value)
return results


On Aug 16, 8:20 am, john  wrote:
> hi,
> i have a form with few fields as optional,i.e can be left blank,
> i want to search my db for values i receive from this form, how should
> i go on about writing my filters when some of values can be " ".
> any reference is kindly 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-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: M2M with self throught int. table, how to access related items?

2011-08-16 Thread Nan
> For example, given a post, how to get set of posts which have traffic from 
> the post (post.tfrom_set ? )

Have you tried:

class Post(models.Model):
  ...
  def posts_with_traffic_from_here(self):
return Post.objects.filter(tto__tfrom=self)

> how to get post with a max "count" which is trafficked to the post

https://docs.djangoproject.com/en/1.2/topics/db/aggregation/#aggregating-annotations



On Aug 16, 2:36 pm, Yaşar Arabacı  wrote:
> Hi,
>
> I have tried to sent this e-mail before, but I guess it didn't make its way
> to the groups so I am trying to resent it, if this is a double post, I am
> sorry. I am having trouble understanding m2m relation to self with a
> intermediary table. Here is my table setup stripped:
>
>    class Post(models.Model):
>
>        relevancy =
> models.ManyToManyField("self",
> through="Traffic",symmetrical=False,related_name="relevant",blank=True)
>
>    class Traffic(models.Model):
>        tfrom = models.ForeignKey(Post,related_name="tfrom")
>        tto = models.ForeignKey(Post,related_name="tto")
>        count = models.PositiveIntegerField(default=0)
>
> This is to be a simple visitor tendency tool, which I keep records of
> which link clicked on which post. I am confused about, getting related
> items. For example, given a post, how to get set of posts which have
> traffic from the post (post.tfrom_set ? ), or how to get post with a
> max "count" which is trafficked to the post
> ( post.tto_set.max("count") ? ) etc.
>
> And also, what is the recommended way of getting, for example, given a post,
> which is the post with max "count" value from this post. Like, get a list of
> traffics where tfrom is given post, and get a Traffic object with max
> "count" and get tto post of that traffic.
>
> PS: English is not my main language. Sorry if I wasn't clear

-- 
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: Json serialization help

2011-08-16 Thread Andre Terra
Thank you a lot for this snippet!

I've wondered about how to export objects to excel in a "more natural way"
and this seems to be a great approach, considering all the different
gotchas.

Thank you for taking the time to write this.. I've been postponing this
little bit of research for the longest time.


Cheers,
AT

On Tue, Aug 16, 2011 at 3:11 PM, Nate  wrote:

> Thank you for the suggestion.
> I actually ended up extending Django's json serializer.  Here is the
> code in case you or someone else needs to do something like this.
>
> from django.core.serializers.json import Serializer as JsonSerializer
> from django.utils.encoding import is_protected_type
> class DisplayNameJsonSerializer(JsonSerializer):
>
>def handle_field(self, obj, field):
>value = field._get_val_from_obj(obj)
>
>#If the object has a get_field_display() method, use it.
>display_method = "get_%s_display" % field.name
>if hasattr(obj, display_method):
>self._current[field.name] = getattr(obj, display_method)()
>
># Protected types (i.e., primitives like None, numbers, dates,
># and Decimals) are passed through as is. All other values are
># converted to string first.
>elif is_protected_type(value):
>self._current[field.name] = value
>else:
>self._current[field.name] = field.value_to_string(obj)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How to Layout a Django Application?

2011-08-16 Thread Andre Terra
There are no particular layouts, but sometimes writing an inclusion tag[1]
can help with abstracting some of the logic from the template (especially in
the case of side columns that can vary based on context).

What I usually do:

Write a base.html file with some "default" data, including dummy content
text wrapped around something like a context block, eg.


{% block content %}
  No content yet.
{% endblock %}


{% extends 'base.html' %}

{% block content %}
  My content
{% endbock %}


I also have blocks for javascript, styles and extrahead, which usually are
called with {{ block.super }} in a specific template, so that I can append
more scripts to a section of the site rather than having to rewrite the
entire block.

Let us know if you need more help!


Cheers,
AT

[1]
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags-inclusion-tags


On Tue, Aug 16, 2011 at 2:46 PM, Andre Lopes  wrote:

> Hi, another question from a Django beginner.
>
> I have played with views and templates a little bit, but now I want to
> make a real layout(Header, Side Column and Footer). There are any
> guides on layouts that I should follow? There are Apps that will help
> me with that task?
>
> Please le me know.
>
> Best 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Limiting choices for inline manytomany field

2011-08-16 Thread DelS
=
> Numerous clever workarounds are given in the forums but I decided to
> try using "formfield_for_manytomany" in the inline class. This works
> brilliantly.
==
Make that
"...using formfield_for_foreignkey() in the inline class."
!!!  (Rushing to go for a coffee!)

On Aug 16, 9:52 am, DelS  wrote:
> I am fairly new and using Django Admin to manage a set of lists and
> forms for a database GUI.
> I am not happy with the performance rendering a form which has
> foreignkey fields or manytomany fields with numerous values. This
> inspired me to get involved with overloading
> "formfield_for_foreignkey" which I eventually managed.
> When I went to tackle a "manytomany" formfield for an 'inline' the
> "admin" doco says "use 'formfield_for_manytomany' as usual, so I
> created the approriate method in the 'inline' Class but it was never
> invoked.
> Numerous clever workarounds are given in the forums but I decided to
> try using "formfield_for_manytomany" in the inline class. This works
> brilliantly.
> I guess the principle is that within the "through" model, the fields
> are actually "foreignkey" fields, and the 'db_field.name' values
> correspond to that model.
>
> Here is a fragment of code where I cache the queryset for multiple
> fields in the session dictionary.
>
> #-
> # use inline feature in Route for Points and Tracks
> class PointsInline(TabularInline):
>     model = Route.points.through
>     extra = 0
>
> class TracksInline(TabularInline):
>     def formfield_for_foreignkey( self,db_field, request, **kwargs):
>         if db_field.name == "track_id" or db_field.name == "point_id":
>             url_split = request.path.split('/')
>             route_id = url_split[-2]
>             try:
>                 previous_id = request.session.get("RouteId")
>             except:
>                 previous_id = None
>             if route_id <> previous_id :
>                 print db_field.name, request.path, "\n"
>                 request.session["RouteId"] = route_id
>                 q_line =
> Route.objects.get(id=route_id).from_signal.location.line
>                 tq_set = Track.objects.filter(location__line=q_line)
>                 request.session["TrackList"] = tq_set
>                 pq_set = Point.objects.filter(location__line=q_line)
>                 request.session["PointList"] = pq_set
>                 print q_line, tq_set.count(), pq_set.count()
>             if db_field.name == "track_id":
>                 q_set = request.session["TrackList"]
>             else:
>                 q_set = request.session["PointList"]
>             kwargs["queryset"] = q_set
>             return super(TracksInline,
> self).formfield_for_foreignkey(db_field, request, **kwargs )
>         else:
>             return None
>     model = Route.tracks.through
>     extra = 0
>
> class RouteAdmin(ModelAdmin):
>     inlines = [ PointsInline, TracksInline ]
>     list_per_page = 48
>     list_display =
> ('__unicode__','from_signal','to_signal','direction')
>     list_filter= ('to_signal__location__line',)
>     exclude = ('tracks','points',)
>     search_fields =
> ('to_signal__location__vcode','from_signal__location__vcode',)
> #-

-- 
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: Displaying results in Template in a Table ? What is the proper way ?Any app?

2011-08-16 Thread Mike Seidle
On Wednesday, August 10, 2011 07:03:51 pm Brian Bouterse wrote:
> I know it's not Django specific, but when I need a table for my Django
> projects, I use jQuery Datatable .  It rocks!


I highly recommend Datatable... It's not to hard to do either.

-- 
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: model save question

2011-08-16 Thread Mike Dewhirst

Yaşar

Thanks .. the "using" kw hadn't occurred to me but I don't know of any 
others. I'm happy now. I figure the force_* kwargs were probably the 
only ones then and it wasn't too difficult for example code to mention 
them. I prefer the *args, **kwargs version anyway. It hides the gory 
detail from me.


Cheers

Mike

On 16/08/2011 5:23pm, Yaþar Arabacý wrote:
Absence of **kwargs would cause problems if for example save method is 
called with "using" keyword argument. You could either list all the 
available keyword arguments or use **kwargs.


By the way, is there any other kwarg for save?

2011/8/16 Mike Dewhirst >


When using save() in a model, what is the difference between ...

save(self, force_insert=False, force_update=False) or
save(self, force_insert=False, force_update=False, **kwargs)
# whatever
super(Xyz, self).save(force_insert, force_update) or
super(Xyz, self).save(force_insert, force_update, **kwargs)

and

save(self, *arg, **kwargs)
# whatever
super(Xyz, self).save(*args, **kwargs)

I see the former in a fair bit of django example code around the
place and the latter in the docs here


https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods

Thanks for any insights

Mike

-- 
You received this message because you are subscribed to the Google

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


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.

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


--
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: 3rd party Apps in Django

2011-08-16 Thread Derek
Chris

"Dingo" projects?  Is that what they call them in Australia ;)

On Aug 16, 12:54 am, Chris Lawlor  wrote:
> +1 for using virtualenv. Indispensable for working on more than one dingo 
> project on the same development machine. If you're developing on Linux or 
> Mac, take a look at virtualenvwrapper. It makes working with virtual 
> environments practically painless.

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