Re: Q Object Oddity

2007-02-03 Thread Mike Axiak

Hello,
I'm surprised this is marked as a "do not fix" bug. I mean,
essentially these Q objects will at the end of the day define sets of
objects, and it doesn't seem expected behavior to me to say a OR b is
a subset of b. Currently I am working around this by explicitly taking
IDs, and doing ors and ands with IN.

While I know that the query follows the key and finds
registrationprofile, and some users do not have it, that is precisely
what I think is going wrong. That is, in the python usage sense (that
is, away from SQL), I told django to use OR. It then interpreted this
and used two inner joins, which IMHO is an incorrect interpretation.

-Mike

On Feb 3, 8:15 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> On 4 Lut, 00:46, "Mike Axiak" <[EMAIL PROTECTED]> wrote:
>
> > y =  Q(satprepreginfo__program = program)
>
> > z = Q(registrationprofile__program = program) & \
> >Q(registrationprofile__student_info__isnull = False)
>
> > This is my result:
>
> >   In [27]: User.objects.filter(y | z).filter(username = 'mlopes')
> >   Out[27]: []
>
> >   In [28]: User.objects.filter(y).filter(username = 'mlopes')
> >   Out[28]: []
>
> This probably means that user mlopes does not have a
> RegistrationProfile.
>
> The registrationprofile__something lookups are done using INNER JOIN
> so adding such a condition filters out all users that do not have
> corresponding entries in registrationprofile table.  You need OUTER
> (or LEFT) JOINS to make this work like you would expect.
>
> > So I am getting something as a result, but I just chose to filter one
> > user that has an interesting property.
> > Question: Am I doing something wrong? Is this a bug/feature/expected
> > behavior?
>
> It is the expected behavior with current implementation of field
> lookups -- they don't provide a nice way to request an outer join.
> There was at least one patch to fix it, currently marked as wontfix,
> seehttp://code.djangoproject.com/ticket/2922
>
> You can also do it without patching Django by creating a custom Q
> object, but it is not too easy or elegant either.  If you don't mind
> patching Django then #2922 might be a better idea.
>
> -mk


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



Re: Q Object Oddity

2007-02-03 Thread [EMAIL PROTECTED]

Hi,

On 4 Lut, 00:46, "Mike Axiak" <[EMAIL PROTECTED]> wrote:
> y =  Q(satprepreginfo__program = program)
>
> z = Q(registrationprofile__program = program) & \
>Q(registrationprofile__student_info__isnull = False)
>
> This is my result:
>
>   In [27]: User.objects.filter(y | z).filter(username = 'mlopes')
>   Out[27]: []
>
>   In [28]: User.objects.filter(y).filter(username = 'mlopes')
>   Out[28]: []

This probably means that user mlopes does not have a
RegistrationProfile.

The registrationprofile__something lookups are done using INNER JOIN
so adding such a condition filters out all users that do not have
corresponding entries in registrationprofile table.  You need OUTER
(or LEFT) JOINS to make this work like you would expect.

> So I am getting something as a result, but I just chose to filter one
> user that has an interesting property.
> Question: Am I doing something wrong? Is this a bug/feature/expected
> behavior?

It is the expected behavior with current implementation of field
lookups -- they don't provide a nice way to request an outer join.
There was at least one patch to fix it, currently marked as wontfix,
see http://code.djangoproject.com/ticket/2922

You can also do it without patching Django by creating a custom Q
object, but it is not too easy or elegant either.  If you don't mind
patching Django then #2922 might be a better idea.

-mk


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



Re: Q Object Oddity

2007-02-03 Thread Russell Keith-Magee

On 2/4/07, Mike Axiak <[EMAIL PROTECTED]> wrote:
>
> Below is the SQL the query,
> User.objects.filter(y|z).distinct().count(),
> generates.
>
> It seems to do the correct OR for the where clauses, and yet still
> uses an INNER JOIN when that type of join is inappropriate for this
> particular query. Is this a known problem? Did I write the queries
> incorrectly?

Depends on what you are trying to do.

The INNER JOIN is a correct interpretation of what you asked Django to
do - Q(registrationprofile__student_info__isnull = False) is
interpreted as 'follow the registrationprofile relation, and on that
related object, check that the value of student_info is not NULL'.

To help solve your problem, it would be helpful to have some more
details. What models are you using to generate this query? What query
are you expecting to see? What results are you expecting to see?

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



Re: Q Object Oddity

2007-02-03 Thread Mike Axiak

Below is the SQL the query,
User.objects.filter(y|z).distinct().count(),
generates.

It seems to do the correct OR for the where clauses, and yet still
uses an INNER JOIN when that type of join is inappropriate for this
particular query. Is this a known problem? Did I write the queries
incorrectly?

-Mike


SELECT COUNT(DISTINCT("auth_user"."id"))
FROM "auth_user"

INNER JOIN "program_registrationprofile" AS
"auth_user__registrationprofile"
  ON "auth_user"."id" =
"auth_user__registrationprofile"."user_id"
INNER JOIN "program_satprepreginfo" AS "auth_user__satprepreginfo"
  ON "auth_user"."id" = "auth_user__satprepreginfo"."user_id"
WHERE (
  (
 ("auth_user__registrationprofile"."program_id" = 6 AND
"auth_user__registrationprofile"."student_info_id" IS NOT NULL)

   OR
 "auth_user__satprepreginfo"."program_id" = 6
  )

)

On Feb 3, 6:46 pm, "Mike Axiak" <[EMAIL PROTECTED]> wrote:
> Hey,
> I'm using Django release (currently 0.95.0, waiting for etch to move
> to 0.95.1) with some patches (lazyuser patch comes to mind) on an
> internal development.
>
> The question is, I was trying to do some Q object combinations and was
> met with some weird results:
>
> y =  Q(satprepreginfo__program = program)
>
> z = Q(registrationprofile__program = program) & \
>Q(registrationprofile__student_info__isnull = False)
>
> This is my result:
>
>   In [27]: User.objects.filter(y | z).filter(username = 'mlopes')
>   Out[27]: []
>
>   In [28]: User.objects.filter(y).filter(username = 'mlopes')
>   Out[28]: []
>
> Note that
>   In [24]: User.objects.filter(y|z).distinct().count()
>   Out[24]: 194L
>
>   In [25]: User.objects.filter(y).distinct().count()
>   Out[25]: 198L
>
> So I am getting something as a result, but I just chose to filter one
> user that has an interesting property.
> Question: Am I doing something wrong? Is this a bug/feature/expected
> behavior?
>
> Any help would be 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reverse query name for field 'foo' clashes with field 'Foo.bar', why?

2007-02-03 Thread Russell Keith-Magee

On 2/4/07, Ramiro Morales <[EMAIL PROTECTED]> wrote:
>
> Now the question :): Why does Django model validation reports name clash
> errors and suggests to use related_name when clearly there are not
> such clashes?:

I can't see any immediately obvious reason - looks like you may have
found a bug. If I had to guess, I would say that the validator is
getting an accidental hit based on the fact that the related model
name and the relation name are the same.

The invalid_models modeltest contains the full set of validation tests
- it is possible that either (1) this test doesn't check the case you
describe, or (2) the expected test results are incorrect.

If you feel like trying to track this one down, the validation checks
are all performed in django/core/management.py, in the
get_validation_errors() method.

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



Q Object Oddity

2007-02-03 Thread Mike Axiak

Hey,
I'm using Django release (currently 0.95.0, waiting for etch to move
to 0.95.1) with some patches (lazyuser patch comes to mind) on an
internal development.

The question is, I was trying to do some Q object combinations and was
met with some weird results:

y =  Q(satprepreginfo__program = program)

z = Q(registrationprofile__program = program) & \
   Q(registrationprofile__student_info__isnull = False)

This is my result:

  In [27]: User.objects.filter(y | z).filter(username = 'mlopes')
  Out[27]: []

  In [28]: User.objects.filter(y).filter(username = 'mlopes')
  Out[28]: []

Note that
  In [24]: User.objects.filter(y|z).distinct().count()
  Out[24]: 194L

  In [25]: User.objects.filter(y).distinct().count()
  Out[25]: 198L

So I am getting something as a result, but I just chose to filter one
user that has an interesting property.
Question: Am I doing something wrong? Is this a bug/feature/expected
behavior?

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



Required edit_in_line object and filter by a joined column

2007-02-03 Thread Michel Thadeu Sabchuk

Hi guys!

I have a project to publish accounting offices on the internet. All
the
accounting offices will have usefull tools avaiable on a centralized
page and each office will have a specific homepage built from database
information. My simplified model structure is:

class Office(Model):

name = CharField(maxlength=200)

def host_name(self):
return self.site.host_name

class Admin:
list_display = ['host_name']

class Site(Model):

office = OneToOneField(Office, edit_in_line=STACKED,
num_in_admin=1) host_name = CharField(maxlength=64,
unique=True) some_data = CharField(editable=False, ...)
some_another_data = CharField(editable=False,...)  logo =
ImageField(editable=False,...)


I can only create I site inline in the Office administration page,
this
is what I wanted, but I want the site to be required, is there a way
to
make a inline element be required on the parent object creation?

Another question: I think it's easy to my users to read the host_name
of each Office reather than his name (in the administration page).
This
was possible using list_display but is there a way to order offices
by host_name (maybe working with joins) and is there a way to filter
by host_name?

Thanks in advance, best regards!

--
Michel Thadeu Sabchuk
Curitiba - Paraná - Brasil


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



Reverse query name for field 'foo' clashes with field 'Foo.bar', why?

2007-02-03 Thread Ramiro Morales

Hi,

(I'm trying to create test cases for ticket #2536 and this is something I
hadn't noted until now):

Say I have a models.py file almost identical to the modeltest/example #24:

from django.db import models

class Parent( models.Model ):
name = models.CharField(maxlength=100)
child = models.ForeignKey("Child", null=True)

class Child( models.Model ):
name = models.CharField(maxlength=100)
parent = models.ForeignKey(Parent)

That is, two mutually referencing models via FKs. But:
* No related_name option has been used in the FK definitions and
* The Parent model has a "child" FK to the Child model

So, the declared Parent->Child relationship gets named "child", and
it's reverse relationship get named "parent_set". Similarly the
declared
Child->Parent relationship is "parent" and it reverse is "child_set".

Now the question :): Why does Django model validation reports name clash
errors and suggests to use related_name when clearly there are not
such clashes?:

ticket2536.parent: Reverse query name for field 'child' clashes with field
'Child.parent'. Add a related_name argument to the definition for 'child'.

ticket2536.child: Reverse query name for field 'parent' clashes with field
'Parent.child'. Add a related_name argument to the definition for 'parent'.

2 errors found.

TIA for any enlightenment.

-- 
 Ramiro Morales

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



Re: Persistent Python objects

2007-02-03 Thread Baczek

On 3 Lut, 20:58, "Tom" <[EMAIL PROTECTED]> wrote:
> What do you suggest for this?

If it needs to be a singleton, you could consider deploying under
FastCGI, I believe the process is started only once and the real
server acts simply as a proxy.

But note that I _believe_, not know :)


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



Re: Persistent Python objects

2007-02-03 Thread Jeremy Dunck

On 2/3/07, Tom <[EMAIL PROTECTED]> wrote:
>
> What do you suggest for this?
>

Is there a single shared state among all players, or is it per player?

If the former, you must already have some way of managing concurrency, no?

In any case, it sounds like maybe you want a Twisted.PerspectiveBroker:
http://twistedmatrix.com/projects/core/documentation/howto/pb-intro.html

On the other hand, I'm doing something that's fairly partitioned per
user, and am just using shelve with a backend that manages an MRU
cache.

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



Re: create a model instance from dictionnary

2007-02-03 Thread Sebastien Armand [Pink]
Thanks a lot, I haven't practice Python for a while, forgot lots of
things...

2007/2/3, Leo Soto M. <[EMAIL PROTECTED]>:
>
>
> On 2/2/07, Sebastien Armand [Pink] <[EMAIL PROTECTED]> wrote:
> > Is it possible to instantiate a model class from a dictionnary?
> >
> > I mean instead of using:
> >
> > MyModel(arg1=1,arg2=2,...)
> >
> > I'd like to use:
> >
> > data= {'arg1':1,'arg2':2,...}
> > MyModel(data)
>
> Just use standard python syntax:
>
> MyModel(**data)
>
> --
> Leo Soto M.
>
> >
>

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



Persistent Python objects

2007-02-03 Thread Tom

I have a web app which currently runs off Python's BaseHTTPServer.  I
want to deploy it under Django instead.

It contains a Python object (the state of play of a board game) which
lives in the process running the server.

If I deploy under Django I'll need some way of keeping the object
around between invocations.  The object is expensive to construct, so
I don't want to serialize and deserialize for each HTTP request.

What do you suggest for this?

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



Re: full content feeds

2007-02-03 Thread James Tauber

Actually, it looks like Atom1Feed is where the restriction is.

Anyone have a replacement for Atom1Feed that does full-content?

Otherwise, I'll write one and contribute it (I'm working on Django  
support for the Atom Publishing Protocol, anyway)

James


On 03/02/2007, at 2:39 PM, James Tauber wrote:

>
> But the description template seems to just control the content of the
> summary element in Atom.
>
> If I want a full content feed, rather than just a summary, it looks
> like I can't use django.contrib.syndication.views.feed
>
>
> On 03/02/2007, at 4:47 AM, aaloy wrote:
>> 2007/2/3, James Tauber <[EMAIL PROTECTED]>:
>>> However, I'd like my feed to be full content. Given what I have
>>> below, what's the most straightforward way to make my feed full
>>> content?
>> The full content would depend on your template. That is, you can make
>> your template to present full content, just a summary, etc. Its  
>> just a
>> matter to work with the template and present what you want.
>>
>>> I'm assuming I'm going to have to write a template for full-content
>>> Atom entries, but I'm not sure how to get
>>> django.contrib.syndication.views.feed to work with that. Currently,
>>> django.contrib.syndication.views.feed just uses a feedgenerator,
>>> right. Not a template?
>> No. In fact it can use a template if you define it as
>> _description.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: full content feeds

2007-02-03 Thread James Tauber

But the description template seems to just control the content of the  
summary element in Atom.

If I want a full content feed, rather than just a summary, it looks  
like I can't use django.contrib.syndication.views.feed


On 03/02/2007, at 4:47 AM, aaloy wrote:
> 2007/2/3, James Tauber <[EMAIL PROTECTED]>:
>> However, I'd like my feed to be full content. Given what I have
>> below, what's the most straightforward way to make my feed full  
>> content?
> The full content would depend on your template. That is, you can make
> your template to present full content, just a summary, etc. Its just a
> matter to work with the template and present what you want.
>
>> I'm assuming I'm going to have to write a template for full-content
>> Atom entries, but I'm not sure how to get
>> django.contrib.syndication.views.feed to work with that. Currently,
>> django.contrib.syndication.views.feed just uses a feedgenerator,
>> right. Not a template?
> No. In fact it can use a template if you define it as
> _description.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: haw access to values from field with choices

2007-02-03 Thread Nebojša Đorđević

On Feb 2, 2007, at 14:51 , kamil wrote:

> Surely it's solved but I can't find any info about it. I'm sure that
> everybody met this problem.
> What is the best way to get rendered the value from the field with
> choices.
> Generic views spits key not value.

.get__display()

-- 
Nebojša Đorđević - nesh, ICQ#43799892
Studio Quattro - Niš - Serbia
http://studioquattro.biz/ | http://trac.studioquattro.biz/djangoutils/
Registered Linux User 282159 [http://counter.li.org]



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



Re: name 'current_datetime' is not defined

2007-02-03 Thread Mike Spradling

I figured it out, I left off

from mysite.views import current_datetime


On Feb 3, 8:50 am, "gordyt" <[EMAIL PROTECTED]> wrote:
> Howdy Mike,
>
> > def current_datetime(request):
> > now = datetime.datetime.now()
> > html = "It is now %s." % now
> > return HttpResponse(html)
>
> > - then edit your urls.py to contain
>
> > from django.conf.urls.defaults import *
>
> > urlpatterns = patterns('',
> > (r'^now/$', current_datetime),
>
> You just need to let Django know about the module that contains the
> current_datetime function.
>
> For example, if your project name is "myproject" and your app name is
> "myapp", you would do this:
>
> urlpatterns = patterns('myproject.myapp.views',
> (r'^now/$', current_datetime),
> )
>
> --gordy


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



Re: Where to put function to instantiate and save a model object?

2007-02-03 Thread Rob Hudson

Russell Keith-Magee wrote:
> Look in django.contrib.auth.models for UserManager for implementation details.

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



Re: messages, filters and templates o my!

2007-02-03 Thread Milan Andric

Cool, so you write a view that returns what, json, html?  Do you
recommend any specific library or possibly have an example?  Since
I've never done it, I'm wondering where all the pieces fit in the
django layout.  I'll search the ML for tips.

Thanks.

On Feb 3, 6:11 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> When I'm doing something like that, I use ajax to do the server side
> stuff and return the message without ever leaving the page.
>
> On Feb 2, 7:39 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I have a small problem, I'm submitting a review form (form x) on a
> > page that has many of these forms in a list, so  you can view other
> > reviews, add new ones or edit your own.   When a review is edited a
> > view processes it and redirects the person back to the review using an
> > anchor like /urlstring/12/#id_review_8.
>
> > Works fine, now I just need to print some kind of notice to the user
> > that the data was saved.
>
> > Messages won't work because i don't have enough control to only print
> > a message for the form that was updated. Or so i think.  In my
> > template I just have a for loop,
> >  e.g. {% for review in reviews %}  > id="id_review_{{review.id}}"> ...
>
> > Do you have any suggestions or examples to lead me towards a solution?
>
> > I guess it's time for this newbie to write a template tag?
>
> > Thank for your help,
>
> > Milan


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



Re: javascript and form fields

2007-02-03 Thread [EMAIL PROTECTED]

Hello :)

> It's 2007. There's better ways of doing these things than littering
> your html with event handlers.

The way of using of such thing was:

...
form.field_name js_fct_string
...

js_fct_handler could be something like this:

"onclick=some_js_fct(this)"

To achieve something like this i have to duplicate code of controls in
forms :/
And do some other modifications, I guess.
This way seems to me quite usefull, clean and simple.

Cheers :)


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



Re: messages, filters and templates o my!

2007-02-03 Thread [EMAIL PROTECTED]

When I'm doing something like that, I use ajax to do the server side
stuff and return the message without ever leaving the page.


On Feb 2, 7:39 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a small problem, I'm submitting a review form (form x) on a
> page that has many of these forms in a list, so  you can view other
> reviews, add new ones or edit your own.   When a review is edited a
> view processes it and redirects the person back to the review using an
> anchor like /urlstring/12/#id_review_8.
>
> Works fine, now I just need to print some kind of notice to the user
> that the data was saved.
>
> Messages won't work because i don't have enough control to only print
> a message for the form that was updated. Or so i think.  In my
> template I just have a for loop,
>  e.g. {% for review in reviews %}  id="id_review_{{review.id}}"> ...
>
> Do you have any suggestions or examples to lead me towards a solution?
>
> I guess it's time for this newbie to write a template tag?
>
> Thank for your help,
>
> Milan


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



Re: name 'current_datetime' is not defined

2007-02-03 Thread gordyt

Howdy Mike,


> def current_datetime(request):
> now = datetime.datetime.now()
> html = "It is now %s." % now
> return HttpResponse(html)
>
> - then edit your urls.py to contain
>
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
> (r'^now/$', current_datetime),

You just need to let Django know about the module that contains the
current_datetime function.

For example, if your project name is "myproject" and your app name is
"myapp", you would do this:

urlpatterns = patterns('myproject.myapp.views',
(r'^now/$', current_datetime),
)

--gordy


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



Re: full content feeds

2007-02-03 Thread aaloy

2007/2/3, James Tauber <[EMAIL PROTECTED]>:


>
> However, I'd like my feed to be full content. Given what I have
> below, what's the most straightforward way to make my feed full content?
The full content would depend on your template. That is, you can make
your template to present full content, just a summary, etc. Its just a
matter to work with the template and present what you want.

> I'm assuming I'm going to have to write a template for full-content
> Atom entries, but I'm not sure how to get
> django.contrib.syndication.views.feed to work with that. Currently,
> django.contrib.syndication.views.feed just uses a feedgenerator,
> right. Not a template?
No. In fact it can use a template if you define it as
_description.html.

Best regards,


-- 
Antoni Aloy López
Binissalem - Mallorca
http://www.trespams.com
Soci de Bulma - http://www.bulma.cat

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



name 'current_datetime' is not defined

2007-02-03 Thread Mike Spradling

I'm baffled.  I'm just getting started with django and am reading the
'Django Book'.  In chapter 3 I'm told,

- Make a file called views.py that contains:

from django.http import HttpResponse
import datetime

def current_datetime(request):
now = datetime.datetime.now()
html = "It is now %s." % now
return HttpResponse(html)

- then edit your urls.py to contain

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^now/$', current_datetime),
)

then start the server and go to http://myserver:8080/now/

I immediately get

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
  68. callback, callback_args, callback_kwargs =
resolver.resolve(request.path)
File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py" in
resolve
  160. for pattern in self.urlconf_module.urlpatterns:
File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py" in
_get_urlconf_module
  177. self._urlconf_module = __import__(self.urlconf_name, {}, {},
[''])

  NameError at /now/
  name 'current_datetime' is not defined

What am I missing?  I tried both the stable build, and the latest svn
with the same results


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