the parameters of the self-defined tags

2009-08-25 Thread Apple

hi , now I want to pass a parameter named user (user is a instance of
User) to the self_defined tags,could I do this ? I think the passed
parameter are all strings , is there a way to get its real type ?
thank you for your replying !
--~--~-~--~~~---~--~~
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: Duplicating objects, avoid signals

2009-08-25 Thread Andy McKay

On 25-Aug-09, at 1:45 PM, Michel Thadeu Sabchuk wrote:
> This way I can disable signals for an specific operation, this is what
> I want but I prefer not modify django source. Is there another way to
> disable signals for an specific operation?

Here's an example:

http://djangozen.com/blog/turning-off-django-signals
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: @clearwind


--~--~-~--~~~---~--~~
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 templates have lexical scope!?

2009-08-25 Thread James Bennett

On Tue, Aug 25, 2009 at 9:26 PM, stevedegrace wrote:
> I suppose this is easy enough to fix by doing the binding in the view
> when the context is first constructed which would probably have been
> easier in the first place, but now I'm curious and want to know what's
> happening.

If you want something available in the template, then yes, making it
available through the context provided in the view is the way to do
it. The various built-in template tags which can add variables to the
context all have limited scope, and in many cases (e.g., the "with"
tag) this is explicit.

> I never suspected this behaviour and got no inkling to expect it from
> the Django docs. Can anyone with more knowledge of the guts of the
> template rendering system suggest why this happens and if there is any
> way to force variables bound by custom tags into the "global scope"?

The answer is that the template context is not a dictionary. It's a
stack of dictionaries, with fall-through lookup semantics.

Various operations going on in the template push a new dictionary onto
the context stack and populate it, then pop that dictionary off the
context stack when they're done. In general, this is a good thing; for
example, it means it's much easier to have tags do whatever they want
without trampling all over each other's context variables. Many
built-in tags take good advantage of this.

If you truly need a way to make a variable available everywhere in a
template, but it's simply not possible to provide that directly
through the initial context, you want to look at the "dicts" attribute
of the Context instance, which is a list of dictionaries. The last one
in the list (e.g., index -1) is the one that originally came from
instantiating the Context with its initial set of variables, and
during normal template use it will always persist for the life of the
rendering process (someone who wanted to shoot themselves in the foot
could write a tag which manually removes it, but the normal context
push/pop operations will not do this and will raise an exception if
you try to pop the last dictionary out of the stack).


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Django templates have lexical scope!?

2009-08-25 Thread stevedegrace

I just discovered something I did not expect.

Apparently a Django template does not behave like its context is a
single global scope where if you set a new variable using a custom
template tag it can be accessed anywhere subsequently in the template.

Variables you set into the context initially when you make the method
call to render the template do act like you would expect.

Variables you bind within the template itself don't seem to behave
this way.

Instead they are scoped. If a variable is bound inside a block tag,
the binding is only valid within that block. I didn't do enough
experiments yet to tell you how it behaves with nested blocks.

This can have a distinct effect in child templates, where apparently
nothing you do outside of a block tag "counts", so you can't put a
variable into the global scope simply by binding it before the block
tags. Let's say you use a custom tag to test whether the currently
logged in user has privilege to edit the document, and this sets a
variable into the context which can be checked to decide whether to
display certain controls. (Not intended as a security measure, just
not to clutter the interface with controls the user can't use anyway).
If you include the tag in one block, the variable can only be accessed
in that block!

I suppose this is easy enough to fix by doing the binding in the view
when the context is first constructed which would probably have been
easier in the first place, but now I'm curious and want to know what's
happening.

I never suspected this behaviour and got no inkling to expect it from
the Django docs. Can anyone with more knowledge of the guts of the
template rendering system suggest why this happens and if there is any
way to force variables bound by custom tags into the "global scope"?

Stephen
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Error deleting user form Admin Panel

2009-08-25 Thread Asinox

Hi guys, i dont know from where is coming this error... but  two hours
ago all was working fine... but know when i try to delete a user from
the Django Admin i got this error:

TypeError: coercing to Unicode: need string or buffer, User found

Somebody know why?

complete error code:

TypeError at /admin/auth/user/
coercing to Unicode: need string or buffer, User found
Request Method: POST
Request URL:http://www.domain.com/admin/auth/user/
Exception Type: TypeError
Exception Value:
coercing to Unicode: need string or buffer, User found
Exception Location: /home/user/webapps/django/lib/python2.5/django/
utils/encoding.py in force_unicode, line 71

Thanks guys

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



Templates not reflecting changes, AGAIN!

2009-08-25 Thread neri...@gmail.com

I had this problem when I started developing this project (my first)
on my server space at Dreamhost, so as suggested by a forum member I
began developing on my local machine with the django dev server. Why
is it that changes made to templates are not reflected upon restarting
the server or refreshing the browser, am I missing something? Is there
something everybody else knows but me? It''s really frustrating when
changes you make, including deleting the whole file, make no
difference when you refresh or restart. I've never had these problems
developing with PHP or straight HTML so I have no idea what I could be
doing wrong.
--~--~-~--~~~---~--~~
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: duplicate primary key problem

2009-08-25 Thread Chris

I had this identical problem. Thanks for the help.

Chris

On Jul 10, 8:12 pm, adelaide_mike  wrote:
> Very cool, Rajesh D.  Thanks.
>
> Mike
>
> On Jul 11, 12:31 am, Rajesh D  wrote:
>
> > On Jul 10, 11:06 am, adelaide_mike 
> > wrote:
>
> > > I suspect this is a question more for a PostgreSQL list, but please
> > > bear with me.
>
> > > In Django 1.0.2 working with PostgreSQL 8.3 I have a model with an
> > > implied pkey.  PostgreSQL syas this:
>
> > > CREATE TABLE wha_property
> > > (
> > >   id serial NOT NULL,
> > >   propnum character varying(16) NOT NULL,
> > >   beds integer,
> > >   baths integer,
> > >   rooms integer,
> > >   garage character varying(8),
> > >   frontage integer,
> > >   is_corner boolean,
> > >   street_id integer NOT NULL,
> > >   land_area numeric(10,2),
> > >   year_built integer,
> > >   valuation_nr character varying(16),
> > >   CONSTRAINT wha_property_pkey PRIMARY KEY (id),
> > >   CONSTRAINT wha_property_street_id_fkey FOREIGN KEY (street_id)
> > >       REFERENCES wha_street (id) MATCH SIMPLE
> > >       ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY
> > > DEFERRED,
> > >   CONSTRAINT wha_property_street_id_key UNIQUE (street_id, propnum)
>
> > > The wha_property table is populated with 500,000 rows from another
> > > database.  There are gaps in the series of used id numbers.
>
> > > If I attempt to insert a new row Django mostly reports an integrity
> > > violation at wha_property_pkey, though a couple of times with
> > > different parent rows it has worked.  My very newbie view for
> > > inserting or updating a row is here:
>
> > >http://dpaste.com/65435/
>
> > > I would be very happy if someone can spot where I have an error.  If
> > > anyone cares to criticise my view, please be gentle.  I am new at this
> > > Django/PostgreSQL magic.
>
> > The sequence for the id column might be out of sync. That would cause
> > your inserts to pick an id that already exists.
>
> > Try the following command:
>
> > python manage.py sqlsequencereset wha
>
> > That will print out the SQL that you need to run to get your sequences
> > back in sync with your data. Run that SQL. Then try inserting new data
> > through your view again.
>
> > -RD
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



SOAPLIB issue with django upgrade

2009-08-25 Thread Wombatpm

I had a working web service that I built with django 1.0.1 , python
2.3, soaplib using the djangostack from BitNami.  Everything worked
fine with the development server.  I never could get my service
working under mod_python and the BitNami apache install.

Throwing caution to the wind, I did a clean install of apache 2.2,
mod_wsgi release candidate 4, activestate python 2.6, downloaded the
easy_install package, and loaded the eggs for django and soaplib.
Installing everything went easy, and I could quickly see my new WSDL
file.  Problem is,  anything that trys to read the WSDL file (excel
macros, SOAPUI ) throw errors.  SOAPUI gives me a Java.Null Exception
and the Excel macros tells me "Unicode strings with encoding
declaration are not supported"

So what am I missing?
Is this python 2.3 - > 2.6 issue?
or django 1.0.1 -> 1.1 issue?
or soaplib 0.79 -> 0.81 issue?

Any help would be appreciated.


#
New NON-working WSDL file
http://my.namespace.org/soap/";
name="HelloWorldService">
-

-
http://my.namespace.org/soap/";>

-

-





-

-





-

-







-



-



-

-






-

-




-

http://schemas.xmlsoap.org/
soap/http"/>
-


-



-





-

-

http://10.217.51.71:8080/AIIM/hello_world/
service"/>




#
OLD Working WSDL file.

-

-
http://my.namespace.org/soap/";>

-

-






-

-




-

-







-



-



-

-






-

-




-

http://schemas.xmlsoap.org/
soap/http"/>
-


-



-





-

-

http://10.217.51.71/AIIM/hello_world/service"/
>




--~--~-~--~~~---~--~~
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: Building enchant-1.5.0

2009-08-25 Thread Karen Tracey
On Tue, Aug 25, 2009 at 7:37 PM, Sonal Breed  wrote:

>
> Hello all,
>
> I am trying to have enchant package on server machine. Just using easy-
> install PyEnchant did not work as I get following errors when I try to
> import enchant package in python interactive window:
> [snip]
> For that, it seems that, I have to first compile
> http://www.abisource.com/projects/enchant/
> library
> I downloaded the enchant-1.5.0, but I do not know what steps to take
> further to build/compile it.
>
> I was not sure where to raise this question, couldn't get much help on
> net either, hence put it in this group.
>

I don't understand why you chose this group to post in.  Does this enchant
thing have anything to do with Django? I think you would be much better off
following the "Get Help" link on that page you list and choose either the
mailing list or the IRC channel pointed to to ask for help there.

Karen

--~--~-~--~~~---~--~~
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: print PDF on windows

2009-08-25 Thread Sam Lai

Use python to call a PDF reader via the command line -

http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm

http://foxit.vo.llnwd.net/o28/pub/foxit/manual/enu/FoxitReader30_Manual.pdf
(see the Command Line section)

Depending on the complexity of your PDFs, I'd recommend using Foxit
instead; Adobe Reader on windows isn't the most stable especially when
it comes to open many PDFs - you might have to manually manage
instances to make sure it doesn't eat up all your memory. Foxit Reader
however doesn't render all PDFs perfectly, or at least the same way
that Adobe Reader does. YMMV though.

2009/8/26 mettwoch :
>
> How do the Django people handle printing directly on Windows? I
> remembered about http://timgolden.me.uk/python/win32_how_do_i/print.html,
> but unfortunately his method for PDFs only print on the default
> printer. I need the server to produce the PDF, save it (works already)
> and send it to a specific shared printer on the network. The printer
> should be determined from a table that holds 'host' - 'printer' pairs
> e.g. ('PC01', '\\PC01\PR01'). The host ('PC01') determined from the
> http request allows to choose the right printer ('\\PC01\PR01') from
> that table.
>
> Printing should be executed directly when the user has submitted the
> request. Any solution that pops up the document locally in a PDFReader
> and where the user has to hit the print button is not viable.
>
> Kindly Yours
> Marc
> >
>

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



template tag response None. but why?

2009-08-25 Thread MIL

Hi guys :o)

Im attempting to create a template tag but I get a strange response.
it returns "None" where I put the {% if blog_detail %} tag

Here is my template tag

class BlogNode(Node):
def __init__(self, user, varname):
self.user, self.varname = user, varname

def render(self, context):
try:
context[self.varname] = Blog.objects.get(user=self.user)
except ObjectDoesNotExist:
context[self.varname] = False

@register.tag
def get_blog(parser, token):
# {% get_blog for user_object as object_detail %}
# {% if blog_detail %} etc...
bits = token.contents.split()
if len(bits) != 5:
raise TemplateSyntaxError, "get_blog tag takes exactly five
arguments"
if bits[1] != 'for':
raise TemplateSyntaxError, "second argument to get_blog tag 
must be
'for'"
if bits[3] != 'as':
raise TemplateSyntaxError, "third argument to get_blog tag must 
be
'as'"
return BlogNode(bits[2], bits[4])


Why does it response with a "None" message?

Thanks :o)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Chaining filters on a ManyToManyField

2009-08-25 Thread David

Hi all,

I am trying to understand spanning multi-valued relationships (as
documented here 
http://docs.djangoproject.com/en/dev/topics/db/queries/#spanning-multi-valued-relationships).
More specifically, these paragraphs:

"Everything inside a single filter() call is applied simultaneously to
filter out items matching all those requirements. Successive filter()
calls further restrict the set of objects, but for multi-valued
relations, they apply to any object linked to the primary model,
***not necessarily*** those objects that were selected by an earlier
filter() call.

[...] the first filter restricted the queryset to all those blogs
linked to that particular type of entry. The second filter restricted
the set of blogs further to those that are also linked to the second
type of entry. The entries select by the second filter ***may or may
not be*** the same as the entries in the first filter."

To place this into context, here is the problem I'm grappling with.
Say I have a model, Entry, with a ManyToManyField, tags. The Tag model
contains just a name field.

If I want to filter entries by all those entries that have tags
'apples' AND 'oranges', the above would suggest something along the
lines of

>>> Entry.objects.filter(tags__name='apples', tags__name='oranges')

which of course, does not work, as the latter argument overrides the
former. So, I was wondering specifically about that "not necessarily"
clause.

Having experimented briefly in the shell, I've discovered that

>>> Entry.objects.filter(tags__name='apples').filter(tags__name='oranges')

seems to do what I want. However, I don't quite understand why!

If I am understanding the excerpt above, it basically means that if
you filter a model on its ManyToManyField, subsequent chained filters
may either use the restricted set returned by the former filter; or it
may ignore it altogether, and effectively filter as if the former was
not there, and thus the result is a union of the two sets of results.
Is that correct?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Building enchant-1.5.0

2009-08-25 Thread Sonal Breed

Hello all,

I am trying to have enchant package on server machine. Just using easy-
install PyEnchant did not work as I get following errors when I try to
import enchant package in python interactive window:

>>> import enchant
Traceback (most recent call last):
File "", line 1, in 
File "/home/mygoplanner/lib/python2.5/pyenchant-1.5.3-py2.5.egg/
enchant/__init__.py", line 94, in 
from enchant import _enchant as _e
File "/home/mygoplanner/lib/python2.5/pyenchant-1.5.3-py2.5.egg/
enchant/_enchant.py", line 72, in 
raise ImportError("enchant C library not found")
ImportError: enchant C library not found


For that, it seems that, I have to first compile 
http://www.abisource.com/projects/enchant/
library
I downloaded the enchant-1.5.0, but I do not know what steps to take
further to build/compile it.

I was not sure where to raise this question, couldn't get much help on
net either, hence put it in this group.

Any help will be really appreciated.

Thanks in advance,
Sincerely,
Sonal.
--~--~-~--~~~---~--~~
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: Adding ManyToMany field to django comments

2009-08-25 Thread grahamu

The solution I eventually used is to require that the reviewer
queryset be stored in a session variable. Since this queryset is
required in the template context in order for the templatetags to
work, saving the value in a session variable isn't much to ask.

Please let me know if you think this solution is problematic in
nature. Thanks!

Graham

On Aug 19, 5:56 pm, grahamu  wrote:
> In general, I'm wondering how to retrieve a Queryset provided to a
> Form (choices for a ManyToMany field) from within a view that only
> accepts POST data from that form. This isn't really a question about
> extending django.contrib.comments, but that framework provides a good
> point of reference for the issue.
>
> For example, suppose I wanted to add: "reviewers = models.ManyToMany
> (User)" to the django.contrib.comment Comment model. This would be a
> list of Users who are allowed to review the comment, specified by the
> comment creator.
>
> In order for this to work we need to provide a Queryset of Users when
> creating the form. This can be accomplished with a template tag of the
> form "{% get_comment_form for [object] with [reviewers] as [varname]
> %}", where 'reviewers' is a Queryset passed in the template context.
> This works fine.
>
> However, when the form is posted, we don't have visibility (in the
> post view) to the Queryset of possible reviewers. The post view, after
> checking the validity of several other pieces of data, creates a new
> comment form to check the validity of the received data. Of course the
> form must have a Queryset for the 'reviewers' field, and this isn't
> part of the request POST data.
>
> Any ideas how one might either pass the queryset data to the view in
> the form, or some other way to manage the form validation in this
> situation?
>
> Graham
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



changing database "design" through admin interface

2009-08-25 Thread Gezim Hoxha
Hi all,
First, congrats on the release of 1.1, real exciting!

Second, I'm working on a web site that basically allows athletes to register
on it with the goal of tracking their game stats. So, for example, if an
athlete plays baseball, he can track specific stats such as number of home
runs, doubles, triples, etc. However, I want to create an admin interface
where the stats that the athlete can track can be changed by an admin. So,
for example, in baseball, the admin might decide one day all of a sudden to
allow athletes to track the number of times they spit! I want this to be
done without changing the code.

How might I be able to do this? Where do I get started?

Thanks,
-Gezim

--~--~-~--~~~---~--~~
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: Test client and form processing

2009-08-25 Thread Joshua Russo
Ya, when I'm writing unit tests for my forms. What I wanted was a way in my
testing logic to generate a dictionary of values to post back to the server
based on the initial values of the forms in the content property of the
response object returned from the test client get() and/or post() methods.
Here is the current response object definition
http://docs.djangoproject.com/en/dev/topics/testing/#testing-responses

I
actually just finished my work on extracting them (or at least a first pass)
today:
http://dpaste.com/hold/85281/

The following is basic usage. As you can see, it simplifies the generation
of values for post or get.

def test_htmlParse(self):

response = self.client.get('/test/')
self.failUnlessEqual(response.status_code, 200, 'Failed to retrieve
the form test page. (1)')

curVals = response.form_values['frmTest']

response = self.client.post('/test/', curVals)
self.failUnlessEqual(response.status_code, 200, 'Failed to retrieve
the form test page. (2)')


On Tue, Aug 25, 2009 at 7:44 PM, Peter Bengtsson  wrote:

>
> Do you mean when you write tests?
> If so, when you get the response you can extract all the variables
> that was created inside the view if you're using locals().
> That way, you can probably get the form instance (created for example
> by form=MyForm(request.POST)) which you can then untangle to get all
> the fields from the form instance.
>
> On Aug 25, 4:31 pm, Joshua Russo  wrote:
> > I'm working on putting together parsing logic so that I can extract the
> form
> > variables from the response content of the test Client. That way I can
> just
> > change a few values and throw it back at the server. This is especially
> > helpful with large dynamic forms that use formsets.
> > My question is, has this already been done? My Google-fu came up with
> nada.
> >
>

--~--~-~--~~~---~--~~
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: Changes not reflected in templates

2009-08-25 Thread Angel Cruz
Since you say you refreshed your web browsers and refreshed your web server,
the only thing I can guess is that you did not save your edits or you did
not commit to your source repositories and do an update of the source on the
server.  If you are sure your edits are there, perhaps there is a hung
server not realeasing the cache.  Reboot.  If that fails, then you have a
gremlin.

On Tue, Aug 25, 2009 at 2:10 PM, neri...@gmail.com wrote:

>
> When I make changes to templates they are not showing up upon refresh
> or restarting the test server, any ideas?
> >
>

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



Changes not reflected in templates

2009-08-25 Thread neri...@gmail.com

When I make changes to templates they are not showing up upon refresh
or restarting the test server, any ideas?
--~--~-~--~~~---~--~~
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: Dynaically fields to a formwizard form

2009-08-25 Thread Peter Bengtsson

You can add and modify fields on a form in the form's __init__
function.

class MyForm(forms.Form):
country = forms.ChoiceField()
def __init__(self, *args, **kwargs):
 super(MyForm, self).__init__(*args, **kwargs)
self.fields['country'].choices = \
  [(c.iso_code, c.name) for c in get_all_choices()]

Perhaps you'll need to do it in the view.
You can create the form instance both before you bind it with
something like request.POST or if you do it later.
E.g.
def my_view(request):
form = MyForm()
form.fields['country'].choices = get_my_country_choices
(request.user)
if request.method == "POST":
# bind the form
form.is_bound = True
form.data = request.POST
if form.is_valid():
return render(request, 'my_template.html', locals())

cool!
On Aug 25, 7:16 am, dingue fever  wrote:
> Hi,
>
> Is it possible to dynamically add fields to a formwizard form. I have
> been able to add the fields I want but if the form fails validation
> the new dynamic fields disappear when the form re-renders. Is it
> possible to override this so that I can validate and return the new
> fields if the validation fails?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems width templatetags

2009-08-25 Thread Mike Ramirez
On Tuesday 25 August 2009 01:44:56 pm Sandra Django wrote:
> Hi Mike, excellent answer, thanks. Look, I followed this example:
> http://www.djangrrl.com/view/custom-template-tags-in-django/
> But my problem is that don't displays list categories, but neither I get
> error. I copied exactly that appears in that article, but I don't have good
> results.
> Can you help me, please??!!
>

Can you repost the current code you have? After looking at the example, it 
appears it should work as is.  

Please include the html for the tag and the template loading and using 
nav_categorylist.

Mike.



-- 
 it has been said that redhat is the thing Marc Ewing wears on
  his head.


signature.asc
Description: This is a digitally signed message part.


Re: Many-to-many column

2009-08-25 Thread Peter Bengtsson

I fear your only option is to write a recursive function which you
feed with what you define to be "the end of the chain".
You can collect all the entries in a mutable list. Some example,
untested, code:

def get_all_parents(list_, current):
for entry in current.following_to.all():
list_.append(entry)
list_.extend(get_all_parents(list_, entry)
return list_

current = A
parents = []
get_all_parents(parents, current)
print parents

Excuse me if I didn't get it right but it should get you started.

On Aug 25, 10:11 am, Sven Richter  wrote:
> Hi,
>
> i implemented a many-to-many field in my model like:
> class Entries(models.Model):
>   following_to = models.ManyToManyField('self', blank=True, null=True)
>
> Now i can get all related Entries in a template with entry.following_to.all.
> But i want to go deeper in relationships.
>
> Lets say i have 4 Entries A, B, C, D.
> A is following_to to B and
> B is following_to to C and
> C is following_to to D.
> A.following_to.all gives back B.
>
> But what i need is to follow until the end of the chain is reached.
> I need something like:
> A.following_to.give_all_related_entries which then returns:
> B, C, D
>
> Do i have to write my own template tag for that or is it already implemented
> in Django?
> Or maybe there is a better approach to solve my issue?
>
> I couldnt find a similar question or answer in the docs.
>
> Greetings
> Sven
--~--~-~--~~~---~--~~
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: Problems width templatetags

2009-08-25 Thread Sandra Django
Hi Mike, excellent answer, thanks. Look, I followed this example:
http://www.djangrrl.com/view/custom-template-tags-in-django/
But my problem is that don't displays list categories, but neither I get
error. I copied exactly that appears in that article, but I don't have good
results.
Can you help me, please??!!

On Tue, Aug 25, 2009 at 4:28 PM, Mike Ramirez  wrote:

> On Tuesday 25 August 2009 12:56:12 pm Sandra Django wrote:
> > Hi friends, I'm trying to custom the index.html of Django. For that, I'm
> > writing a custom template tag (categories.py). This module should display
> a
> > list, but don't display anything. Why? I'll describe that I did because
> if
> > you can you explain me what is the problem, ok?
> > 1) I created "templatetags" folder at the same level of model.py, inside
> my
> > app
> > 2) "templatetags" folder has inside __init___.py (it's empty), and
> > categories.py
> > 3) In categories.py I wrote:
> >from django.template import Library
> >from myproject.app.models import Category
> >
> >register = Library()
> >
> > def nav_categorylist(request):
> > categories = Category.objects.all().order_by('name')[:3]
> > return {'categories': categories}
> >
> > register.inclusion_tag('admin/index.html')(nav_categorylist)
> > 4) "index.html" is in the path: myproject/templates/admin/ index.html
> > 5) In index.html I put this:
> > {% load categories %}
> > {% for cat in categories %}
> >   {{ cat.name }}
> > {% endfor %}
> > 6) In INSTALLED_APP I put ('myproject.app.templatetags')
> >
> > What is the mistake? Thank's for any help
> >
>
> Two things, for INSTALL_APPS it should only be myproject.app
> Django will find the templatetags directory in your apps directory.
>
> You don't need to load the tags in your admin/index.html file, the context
> is
> passed to it already. Should only load it if you're using other custom
> filters or tags from the same app.
>
> Your html for admin/index.html should be:
>
> {% for cat in categories %}
>   {{ cat.name }}
> {% endfor %}
>
> In the html/template file that is using the nav_categorieslist tag, it
> should
> look like this:
>
> {% load categories %}
>
> {% nav_categorylist %}
>
>
> I normally put my load tags at the top of the template file.
>
> If you set the TEMPLATE_LOADERS setting to include
>
> 'django.template.loaders.app_directories.load_template_source',
>
> You can put the template tags html file in your app directory also, i.e.
> app/templates/admin/index.html; I do it this way to seperate the html from
> template tags from the rest of the html.
>
> Mike
>
> --
> I feel ... JUGULAR ...
>

--~--~-~--~~~---~--~~
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 error on arrays

2009-08-25 Thread Peter Bengtsson

what's wrong with turning it into a list? If you gzip it it won't be
that big.

On Aug 25, 5:16 pm, John Baker  wrote:
> I need to json serialize some very large objects which include large
> arrays. How can I do this in django? The arrays will be very big and
> heavily processed before so need to use efficient array storage.
>
> Testing with arrays I get..
>
> TypeError at /zeros/
>
> array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]) is not JSON
> serializable
>
> What would you recommend I do to support arrays?
>
> Thanks in advance,
> John
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Duplicating objects, avoid signals

2009-08-25 Thread Michel Thadeu Sabchuk

Hi guys,

I'm using the following snippet to duplicate instances of objects:

http://www.djangosnippets.org/snippets/1282/

The problem is that some objects have signals connected to auto create
some related information. What do you suggests me to avoid problems
with these signals? I found the following patch:

http://code.djangoproject.com/ticket/8077

This way I can disable signals for an specific operation, this is what
I want but I prefer not modify django source. Is there another way to
disable signals for an specific operation?

Thanks in advance.
--~--~-~--~~~---~--~~
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: Test client and form processing

2009-08-25 Thread Peter Bengtsson

Do you mean when you write tests?
If so, when you get the response you can extract all the variables
that was created inside the view if you're using locals().
That way, you can probably get the form instance (created for example
by form=MyForm(request.POST)) which you can then untangle to get all
the fields from the form instance.

On Aug 25, 4:31 pm, Joshua Russo  wrote:
> I'm working on putting together parsing logic so that I can extract the form
> variables from the response content of the test Client. That way I can just
> change a few values and throw it back at the server. This is especially
> helpful with large dynamic forms that use formsets.
> My question is, has this already been done? My Google-fu came up with nada.
--~--~-~--~~~---~--~~
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: Raw HTTP request processing?

2009-08-25 Thread Peter Bengtsson

Here's an example:
http://www.djangosnippets.org/snippets/1322/

On Aug 25, 5:43 pm, John  wrote:
> > Isn't it just
> > request.raw_post_data
>
> Thanks and I suspected it was that but hoped there might be a little
> example somewhere as the docs don't say much only this:
>
> HttpRequest.raw_post_data
>     The raw HTTP POST data. This is only useful for advanced
> processing. Use POST instead.
>
> As I am going to be dealing with potentially very large streams in and
> out, I need it to access the streams rather than a variable stored in
> memory. Any examples of doing this that you know about?
--~--~-~--~~~---~--~~
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: Problems width templatetags

2009-08-25 Thread Mike Ramirez
On Tuesday 25 August 2009 12:56:12 pm Sandra Django wrote:
> Hi friends, I'm trying to custom the index.html of Django. For that, I'm
> writing a custom template tag (categories.py). This module should display a
> list, but don't display anything. Why? I'll describe that I did because if
> you can you explain me what is the problem, ok?
> 1) I created "templatetags" folder at the same level of model.py, inside my
> app
> 2) "templatetags" folder has inside __init___.py (it's empty), and
> categories.py
> 3) In categories.py I wrote:
>from django.template import Library
>from myproject.app.models import Category
>
>register = Library()
>
> def nav_categorylist(request):
> categories = Category.objects.all().order_by('name')[:3]
> return {'categories': categories}
>
> register.inclusion_tag('admin/index.html')(nav_categorylist)
> 4) "index.html" is in the path: myproject/templates/admin/ index.html
> 5) In index.html I put this:
> {% load categories %}
> {% for cat in categories %}
>   {{ cat.name }}
> {% endfor %}
> 6) In INSTALLED_APP I put ('myproject.app.templatetags')
>
> What is the mistake? Thank's for any help
>

Two things, for INSTALL_APPS it should only be myproject.app
Django will find the templatetags directory in your apps directory.

You don't need to load the tags in your admin/index.html file, the context is 
passed to it already. Should only load it if you're using other custom 
filters or tags from the same app.

Your html for admin/index.html should be:

 {% for cat in categories %}
   {{ cat.name }}
 {% endfor %}

In the html/template file that is using the nav_categorieslist tag, it should 
look like this:

{% load categories %}

{% nav_categorylist %}


I normally put my load tags at the top of the template file.

If you set the TEMPLATE_LOADERS setting to include

'django.template.loaders.app_directories.load_template_source',

You can put the template tags html file in your app directory also, i.e. 
app/templates/admin/index.html; I do it this way to seperate the html from 
template tags from the rest of the html. 

Mike

-- 
I feel ... JUGULAR ...


signature.asc
Description: This is a digitally signed message part.


Problems width templatetags

2009-08-25 Thread Sandra Django
Hi friends, I'm trying to custom the index.html of Django. For that, I'm
writing a custom template tag (categories.py). This module should display a
list, but don't display anything. Why? I'll describe that I did because if
you can you explain me what is the problem, ok?
1) I created "templatetags" folder at the same level of model.py, inside my
app
2) "templatetags" folder has inside __init___.py (it's empty), and
categories.py
3) In categories.py I wrote:
   from django.template import Library
   from myproject.app.models import Category

   register = Library()

def nav_categorylist(request):
categories = Category.objects.all().order_by('name')[:3]
return {'categories': categories}

register.inclusion_tag('admin/index.html')(nav_categorylist)
4) "index.html" is in the path: myproject/templates/admin/ index.html
5) In index.html I put this:
{% load categories %}
{% for cat in categories %}
  {{ cat.name }}
{% endfor %}
6) In INSTALLED_APP I put ('myproject.app.templatetags')

What is the mistake? Thank's for any help

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Trouble getting doctests to execute in app with no model...

2009-08-25 Thread Joseph (Driftwood Cove Designs)

On Aug 25, 12:22 pm, Alex Gaynor  wrote:
> You can put your tests in a tests.py file, however you still need to
> have an empty models.py file, so Django picks up the app correctly.

Thanks Alex - unfortunately, if I put an empty models.py file in, I
get an exception when the test runner creates the test DB.  By looking
at the verbose output, it appears that:
Creating many-to-many tables for auth.Group model
is being run a second time, resulting, predictably, in the error:
 table "auth_group_permissions" already exists

This seems like a bit of magic to me - I'm not sure why Django is
trying to create the auth many-to-many tables a second time simply
because I add an empty models.py file to my app.  My custom auth app
IS also called auth, but lives under a completely different project
path h.
--~--~-~--~~~---~--~~
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: Creating forms

2009-08-25 Thread Alex Gaynor

On Tue, Aug 25, 2009 at 2:40 PM, tom wrote:
> Hi all,
>
> i want to create a form with django. the form should look like a matrix
> (or like an excel/oocalc sheet). i attached a screenshot how the form
> should look like.
> can anybody tell me how to do this with django?
>
>
> Cheers
>
> tom
>
> >
>

Take a look at formsets:
http://docs.djangoproject.com/en/dev/topics/forms/formsets/

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Creating forms

2009-08-25 Thread tom
Hi all,

i want to create a form with django. the form should look like a matrix
(or like an excel/oocalc sheet). i attached a screenshot how the form
should look like.
can anybody tell me how to do this with django?


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: Closures, Django Request Object, Django architecture

2009-08-25 Thread Matthias Kestenholz

On Tue, Aug 25, 2009 at 8:35 PM, Dennis Fogg wrote:
> PS: more succinctly: status notifications can happen in many places and
> passing the session to all these places just for the status notification
> does not make the code any clearer.  Thus, I just want to access the session
> as a global variable -- how can I do that?
>

Sending messages to an user is very much tied to the current request
-- only the current request can tell you which user is active
currently, so whatever way you choose to store and retrieve
notifications (database, sessions etc) you always need the request
object in one way or the other. Really, there is a reason why Django
does not provide global (or thread local) request / user objects. If
you still want do do it, google for "threadlocals user", but I'd
advise against doing that. In the end, it's your decision though.

Btw, I've used this thread locals hack in the past, and it served me
well for some time. It came back to bite me though, and I wish I
hadn't used it; it really makes writing a testsuite a pain; dumpdata
does not work because the manager of a single model depends on a
thread local request object with an authenticated user etc. It's much
better to cope with the need of having to pass the request around than
pick up the pieces afterwards when choosing the simple path now.


Matthias



-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

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



need help: unique_together in both directions

2009-08-25 Thread ckar...@googlemail.com

Hi,

first, my models:

class Connection(models.Model):
p1 = models.ForeignKey(SinglePoint, related_name='p1_set',
help_text="Punkt 1")
p2 = models.ForeignKey(SinglePoint, related_name='p2_set',
help_text="Punkt 2")
...
class Meta:
unique_together = (('p1', 'p2'),('p2','p1'))

class SinglePoint(models.Model):
name = models.CharField(max_length=100)
...


With that code I can create 2 Connections like:

Connection 1: p1 = A, p2 = B
Connection 2: p1 = B, p2 = A

But I want to disallow that way, I wish to have just

Connection 1: p1 = A, p2 = B
OR
Connection 2: p1 = B, p2 = A

and not both. How is this possible?

Thank you very much!!

Christian


--~--~-~--~~~---~--~~
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: Trouble getting doctests to execute in app with no model...

2009-08-25 Thread Alex Gaynor

On Tue, Aug 25, 2009 at 2:12 PM, Joseph (Driftwood Cove
Designs) wrote:
>
> We use a custom authentication backend, and I'm trying to develop a
> test suite for it.  The app has no model, since it uses the model from
> contrib.auth  So, I put my tests in tests.py, but the test runner does
> not load it, even though the custom auth app is in INSTALLED_APPS.  I
> tried adding an empty models.py file to the folder, but that seemed to
> cause some major issues during syncdb (trying to create duplicate
> tables)
>
> When I move test.py to another app (with a models.py), it runs fine,
> but doesn't run at all when I move it back into the custom auth app
> (with no model).
>
> From the Django documentation:
> For a given Django application, the test runner looks for doctests in
> two places:
>    * The models.py file. ...
>    * A file called tests.py in the application directory -- i.e., the
> directory that holds models.py. ...
> ...
> $ ./manage.py test
> By default, this will run every test in every application in
> INSTALLED_APPS.
>
> The first bit of documentation seems to indicate that the test runner
> will only look in directories that contain a models.py (why?).  The
> second bit seems more sensible, but does not appear to be true.
>
> Any advice on how to get the test runner to run my tests or where to
> put the tests (sensibly) so they run?
> >
>

You can put your tests in a tests.py file, however you still need to
have an empty models.py file, so Django picks up the app correctly.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Trouble getting doctests to execute in app with no model...

2009-08-25 Thread Joseph (Driftwood Cove Designs)

We use a custom authentication backend, and I'm trying to develop a
test suite for it.  The app has no model, since it uses the model from
contrib.auth  So, I put my tests in tests.py, but the test runner does
not load it, even though the custom auth app is in INSTALLED_APPS.  I
tried adding an empty models.py file to the folder, but that seemed to
cause some major issues during syncdb (trying to create duplicate
tables)

When I move test.py to another app (with a models.py), it runs fine,
but doesn't run at all when I move it back into the custom auth app
(with no model).

>From the Django documentation:
For a given Django application, the test runner looks for doctests in
two places:
* The models.py file. ...
* A file called tests.py in the application directory -- i.e., the
directory that holds models.py. ...
...
$ ./manage.py test
By default, this will run every test in every application in
INSTALLED_APPS.

The first bit of documentation seems to indicate that the test runner
will only look in directories that contain a models.py (why?).  The
second bit seems more sensible, but does not appear to be true.

Any advice on how to get the test runner to run my tests or where to
put the tests (sensibly) so they run?
--~--~-~--~~~---~--~~
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: Closures, Django Request Object, Django architecture

2009-08-25 Thread Dennis Fogg
PS: more succinctly: status notifications can happen in many places and
passing the session to all these places just for the status notification
does not make the code any clearer.  Thus, I just want to access the session
as a global variable -- how can I do that?



On Wed, Aug 26, 2009 at 2:30 AM, Dennis Fogg  wrote:

> I looked at my code based on your feedback.
> In this particular case, the code that needs the request is doing status
> notifications
> http://blog.ianbicking.org/web-application-patterns-status-notification.html 
> and
> it needs access to the session from the request object.
>
> You are correct in that what I really want is per thread architectural
> hooks so I can store the request there.
> Django does not provide these hooks (probably on purpose) so I'm
> discouraged in using it.
>
> But, sessions are a part of the overall web architecture and therefore need
> to be exposed.
> Sessions act like per user dictionaries to store information that are
> similar to global variables.
> So, I'm wanting access to this architectural element from anywhere (instead
> of through the request object).
> For status notifications, it makes sense to add something to the
> notification from places other than the view
> (and not have to pass the request or session since it's really an exception
> use case).
> This seems like a reasonable use case and rationale for accessing the
> session.
> But the question is: how do I implement this in django (or, rather, will
> closures in middleware work).
>
>
>
>
>
> On Wed, Aug 26, 2009 at 1:42 AM, Matthias Kestenholz <
> matthias.kestenh...@gmail.com> wrote:
>
>>
>> On Tue, Aug 25, 2009 at 7:32 PM, Dennis wrote:
>> >
>> > I seem to need the Django HttpRequest object in functions that are
>> > called by view functions.
>> > I could pass the request, but I'm thinking of trying to create a
>> > closure in middleware so that
>> > I can access the request object (and maybe other objects) from
>> > anywhere.
>> > This seems like it's stretching the django architecture a bit -- not
>> > sure if I do this or if I should do this.
>> > I'm still new to python and django, so I thought I'd solicit advice
>> > first.
>> >
>> > I'm thinking that the django middleware will access the request object
>> > and create a closure.
>> > I think I can use a classmethod for the closure so I can access it
>> > from anywhere.
>> > This will create a new object for every request -- I'm assuming that
>> > it will not impact
>> > performance but I'm not sure.
>> >
>>
>> What you are describing is not really different from storing the
>> request object in a thread local variable, which in turn does have the
>> same problems as storing a variable globally. It makes it non-obvious
>> what's going on, and the functions work differently depending on
>> external factors instead of depending only on the arguments you pass.
>>
>> In other words, it is bad style, makes it harder to write tests and
>> generally makes the code non-obvious.
>>
>> If you need the whole request object inside a function, pass it
>> explicitly. If you only need aspects of the request (f.e. the current
>> path), only pass in the current path. It seems like more work for now,
>> but will lead to cleaner, better and more maintainable code in the
>> future.
>>
>> Remember, "Explicit is better than implicit."
>>
>>
>> Matthias
>>
>>
>>
>> --
>> FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
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: Closures, Django Request Object, Django architecture

2009-08-25 Thread Dennis Fogg
I looked at my code based on your feedback.
In this particular case, the code that needs the request is doing status
notifications
http://blog.ianbicking.org/web-application-patterns-status-notification.html
and
it needs access to the session from the request object.

You are correct in that what I really want is per thread architectural hooks
so I can store the request there.
Django does not provide these hooks (probably on purpose) so I'm discouraged
in using it.

But, sessions are a part of the overall web architecture and therefore need
to be exposed.
Sessions act like per user dictionaries to store information that are
similar to global variables.
So, I'm wanting access to this architectural element from anywhere (instead
of through the request object).
For status notifications, it makes sense to add something to the
notification from places other than the view
(and not have to pass the request or session since it's really an exception
use case).
This seems like a reasonable use case and rationale for accessing the
session.
But the question is: how do I implement this in django (or, rather, will
closures in middleware work).





On Wed, Aug 26, 2009 at 1:42 AM, Matthias Kestenholz <
matthias.kestenh...@gmail.com> wrote:

>
> On Tue, Aug 25, 2009 at 7:32 PM, Dennis wrote:
> >
> > I seem to need the Django HttpRequest object in functions that are
> > called by view functions.
> > I could pass the request, but I'm thinking of trying to create a
> > closure in middleware so that
> > I can access the request object (and maybe other objects) from
> > anywhere.
> > This seems like it's stretching the django architecture a bit -- not
> > sure if I do this or if I should do this.
> > I'm still new to python and django, so I thought I'd solicit advice
> > first.
> >
> > I'm thinking that the django middleware will access the request object
> > and create a closure.
> > I think I can use a classmethod for the closure so I can access it
> > from anywhere.
> > This will create a new object for every request -- I'm assuming that
> > it will not impact
> > performance but I'm not sure.
> >
>
> What you are describing is not really different from storing the
> request object in a thread local variable, which in turn does have the
> same problems as storing a variable globally. It makes it non-obvious
> what's going on, and the functions work differently depending on
> external factors instead of depending only on the arguments you pass.
>
> In other words, it is bad style, makes it harder to write tests and
> generally makes the code non-obvious.
>
> If you need the whole request object inside a function, pass it
> explicitly. If you only need aspects of the request (f.e. the current
> path), only pass in the current path. It seems like more work for now,
> but will lead to cleaner, better and more maintainable code in the
> future.
>
> Remember, "Explicit is better than implicit."
>
>
> Matthias
>
>
>
> --
> FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/
>
> >
>

--~--~-~--~~~---~--~~
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: Auth test with custom auth backend

2009-08-25 Thread Joseph (Driftwood Cove Designs)

On Jul 26, 6:06 pm, Russell Keith-Magee 
wrote:
> One approach that may be worth considering is to look at whether you
> actually need to put contrib.authin INSTALLED APPS. If you're just
> using some of the backend utilities - such as the authentication
> backends - you may not need to sync theauthapplication itself.

I'm having a similar issue, but perhaps more subtle?
We are using contrib.auth to do most of the work, so it needs to be an
INSTALLED_APPS, but we use a custom backend to authenticate to a 3rd
party server.  This causes most of the auth tests to fail because they
assume (reasonably) that authentication is performed against the
auth_user data loaded from the fixture.
To solve this, I created a new setting, TESTING, and added the
following lines to my settings.py:

TESTING = True
AUTHENTICATION_BACKENDS = ('my.apps.auth.aashe.MyAuthBackend',)
if TESTING:
AUTHENTICATION_BACKENDS = AUTHENTICATION_BACKENDS +
('django.contrib.auth.backends.ModelBackend',)

In this way, when the custom backend fails to authenticate, the
default ModelBackend is consulted and the tests pass.  Then I added
additional tests specifically for our custom authentication backend.
Hoping this helps others.

--~--~-~--~~~---~--~~
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: Closures, Django Request Object, Django architecture

2009-08-25 Thread Matthias Kestenholz

On Tue, Aug 25, 2009 at 7:32 PM, Dennis wrote:
>
> I seem to need the Django HttpRequest object in functions that are
> called by view functions.
> I could pass the request, but I'm thinking of trying to create a
> closure in middleware so that
> I can access the request object (and maybe other objects) from
> anywhere.
> This seems like it's stretching the django architecture a bit -- not
> sure if I do this or if I should do this.
> I'm still new to python and django, so I thought I'd solicit advice
> first.
>
> I'm thinking that the django middleware will access the request object
> and create a closure.
> I think I can use a classmethod for the closure so I can access it
> from anywhere.
> This will create a new object for every request -- I'm assuming that
> it will not impact
> performance but I'm not sure.
>

What you are describing is not really different from storing the
request object in a thread local variable, which in turn does have the
same problems as storing a variable globally. It makes it non-obvious
what's going on, and the functions work differently depending on
external factors instead of depending only on the arguments you pass.

In other words, it is bad style, makes it harder to write tests and
generally makes the code non-obvious.

If you need the whole request object inside a function, pass it
explicitly. If you only need aspects of the request (f.e. the current
path), only pass in the current path. It seems like more work for now,
but will lead to cleaner, better and more maintainable code in the
future.

Remember, "Explicit is better than implicit."


Matthias



-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

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



Closures, Django Request Object, Django architecture

2009-08-25 Thread Dennis

I seem to need the Django HttpRequest object in functions that are
called by view functions.
I could pass the request, but I'm thinking of trying to create a
closure in middleware so that
I can access the request object (and maybe other objects) from
anywhere.
This seems like it's stretching the django architecture a bit -- not
sure if I do this or if I should do this.
I'm still new to python and django, so I thought I'd solicit advice
first.

I'm thinking that the django middleware will access the request object
and create a closure.
I think I can use a classmethod for the closure so I can access it
from anywhere.
This will create a new object for every request -- I'm assuming that
it will not impact
performance but I'm not sure.

Any thoughts?

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



list_filter on Related field

2009-08-25 Thread Matt

I am putting together a project that involves the following models:

class contentcreator(models.Model):
name = models.CharField(max_length=50)
phone = models.CharField(max_length=60, blank=True)
supervisor = models.CharField(max_length=60)
department = models.CharField(max_length=60, blank=True)

class accuracyreport(models.Model):
author = models.ForeignKey(contentcreator)
date = models.DateField()
slug = models.CharField(max_length=50)
description = models.TextField()
resolved = models.BooleanField(null=True)
responsible = models.ForeignKey(contentcreator)
resolutionnotes = models.TextField(blank=True)

The accuracyreport model is the meat. I'd like for supervisors to be
able to filter to errors made by their employees only.

How would I go about adding the 'supervisor' value to the list_filter?
Any adive is much appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Raw HTTP request processing?

2009-08-25 Thread John


> Isn't it just
> request.raw_post_data

Thanks and I suspected it was that but hoped there might be a little
example somewhere as the docs don't say much only this:

HttpRequest.raw_post_data
The raw HTTP POST data. This is only useful for advanced
processing. Use POST instead.

As I am going to be dealing with potentially very large streams in and
out, I need it to access the streams rather than a variable stored in
memory. Any examples of doing this that you know about?
--~--~-~--~~~---~--~~
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: Documenting Django with sphinx: autodoc doesn't pick up field definitions

2009-08-25 Thread Matthias Kestenholz

On Tue, Aug 25, 2009 at 4:44 PM, Benjamin  Wohlwend wrote:
>
> Hi,
>
> I'm trying to generate documentation for my django project with sphinx
> [1] and autodoc[2]. It's mostly working, but I can't get sphinx to
> pick up my model field definitions (with the exception of related
> fields like m2m or ForeignKey). I asked in the IRC channel of sphinx
> (#pocoo on freenode), and they told me that it generally should work
> and that it's probably an issue with my configuration.
>
> My configuration is quite simple: I have all my apps and dependencies
> in a virtualenv and export DJANGO_SETTINGS_MODULE before running "make
> html" in the doc folder. Sphinx can import everything and doesn't
> throw any errors or warnings.
>
> So, did anybody here manage to get autodoc to recognize model fields?
> If yes, could you share how you set up your sphinx environment?
>
> Just to make sure I'm not doing something completely stupid (which,
> I'm told, does indeed happen from time to time), here's an example of
> my model
>
> http://dpaste.com/hold/85108/
>
> and my rst source:
>
> http://dpaste.com/85109/
>

It's quite easy to find out why this happens. The ForeignKey adds an
actual descriptor to the class, CharFields however do not add
top-level attributes to the class itself.

Sphinx does not that it should look into Page._meta.fields to find all
defined fields and therefore does not find most Django fields, only
the fields adding descriptors.

You might want to find out how to modify sphinx / add a new sphinx
extension which knows how Django models should be handled.


IPython session transscript:

In [1]: from feincms.module.page.models import Page

In [2]: Page.parent
Out[2]: 

In [3]: Page._cached_url
---
AttributeErrorTraceback (most recent call last)

/home/mk/tmp/feincms/example/ in ()

AttributeError: type object 'Page' has no attribute '_cached_url'




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: print PDF on windows

2009-08-25 Thread Peter Bengtsson

Suppose you have a PDF (generated or downloaded from the internet),
are you able to get it printed by scripting?

On Aug 25, 4:38 pm, mettwoch  wrote:
> How do the Django people handle printing directly on Windows? I
> remembered abouthttp://timgolden.me.uk/python/win32_how_do_i/print.html,
> but unfortunately his method for PDFs only print on the default
> printer. I need the server to produce the PDF, save it (works already)
> and send it to a specific shared printer on the network. The printer
> should be determined from a table that holds 'host' - 'printer' pairs
> e.g. ('PC01', '\\PC01\PR01'). The host ('PC01') determined from the
> http request allows to choose the right printer ('\\PC01\PR01') from
> that table.
>
> Printing should be executed directly when the user has submitted the
> request. Any solution that pops up the document locally in a PDFReader
> and where the user has to hit the print button is not viable.
>
> Kindly Yours
> Marc
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



json serialization error on arrays

2009-08-25 Thread John Baker

I need to json serialize some very large objects which include large
arrays. How can I do this in django? The arrays will be very big and
heavily processed before so need to use efficient array storage.

Testing with arrays I get..

TypeError at /zeros/

array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]) is not JSON
serializable

What would you recommend I do to support arrays?

Thanks in advance,
John
--~--~-~--~~~---~--~~
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: Raw HTTP request processing?

2009-08-25 Thread Peter Bengtsson


On Aug 25, 4:54 pm, John Baker  wrote:
> Some of my views need to process arbitrary incoming data that isn't a
> normal web request i.e. process an incoming document and return an
> altered document.
>
> How do I get a view to process raw incoming data rather than the usual
> encoded parameters and form etc?
>

Isn't it just
request.raw_post_data

> It is obvious how to do this on output as you create the response
> object yourself, but with a request?
>
> Thanks in advance,
> John
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



10061 Connection refused - pyodbc - SQL Server 2008 - Win7

2009-08-25 Thread -colin-

Group,

I am attempting to connect Django with SQL Server 2008. My dev server
is running on a Win 7 box and SQL Server is on a Win 2003 box. When
posting from the authentication form, I get exception 10061,
'Connection refused'. Traceback below. I am using django-pyodbc
revision 115. I had it all working with the same versions on Win XP
with SQL Server on the same Win 2003 box. I suspected there was an
issue with the added security on Win 7, so I am allowing python.exe
through the firewall. That didn't solve it. Any other ideas?

Thank you for your help,

-colin-

==

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/brazil/admin/
Django Version: 1.0.2 final
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'Brazil_App']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg\django
\core\handlers\base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg\django
\contrib\admin\sites.py" in root
  141. return self.login(request)
File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg\django
\views\decorators\cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg\django
\contrib\admin\sites.py" in login
  241. user = authenticate(username=username,
password=password)
File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg\django
\contrib\auth\__init__.py" in authenticate
  36. user = backend.authenticate(**credentials)
File "C:\Code\POS Resources\Brazil\Brazil_App\auth\__init__.py" in
authenticate
  7. if svc.authenticate(username, password):
File "C:\Code\POS Resources\Brazil\Brazil_App\soap\__init__.py" in
authenticate
  36. ws.endheaders()
File "C:\Python25\lib\httplib.py" in endheaders
  860. self._send_output()
File "C:\Python25\lib\httplib.py" in _send_output
  732. self.send(msg)
File "C:\Python25\lib\httplib.py" in send
  699. self.connect()
File "C:\Python25\lib\httplib.py" in connect
  683. raise socket.error, msg

Exception Type: error at /brazil/admin/
Exception Value: (10061, 'Connection refused')

--~--~-~--~~~---~--~~
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: Django1.1 logs me out after few seconds inactivity

2009-08-25 Thread Florian Schweikert
Now I'm able to login etc, but only with django-server, with apache also the
admin interface informs me that my browser doesn't allow cookies. So there's
a problem with apache and/or mod_python. :-/
I'll test this after the planned upgrade to lenny again.

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



Raw HTTP request processing?

2009-08-25 Thread John Baker

Some of my views need to process arbitrary incoming data that isn't a
normal web request i.e. process an incoming document and return an
altered document.

How do I get a view to process raw incoming data rather than the usual
encoded parameters and form etc?

It is obvious how to do this on output as you create the response
object yourself, but with a request?

Thanks in advance,
John
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



print PDF on windows

2009-08-25 Thread mettwoch

How do the Django people handle printing directly on Windows? I
remembered about http://timgolden.me.uk/python/win32_how_do_i/print.html,
but unfortunately his method for PDFs only print on the default
printer. I need the server to produce the PDF, save it (works already)
and send it to a specific shared printer on the network. The printer
should be determined from a table that holds 'host' - 'printer' pairs
e.g. ('PC01', '\\PC01\PR01'). The host ('PC01') determined from the
http request allows to choose the right printer ('\\PC01\PR01') from
that table.

Printing should be executed directly when the user has submitted the
request. Any solution that pops up the document locally in a PDFReader
and where the user has to hit the print button is not viable.

Kindly Yours
Marc
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Test client and form processing

2009-08-25 Thread Joshua Russo
I'm working on putting together parsing logic so that I can extract the form
variables from the response content of the test Client. That way I can just
change a few values and throw it back at the server. This is especially
helpful with large dynamic forms that use formsets.
My question is, has this already been done? My Google-fu came up with nada.

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



Django lucene

2009-08-25 Thread Puneet

Hi,

Does anyone have tried django-lucene module for search ??

I am able to compile the lucene and jcc as  required but the module is
not working properly as it is expected to work.  As mentioned in the
docs I have added to fields in my model

   objects = models.Manager()
   objects_search = Manager() # add search manager

But when I say ModelName.save() its not getting indexed with lucene
and when I say

 ModelName.objects.objects_search(name_first="Spike")

I am getting error that

AttributeError: 'Manager' object has no attribute 'objects_search'

Can any one help me with this ?? Does anyone have a small working
example ?

Thanks,
Puneet

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



Documenting Django with sphinx: autodoc doesn't pick up field definitions

2009-08-25 Thread Benjamin Wohlwend

Hi,

I'm trying to generate documentation for my django project with sphinx
[1] and autodoc[2]. It's mostly working, but I can't get sphinx to
pick up my model field definitions (with the exception of related
fields like m2m or ForeignKey). I asked in the IRC channel of sphinx
(#pocoo on freenode), and they told me that it generally should work
and that it's probably an issue with my configuration.

My configuration is quite simple: I have all my apps and dependencies
in a virtualenv and export DJANGO_SETTINGS_MODULE before running "make
html" in the doc folder. Sphinx can import everything and doesn't
throw any errors or warnings.

So, did anybody here manage to get autodoc to recognize model fields?
If yes, could you share how you set up your sphinx environment?

Just to make sure I'm not doing something completely stupid (which,
I'm told, does indeed happen from time to time), here's an example of
my model

http://dpaste.com/hold/85108/

and my rst source:

http://dpaste.com/85109/

Regards,
Benjamin


[1] http://sphinx.pocoo.org/
[2] http://sphinx.pocoo.org/ext/autodoc.html
--~--~-~--~~~---~--~~
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: custom filtering

2009-08-25 Thread Alsond

Almost resolved with this code:

class EntryForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EntryForm, self).__init__(*args, **kwargs)
self.fields['authorcategory'].queryset =
AuthorCategory.objects.filter(
author=2)

class EntryAdmin(admin.ModelAdmin):
form = EntryForm


Just need to get:

AuthorCategory.objects.filter(
author=request.user)

instead of

AuthorCategory.objects.filter(
author=2

On Aug 25, 4:28 pm, Alsond  wrote:
> So, how to see AuthorCategory items filtered by currently loged in
> user in admin ?
>
> On Aug 25, 3:54 pm, Alsond  wrote:
>
>
>
> > System needs to types of categories. First one is used by all. Second
> > one is created by author.
> > In admin on new Entry I would like tu see all items from Category
> > and in AuthorCategory would like to see AuthorCategory items where
> > User is current user.
>
> > from django.contrib.auth.models import User
>
> > class AuthorCategory(models.Model):
> >     title = models.CharField(max_length=250)
> >     author = models.ForeignKey(User)
>
> > class Category(models.Model):
> >     title = models.CharField(max_length=250)
>
> > class Entry(models.Model):
> >     title = models.CharField(max_length=250)
> >     category = models.ForeignKey(Category)
> >     authorcategory = models.ForeignKey(AuthorCategory)
--~--~-~--~~~---~--~~
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 use form_class with generic views?

2009-08-25 Thread BobZ

Does anyone else have an idea of what could possibly cause this type
of error?

No  found
matching the query

I'm not looking for a spoonfed solution, just an idea of why this type
of error occurs.

Thanks for all your help,

Bob


On Aug 24, 1:24 pm, Daniel Roseman  wrote:
> On Aug 24, 5:06 pm, BobZ  wrote:
>
>
>
> > The real brain buster is that I get this error whether I'm passing a
> > form_class or a simple Model in urls.py
>
> > On Aug 24, 11:05 am, BobZ  wrote:
>
> > > Thanks for the quick response!
>
> > > forms.py
>
> > > from django import forms
> > > from django.forms import ModelForm
> > > from models import Photo
>
> > > class UserPhotoUploadForm(ModelForm):
> > >     def __init__(self, *args, **kwargs ):
> > >         self.user = kwargs.pop("user")
> > >         super(UserPhotoUploadForm, self).__init__(*args, **kwargs)
>
> > >     class Meta:
> > >         model = Photo
> > >         exclude = ( 'user', 'title_slug', 'view_count',
> > > 'date_added', )
>
> The only thing I can think of is that you're somehow redefining Photo
> somewhere, so that it's not actually a model. I can't think what would
> give that specific error, though.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: question about custom save() and unique slug

2009-08-25 Thread aschmid

i solved it with:

def add_project(request):
if request.method == 'POST':
form = ProjectForm(data=request.POST)
if form.is_valid():
new_project = form.save(commit=False)
new_project.slug = new_project.title.lower().replace('
','-')
new_project.pub_date = datetime.datetime.now()
if Project.objects.filter(pub_date__year='%s' %
new_project.pub_date.year,
  slug__iexact='%s' %
new_project.slug) :
form = ProjectForm(data=request.POST)
else:
...


On Aug 25, 2:50 pm, andreas schmid  wrote:
> hi,
>
> i have a custom add method for a front end editing of my project model.
>
> now i have the problem that my url is composed by /year/slug and slug is
> set as unique for pub_date__year in the model. obviously this is not
> respected by my form so i want to check if the slug already exists for
> the given year but i cant find the right solution.
>
> here my code and i know its wrong:
>
>     def add_project(request):      
>         if request.method == 'POST':
>             form = ProjectForm(data=request.POST)
>             if form.is_valid():
>                 new_project = form.save(commit=False)
>                 projects = Project.objects.all()
>                 if new_project.slug == projects.slug :
>                     form = ProjectForm()
>                 else:
>                     new_project = form.save(commit=False)
>                     new_project.author = request.user
>                     new_project.pub_date = datetime.datetime.now()
>                     new_project.slug =
>     new_project.title.lower().replace(' ','-')
>
>                     new_project.percentage_to_pay_by_tis =
>     100-new_project.financing  
>                     calculationpercentage =
>     (100-new_project.financing)/100            
>                     new_project.amount_to_finance=
>     new_project.budget*calculationpercentage
>                     new_project.restamount_to_pay =
>     new_project.amount_to_finance- new_project.already_paid_amount_by_tis
>
>                     new_project.save()
>                     return
>     HttpResponseRedirect(new_project.get_absolute_url())
>         else:
>             form = ProjectForm()
>         return render_to_response('eufinance/project_form.html',
>                                       { 'form': form, 'add':True },
>
>     context_instance=RequestContext(request))
>
>     can anybody help me please...
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Django] Django + Godaddy

2009-08-25 Thread Andrés Martín - martyn
Hi django Users.

I need to know if somebody has used Django on godaddy Host service ?

If yes, is easy to configure ? what recomended to me in that case ?

Thank you!

Regards
-- 
Andrés Martín Ochoa;
passport: andresmar...@linuxmail.org;
Linux Registered User #436420;
Asterisk User Number: 1000;
PBX: (57) 1 327 8000;
Ext: 3011

--~--~-~--~~~---~--~~
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: too much GROUP BY columns in generated sql query

2009-08-25 Thread Russell Keith-Magee

On Tue, Aug 25, 2009 at 6:28 PM, peterf81 wrote:
>
> Hello,
> what could be the problem when from this code :
>
>    reputation = Repute.objects.extra(
>        select={'positive': 'sum(positive)', 'negative': 'sum
> (negative)', 'question_id':'question_id',
>            'title': 'question.title'},
>        tables=['repute', 'question'],
>        order_by=['-reputed_at'],
>        where=['user_id=%s AND question_id=question.id'],
>        params=[user.id]
>    ).values('positive', 'negative', 'question_id', 'title',
> 'reputed_at', 'reputation')
>    reputation.query.group_by = ['question_id']
>
> this SQL query is generated :
>
> SELECT (sum(positive)) AS `positive`, (question.title) AS `title`, (sum
> (negative)) AS `negative`, (question_id) AS `question_id`,
> `repute`.`reputed_at`, `repute`.`reputation`
> FROM `repute` , `question`
> WHERE user_id=1 AND question_id=question.id
> GROUP BY question_id, sum(positive), question.title, sum(negative),
> question_id
> ORDER BY `repute`.`reputed_at`
> DESC LIMIT 21
>
> I think there are too much GROUP BY columns. It should be only "GROUP
> BY question_id". I get the error "Caught an exception while rendering:
> (, 'Invalid use of group function')".

There's exactly the right amount of GROUP BY information, given a
known limitation of the extra() clause. Django currently assumes that
every column in the select argument to extra is a normal column that
needs to be included in the group by, since there is no way for Django
to tell if an extra selected column is an aggregate or not.

You're also modifying the internal query attribute of the queryset,
which is highly non-recommended behaviour.

Luckily, it appears that what you are trying to do can be achieved
using the aggregate() modifier on querysets (provided you are using
Django v1.1). See the documentation for more details, but your query
will end up being something like:

Repute.objects.annotate(positive=Sum('question__positive'),negative=Sum('question__negative'))

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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: html Escape

2009-08-25 Thread Ismail Dhorat

If you have plain text (After you have removed out all HTML tags), a
simple URLIZE filter would work, and allow links to be clickable.

more details:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#urlize



On Tue, Aug 25, 2009 at 2:27 PM, Matias wrote:
> Hi,
> I think there is no such filter, so you'll have to code it.
> This http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping
> may help
> HTH,
> Matias.
>
> On Tue, Aug 25, 2009 at 5:54 AM, When ideas fail 
> wrote:
>>
>> Thanks, can i strip out all tags other than  tags.
>>
>> I would like people to be able to put links in comments.
>>
>> Andrew
>>
>> On 25 Aug, 03:42, Parag Shah  wrote:
>> > Hi,
>> >
>> > You can use the strip_tags function to strip all html from text.
>> >
>> > from django.utils.html import strip_tags
>> >
>> > In your view
>> > comment = strip_tags(request.POST["comment"])
>> >
>> > --
>> > Regards
>> > Parag
>> >
>> > On Tue, Aug 25, 2009 at 4:25 AM, When ideas fail
>> > wrote:
>> >
>> >
>> >
>> > > Hello, i want to allow users to post comments and I don't want them to
>> > > be allowed to put html in comments.
>> >
>> > > However I would like the to be able to use paragraph p tags and 
>> > > tags but not anything other. Could someone tell me how to do this?
>> >
>> > > Thanks
>> >
>> > > Andrew
>> >
>> > --
>> > Thanks & Regards
>> > Parag Shahhttp://blog.adaptivesoftware.biz
>>
>
>
>
> --
> :wq
>
> >
>

--~--~-~--~~~---~--~~
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: custom filtering

2009-08-25 Thread Alsond

So, how to see AuthorCategory items filtered by currently loged in
user in admin ?

On Aug 25, 3:54 pm, Alsond  wrote:
> System needs to types of categories. First one is used by all. Second
> one is created by author.
> In admin on new Entry I would like tu see all items from Category
> and in AuthorCategory would like to see AuthorCategory items where
> User is current user.
>
> from django.contrib.auth.models import User
>
> class AuthorCategory(models.Model):
>     title = models.CharField(max_length=250)
>     author = models.ForeignKey(User)
>
> class Category(models.Model):
>     title = models.CharField(max_length=250)
>
> class Entry(models.Model):
>     title = models.CharField(max_length=250)
>     category = models.ForeignKey(Category)
>     authorcategory = models.ForeignKey(AuthorCategory)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



marksafe

2009-08-25 Thread luca72

Hello i have this:
errore = """
{ alert('test_js')};
"""
return mark_safe(errore)
I get this error : AttributeError: 'SafeString' object has no
attribute 'status_code'
can you help me to write the correct one?
Thanks

Luca


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



custom filtering

2009-08-25 Thread Alsond

System needs to types of categories. First one is used by all. Second
one is created by author.
In admin on new Entry I would like tu see all items from Category
and in AuthorCategory would like to see AuthorCategory items where
User is current user.


from django.contrib.auth.models import User

class AuthorCategory(models.Model):
title = models.CharField(max_length=250)
author = models.ForeignKey(User)

class Category(models.Model):
title = models.CharField(max_length=250)

class Entry(models.Model):
title = models.CharField(max_length=250)
category = models.ForeignKey(Category)
authorcategory = models.ForeignKey(AuthorCategory)

--~--~-~--~~~---~--~~
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: marksafe

2009-08-25 Thread Daniel Roseman

On Aug 25, 2:07 pm, luca72  wrote:
> Hello i have this:
> errore = """
>                     { alert('test_js')};
>                     """
> return mark_safe(errore)
> I get this error : AttributeError: 'SafeString' object has no
> attribute 'status_code'
> can you help me to write the correct one?
> Thanks
>
> Luca

You don't say where you're using this, but if it's in a view, you must
always return an HttpResponse, not just a string. So try:
return HttpResponse(mark_safe(errore))
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



question about custom save() and unique slug

2009-08-25 Thread andreas schmid

hi,

i have a custom add method for a front end editing of my project model.

now i have the problem that my url is composed by /year/slug and slug is
set as unique for pub_date__year in the model. obviously this is not
respected by my form so i want to check if the slug already exists for
the given year but i cant find the right solution.

here my code and i know its wrong:

def add_project(request):   
if request.method == 'POST':
form = ProjectForm(data=request.POST)
if form.is_valid():
new_project = form.save(commit=False)
projects = Project.objects.all()
if new_project.slug == projects.slug :
form = ProjectForm()
else:
new_project = form.save(commit=False)
new_project.author = request.user
new_project.pub_date = datetime.datetime.now()
new_project.slug =
new_project.title.lower().replace(' ','-')
   
new_project.percentage_to_pay_by_tis =
100-new_project.financing  
calculationpercentage =
(100-new_project.financing)/100
new_project.amount_to_finance=
new_project.budget*calculationpercentage
new_project.restamount_to_pay =
new_project.amount_to_finance- new_project.already_paid_amount_by_tis
   
new_project.save()
return
HttpResponseRedirect(new_project.get_absolute_url())
else:
form = ProjectForm()
return render_to_response('eufinance/project_form.html',
  { 'form': form, 'add':True },
 
context_instance=RequestContext(request))


   

can anybody help me please...



--~--~-~--~~~---~--~~
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: marksafe

2009-08-25 Thread luca72

Thanks now it works
Luca


On 25 Ago, 15:12, Daniel Roseman  wrote:
> On Aug 25, 2:07 pm, luca72  wrote:
>
> > Hello i have this:
> > errore = """
> >                     { alert('test_js')};
> >                     """
> > return mark_safe(errore)
> > I get this error : AttributeError: 'SafeString' object has no
> > attribute 'status_code'
> > can you help me to write the correct one?
> > Thanks
>
> > Luca
>
> You don't say where you're using this, but if it's in a view, you must
> always return an HttpResponse, not just a string. So try:
>     return HttpResponse(mark_safe(errore))
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: html Escape

2009-08-25 Thread Matias
Hi,
I think there is no such filter, so you'll have to code it.
This
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escapingmay
help

HTH,
Matias.

On Tue, Aug 25, 2009 at 5:54 AM, When ideas fail
wrote:

>
> Thanks, can i strip out all tags other than  tags.
>
> I would like people to be able to put links in comments.
>
> Andrew
>
> On 25 Aug, 03:42, Parag Shah  wrote:
> > Hi,
> >
> > You can use the strip_tags function to strip all html from text.
> >
> > from django.utils.html import strip_tags
> >
> > In your view
> > comment = strip_tags(request.POST["comment"])
> >
> > --
> > Regards
> > Parag
> >
> > On Tue, Aug 25, 2009 at 4:25 AM, When ideas fail
> > wrote:
> >
> >
> >
> > > Hello, i want to allow users to post comments and I don't want them to
> > > be allowed to put html in comments.
> >
> > > However I would like the to be able to use paragraph p tags and 
> > > tags but not anything other. Could someone tell me how to do this?
> >
> > > Thanks
> >
> > > Andrew
> >
> > --
> > Thanks & Regards
> > Parag Shahhttp://blog.adaptivesoftware.biz
> >
>


-- 
:wq

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



too much GROUP BY columns in generated sql query

2009-08-25 Thread peterf81

Hello,
what could be the problem when from this code :

reputation = Repute.objects.extra(
select={'positive': 'sum(positive)', 'negative': 'sum
(negative)', 'question_id':'question_id',
'title': 'question.title'},
tables=['repute', 'question'],
order_by=['-reputed_at'],
where=['user_id=%s AND question_id=question.id'],
params=[user.id]
).values('positive', 'negative', 'question_id', 'title',
'reputed_at', 'reputation')
reputation.query.group_by = ['question_id']

this SQL query is generated :

SELECT (sum(positive)) AS `positive`, (question.title) AS `title`, (sum
(negative)) AS `negative`, (question_id) AS `question_id`,
`repute`.`reputed_at`, `repute`.`reputation`
FROM `repute` , `question`
WHERE user_id=1 AND question_id=question.id
GROUP BY question_id, sum(positive), question.title, sum(negative),
question_id
ORDER BY `repute`.`reputed_at`
DESC LIMIT 21

I think there are too much GROUP BY columns. It should be only "GROUP
BY question_id". I get the error "Caught an exception while rendering:
(, 'Invalid use of group function')".

Peter

--~--~-~--~~~---~--~~
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: ModelForm and ForeignKeys

2009-08-25 Thread Alexandru-Emil Lupu
an ideea:
build a custom Model Form for Character, and after that define CharacterHome
Model Form.

class CharacterForm(forms.ModelForm):
class Meta:
model = Character
exclude = ('some', 'fields','here', 'that', 'you', 'do', 'not',
'want', 'to', 'display' )

class CharacterHomeForm(forms.ModelForm):
class Meta:
model = CharacterHome
exclude = ('character',)

If you want to display them, you just use


obj = CharacterHome.objects.get() # whatever you get your object

chform = CharacterHome(instance=obj)
cform = Character(instance= obj.character)

the rest, should be fun.

Alecs


On Tue, Aug 25, 2009 at 1:14 PM, goobee  wrote:

>
> Hi Léon,
> it's not that basic. Picking up your example, I define a Form based on
> CharacterHome. Then I show 1 entry from CharacterHome; the field
> 'character' is shown as a MultipleChoiceField where ALL entries from
> Character are listed. But I need only the one particular record that
> ist referenced by the selected CharacterHome.
> In addition the user should only get non-editable fields on the html-
> page
>
> regards
> goobee
>
> On 24 Aug., 12:11, Léon Dignòn  wrote:
> > Basically you have to link them with a foreign key. I hope this fits
> > your needs with the legacy table.
> >
> > class Character(models.Model):
> > guid = models.IntegerField(primary_key=True)
> > name = models.CharField()
> > …
> > class CharacterHome(models.Model):
> > character = models.ForeignKey(Character, primary_key=True)
> > …
> >
> > If you want an instance of character returning the guid, define a
> > __unicode__() function
> >
> > def __unicode__(self):
> > return self.guid
> >
> > -ld
> >
> > On Aug 22, 9:36 pm, Ryan Bales  wrote:
> >
> > > I have experienced this same issue, and that link didn't really help.
> > > I am trying to hook into a legacy database using "inspectdb", and I
> > > can't index the tables.
> >
> > > class Character(models.Model):
> > >  guid = models.IntegerField(primary_key=True)
> > >  name = models.CharField()
> > >  ...
> > >  ...
> > > class CharacterHome(models.Model):
> > >  character = models.IntegerField(primary_key=True)
> > >  ...
> > >  ...
> >
> > > Even though django accurately assesses the datatypes of these tables,
> > > I want to be able to set CharacterHome.character as a ForeignKey
> > > (Character) and have Character return the "guid" integer value.
> >
> > > On Aug 22, 5:29 am, Léon Dignòn  wrote:
> >
> > > >
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a...
> >
> > > > Good luck!
> >
> > > > -ld
> >
> > > > On Aug 21, 3:49 pm, goobee  wrote:
> >
> > > > > hi there
> >
> > > > > I'm in dire need of a good idea. django drives me crazy with its
> > > > > foreignkey-resolver.
> >
> > > > > class person(models.Model):
> > > > > name ...
> > > > > firstname 
> > > > > 
> > > > > 
> >
> > > > > class participant(models.Model):
> > > > > group ..
> > > > > person(foreignkey(person))
> > > > > funk ...
> >
> > > > > I want to show 'participant' using the ModelForm-feature. From
> model
> > > > > 'person' I need name and firstname only (or __unicode__) of the
> > > > > particular participant, but django delivers the entire table
> 'person'
> > > > > which is an unnecessary overkill (especially with several FKs in
> > > > > 'participant'). There must be an option to avoid this behaviour!?
> >
> > > > > thanks for any ideas- Hide quoted text -
> >
> > > - Show quoted text -
> >
>


-- 
As programmers create bigger & better idiot proof programs, so the universe
creates bigger & better idiots!
I am on web:  http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798

--~--~-~--~~~---~--~~
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: Error in setting up psycopg2

2009-08-25 Thread Simon Lee

Hi Thomas,

I did a Google search and did as one suggestion:
$ export PYTHONPATH=$HOME/:$PYTHONPATH
$ export DJANGO_SETTINGS_MODULE=mysite3.settings
$ python
>>> from django.contrib.sessions.backends import db

It works with no error. The same thing works if I do "python manage.py
shell" without the export.

That does not solve my problem though. I changed myapp.wsgi to the
following:

--

import os, sys
sys.path.append('/Users/simonlee')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite3.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

--

It shows the following error in my log:

[Tue Aug 25 19:12:24 2009] [info] [client 127.0.0.1] mod_wsgi
(pid=170, process='', application='www.test-hago-group.com|'): Loading
WSGI script '/Users/simonlee/mysite3/apache/myapp.wsgi'.
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=170): Exception occurred processing WSGI script '/Users/simonlee/
mysite3/apache/myapp.wsgi'.
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/core/handlers/wsgi.py", line 241, in __call__
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] response =
self.get_response(request)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/core/handlers/base.py", line 73, in get_response
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] response =
middleware_method(request)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/contrib/sessions/middleware.py", line 10, in process_request
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] engine =
import_module(settings.SESSION_ENGINE)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/utils/importlib.py", line 35, in import_module
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] __import__
(name)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/contrib/sessions/backends/db.py", line 2, in 
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] from
django.contrib.sessions.models import Session
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/contrib/sessions/models.py", line 4, in 
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] from
django.db import models
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/db/__init__.py", line 41, in 
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] backend =
load_backend(settings.DATABASE_ENGINE)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/db/__init__.py", line 17, in load_backend
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] return
import_module('.base', 'django.db.backends.%s' % backend_name)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/utils/importlib.py", line 35, in import_module
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] __import__
(name)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/db/backends/postgresql_psycopg2/base.py", line 22, in 
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] raise
ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]
ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   Referenced
from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/psycopg2/_psycopg.so
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   Expected in:
dynamic lookup
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]

---

I did a search on the web but found only two links on similar error
without any solution. Does anyone know what caused "Symbol not found:
_PQbackendPID"?

Simon

On Aug 25, 4:25 pm, Simon Lee  wrote:
> Hi Thomas,
> When I typed the following into my python console as advised:>>> from 
> django.contrib.session.backends import db
>
> I got the following error:
> Traceb

Re: ModelForm and ForeignKeys

2009-08-25 Thread goobee

Hi Léon,
it's not that basic. Picking up your example, I define a Form based on
CharacterHome. Then I show 1 entry from CharacterHome; the field
'character' is shown as a MultipleChoiceField where ALL entries from
Character are listed. But I need only the one particular record that
ist referenced by the selected CharacterHome.
In addition the user should only get non-editable fields on the html-
page

regards
goobee

On 24 Aug., 12:11, Léon Dignòn  wrote:
> Basically you have to link them with a foreign key. I hope this fits
> your needs with the legacy table.
>
> class Character(models.Model):
>     guid = models.IntegerField(primary_key=True)
>     name = models.CharField()
>     …
> class CharacterHome(models.Model):
>     character = models.ForeignKey(Character, primary_key=True)
>     …
>
> If you want an instance of character returning the guid, define a
> __unicode__() function
>
> def __unicode__(self):
>     return self.guid
>
> -ld
>
> On Aug 22, 9:36 pm, Ryan Bales  wrote:
>
> > I have experienced this same issue, and that link didn't really help.
> > I am trying to hook into a legacy database using "inspectdb", and I
> > can't index the tables.
>
> > class Character(models.Model):
> >      guid = models.IntegerField(primary_key=True)
> >      name = models.CharField()
> >      ...
> >      ...
> > class CharacterHome(models.Model):
> >      character = models.IntegerField(primary_key=True)
> >      ...
> >      ...
>
> > Even though django accurately assesses the datatypes of these tables,
> > I want to be able to set CharacterHome.character as a ForeignKey
> > (Character) and have Character return the "guid" integer value.
>
> > On Aug 22, 5:29 am, Léon Dignòn  wrote:
>
> > >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a...
>
> > > Good luck!
>
> > > -ld
>
> > > On Aug 21, 3:49 pm, goobee  wrote:
>
> > > > hi there
>
> > > > I'm in dire need of a good idea. django drives me crazy with its
> > > > foreignkey-resolver.
>
> > > > class person(models.Model):
> > > >     name ...
> > > >     firstname 
> > > >     
> > > >     
>
> > > > class participant(models.Model):
> > > >     group ..
> > > >     person(foreignkey(person))
> > > >     funk ...
>
> > > > I want to show 'participant' using the ModelForm-feature. From model
> > > > 'person' I need name and firstname only (or __unicode__) of the
> > > > particular participant, but django delivers the entire table 'person'
> > > > which is an unnecessary overkill (especially with several FKs in
> > > > 'participant'). There must be an option to avoid this behaviour!?
>
> > > > thanks for any ideas- Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: ModelForm and ForeignKeys

2009-08-25 Thread goobee

Hi Léon,
it's not that basic. Picking up your example, I define a Form based on
CharacterHome. Then I show 1 entry from CharacterHome; the field
'character' is shown as a MultipleChoiceField where ALL entries from
Character are listed. But I need only the one particular record that
ist referenced by the selected CharacterHome.
In addition the user should only get non-editable fields on the html-
page

regards
goobee

On 24 Aug., 12:11, Léon Dignòn  wrote:
> Basically you have to link them with a foreign key. I hope this fits
> your needs with the legacy table.
>
> class Character(models.Model):
>     guid = models.IntegerField(primary_key=True)
>     name = models.CharField()
>     …
> class CharacterHome(models.Model):
>     character = models.ForeignKey(Character, primary_key=True)
>     …
>
> If you want an instance of character returning the guid, define a
> __unicode__() function
>
> def __unicode__(self):
>     return self.guid
>
> -ld
>
> On Aug 22, 9:36 pm, Ryan Bales  wrote:
>
> > I have experienced this same issue, and that link didn't really help.
> > I am trying to hook into a legacy database using "inspectdb", and I
> > can't index the tables.
>
> > class Character(models.Model):
> >      guid = models.IntegerField(primary_key=True)
> >      name = models.CharField()
> >      ...
> >      ...
> > class CharacterHome(models.Model):
> >      character = models.IntegerField(primary_key=True)
> >      ...
> >      ...
>
> > Even though django accurately assesses the datatypes of these tables,
> > I want to be able to set CharacterHome.character as a ForeignKey
> > (Character) and have Character return the "guid" integer value.
>
> > On Aug 22, 5:29 am, Léon Dignòn  wrote:
>
> > >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a...
>
> > > Good luck!
>
> > > -ld
>
> > > On Aug 21, 3:49 pm, goobee  wrote:
>
> > > > hi there
>
> > > > I'm in dire need of a good idea. django drives me crazy with its
> > > > foreignkey-resolver.
>
> > > > class person(models.Model):
> > > >     name ...
> > > >     firstname 
> > > >     
> > > >     
>
> > > > class participant(models.Model):
> > > >     group ..
> > > >     person(foreignkey(person))
> > > >     funk ...
>
> > > > I want to show 'participant' using the ModelForm-feature. From model
> > > > 'person' I need name and firstname only (or __unicode__) of the
> > > > particular participant, but django delivers the entire table 'person'
> > > > which is an unnecessary overkill (especially with several FKs in
> > > > 'participant'). There must be an option to avoid this behaviour!?
>
> > > > thanks for any ideas- Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Many-to-many column

2009-08-25 Thread Sven Richter
Hi,

i implemented a many-to-many field in my model like:
class Entries(models.Model):
  following_to = models.ManyToManyField('self', blank=True, null=True)

Now i can get all related Entries in a template with entry.following_to.all.
But i want to go deeper in relationships.

Lets say i have 4 Entries A, B, C, D.
A is following_to to B and
B is following_to to C and
C is following_to to D.
A.following_to.all gives back B.

But what i need is to follow until the end of the chain is reached.
I need something like:
A.following_to.give_all_related_entries which then returns:
B, C, D

Do i have to write my own template tag for that or is it already implemented
in Django?
Or maybe there is a better approach to solve my issue?

I couldnt find a similar question or answer in the docs.


Greetings
Sven

--~--~-~--~~~---~--~~
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 mark_safe() in a view returns False

2009-08-25 Thread MIL

Hi. Im sorry. I closed the question again, cause I found out that it
worked just fine :o)

Thanks for helping though :o)

On 25 Aug., 02:51, Karen Tracey  wrote:
> On Mon, Aug 24, 2009 at 7:01 PM, MIL  wrote:Since I had
>
> the pleasure of getting help in here once I will try
>
>
>
> > again :o)
>
> > I have read about the mark_safe, and I would like to use it, but it
> > just returns the value "False"
>
> > What am I doing wrong?
>
> > i my view:
> > from django.utils.safestring import mark_safe
> > 
> > ...
> > context = RequestContext(request, {
> >        'title'           : title,
> >        'p_txt'         : mark_safe(some_text),
> > })
> > .
>
> Are you sure some_text is actually some text and not something like a
> boolean with value False?
>
> Karen
--~--~-~--~~~---~--~~
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: html Escape

2009-08-25 Thread When ideas fail

Thanks, can i strip out all tags other than  tags.

I would like people to be able to put links in comments.

Andrew

On 25 Aug, 03:42, Parag Shah  wrote:
> Hi,
>
> You can use the strip_tags function to strip all html from text.
>
> from django.utils.html import strip_tags
>
> In your view
> comment = strip_tags(request.POST["comment"])
>
> --
> Regards
> Parag
>
> On Tue, Aug 25, 2009 at 4:25 AM, When ideas fail
> wrote:
>
>
>
> > Hello, i want to allow users to post comments and I don't want them to
> > be allowed to put html in comments.
>
> > However I would like the to be able to use paragraph p tags and 
> > tags but not anything other. Could someone tell me how to do this?
>
> > Thanks
>
> > Andrew
>
> --
> Thanks & Regards
> Parag Shahhttp://blog.adaptivesoftware.biz
--~--~-~--~~~---~--~~
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: Error in setting up psycopg2

2009-08-25 Thread Simon Lee
Hi Thomas,
When I typed the following into my python console as advised:
>>> from django.contrib.session.backends import db
I got the following error:
Traceback (most recent call last):  File "", line 1, in   File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/contrib/sessions/backends/db.py",
 line 2, in     from django.contrib.sessions.models import 
Session  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/contrib/sessions/models.py",
 line 4, in     from django.db import models  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py",
 line 10, in     if not settings.DATABASE_ENGINE:  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/utils/functional.py",
 line 269, in __getattr__    self._setup()  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/conf/__init__.py",
 line 38, in _setup    raise ImportError("Settings cannot be
 imported, because environment variable %s is undefined." % 
ENVIRONMENT_VARIABLE)ImportError: Settings cannot be imported, because 
environment variable DJANGO_SETTINGS_MODULE is undefined.
I searched "/Users/myname/mysite3/settings.py" for the variable SESSION_ENGINE 
but it is not defined in that file. I don't know where settings.SESSION_ENGINE 
is defined???
Simon

--- On Mon, 8/24/09, Thomas Guettler  wrote:

From: Thomas Guettler 
Subject: Re: Error in setting up psycopg2
To: "Simon Lee" , django-users@googlegroups.com
Date: Monday, August 24, 2009, 11:17 PM


Hi Simon,

your first traceback looked like this:

[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=120): Exception occurred processing WSGI script '/Users/myname/
mysite3/apache/myapp.wsgi'.
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/core/handlers/wsgi.py", line 239, in __call__
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/core/handlers/base.py", line 67, in get_response
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/contrib/sessions/middleware.py", line 9, in
process_request
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] ImportError: No
module named db

My line 9 of middleware.py of sessions looks like this:
engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])

What does your variable settings.SESSION_ENGINE look like?

Is it 'django.contrib.sessions.backends.db'?

Try to import this as www user:
w...@host> python
>>> from django.contrib.session.backends import db

Does this work?

Simon Lee schrieb:
> You are right. I am a newbie on Linux, trying hard to learn it at the
> same time with the other stuff.
> 
> I did the following in the shell:
> 
> macbook:~myname$ su
> Password: 
> sh-3.2# su - _www
> sh-3.2# more /Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/site-packages/psycopg2/tz.py
> 
> I can read the file with more. Seems that there is no problem on
> permission. Please advise.
> 


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de





  
--~--~-~--~~~---~--~~
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: Ordering a django change list page via jQuery?

2009-08-25 Thread Niall Mccormack

You have a good point there.

I only needed this to work with a small number of items.

Would you know how to do this any other way?


On 20 Aug 2009, at 14:36, krylatij wrote:

>
> I think that is not the best solution.
> As i understand you are ordering only displayed items because of
> pagination
> >


--~--~-~--~~~---~--~~
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: register() takes at most 3 arguments (4 given)

2009-08-25 Thread Hotmail

On Pzt, 2009-08-24 at 07:14 -0700, Daniel Roseman wrote:
> On Aug 24, 2:45 pm, Hotmail  wrote:
> > On Pzt, 2009-08-24 at 06:17 -0700, Daniel Roseman wrote:
> >
> > > On Aug 24, 12:51 pm, Gungor  wrote:
> > > > I have a  register() takes at most 3 arguments (4 given) problem with
> > > > these codes.
> >
> > > > from randevu.rts.models import Randevu
> > > > from django.contrib import admin
> > > > from datetime import datetime
> >
> > > > class Admin_Panel(admin.ModelAdmin):
> > > > list_display=("name","surname","date","time")
> > > > ordering=["-date","time"]
> > > > search_fields=("name","surname","date")
> > > > class Filtre():
> > > > fil = Randevu.objects.filter(date__gte = datetime(2009,8,24))
> > > > #fil2 = fil.filter(fil.time__equ = Time(time))
> >
> > > > admin.site.register(Randevu,Admin_Panel,Filtre)
> >
> > > What are you trying to do with this? What is Filtre, and why are you
> > > trying to register it in the admin? As the error says, register
> > > accepts the model and the admin class as parameters, it doesn't expect
> > > a third argument.
> > > --
> > > DR.
> >
> > filtre is filter in Turkish meaning.I am trying to develop an appoinment 
> > application.here is a problem with the date and time filter. if smbd have 
> > an appoinment at that time, anybody can not have an appointment.
> >
> > ex:
> > John Malcovich at 9:00am 20 July 2009 (has an appoinment)
> > Benjamin Button want to take an appoinment at 9:00am .But the system
> > does not give the permission.
> >
> 
> Fine, but you can't just randomly create classes and assign them to
> things and expect it to just work. How are you expecting this filter
> class to work? Where is the filter going to be applied? What is it
> going to filter? Where are the results going to be displayed?
> 
> If you just want to ensure that a field is unique across all instances
> of a model, use unique=True in the field definition.
> --
> DR.
> > 
> 

I am a new guy.I don't know how to do a filter.Can you help me for this?
-- 
Force will be with you...


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