Re: Close window after download

2010-05-12 Thread Sebastian Pawlus
I'm not sure about your case
http://jquery.malsup.com/form/
and event "success",
take a look on http://jquery.malsup.com/form/#ajaxSubmit.


> Does anyone know how to track if a download completed?
>
> On May 6, 9:52 pm, CrabbyPete  wrote:
>> I have code that generates a file for download. I want to close the
>> window after the user selects the download or even redirect them.
>>
>> Here is my code:
>>
>> response = HttpResponse(cal.as_string(), mimetype='text/calendar')
>> response['Content-Disposition'] = 'attachment; filename=schedule.ics'
>> return response
>>
>> I can't close the window before the download using
>>
>> 
>>  
>> 
>>
>> because I get an error that the window closed.
>>
>> So after the form download the window is hanging in limbo. If anyone
>> knows
>> how to close the window I'd appreciate it.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group 
>> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 display an image inside Django

2010-05-12 Thread Daniel Roseman
On May 12, 5:36 am, ravi krishna  wrote:
> Hi,
> Thanks for ur reply. I was asking about the ImageField. tried out the
> tutorials, but its not working out. Where
> all(views,models,urls.py,settings.py) should we make editings inorder to
> work. Please help me

If you really want someone to help you, you need to be a bit clearer.
What doesn't work? What have you tried? What happens? What error
messages do you get? What unexpected behaviour are you seeing? What
code are you running?
--
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-us...@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 display an image inside Django

2010-05-12 Thread Sam Walters
Specifically what do you want to do?

1. Write a form to upload and display an image?
2. Dynamically display/generate an image? eg:
http://effbot.org/zone/django-pil.htm
3. hyperlink an image from a templates folder or media folder? (with
either django test server or a production server)



On Tue, May 11, 2010 at 9:10 PM, ravi krishna  wrote:
> Hi,
> I am a beginner in Django .
> Can somebody tel me how to display an image in django...
> if anyone has the right tutorial for beginners, please share with me..
> --
> Regards,
> Rav!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Many2Many / Generic Relation filter, doesn't behave like expected, how is the right way to do it?

2010-05-12 Thread tom
hello all!
I have similar problem:
assume books-tabls, in manyToMany relation with tags-table through
bookTagMatch-table

I am looking for a way to do this through the admin filter:
subclass relatedFilter to interpret the url: /?bookTag=7&bookTag=3
and returns book tuples that are tagged under class 7 AND also tagged
under class 3
which equal to books.object.all().filter(tag=3).filter(tag=7)

I search over 'QuerySet API reference' for maybe another url syntax
for it, but failed to... what am I missing?

does anyone know how?

thanks!

tom

On 28 אפריל, 19:37, Tom Evans  wrote:
> On Wed, Apr 28, 2010 at 5:12 PM, HWM-Rocker  wrote:
>
> > On Apr 28, 4:21 am, Tom Evans  wrote:
> >> On Wed, Apr 28, 2010 at 1:00 AM, HWM-Rocker  wrote:
> >> > I have a TaggedObject that has a GenericRelation to Foo with the name
> >> > tags. When I am searching something like that
>
> >> > TaggedObject.objects.filter(Q(tags__tag=1)&Q(tags__tag=4))
>
> >> > I get no Objects in return. But when Ifilterwith (or) '|' then I get
> >> > 4 Objects. But I have only 3 objects tagged. So the object, that was
> >> > tagged with 1 and with 4 will be returnedtwice?
>
> >> > Thats strange. Any idea how to create this queries correctly?
>
> >> > thanks in advance!!!
>
> >> That query looks for tags which are both 1 and 4 at thesametime.
> >> What you want to do is look for tags which are 1, look for tags which
> >> are 4, and intersect them.
>
> >> In other words:
>
> >> TaggedObject.objects.filter(tags__tag=1).filter(tags__tag=4)
>
> > yeah I changed my code, but is there any possibility to do this with
> > Q, so that I can just execute one query in the end? I want to build a
> > complex nested search/filterand Q gives me the possibility to negate
> > queries. Is there a possibility to split those two Q's to behave in a
> > way that would be useful for my case.
>
> >> Cheers
>
> >> Tom
>
> > thx for your tip !!
>
> What you ask the ORM for has more effect on how many queries are done
> than how many times you callfilter() - querysets are only evaluated
> (go to the DB) when they are displayed/iterated through.
>
> This ORM statement:
>   TaggedObject.objects.filter(tags__tag=1).filter(tags__tag=4)
>
> would boil down to one SQL statement, joining to the tags tabletwice.
>
> Use the django debug toolbar, or manually examine
> django.db.connection.queries ("from django.db import connection; print
> connection.queries") to see more clearly what the ORM is doing.
>
> In this case you are asking for how you can dynamicallyfilterby tags
> (in an AND search):
>
> qs = TaggedObjects.objects.filter( .. )
> for tag in tag:
>   qs = qs.filter(tags__tag=tag)
>
> If you wanted tofilteron (tag a or tag b) and tag c:
> qs = qs.filter(Q(tags__tag=taga) | Q(tags__tag=tagb)).filter(tags__tag=tagc)
>
> I'll leave it up to you to turn that into something dynamic :P
>
> Be aware, each tag you 'AND'filteron adds another join - the joys of RDBMS
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Updating profiles

2010-05-12 Thread Wiiboy
Just as a side note, I made the user part of my Profile model a
OneToOneField.  Makes it easier to reference, i.e. user.profile.FIELD
vs. user.get_profile().field

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: unit tests: database confusion

2010-05-12 Thread gulle



jararaca wrote:
> 
> 
> Thanks Russ, I don't have a stray settings-file but I've spotted the
> problem now: One of my files with custom SQL for the models contained
> the line USE xy; (with xy being my database, argh!). So everything
> before the execution of this line used my test database correctly but
> all later commands were executed on the real database.
> 
> Happy testing to all of you,
> micha
> 
>> > But the strangest part is yet to come: When testing, it is obviously
>> > always my "real" database that is being read, not the 'test_xy'
>> > database, even if I change DATABASE_NAME in settings!
> 
> 
> --~--~-~--~~~---~--~~
> 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
> -~--~~~~--~~--~--~---
> 
> 
> 

Hi jararaca
  Can u brief me the solution.Even i am not able to access test
database ,some how it fetch production database itself

regards,
//g


-- 
View this message in context: 
http://old.nabble.com/unit-tests%3A-database-confusion-tp10737510p28536896.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Saving objects that have foreign key fields using the pk instead of an instance of the foreignkeyed object

2010-05-12 Thread Nick Serra
Sorry for the confusing title. Here is a simple example to illustrate
my question:

class Item(models.Model):
name = models.CharField()

class Manager(models.Model):
item = models.ForeignKey(Item)


On a POST I have the PK of the Item I want to link to a new instance
of the Manager object. I am saving a new Manager object that will be
linked to the Item with the PK i have. So I can do:

item_pk = request.POST.get('item')
item = Item.objects.get(pk=item_pk)
new_manager = Manager(item=item)
new_manager.save()

...but I don't like the idea of grabbing the item object first. Is
there any way to just save the new Manager object with just the PK of
the Item, thus avoiding the database call to grab the Item object?

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



Dynamically content in include statement not working

2010-05-12 Thread Brian
Help:

Chapter 4: The Django Template System
http://www.djangobook.com/en/1.0/chapter04/

This example includes the contents of the template whose name is
contained in the variable template_name:
{% include template_name %}


All i'm trying to do is dynamically include an html template file:

This works just fine:
{% load "FooterMessage.htm" %}

This will NOT work for me:
{% load "{{inpage.footer}}" %}

fyi: (I know that inpage.footer == "FooterMessage.htm")

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Dynamically content in include statement not working

2010-05-12 Thread Tom Evans
On Wed, May 12, 2010 at 4:10 PM, Brian  wrote:
> Help:
>
> Chapter 4: The Django Template System
> http://www.djangobook.com/en/1.0/chapter04/
>
> This example includes the contents of the template whose name is
> contained in the variable template_name:
> {% include template_name %}
>
>
> All i'm trying to do is dynamically include an html template file:
>
> This works just fine:
> {% load "FooterMessage.htm" %}
>
> This will NOT work for me:
> {% load "{{inpage.footer}}" %}
>
> fyi: (I know that inpage.footer == "FooterMessage.htm")
>
This
  {% load "{{inpage.footer}}" %}
isn't valid syntax. You can't do variable interpolation inside
template tags. Furthermore, the {% load %} tag is for loading custom
template tag libraries, not including extra content. You want the {%
include %} tag, as you correctly state in the first paragraph.

It isn't usually necessary. In this case, this should work:
  {% include inpage.footer %}

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-us...@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: Saving objects that have foreign key fields using the pk instead of an instance of the foreignkeyed object

2010-05-12 Thread Daniel Roseman
On May 12, 4:04 pm, Nick Serra  wrote:
> Sorry for the confusing title. Here is a simple example to illustrate
> my question:
>
> class Item(models.Model):
>     name = models.CharField()
>
> class Manager(models.Model):
>     item = models.ForeignKey(Item)
>
> On a POST I have the PK of the Item I want to link to a new instance
> of the Manager object. I am saving a new Manager object that will be
> linked to the Item with the PK i have. So I can do:
>
> item_pk = request.POST.get('item')
> item = Item.objects.get(pk=item_pk)
> new_manager = Manager(item=item)
> new_manager.save()
>
> ...but I don't like the idea of grabbing the item object first. Is
> there any way to just save the new Manager object with just the PK of
> the Item, thus avoiding the database call to grab the Item object?
>
> Thanks!
>

You should just be able to do
manager = Manager(item=item_pk)
but in general, you can always refer to item_id, as the underlying
database field representing the foreign key value.
--
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-us...@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: surveys

2010-05-12 Thread Scot Hacker

On May 11, 3:16 pm, HARRY POTTRER  wrote:
> I have a project that I'm working on that works like this:
>
> the user enters some points on a map which are then stored in a
> database as a LineString object (via geodjango). Along with the
> geographic data, the user is given a survey to fill out consisting of
> simple questions like "how fun was this", "how old are you", and "was
> the parking sufficient", etc. There will be a pool of roughly 100
> questions, and the survey will be constructed based on the locale of
> the user. Different locales results in different sets of questions.
> There are 40-50 locales for this project.
>
> My question is how should I set up the surveys. I don't really want to
> hard code each survey per locale. I'd prefer to have the questions and
> choices defined in the database.
>
> There is a reusable app called "django-survey" but as far as I can
> tell the project is completely undocumented. I have it installed, but
> I can't figure out how to use it. Is this app the kind of thing that I
> can use, or is it meant for something else completely?

django-survey is probably your best starting point, but it will
probably take some customizing given your need to ask different
questions depending on answers to previous questions. No, it's not
well-documented, but it's also not too hard to get working. I found
the author pretty responsive to feedback when working with it last
year. But the Django world really needs a full-featured alternative to
Lime Survey, with all the bells and whistles people expect from survey
tools these days.

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Dynamically content in include statement not working

2010-05-12 Thread Brian
Help:

Chapter 4: The Django Template System
http://www.djangobook.com/en/1.0/chapter04/

This example includes the contents of the template whose name is
contained in the variable template_name:
{% include template_name %}


All i'm trying to do is dynamically include a html template file

This works just fine:
{% include "FooterMessage.htm" %}


This will NOT work for me:
{% include "{{inpage.footer}}" %}

(I know that inpage.footer == "FooterMessage.htm")

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Dynamically content in include statement not working

2010-05-12 Thread Brian
Tom, I'm sorry
I am using include and it's not working:
Dynamically content in include statement not working:

This works just fine:
{% include "FooterMessage.htm" %}


This will NOT work for me:
{% include "{{inpage.footer}}" %}

(I know that inpage.footer == "FooterMessage.htm")




On May 12, 11:19 am, Tom Evans  wrote:
> On Wed, May 12, 2010 at 4:10 PM, Brian  wrote:
> > Help:
>
> > Chapter 4: The Django Template System
> >http://www.djangobook.com/en/1.0/chapter04/
>
> > This example includes the contents of the template whose name is
> > contained in the variable template_name:
> > {% include template_name %}
>
> > All i'm trying to do is dynamically include an html template file:
>
> > This works just fine:
> > {% load "FooterMessage.htm" %}
>
> > This will NOT work for me:
> > {% load "{{inpage.footer}}" %}
>
> > fyi: (I know that inpage.footer == "FooterMessage.htm")
>
> This
>   {% load "{{inpage.footer}}" %}
> isn't valid syntax. You can't do variable interpolation inside
> template tags. Furthermore, the {% load %} tag is for loading custom
> template tag libraries, not including extra content. You want the {%
> include %} tag, as you correctly state in the first paragraph.
>
> It isn't usually necessary. In this case, this should work:
>   {% include inpage.footer %}
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Saving objects that have foreign key fields using the pk instead of an instance of the foreignkeyed object

2010-05-12 Thread Nick Serra
Thanks for the response. I actually will already have the PK, and am
trying to avoid grabbing an instance of the actual item object.

On May 12, 11:26 am, Daniel Roseman  wrote:
> On May 12, 4:04 pm, Nick Serra  wrote:
>
>
>
>
>
> > Sorry for the confusing title. Here is a simple example to illustrate
> > my question:
>
> > class Item(models.Model):
> >     name = models.CharField()
>
> > class Manager(models.Model):
> >     item = models.ForeignKey(Item)
>
> > On a POST I have the PK of the Item I want to link to a new instance
> > of the Manager object. I am saving a new Manager object that will be
> > linked to the Item with the PK i have. So I can do:
>
> > item_pk = request.POST.get('item')
> > item = Item.objects.get(pk=item_pk)
> > new_manager = Manager(item=item)
> > new_manager.save()
>
> > ...but I don't like the idea of grabbing the item object first. Is
> > there any way to just save the new Manager object with just the PK of
> > the Item, thus avoiding the database call to grab the Item object?
>
> > Thanks!
>
> You should just be able to do
>     manager = Manager(item=item_pk)
> but in general, you can always refer to item_id, as the underlying
> database field representing the foreign key value.
> --
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Dynamically content in include statement not working

2010-05-12 Thread Tom Evans
On Wed, May 12, 2010 at 4:31 PM, Brian  wrote:
> Tom, I'm sorry
> I am using include and it's not working:
> Dynamically content in include statement not working:
>
> This works just fine:
> {% include "FooterMessage.htm" %}
>
>
> This will NOT work for me:
> {% include "{{inpage.footer}}" %}
>
> (I know that inpage.footer == "FooterMessage.htm")
>
>
>
>
> On May 12, 11:19 am, Tom Evans  wrote:
>> On Wed, May 12, 2010 at 4:10 PM, Brian  wrote:
>> > Help:
>>
>> > Chapter 4: The Django Template System
>> >http://www.djangobook.com/en/1.0/chapter04/
>>
>> > This example includes the contents of the template whose name is
>> > contained in the variable template_name:
>> > {% include template_name %}
>>
>> > All i'm trying to do is dynamically include an html template file:
>>
>> > This works just fine:
>> > {% load "FooterMessage.htm" %}
>>
>> > This will NOT work for me:
>> > {% load "{{inpage.footer}}" %}
>>
>> > fyi: (I know that inpage.footer == "FooterMessage.htm")
>>
>> This
>>   {% load "{{inpage.footer}}" %}
>> isn't valid syntax. You can't do variable interpolation inside
>> template tags. Furthermore, the {% load %} tag is for loading custom
>> template tag libraries, not including extra content. You want the {%
>> include %} tag, as you correctly state in the first paragraph.
>>
>> It isn't usually necessary. In this case, this should work:
>>   {% include inpage.footer %}
>>
>> Cheers
>>
>> Tom
>>

Did you read my email at all? I clearly explained why that method does
not work, and clearly gave you an alternative that should work.

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



Extending and Entity with the Django User model

2010-05-12 Thread x13
Hello, I need to extend the Django User model in this way: I have an
Entity model an I want to define a relationship one-2-one from User to
Entity (so a Django User can be an Entity, but an Entity can be
something else).


So what's the best way to extend the User model for this particular
case??

I've read the 'official' ways to extend Django User model
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

and the Django book's way too:
http://www.djangobook.com/en/1.0/chapter12/#cn222

Iv'e read this one too
http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/

but can't decide on which one is the best for my case. The problem is
that I don't want to extend the User with a custom profile, I want to
extend my custom Entity model with User model, something like that
maybe works:

class MyUser(models.Model):
user = models.ForeignKey(User, unique=True)
entity = models.ForeignKey(Entity, unique=True)


Any opinions? Thanks in advance.
x13






-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Extending and Entity with the Django User model

2010-05-12 Thread x13
> something like that maybe works:
>
> class MyUser(models.Model):
>     user = models.ForeignKey(User, unique=True)
>     entity = models.ForeignKey(Entity, unique=True)
>     
>

Sorry, this is my current proposal (but I really don't know if there
is some difference with the previous one):

class MyUser(models.Model):
    user = models.ForeignKey(User, unique=True)
    entity = models.OneToOneField(Entity, primary_key=True)
    


cheers,
x13

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Dynamically content in include statement not working

2010-05-12 Thread Brian
Tom
Thank you, Thanks you, Thank you.
 {% include inpage.footer %} works just fine. The {{}} is unnecessary
as I had it.

Sometime the brain is not working.
Thanks again.


On May 12, 11:36 am, Tom Evans  wrote:
> On Wed, May 12, 2010 at 4:31 PM, Brian  wrote:
> > Tom, I'm sorry
> > I am using include and it's not working:
> > Dynamically content in include statement not working:
>
> > This works just fine:
> > {% include "FooterMessage.htm" %}
>
> > This will NOT work for me:
> > {% include "{{inpage.footer}}" %}
>
> > (I know that inpage.footer == "FooterMessage.htm")
>
> > On May 12, 11:19 am, Tom Evans  wrote:
> >> On Wed, May 12, 2010 at 4:10 PM, Brian  wrote:
> >> > Help:
>
> >> > Chapter 4: The Django Template System
> >> >http://www.djangobook.com/en/1.0/chapter04/
>
> >> > This example includes the contents of the template whose name is
> >> > contained in the variable template_name:
> >> > {% include template_name %}
>
> >> > All i'm trying to do is dynamically include an html template file:
>
> >> > This works just fine:
> >> > {% load "FooterMessage.htm" %}
>
> >> > This will NOT work for me:
> >> > {% load "{{inpage.footer}}" %}
>
> >> > fyi: (I know that inpage.footer == "FooterMessage.htm")
>
> >> This
> >>   {% load "{{inpage.footer}}" %}
> >> isn't valid syntax. You can't do variable interpolation inside
> >> template tags. Furthermore, the {% load %} tag is for loading custom
> >> template tag libraries, not including extra content. You want the {%
> >> include %} tag, as you correctly state in the first paragraph.
>
> >> It isn't usually necessary. In this case, this should work:
> >>   {% include inpage.footer %}
>
> >> Cheers
>
> >> Tom
>
> Did you read my email at all? I clearly explained why that method does
> not work, and clearly gave you an alternative that should work.
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Saving objects that have foreign key fields using the pk instead of an instance of the foreignkeyed object

2010-05-12 Thread Daniel Roseman
On May 12, 4:34 pm, Nick Serra  wrote:
> Thanks for the response. I actually will already have the PK, and am
> trying to avoid grabbing an instance of the actual item object.

Yes, that's what I meant. You can assign the foreign key directly when
instantiating an object, without having to get the item object by
using the FOO_id field.

  manager = Manager(item_id=mypkvalue)

(sorry, previous example was missing the "_id" suffix.)
--
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-us...@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: Saving objects that have foreign key fields using the pk instead of an instance of the foreignkeyed object

2010-05-12 Thread Nick Serra
Exactly what I was looking for, thanks!

On May 12, 11:50 am, Daniel Roseman  wrote:
> On May 12, 4:34 pm, Nick Serra  wrote:
>
> > Thanks for the response. I actually will already have the PK, and am
> > trying to avoid grabbing an instance of the actual item object.
>
> Yes, that's what I meant. You can assign the foreign key directly when
> instantiating an object, without having to get the item object by
> using the FOO_id field.
>
>   manager = Manager(item_id=mypkvalue)
>
> (sorry, previous example was missing the "_id" suffix.)
> --
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: unit tests: database confusion

2010-05-12 Thread Phlip
> Hi jararaca
>               Can u brief me the solution.Even i am not able to access test
> database ,some how it fetch production database itself

Hear galloping, think horses not zebras.

are y'all running your test batch like this?

  python manage.py test --settings=test_settings.py

does test_settings.py contain only correct DATABASE settings?

If u ran python manage.py shell --settings=test_settings.py

  > from django.conf import settings
  > print settings.__dict__

what settings do u see?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Taking on a NoneType error

2010-05-12 Thread Nick
I am using a custom template tag called calculate age to produce an
age in numbers based on a filter for a template tag.

Here is the tag:

def age(bday, d=None):
if d is None:
d = datetime.datetime.now()
return (d.year - bday.year) - int((d.month, d.day) < (bday.month,
bday.day))

register.filter('age', age)

here is how it is used in a template:

{{ entry.DOB|age }} # that produces an age


Here is the problem, not all of the entries in my DB have a date of
birth (henceforth known as DOB).

This raises and error.

I have tried to get around this many different ways. Here are few:

{% ifequal entry.DOB None %} N/A {% else %}  {{ entry.DOB|age }} {%
endif %}

{% ifequal entry.DOB "None" %} N/A {% else %}  {{ entry.DOB|age }} {%
endif %}

{% if entry.DOB == None #I have custom operators set up and this logic
works in the shell but not in the template %} N/A {% else %}
{{ entry.DOB|age }} {% endif %}

{% if entry.DOB == 'None' %} N/A {% else %}  {{ entry.DOB|age }} {%
endif %}

I've even tried it in my view:


def detail(request, last_name, first_name):
r = get_object_or_404(Rep, Last_Name=last_name,
First_Name=first_name)
if r.DOB == None:
r.DOB = NULLage
return render_to_response('Government/repsSingle.html', {'entry':
r, 'NULLage': NULLage})

The in the template:

{% if NULLage %}

This is a good grief sort of error and is making my brain blood boil.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Taking on a NoneType error

2010-05-12 Thread Nuno Maltez
Hi,

I think the simple

{% if entry.DOB %} {{ entry.DOB|age }}{% else  %} N/A {% endif %}

should work. Or, the other way around:

{% if not entry.DOB %} ...


You could also try testing in your filter:

def age(bday, d=None):
   if bday is None:
 return None
   

and use the default_if_none filter

{{ entry.DOB|age|default_if_none:"N/A" }}

This, however, doesn't seem to make sense:
>
> def detail(request, last_name, first_name):
>r = get_object_or_404(Rep, Last_Name=last_name,
> First_Name=first_name)
>if r.DOB == None:
>r.DOB = NULLage
>return render_to_response('Government/repsSingle.html', {'entry':
> r, 'NULLage': NULLage})
>
> The in the template:
>
> {% if NULLage %}

NULLage is never set by your test in the view, seems like it's a
constant value, and the if in the template would always evaluate the
same way (be it True or False).

HTH,
Nuno

On Wed, May 12, 2010 at 6:06 PM, Nick  wrote:
> I am using a custom template tag called calculate age to produce an
> age in numbers based on a filter for a template tag.
>
> Here is the tag:
>
> def age(bday, d=None):
>    if d is None:
>        d = datetime.datetime.now()
>    return (d.year - bday.year) - int((d.month, d.day) < (bday.month,
> bday.day))
>
> register.filter('age', age)
>
> here is how it is used in a template:
>
> {{ entry.DOB|age }} # that produces an age
>
>
> Here is the problem, not all of the entries in my DB have a date of
> birth (henceforth known as DOB).
>
> This raises and error.
>
> I have tried to get around this many different ways. Here are few:
>
> {% ifequal entry.DOB None %} N/A {% else %}  {{ entry.DOB|age }} {%
> endif %}
>
> {% ifequal entry.DOB "None" %} N/A {% else %}  {{ entry.DOB|age }} {%
> endif %}
>
> {% if entry.DOB == None #I have custom operators set up and this logic
> works in the shell but not in the template %} N/A {% else %}
> {{ entry.DOB|age }} {% endif %}
>
> {% if entry.DOB == 'None' %} N/A {% else %}  {{ entry.DOB|age }} {%
> endif %}
>
> I've even tried it in my view:
>

>
> This is a good grief sort of error and is making my brain blood boil.
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Taking on a NoneType error

2010-05-12 Thread Karen Tracey
On Wed, May 12, 2010 at 1:06 PM, Nick  wrote:

> I am using a custom template tag called calculate age to produce an
> age in numbers based on a filter for a template tag.
>
> Here is the tag:
>
> def age(bday, d=None):
>if d is None:
>d = datetime.datetime.now()
>return (d.year - bday.year) - int((d.month, d.day) < (bday.month,
> bday.day))
>
> register.filter('age', age)
>
> here is how it is used in a template:
>
> {{ entry.DOB|age }} # that produces an age
>
>
> Here is the problem, not all of the entries in my DB have a date of
> birth (henceforth known as DOB).
>
> This raises and error.
>
[snip remainder]

Why not just handle it in the age filter itself:

def age(bday, d=None):
   if not bday:
  return 'N/A'
   if d is None:
   d = datetime.datetime.now()
... remainder of filter ...

?

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Comments inside a loop

2010-05-12 Thread Yanik
Hello,

I'm trying to do something that seemed simple, but can't get to work:
displaying comments using Django (1.2 RC)'s Comment framework inside a
loop.


{% for entry in entries %}
{% get_comment_list for entry as comments %}
{% render_comment_form for entry %}
{% endfor %}

but I get an error:

Invalid block tag: 'get_comment_list', expected 'empty' or 'endfor'


What should I do?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Removing template newlines in

2010-05-12 Thread Noah Watkins
I have a variable amount of lines that need to be displayed in a
 block:


  header
  {% if var1 %}{{ ... }}{% endif %}
  {% if var2 %}{{ ... }}{% endif %}
  {% if var3 %}{{ ... }}{% endif %}
  footer


However, if some of the if-statements are not evaluated to be true
then the line breaks are still displayed in the pre area causing
"gaps". Are there any easy approaches to addressing this issue?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Removing template newlines in

2010-05-12 Thread Peter Landry
If you want to keep the newlines in your template, you can use
http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#spaceless

Peter


On 5/12/10 2:02 PM, "Noah Watkins"  wrote:

> I have a variable amount of lines that need to be displayed in a
>  block:
> 
> 
>   header
>   {% if var1 %}{{ ... }}{% endif %}
>   {% if var2 %}{{ ... }}{% endif %}
>   {% if var3 %}{{ ... }}{% endif %}
>   footer
> 
> 
> However, if some of the if-statements are not evaluated to be true
> then the line breaks are still displayed in the pre area causing
> "gaps". Are there any easy approaches to addressing this issue?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Taking on a NoneType error

2010-05-12 Thread Nick
Well, I am embarrassed to admin that this issue was 100% user error.

I recently set up a dev and production server and copied everything
from the old production server to the two new servers.

I was testing the search results page on dev, that's the page that
generates the links to the pages that I'm having issue with (they
appear in a pop up, BTW). While the search results page was on dev the
actual page that was having the age issue was on production. So as I
edited the templates for the age pages on dev it was not updating
production so that's why i couldn't get the simple "if" statements to
work. I had full absolute URLS to the age pages, they've been changed
to relative URLS to prevent this from happening.

There is, however, a bright side to my ignorance.  The suggestions to
update the template tag filter were right on. I use this filter a lot
so it makes more since to have a built in fail safe rather than
checking in the templates each time.

Thanks a bunch,

Dummy

On May 12, 12:46 pm, Karen Tracey  wrote:
> On Wed, May 12, 2010 at 1:06 PM, Nick  wrote:
> > I am using a custom template tag called calculate age to produce an
> > age in numbers based on a filter for a template tag.
>
> > Here is the tag:
>
> > def age(bday, d=None):
> >    if d is None:
> >        d = datetime.datetime.now()
> >    return (d.year - bday.year) - int((d.month, d.day) < (bday.month,
> > bday.day))
>
> > register.filter('age', age)
>
> > here is how it is used in a template:
>
> > {{ entry.DOB|age }} # that produces an age
>
> > Here is the problem, not all of the entries in my DB have a date of
> > birth (henceforth known as DOB).
>
> > This raises and error.
>
> [snip remainder]
>
> Why not just handle it in the age filter itself:
>
> def age(bday, d=None):
>    if not bday:
>       return 'N/A'
>    if d is None:
>        d = datetime.datetime.now()
> ... remainder of filter ...
>
> ?
>
> Karen
> --http://tracey.org/kmt/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Comments inside a loop

2010-05-12 Thread Karen Tracey
On Wed, May 12, 2010 at 1:52 PM, Yanik  wrote:

> Hello,
>
> I'm trying to do something that seemed simple, but can't get to work:
> displaying comments using Django (1.2 RC)'s Comment framework inside a
> loop.
>
>
> {% for entry in entries %}
>{% get_comment_list for entry as comments %}
>{% render_comment_form for entry %}
> {% endfor %}
>
> but I get an error:
>
> Invalid block tag: 'get_comment_list', expected 'empty' or 'endfor'
>

This is the template system's way of saying you forgot to:

{% load comments %}

before trying to use one of the comment tags.

get_comment_list is an invalid block tag because it has not been loaded yet.

(By the way you are not doing anything with the list of comments after you
retrieve it?)

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



RSS Aggregator

2010-05-12 Thread beetlecube
Hello,
 Just wondering if there are alternatives to the feedjack RSS
aggregator that anyone has used. It doesn't have to be "Django-ized"
like feedjack is.

Just any Python library that you've had good luck with, parsing a lot
of different RSS feeds.  I know there are examples of using Mark
Pilgrim's feedparser with an aggregator tool, on his site. Was
thinking of just using that.

Thanks,
Steve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Removing template newlines in

2010-05-12 Thread Noah Watkins
Peter

I don't believe "spaceless" will work because in the example I posted
there are no html tags within the  block.
Consider the same example where var2 is evaluated to be false:


  header
  ...
--NEWLINE--
  ...
  footer


The newline remains, but is displayed on a webpage because it is in
the  block.


On May 12, 11:10 am, Peter Landry  wrote:
> If you want to keep the newlines in your template, you can 
> usehttp://docs.djangoproject.com/en/1.1/ref/templates/builtins/#spaceless
>
> Peter
>
> On 5/12/10 2:02 PM, "Noah Watkins"  wrote:
>
> > I have a variable amount of lines that need to be displayed in a
> >  block:
>
> > 
> >   header
> >   {% if var1 %}{{ ... }}{% endif %}
> >   {% if var2 %}{{ ... }}{% endif %}
> >   {% if var3 %}{{ ... }}{% endif %}
> >   footer
> > 
>
> > However, if some of the if-statements are not evaluated to be true
> > then the line breaks are still displayed in the pre area causing
> > "gaps". Are there any easy approaches to addressing this issue?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Removing template newlines in

2010-05-12 Thread zinckiwi
Not the prettiest thing in the world, but there's always:


  header
  {% if var1 %}{{ ... }}
  {% endif %}{% if var2 %}{{ ... }}
  {% endif %}{% if var3 %}{{ ... }}
  {% endif %}
  footer


Regards
Scott

On May 12, 2:20 pm, Noah Watkins  wrote:
> Peter
>
> I don't believe "spaceless" will work because in the example I posted
> there are no html tags within the  block.
> Consider the same example where var2 is evaluated to be false:
>
> 
>   header
>   ...
> --NEWLINE--
>   ...
>   footer
> 
>
> The newline remains, but is displayed on a webpage because it is in
> the  block.
>
> On May 12, 11:10 am, Peter Landry  wrote:
>
>
>
>
>
> > If you want to keep the newlines in your template, you can 
> > usehttp://docs.djangoproject.com/en/1.1/ref/templates/builtins/#spaceless
>
> > Peter
>
> > On 5/12/10 2:02 PM, "Noah Watkins"  wrote:
>
> > > I have a variable amount of lines that need to be displayed in a
> > >  block:
>
> > > 
> > >   header
> > >   {% if var1 %}{{ ... }}{% endif %}
> > >   {% if var2 %}{{ ... }}{% endif %}
> > >   {% if var3 %}{{ ... }}{% endif %}
> > >   footer
> > > 
>
> > > However, if some of the if-statements are not evaluated to be true
> > > then the line breaks are still displayed in the pre area causing
> > > "gaps". Are there any easy approaches to addressing this issue?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Removing template newlines in

2010-05-12 Thread Noah Watkins
I just stumbled upon this alternative too. Thanks for the reply, and
really I don't think it's too ugly.

On May 12, 11:50 am, zinckiwi  wrote:
> Not the prettiest thing in the world, but there's always:
>
> 
>   header
>   {% if var1 %}{{ ... }}
>   {% endif %}{% if var2 %}{{ ... }}
>   {% endif %}{% if var3 %}{{ ... }}
>   {% endif %}
>   footer
> 
>
> Regards
> Scott
>
> On May 12, 2:20 pm, Noah Watkins  wrote:
>
>
>
>
>
> > Peter
>
> > I don't believe "spaceless" will work because in the example I posted
> > there are no html tags within the  block.
> > Consider the same example where var2 is evaluated to be false:
>
> > 
> >   header
> >   ...
> > --NEWLINE--
> >   ...
> >   footer
> > 
>
> > The newline remains, but is displayed on a webpage because it is in
> > the  block.
>
> > On May 12, 11:10 am, Peter Landry  wrote:
>
> > > If you want to keep the newlines in your template, you can 
> > > usehttp://docs.djangoproject.com/en/1.1/ref/templates/builtins/#spaceless
>
> > > Peter
>
> > > On 5/12/10 2:02 PM, "Noah Watkins"  wrote:
>
> > > > I have a variable amount of lines that need to be displayed in a
> > > >  block:
>
> > > > 
> > > >   header
> > > >   {% if var1 %}{{ ... }}{% endif %}
> > > >   {% if var2 %}{{ ... }}{% endif %}
> > > >   {% if var3 %}{{ ... }}{% endif %}
> > > >   footer
> > > > 
>
> > > > However, if some of the if-statements are not evaluated to be true
> > > > then the line breaks are still displayed in the pre area causing
> > > > "gaps". Are there any easy approaches to addressing this issue?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Comments inside a loop

2010-05-12 Thread Yanik
Wow, I feel totally stupid... works like a charm now :)

On May 12, 2:14 pm, Karen Tracey  wrote:
> On Wed, May 12, 2010 at 1:52 PM, Yanik  wrote:
> > Hello,
>
> > I'm trying to do something that seemed simple, but can't get to work:
> > displaying comments using Django (1.2 RC)'s Comment framework inside a
> > loop.
>
> > {% for entry in entries %}
> >        {% get_comment_list for entry as comments %}
> >        {% render_comment_form for entry %}
> > {% endfor %}
>
> > but I get an error:
>
> > Invalid block tag: 'get_comment_list', expected 'empty' or 'endfor'
>
> This is the template system's way of saying you forgot to:
>
> {% load comments %}
>
> before trying to use one of the comment tags.
>
> get_comment_list is an invalid block tag because it has not been loaded yet.
>
> (By the way you are not doing anything with the list of comments after you
> retrieve it?)
>
> Karen
> --http://tracey.org/kmt/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Removing template newlines in

2010-05-12 Thread Peter Landry
Right, sorry! Read your question too quickly.

Peter


On 5/12/10 2:20 PM, "Noah Watkins"  wrote:

> Peter
> 
> I don't believe "spaceless" will work because in the example I posted
> there are no html tags within the  block.
> Consider the same example where var2 is evaluated to be false:
> 
> 
>   header
>   ...
> --NEWLINE--
>   ...
>   footer
> 
> 
> The newline remains, but is displayed on a webpage because it is in
> the  block.
> 
> 
> On May 12, 11:10 am, Peter Landry  wrote:
>> If you want to keep the newlines in your template, you can
>> usehttp://docs.djangoproject.com/en/1.1/ref/templates/builtins/#spaceless
>> 
>> Peter
>> 
>> On 5/12/10 2:02 PM, "Noah Watkins"  wrote:
>> 
>>> I have a variable amount of lines that need to be displayed in a
>>>  block:
>> 
>>> 
>>>   header
>>>   {% if var1 %}{{ ... }}{% endif %}
>>>   {% if var2 %}{{ ... }}{% endif %}
>>>   {% if var3 %}{{ ... }}{% endif %}
>>>   footer
>>> 
>> 
>>> However, if some of the if-statements are not evaluated to be true
>>> then the line breaks are still displayed in the pre area causing
>>> "gaps". Are there any easy approaches to addressing this issue?
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group
>> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 with multi-db test suite.

2010-05-12 Thread J. Cliff Dyer
On Wed, 2010-05-05 at 08:08 +0800, Russell Keith-Magee wrote: 
> On Wed, May 5, 2010 at 1:43 AM, J. Cliff Dyer  wrote:
> > I'm having trouble working with multi-db using mysql replication.  When
> > I run our test suite, I'm getting several hundred errors if I have more
> > than one database configured, and none if I have only one configured.
> >
> > It seems that something isn't getting properly cleared out between test
> > cases, so duplicate objects are getting created.
> >
> > My DATABASES setting looks like this:
> >
> >
> > DATABASES = {
> >'default': {
> >'ENGINE': 'django.db.backends.mysql',
> >'HOST': 'jellyroll',
> >'NAME': 'ee',
> >'USER': 'ee',
> >'PASSWORD': 'ee',
> >'OPTIONS': {
> >'init_command': 'SET storage_engine=INNODB',
> >'charset' : 'utf8',
> >'use_unicode' : True,
> >},
> >},
> >'replicant0': {
> >'ENGINE': 'django.db.backends.mysql',
> >'HOST': 'jellyroll-rep0',
> >'NAME': 'test',
> >'USER': 'ee',
> >'PASSWORD': 'ee',
> >'TEST_MIRROR': 'default',
> >'OPTIONS': {
> >'init_command': 'SET storage_engine=INNODB',
> >'charset' : 'utf8',
> >'use_unicode' : True,
> >},
> >},
> > }
> >
> >
> > My router looks like this:
> >
> > class PrimaryReplicantRouter(object):
> >"""Set up routing with one primary database, and zero or more
> >replicant databases."""
> >
> >db_list = settings.DATABASES.keys()
> >primary_db = 'default'
> >replicant_db_list = [x for x in db_list if x != primary_db]
> >
> >def db_for_read(self, model, **hints):
> >try:
> >return random.choice(self.replicant_db_list)
> >except IndexError:
> >return self.primary_db
> >
> >
> >def db_for_write(self, model, **hints):
> >"""Write to the Primary DB"""
> >return self.primary_db
> >
> >def allow_relation(self, obj1, obj2, **hints):
> >"""Allow a relationship between any two objects in the db
> >pool"""
> >
> >if (obj1._state.db in self.db_list
> >and obj2._state.db in self.db_list):
> >return True
> >return None
> >
> >def allow_syncdb(self, db, models):
> >"""All writes go to the primary db."""
> >return db == self.primary_db
> >
> > The first error that comes out of the test suite is a duplicate username
> > in auth during a testcase's setUp, which makes it look like the object
> > is getting created on one test pass, and then created again the next
> > time around without deleting it properly:
> >
> >
> > $ ./manage.py test --failfast
> > .E
> > ==
> > ERROR: Regressiontest for #12462
> > --
> > Traceback (most recent call last):
> >  File
> > "/home/cliff/projects/lr-mdb/lexilereader/web/../contrib/django/contrib/auth/tests/auth_backends.py",
> >  line 14, in setUp
> >User.objects.create_user('test', 't...@example.com', 'test')
> > ...
> > IntegrityError: (1062, "Duplicate entry 'test' for key 2")
> >
> >
> > Any ideas what's going wrong?
> 
> I can't say I've seen this problem myself. Some more details might
> help narrow down the problem:
> 
>  * Is your test case marked as a multidb test? (i.e., multidb=True on
> the test case itself)
> 
>  * Can you describe your database configuration in more detaill?
> Specifically, when the test framework creates the test database
> (presumably on 'jellyroll') does a slave also get created
> automatically? Is the test slave automatically paired to the test
> master?
> 
> Yours,
> Russ Magee %-)
> 

Thanks, and sorry it took so long for me to revive this.  I traced the
problem to a replication error.  Somehow, the primary database was
getting created with the InnoDB engine, but the replicants were getting
created with MyISAM.  

Cheers,
Cliff


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 display an image inside Django

2010-05-12 Thread newbiedjango
If you are trying to upload images as static images just as we do in
html with an img tag then you might want to look for how to serve
static documentation on the django book.
You would need to make changes in settings.py by defining media_url,
media_root, etc.
and then make sure your root is on PYTHON PATH. then its just like
html tags..you can add img tag whereevr in ur template.
hope this will help..!!
Andy

On May 11, 8:10 pm, ravi krishna  wrote:
> Hi,
> I am a beginner in Django .
> Can somebody tel me how to display an image in django...
> if anyone has the right tutorial for beginners, please share with me..
> --
> Regards,
> Rav!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 url tag fetches wrong URL with generic view

2010-05-12 Thread Mike Dewhirst
I'm working through the Coltrane weblog tutorial and trying to implement 
semi-hard-coded breadcrumbs. It seems reverse doesn't like what I've done.


This is the template inheritance chain ...

1. Salient parts of underlying template ...

{% block breadcrumbs %}{{ block.super }}
  › Mike's Blog
{% endblock %}


2. A separate template coltrane/entry_archive.html inherits the above 
breadcrumbs properly with block.super. It contains a link to a blog 
entry which successfully brings up a page containing the full entry via 
a generic view and coltrane/entry_detail.html but ...



3. I have a problem in breadcrumbs in coltrane/entry_detail.html ...

{% block breadcrumbs %}{{ block.super }}
  › Entries
  › Entry detail
{% endblock %}

... and here the url tag fetches the wrong URL. Instead of rendering 
entry_archive.html as I expected, it renders entry_detail.html with 
exactly the same detail as the link in 2 above.


I have tried closing down the dev server and browser and starting again 
but the same thing happens.


My urls.py and /urls/*.py files are as documented in the book.

Where have I gone astray?

Thanks

Mike

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.



[Solved] template url tag fetches wrong URL with generic view

2010-05-12 Thread Mike Dewhirst

On 13/05/2010 12:43pm, Mike Dewhirst wrote:

I'm working through the Coltrane weblog tutorial and trying to implement
semi-hard-coded breadcrumbs. It seems reverse doesn't like what I've done.


Totally fair. I don't like what I did either.

In 3. below I left out the = between href and the url tag.

Sorry to bother you

Mike



This is the template inheritance chain ...

1. Salient parts of underlying template ...

{% block breadcrumbs %}{{ block.super }}
› Mike's Blog
{% endblock %}


2. A separate template coltrane/entry_archive.html inherits the above
breadcrumbs properly with block.super. It contains a link to a blog
entry which successfully brings up a page containing the full entry via
a generic view and coltrane/entry_detail.html but ...


3. I have a problem in breadcrumbs in coltrane/entry_detail.html ...

{% block breadcrumbs %}{{ block.super }}
› Entries
› Entry detail
{% endblock %}

... and here the url tag fetches the wrong URL. Instead of rendering
entry_archive.html as I expected, it renders entry_detail.html with
exactly the same detail as the link in 2 above.

I have tried closing down the dev server and browser and starting again
but the same thing happens.

My urls.py and /urls/*.py files are as documented in the book.

Where have I gone astray?

Thanks

Mike



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.



Shows indendation error

2010-05-12 Thread ravi krishna
Hi,,This is my url.py file, when i run this it shows indendation error at
line 25. But i dont see an indendation error. Can somebody help me. I am
just a  beginner with Django.


from django.conf.urls.defaults import *
from django.conf import settings

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
#if settings.DEBUG:
# urlpatterns += patterns('django.views.static',
# (r'^static_media/(?P.*)$',
# 'serve', {
# 'document_root': '/path/to/static_media',
# 'show_indexes': True }),)

)
# Example:
# (r'^mysite/', include('mysite.foo.urls')),

# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/',include('admin.site.urls')),
(r'^$','mysite.polls.views.index'),
(r'^index','mysite.polls.views.index'),
(r'^detail/(?P\d+)','mysite.polls.views.detail'),
(r'^results/(?P\d+)','mysite.polls.views.results'),
(r'^vote/(?P\d+)','mysite.polls.views.vote'),
(r'^latest','mysite.polls.views.latest'),
(r'^page1', 'polls.views.page1'),
(r'^page2','polls.views.page2'),
(r'^page3','polls.views.page3'),
#(r'^site_media/(?P.*)$')
#django.views.static.serve', {'document_root': '/path/to/media'})
(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/root/Desktop/mysite/temp1/images'})
)


-- 
Regards,
Rav!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.