Re: Banned from the #django irc channel

2010-02-26 Thread James Purser
On Fri, 2010-02-26 at 22:17 -0500, Shawn Milochik wrote:
> I asked in the IRC, but nobody answered. There seemed to be almost no  
> activity at all, though. Maybe someone who's associated with the room  
> will see this thread and help.
> 
> Shawn 

You could always ask in #freenode to see if you have been banned.
-- 
James Purser
Collaborynth
http://collaborynth.com.au
Mob: +61 406 576 553
Skype: purserj1977
Twitter: http://twitter.com/purserj
GWave: jamesrpur...@gmail.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.



Re: fixtures getting created with terminal message prefixed

2010-02-26 Thread Russell Keith-Magee
On Sat, Feb 27, 2010 at 4:07 AM, Joel Stransky  wrote:
> When ever I create a fixture via dumpdata, I get this text prior to the
> start of the data.
>
> Please select your server identifier.
>    1) admin
>    2) aws
>    3) dipsy
>    4) dot
>    5) local
>    6) sdeng
>    7) soup
>    8) tomcatdev
>    9) www
> What server identifier would you like to use? []
>
> So if I run:
> manage.py dumpdata > path/to/my/fixtures/myFixture.json
>
> I have to open the file and delete that text before I can run:
> manage.py loaddata myFixture.
>
> Anything I can do to prevent that text from getting saved into my fixture?

To the best of my knowledge, this isn't text that is produced by
Django. I can't even think what might be generating this text. Without
knowing the cause, there isn't much we can do to help.

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-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: Banned from the #django irc channel

2010-02-26 Thread James Bennett
2010/2/26 Matías Iturburu :
> Hi guys, Sorry to bring such an off topic, but I've notice that I'm banned
> on the django irc channel (at least I'm receaving #django :Cannot send to
> channel any time I want to talk there, my nick name is *tutuca*).
> I don't think I've ever been disrespectful or, in any other way, rude in the
> channel, so I would like to know why I've been banned, or if there is any
> way I can know the reason of this.

If you were banned you'd be getting a message in your IRC client
saying something like "you're banned" or "you cannot join #django"
(and so far as I can tell you aren't). The message you're receiving,
however, is more indicative of trying to send a message to the channel
without actually being in the channel at the time; no-one is allowed
to do that, because it's too often abused by spambots.


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

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



how to determine field type in a form field?

2010-02-26 Thread Tom von Schwerdtner
When looping through form fields in a template, is there any way to
tell what type of field/widget I'm dealing with in the template?  I
have found input_type, but that is only used on subclasses of Input
and not Widget (eg, not textarea or checkbox).

TIA
-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: Banned from the #django irc channel

2010-02-26 Thread Shawn Milochik
I asked in the IRC, but nobody answered. There seemed to be almost no  
activity at all, though. Maybe someone who's associated with the room  
will see this thread and help.


Shawn 
 


--
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: Banned from the #django irc channel

2010-02-26 Thread Matías Iturburu
On Fri, Feb 26, 2010 at 11:17 PM, Shawn Milochik  wrote:

> Have you tried different clients?
>

Empathy and Xchat. I don't think it has to do with it.


>
> Have you tried posting in different Freenode chat rooms?
>

Currently active in at least 4 freenode chat rooms


>
> Is your account an authenticated one with Freenode?
>

yes sir


>
> Shawn
>

Thanks for the quick feedback, hope my answers help work around this. Is
there any way to get the logs of the chat channel regarding this kind of
issues?



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


-- 
Matías Iturburu
http://www.linkedin.com/in/miturburu

-- 
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: Banned from the #django irc channel

2010-02-26 Thread Shawn Milochik
Have you tried different clients? 

Have you tried posting in different Freenode chat rooms?

Is your account an authenticated one with Freenode?

Shawn

-- 
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: charField null=false not enforced for table creation in oracle

2010-02-26 Thread Karen Tracey
On Fri, Feb 26, 2010 at 5:35 PM, Wayne  wrote:

> Hi,
> I try to create tables using Django models in our test oracle
> database. I define a model with one column like this: name =
> models.CharField(max_length=512, null=False, blank=False). After
> running python manage.py syncdb, I found that column 'name' in the
> generated table still allows null value in the column definition. I
> understand that null = false is the default option. And I verified
> that for other types of Django fields, null = false or no such option
> at all would generate columns that do not allow null values in the
> database. Is there particular reason why null = false is not enforced
> for charField?


Yes. Oracle does not distinguish between null and an empty string. So
null=False applied at the database level would mean that you also could not
store the empty string in that field, which would be quite different from
what you would see running the same code on most other databases, where the
empty string is a valid value for a NOT NULL character field.

The behavior is documented, see the note here:
http://docs.djangoproject.com/en/dev/ref/models/fields/#null. The note is
perhaps not as clear as it could be about when the empty string is allowed
for a field. That's a property of the field type (for example, empty strings
are allowed for CharField but not a DateField), and is not in any way tied
to the value of the field's blank option. The blank option, as noted in its
description, is used for validation and is not applied at the database
level.

Karen

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



Banned from the #django irc channel

2010-02-26 Thread Matías Iturburu
Hi guys, Sorry to bring such an off topic, but I've notice that I'm banned
on the django irc channel (at least I'm receaving #django :Cannot send to
channel any time I want to talk there, my nick name is *tutuca*).
I don't think I've ever been disrespectful or, in any other way, rude in the
channel, so I would like to know why I've been banned, or if there is any
way I can know the reason of this.
The irc is a great way of having a quick feedback about roadblocks so I'm
very annoyed of this (at least from my part) un understable situation.

Hope somebody can give me a pointer.
Thanks in advance

-- 
Matías Iturburu
http://www.linkedin.com/in/miturburu

-- 
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: Handling input of external urls

2010-02-26 Thread russianbandit
Sorry for being sort of a newb when it comes to regex. But what
exactly does that line do?

On Feb 26, 3:59 pm, "ge...@aquarianhouse.com"
 wrote:
> Check it with regex?
>
> re.compile("[a-z0-9]\.[a-z]{2,6}$", re.I)

-- 
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: Handling input of external urls

2010-02-26 Thread ge...@aquarianhouse.com
Check it with regex?

re.compile("[a-z0-9]\.[a-z]{2,6}$", re.I)

-- 
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: update a record without typing too much

2010-02-26 Thread ge...@aquarianhouse.com
maybe like this?:

def up(model, **kw):
m.objects.filter(pk=model.pk).update(**kw)

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



charField null=false not enforced for table creation in oracle

2010-02-26 Thread Wayne
Hi,
I try to create tables using Django models in our test oracle
database. I define a model with one column like this: name =
models.CharField(max_length=512, null=False, blank=False). After
running python manage.py syncdb, I found that column 'name' in the
generated table still allows null value in the column definition. I
understand that null = false is the default option. And I verified
that for other types of Django fields, null = false or no such option
at all would generate columns that do not allow null values in the
database. Is there particular reason why null = false is not enforced
for charField?
My Django version is 1.1.1, Python version is 2.6, and oracle server
is 10g release 2.

Many thanks for your help.

Wayne

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



Handling input of external urls

2010-02-26 Thread russianbandit
This is a fairly general question, but what is the best way to handle
and verify user entry of external urls? For example, if the user types
in "google.com", django will try to render "http://localhost:8000/
users/google.com". That is obviously not what I want. I know that if
the user types in "http://google.com; the request will be forwarded
correctly to Google. Thus my question is, what is the right/best way
to handle user input of external urls?

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



using ForeignKeyRawIdWidget

2010-02-26 Thread pablo platt
Hi,

I want to extend ForeignKeyRawIdWidget so I want to be able to use it
without setting raw_id_fields.

With the following I don't get an error but I see no effect:

# models.py
class Product(models.Model):
...

class GroupProduct(Product):
...
products = models.ManyToManyField(Product,
related_name="%(class)s_related")

# forms.py
class GroupProductAdminForm(forms.ModelForm):
class Meta:
model = GroupProduct
widgets = {
'products':
ForeignKeyRawIdWidget(GroupProduct._meta.get_field('products').rel),
}

This gives me an error: *init*() takes at least 2 non-keyword arguments (1
given)
class GroupProductAdminForm(forms.ModelForm):
class Meta:
model = GroupProduct
products =
forms.ModelMultipleChoiceField(widget=ForeignKeyRawIdWidget(GroupProduct._meta.get_field('products').rel))

What am I doing wrong?

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.



fixtures getting created with terminal message prefixed

2010-02-26 Thread Joel Stransky
When ever I create a fixture via dumpdata, I get this text prior to the
start of the data.

Please select your server identifier.
   1) admin
   2) aws
   3) dipsy
   4) dot
   5) local
   6) sdeng
   7) soup
   8) tomcatdev
   9) www
What server identifier would you like to use? []

So if I run:
manage.py dumpdata > path/to/my/fixtures/myFixture.json

I have to open the file and delete that text before I can run:
manage.py loaddata myFixture.

Anything I can do to prevent that text from getting saved into my fixture?

Thanks.

-- 
--Joel Stransky
stranskydesign.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.



Django/Satchmo for Membership orgs (dues, event registration, etc.)

2010-02-26 Thread django_jedi
Can anyone show me any examples of Membership organizations that use
Django/Satchmo for:

* membership registration w/recurring billing for annual dues
* events registration (like eventbrite type stuff)

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: test_cookie_worked() fails although cookie is set

2010-02-26 Thread Timothy Kinney
Okay, the problem was that the cookie was from my admin login (which I had
not logged out of). When I deleted this cookie, the cookie test seemed to
work. It does seem odd that I can't have two cookies for two different users
on the same browser. Is there a way to change this? Maybe by incorporating
the user id into the session id? My cookie was just called
myproject_myapp_sessionid.

-Tim


On Fri, Feb 26, 2010 at 2:07 AM, Timothy Kinney wrote:

> Following: http://www.djangobook.com/en/2.0/chapter14/
>
> I used the request.session.set_test_cookie() method when I pass the
> login form. I then use the request.session.test_cookie_worked() method
> to see if the cookie was set.
>
> My view is setup to tell me when the test_cookie_worked() method
> fails, and it always shows that it fails. However, if I go into
> Firefox and search for the cookie it is there.
>
> What's going on?
>
> ** views.py **
>
> def login_view(request, user=None):
>if request.method == 'POST': # If the form has been submitted...
>if request.session.test_cookie_worked():
>request.session.delete_test_cookie()
>
>form = LoginForm(request.POST) # A form bound to the POST
> data
>if form.is_valid():
>username = form.cleaned_data['username']
>password = form.cleaned_data['password']
>
>user = authenticate(username=username,
> password=password)
>
>if user is not None:
>if user.is_active:
>login(request, user)
>u =
> User.objects.get(username__exact=request.POST['username'])
>request.session['user'] = u.username
>return HttpResponseRedirectView("logged in")
>
>else:
>return HttpResponse("Your account is
> inactive.")
>
>elif user is None:
>return render_to_response('login.html',
>  {'error_message': 'You failed to
> authenticate.'})
>else:
>return render_to_response('login.html', {'form': form,
>'error_message': 'Invalid form. Did you leave one
> of the fields blank?'})
>else:
>   return HttpResponse("Cookies are required to login.")
>else:
>form = LoginForm() # An unbound form
>request.session.set_test_cookie()
>return render_to_response('login.html', {'form': form,
>'error_message': 'Login please'})
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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: Storing Template Vars in Database and rendering

2010-02-26 Thread Timothy Kinney
Also, take a look at the template Tag feature.
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags(scroll
down about half way).

It allows you to define a template (such as a dialog object) and call it
from another template, thereby inserting it where you want it. I think this
is the way to go for a django text adventure.

I'm also working on Django browser games and I'm glad to see others working
in this realm. Let me know when you need a beta tester and I'll be happy to
help.

-Tim


On Fri, Feb 26, 2010 at 11:42 AM, HumanSimulator <
thehumansimula...@gmail.com> wrote:

> Thank you for the help. I'm going to test it when I get a chance. Now
> that you've said it, it should have been clear to me from the start.
>
> On Feb 26, 11:38 am, Tom Evans  wrote:
> > On Fri, Feb 26, 2010 at 4:25 PM, HumanSimulator
> >
> >
> >
> >
> >
> >  wrote:
> > > I apologize if this has been discussed before but I did search and
> > > wasn't able to find what I'm looking for.
> >
> > > Anyways, I'm currently writing a very simplistic text adventure style
> > > game in Django and what I'm looking for is to store a template var in
> > > the database and then render it.
> >
> > > Like say I have
> >
> > > zone_text = "A shadowy figure comes up to you and says 'Hey
> > > {{ character.name }} I've been waiting for you"
> >
> > > If character.name is passed in through the context as "Hernan" I would
> > > obviously want it to show up as Hey Hernan I've been waiting for you.
> > > Instead it leaves it unevaluated though.
> >
> > > Is there already a way either in Django, or that someone has already
> > > coded that will re-parse the text and put out the correct sentence? I
> > > don't want to re-invent the wheel if it's already been done.
> >
> > > Thank you for your help.
> > > -Bob
> >
> > You will need to render it:
> >
> > from django.template import RequestContext, Template
> > zone_text = '...'
> > rendered_zone_text =
> > Template(zone_text).render(RequestContext(request, { 'foo': 'bar' })
> >
> > 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.
>
>

-- 
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: what's the right way to extend an admin view with AJAX?

2010-02-26 Thread snfctech
Thanks for the encouragement, Timothy.  I haven't given up, but I'm
scratching my head, and puzzled by why I have to look at people's blog
posts to figure out how to use javascript/AJAX with Django.  It may be
that I disagree with Django's philosophy that the framework should not
be coupled with JS.

On Feb 26, 10:34 am, Timothy Kinney  wrote:
> Django was definitely designed to be extended. But it is sometimes hard to
> find the write ways to extend what you specifically want. Don't give up on
> extending admin. Hopefully someone will point you in the write direction.
>
> On Fri, Feb 26, 2010 at 11:06 AM, snfctech  wrote:
> > (Disclamor: I am new to Python/Django.  Used to PHP/MVC ways of doing
> > things.)
>
> > I want to customize the admin view, because it already does >50% of
> > what I want for my application.
>
> > So, do I...
>
> > 1. Alter the HTML sent to the template?
>
> > One of the first things I want to do is add an AJAX onclick record
> > detail display below the built-in change_list view.  So, I started by
> > thinking I need to add an onclick attribute or at least a  id to
> > the HTML that is rendered for the result_list block in the change_list
> > template.  This got me sniffing around django.contrib.admin.views.main
> > and other files and I soon felt like I was barking up the wrong tree.
>
> > 2. Traverse the DOM on domready?
>
> > Then SmileyChris on #django suggested I add JS to traverse the DOM in
> > order to add my onclick attribute.  So I thought, okay, now I need to
> > learn the right way to write javascript for Django.  So I entered the
> > keyword "javascript" in the Django documentation search field, and the
> > results were not very satisfying.  Then I checked djangobook.com and
> > found a tiny section called "Custom JavaScript" in chapter 17.  I
> > thought, "great, I'll just window.addEvent('domready', function()
> > { var changelist = document.getElementById('changelist')}); and go
> > from there."  But, no dice.  No 'changelist' node on domready.  I
> > don't get it.
>
> > So I spent the rest of the day googling and banging my head trying to
> > figure out how Django deals with Javascript.  The best I found were
> > some links to random blogs like:
>
> >http://lethain.com/entry/2008/sep/21/intro-to-unintrusive-javascript-...
> > .
> > But I kept searching because I thought learning how to work with
> > javascript/AJAX in Django must certainly be in the core documentation
> > somewhere, not in a random blog.  Am I missing something?
>
> > So, is the right way to extend and admin view with AJAX one of the
> > above methods I mentioned?
>
> > Is the authoritative Django documentation for how to work with
> > javascript/AJAX a blog like
> >http://lethain.com/entry/2008/sep/21/intro-to-unintrusive-javascript-...
> > ?
>
> > Am I already going down the wrong path because, even though the admin
> > code does >50% of what I want my app to do, I should not be
> > customizing the admin code to build my app.
>
> > Thanks in advance for any tips.
>
> > --
> > 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: what's the right way to extend an admin view with AJAX?

2010-02-26 Thread Timothy Kinney
Django was definitely designed to be extended. But it is sometimes hard to
find the write ways to extend what you specifically want. Don't give up on
extending admin. Hopefully someone will point you in the write direction.

On Fri, Feb 26, 2010 at 11:06 AM, snfctech  wrote:

> (Disclamor: I am new to Python/Django.  Used to PHP/MVC ways of doing
> things.)
>
> I want to customize the admin view, because it already does >50% of
> what I want for my application.
>
> So, do I...
>
> 1. Alter the HTML sent to the template?
>
> One of the first things I want to do is add an AJAX onclick record
> detail display below the built-in change_list view.  So, I started by
> thinking I need to add an onclick attribute or at least a  id to
> the HTML that is rendered for the result_list block in the change_list
> template.  This got me sniffing around django.contrib.admin.views.main
> and other files and I soon felt like I was barking up the wrong tree.
>
> 2. Traverse the DOM on domready?
>
> Then SmileyChris on #django suggested I add JS to traverse the DOM in
> order to add my onclick attribute.  So I thought, okay, now I need to
> learn the right way to write javascript for Django.  So I entered the
> keyword "javascript" in the Django documentation search field, and the
> results were not very satisfying.  Then I checked djangobook.com and
> found a tiny section called "Custom JavaScript" in chapter 17.  I
> thought, "great, I'll just window.addEvent('domready', function()
> { var changelist = document.getElementById('changelist')}); and go
> from there."  But, no dice.  No 'changelist' node on domready.  I
> don't get it.
>
> So I spent the rest of the day googling and banging my head trying to
> figure out how Django deals with Javascript.  The best I found were
> some links to random blogs like:
>
> http://lethain.com/entry/2008/sep/21/intro-to-unintrusive-javascript-with-django/
> .
> But I kept searching because I thought learning how to work with
> javascript/AJAX in Django must certainly be in the core documentation
> somewhere, not in a random blog.  Am I missing something?
>
> So, is the right way to extend and admin view with AJAX one of the
> above methods I mentioned?
>
> Is the authoritative Django documentation for how to work with
> javascript/AJAX a blog like
> http://lethain.com/entry/2008/sep/21/intro-to-unintrusive-javascript-with-django/
> ?
>
> Am I already going down the wrong path because, even though the admin
> code does >50% of what I want my app to do, I should not be
> customizing the admin code to build my app.
>
> Thanks in advance for any tips.
>
> --
> 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.



buildout and fixtures

2010-02-26 Thread }--o
Hi,

we are switching to buildout for django development, but have several
problems for the moment, mainly related to test running.

Previously we've had a django project in all our applications' directory to
easily run ./manage.py test myapp from inside Eclipse.
now using djangorecipe we can run $ bin/test-1.1, but this is not integrated
into eclipse, which makes its use rather unconvenient.
How should we set up buildout in order to Eclipse recognise the lines of
output?

A related question is about fixtures. How can we load fixtures of an egg?
Here is one of our buildouts:

[buildout]
parts = python django-1.1 omelette
develop = .
eggs =
django-contacts
django-l10n
django-registration
django-uni-form
django-sugar
eggs-directory = /home/nagyv/.buildout/eggs
find-links =
${buildout:eggs-directory}
http://pypi.python.org/simple/
download-cache = /home/nagyv/.buildout/dlcache

extensions = mr.developer
sources = sources
auto-checkout =
uni-form
sugar

[omelette]
recipe = collective.recipe.omelette
eggs = ${buildout:eggs}

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

[django-1.1]
recipe = djangorecipe
version = 1.1.1
project = contacts
projectegg = contacts
settings = testsettings
test = contacts
testrunner = test-1.1
eggs = ${buildout:eggs}

[sources]
uni-form = git git://github.com/nagyv/django-uni-form.git
sugar = git git://github.com/nagyv/django-sugar.git

As a bonus question, I would like to ask as well how to set
${buildout:eggs-directory} and ${buildout:download-directory} for something
like $HOME/.buidout/ I was Googleing after this but without much
success.

thanks for your greatly appreciated help

Enjoy your day!
Viktor

-- 
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: session key

2010-02-26 Thread Sumanth
Thanks David,
Makes sense .


On Feb 26, 9:39 am, David De La Harpe Golden
 wrote:
> On 26/02/10 16:50, Sumanth wrote:
>
> > Hi ,
>
> > I was trying to access the session key using request.session object in
> > django.  To do this we can use
> > request.session._session_key or request.session.session_key out of
> > this which is the right one to use ?
>
> The latter, without the leading underscore. This is really a python
> question -  A leading underscore '_' is a standard python naming
> convention for "consider this private":
>
> http://www.python.org/dev/peps/pep-0008/
>
> The privacy is not rigidly enforced like some languages, however things
> like "import *" do respect it by default.
>
> > But would like to know why _session_key returns None for first
> > time .
>
> Probably because it's lazily maintained - accessing session_key
> will call _get_session_key (it's property wrapped), which
> will wind up setting the private _session_key - if it's not already set.
>
> http://docs.python.org/library/functions.html#property
>
> http://code.djangoproject.com/browser/django/trunk/django/contrib/ses...

-- 
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: Storing Template Vars in Database and rendering

2010-02-26 Thread HumanSimulator
Thank you for the help. I'm going to test it when I get a chance. Now
that you've said it, it should have been clear to me from the start.

On Feb 26, 11:38 am, Tom Evans  wrote:
> On Fri, Feb 26, 2010 at 4:25 PM, HumanSimulator
>
>
>
>
>
>  wrote:
> > I apologize if this has been discussed before but I did search and
> > wasn't able to find what I'm looking for.
>
> > Anyways, I'm currently writing a very simplistic text adventure style
> > game in Django and what I'm looking for is to store a template var in
> > the database and then render it.
>
> > Like say I have
>
> > zone_text = "A shadowy figure comes up to you and says 'Hey
> > {{ character.name }} I've been waiting for you"
>
> > If character.name is passed in through the context as "Hernan" I would
> > obviously want it to show up as Hey Hernan I've been waiting for you.
> > Instead it leaves it unevaluated though.
>
> > Is there already a way either in Django, or that someone has already
> > coded that will re-parse the text and put out the correct sentence? I
> > don't want to re-invent the wheel if it's already been done.
>
> > Thank you for your help.
> > -Bob
>
> You will need to render it:
>
> from django.template import RequestContext, Template
> zone_text = '...'
> rendered_zone_text =
> Template(zone_text).render(RequestContext(request, { 'foo': 'bar' })
>
> 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: session key

2010-02-26 Thread David De La Harpe Golden

On 26/02/10 16:50, Sumanth wrote:

Hi ,

I was trying to access the session key using request.session object in
django.  To do this we can use
request.session._session_key or request.session.session_key out of
this which is the right one to use ?



The latter, without the leading underscore. This is really a python 
question -  A leading underscore '_' is a standard python naming 
convention for "consider this private":


http://www.python.org/dev/peps/pep-0008/

The privacy is not rigidly enforced like some languages, however things 
like "import *" do respect it by default.



But would like to know why _session_key returns None for first
time .



Probably because it's lazily maintained - accessing session_key
will call _get_session_key (it's property wrapped), which
will wind up setting the private _session_key - if it's not already set.

http://docs.python.org/library/functions.html#property

http://code.djangoproject.com/browser/django/trunk/django/contrib/sessions/backends/base.py#L158

--
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: RV: photos sexy

2010-02-26 Thread Frank DiRocco

I was kinda in the mood for Raven ;)

On Feb 26, 2010, at 12:10 PM, Gisela Cartaya wrote:

My apologize for all, this has been a big mistake error, this is a  
technical mailing list I ask to the administrator to delete from  
archive that email as soon as possible.

Thanks
Greetings.

De: Nicolas Couture [mailto:nicolas.cout...@gmail.com]
Enviado el: Friday, February 26, 2010 1:16 AM
Para: django-users@googlegroups.com
CC: isaacr...@gmail.com
Asunto: Re: RV: photos sexy

This is probably the funniest post I've seen on a technical mailing  
list this year.





__ Information from ESET NOD32 Antivirus, version of virus  
signature database 4220 (20090706) __


The message was checked by ESET NOD32 Antivirus.

http://www.eset.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 
.


--
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: update a record without typing too much

2010-02-26 Thread Ethan Jucovy
On Fri, Feb 26, 2010 at 12:11 PM, Phlip  wrote:
> Djangoids:
>
> Consider this pattern:
>
>    product.brand = brand
>    product.in_stock = True
>    product.save()
>
> Because business-layer code does that all the time, can we DRY the
> code up a little?
>
> def up(model, **kw):
>    for key, value in kw.iteritems():
>        model.__dict__[key] = value
>
>    model.save()
>
> That provides this:
>
>   up(product, brand=brand, in_stock=True)
>
> It indeed looks kewt, but it does not always work. If, for
> example, .brand is a model object, then it ain't in the __dict__.
>
> So is there some more clever way to do this?

setattr(model, key, value)

-- 
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: RV: photos sexy

2010-02-26 Thread Jaime Casanova
On Fri, Feb 26, 2010 at 12:10 PM, Gisela Cartaya
 wrote:
> My apologize for all, this has been a big mistake error, this is a technical
> mailing list I ask to the administrator to delete from archive that email as
> soon as possible.
>

let it him take it easy... the photos were good ;)

-- 
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157

-- 
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: RV: photos sexy

2010-02-26 Thread Brice Leroy
It's just that dev in django makes you more attractive I guess

2010/2/26 Tiago Freire 

> I bet this is a ploy of the django team to draw in more developers...
>
> ---
> Tiago Mikhael Pastorello Freire
>
> Av. Getúlio Vargas, 901 sala 1502
> Bairro Menino Deus
> Porto Alegre
> CEP 90150-003
> +55 (51) 3012-7080
> www.cert-id.com.br
>
> On Feb 26, 2010, at 3:16 AM, Nicolas Couture wrote:
>
> This is probably the funniest post I've seen on a technical mailing list
> this year.
>
> 2010/2/26 Gisela Cartaya 
>
>  --
> 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.
>



-- 
blog: http://alpha.debrice.com
project: http://alpha.kaaloo.com http://www.djangogenerator.com
linkedin: http://www.linkedin.com/in/bricepleroy

-- 
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: RV: photos sexy

2010-02-26 Thread Jeremy Dunck
That's enough, folks.  Gisela seems to be doing some off-topic work
and made a silly mistake using gmail autocomplete.

Let's let this one go.  There's no need to be crass or misogynist.


On Fri, Feb 26, 2010 at 11:22 AM, Juan Hernandez  wrote:
> Lastima que esa no seas tu Gisela!! jajajaj
>
> slds desde vzla
>
> On Fri, Feb 26, 2010 at 12:40 PM, Gisela Cartaya 
> wrote:
>>
>> My apologize for all, this has been a big mistake error, this is a
>> technical mailing list I ask to the administrator to delete from archive
>> that email as soon as possible.
>>
>> Thanks
>>
>> Greetings.
>>
>>
>>
>> De: Nicolas Couture [mailto:nicolas.cout...@gmail.com]
>> Enviado el: Friday, February 26, 2010 1:16 AM
>> Para: django-users@googlegroups.com
>> CC: isaacr...@gmail.com
>> Asunto: Re: RV: photos sexy
>>
>>
>>
>> This is probably the funniest post I've seen on a technical mailing list
>> this year.
>>
>>
>>
>> __ Information from ESET NOD32 Antivirus, version of virus
>> signature database 4220 (20090706) __
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.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.
>
> --
> 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: RV: photos sexy

2010-02-26 Thread Tiago Freire
I bet this is a ploy of the django team to draw in more developers...

---
Tiago Mikhael Pastorello Freire

Av. Getúlio Vargas, 901 sala 1502
Bairro Menino Deus
Porto Alegre
CEP 90150-003
+55 (51) 3012-7080
www.cert-id.com.br

On Feb 26, 2010, at 3:16 AM, Nicolas Couture wrote:

> This is probably the funniest post I've seen on a technical mailing list this 
> year.
> 
> 2010/2/26 Gisela Cartaya 

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



Please don't respond to spam conversations

2010-02-26 Thread Karen Tracey
Please don't respond to spam conversations. It's due to a bug in the Groups
infrastructure that they get through in the first place. They are deleted
from the archives as soon as they are noticed, but nothing can be done about
the fact that they get sent as email to subscribers who read the groups that
way. Please just ignore them.

Karen

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

2010-02-26 Thread Juan Hernandez
Lastima que esa no seas tu Gisela!! jajajaj

slds desde vzla

On Fri, Feb 26, 2010 at 12:40 PM, Gisela Cartaya wrote:

>  My apologize for all, this has been a big mistake error, this is a
> technical mailing list I ask to the administrator to delete from archive
> that email as soon as possible.
>
> Thanks
>
> Greetings.
>
>
>
> *De:* Nicolas Couture [mailto:nicolas.cout...@gmail.com]
> *Enviado el:* Friday, February 26, 2010 1:16 AM
> *Para:* django-users@googlegroups.com
> *CC:* isaacr...@gmail.com
> *Asunto:* Re: RV: photos sexy
>
>
>
> This is probably the funniest post I've seen on a technical mailing list
> this year.
>
>
>
>
> __ Information from ESET NOD32 Antivirus, version of virus
> signature database 4220 (20090706) __
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.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.
>

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



A search project beginneth

2010-02-26 Thread Nick
I am working on a search form for a project. I think I have down how
django handles forms (on a simple level). I am using an thml form
written in a template and passing it through a view.  I tried to write
this out as a form in a form.py file but something screwball was
happening with the file and I gave it up for the time being.

Here is my Model:


Type = models.CharField(max_length=100, choices=Type_Choices,
blank=True)
Last_Name = models.CharField('Last Name', max_length=100,
blank=True)
First_Name = models.CharField('First Name', max_length=100,
blank=True)
Position = models.CharField('Position', help_text="Only used for
non-council City and Local officials", max_length=100, blank=True,
choices=Position_Choices)
Party = models.CharField(max_length=3, choices=Party_Choices,
blank=True)
District = models.IntegerField(help_text="For State, Federal and
County Commissioners", blank=True, null=True)
Ward = models.IntegerField(help_text="For City Councils",
blank=True, null=True)
City = models.CharField(max_length=100, blank=True)
Phone = models.CharField(max_length=15, help_text="Use the form
xxx-xxx-", blank=True)
Email = models.EmailField(max_length=100, blank=True)
Contact_URL = models.URLField(max_length=200, blank=True)
DOB = models.DateField('Date of Birth',blank=True, null=True)
Gender = models.CharField(blank=True, max_length=2,
choices=Gender_Choices)
Begin_Serve = models.IntegerField('Began Serving in', blank=True,
null=True)
End_Serve = models.IntegerField('Term Limited in', blank=True,
null=True)
MugShot = models.ImageField('Mug Shot Upload', help_text="images
are to be no larger that 150x200", storage=s3_storage,
upload_to='newsok/images/Government/images', height_field=None,
width_field=None, max_length=300, blank=True)
Committees = models.ManyToManyField('Committees', blank=True)
Approp_Committee = models.ManyToManyField('Approp_Committees',
blank=True)

Here are  my (still in progress, just testing things) form and views:



Button Check





def search(request):
error = False
if 'q' in request.GET:
q = request.GET['q']
party = request.GET['party']
if not q:
error = True
else:
reps =
Rep.objects.filter(Last_Name__icontains=q).filter(Party__icontains=party)
return render_to_response('Government/
search_results.html',
{'reps': reps, 'query': q})
return render_to_response('Government/search.html', {'error':
error})


What I am looking to do is create a form that has a general search
field that queries against the last and first names and then a series
of checkboxes and radio buttons (some can have multiple selections and
some can't) to filter the search based on type of representative,
district, city. etc.

I'm throwing this out as I battle through the forms processing part of
the Django book.

Thanks,
Nick

-- 
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: RV: photos sexy

2010-02-26 Thread Gisela Cartaya
My apologize for all, this has been a big mistake error, this is a technical 
mailing list I ask to the administrator to delete from archive that email as 
soon as possible.

Thanks

Greetings.

 

De: Nicolas Couture [mailto:nicolas.cout...@gmail.com] 
Enviado el: Friday, February 26, 2010 1:16 AM
Para: django-users@googlegroups.com
CC: isaacr...@gmail.com
Asunto: Re: RV: photos sexy

 

This is probably the funniest post I've seen on a technical mailing list this 
year.

 



--

Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

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



update a record without typing too much

2010-02-26 Thread Phlip
Djangoids:

Consider this pattern:

product.brand = brand
product.in_stock = True
product.save()

Because business-layer code does that all the time, can we DRY the
code up a little?

def up(model, **kw):
for key, value in kw.iteritems():
model.__dict__[key] = value

model.save()

That provides this:

   up(product, brand=brand, in_stock=True)

It indeed looks kewt, but it does not always work. If, for
example, .brand is a model object, then it ain't in the __dict__.

So is there some more clever way to do this? (or does Django already
have it?) hopefully some way that bypasses "eval()", and other tawdry
assaults on an object's private data?

--
  Phlip
  http://penbird.tumblr.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.



what's the right way to extend an admin view with AJAX?

2010-02-26 Thread snfctech
(Disclamor: I am new to Python/Django.  Used to PHP/MVC ways of doing
things.)

I want to customize the admin view, because it already does >50% of
what I want for my application.

So, do I...

1. Alter the HTML sent to the template?

One of the first things I want to do is add an AJAX onclick record
detail display below the built-in change_list view.  So, I started by
thinking I need to add an onclick attribute or at least a  id to
the HTML that is rendered for the result_list block in the change_list
template.  This got me sniffing around django.contrib.admin.views.main
and other files and I soon felt like I was barking up the wrong tree.

2. Traverse the DOM on domready?

Then SmileyChris on #django suggested I add JS to traverse the DOM in
order to add my onclick attribute.  So I thought, okay, now I need to
learn the right way to write javascript for Django.  So I entered the
keyword "javascript" in the Django documentation search field, and the
results were not very satisfying.  Then I checked djangobook.com and
found a tiny section called "Custom JavaScript" in chapter 17.  I
thought, "great, I'll just window.addEvent('domready', function()
{ var changelist = document.getElementById('changelist')}); and go
from there."  But, no dice.  No 'changelist' node on domready.  I
don't get it.

So I spent the rest of the day googling and banging my head trying to
figure out how Django deals with Javascript.  The best I found were
some links to random blogs like:
http://lethain.com/entry/2008/sep/21/intro-to-unintrusive-javascript-with-django/.
But I kept searching because I thought learning how to work with
javascript/AJAX in Django must certainly be in the core documentation
somewhere, not in a random blog.  Am I missing something?

So, is the right way to extend and admin view with AJAX one of the
above methods I mentioned?

Is the authoritative Django documentation for how to work with
javascript/AJAX a blog like 
http://lethain.com/entry/2008/sep/21/intro-to-unintrusive-javascript-with-django/?

Am I already going down the wrong path because, even though the admin
code does >50% of what I want my app to do, I should not be
customizing the admin code to build my app.

Thanks in advance for any tips.

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



session key

2010-02-26 Thread Sumanth
Hi ,

I was trying to access the session key using request.session object in
django.  To do this we can use
request.session._session_key or request.session.session_key out of
this which is the right one to use ?


The Problem:

When you open browser for first time on web server the
request.session._session_key returns None object . What could be the
reason for this ?  Using request.session.session_key eliminates this
error . But would like to know why _session_key returns None for first
time .

I am using Djang0 1.1 and python 2.4.3

Thanks in advance
Sumanth

-- 
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: Storing Template Vars in Database and rendering

2010-02-26 Thread Tom Evans
On Fri, Feb 26, 2010 at 4:25 PM, HumanSimulator
 wrote:
> I apologize if this has been discussed before but I did search and
> wasn't able to find what I'm looking for.
>
> Anyways, I'm currently writing a very simplistic text adventure style
> game in Django and what I'm looking for is to store a template var in
> the database and then render it.
>
> Like say I have
>
> zone_text = "A shadowy figure comes up to you and says 'Hey
> {{ character.name }} I've been waiting for you"
>
> If character.name is passed in through the context as "Hernan" I would
> obviously want it to show up as Hey Hernan I've been waiting for you.
> Instead it leaves it unevaluated though.
>
> Is there already a way either in Django, or that someone has already
> coded that will re-parse the text and put out the correct sentence? I
> don't want to re-invent the wheel if it's already been done.
>
> Thank you for your help.
> -Bob
>

You will need to render it:

from django.template import RequestContext, Template
zone_text = '...'
rendered_zone_text =
Template(zone_text).render(RequestContext(request, { 'foo': 'bar' })

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.



Storing Template Vars in Database and rendering

2010-02-26 Thread HumanSimulator
I apologize if this has been discussed before but I did search and
wasn't able to find what I'm looking for.

Anyways, I'm currently writing a very simplistic text adventure style
game in Django and what I'm looking for is to store a template var in
the database and then render it.

Like say I have

zone_text = "A shadowy figure comes up to you and says 'Hey
{{ character.name }} I've been waiting for you"

If character.name is passed in through the context as "Hernan" I would
obviously want it to show up as Hey Hernan I've been waiting for you.
Instead it leaves it unevaluated though.

Is there already a way either in Django, or that someone has already
coded that will re-parse the text and put out the correct sentence? I
don't want to re-invent the wheel if it's already been done.

Thank you for your help.
-Bob

-- 
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: RV: photos sexy

2010-02-26 Thread GaRaGeD Style
totally agree :)

-- 
$ echo "scale=100; 4*a(1)" | bc -l

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



DjangoUnicodeDecodeError sqlserver latin-1

2010-02-26 Thread PyMan
Hi guys I'm having a problem with encoding (the bad beast :D ).

I'm using django 1.1.1, sqlserver 2005 with charset latin1,
sql_server.pyodbc as DATABASE_ENGINE

Here's my model-like:

class MgArtbase(models.Model):
  cod_art = models.TextField(primary_key=True)
  des_articolo = models.TextField()

  class Meta:
managed = False
db_table = u'MG_ARTBASE'

The record I read and immediatly save has a '\xe0' (that is a right-
coded "à" in latin1) in "des_articolo" field and this causes the error
you can see in the following traceback.

item = MgArtbase.objects.get(cod_art = 'xxx')
item.save() #error

TRACEBACK
Environment:

Request Method: POST
Request URL: http://localhost:8000/wec/ajax/articoli/tab/dati_articolo/10102010/
Django Version: 1.1.1
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'wec.web',
 'compress',
 'wec.std_backoffice']
Installed Middleware:
['django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'wec.middleware.DBConnect.DBConnect']


Traceback:
File "c:\python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "c:\python26\lib\site-packages\django\contrib\auth\decorators.py"
in __call__
  78. return self.view_func(request, *args, **kwargs)
File "C:\Users\User\Documents\MYDOCUMENTS\RSoft\svn\wec3_HEAD\wec\..
\wec\utils\viewutils.py" in decorator
  67. return func(request, *args, **kwargs)
File "C:\Users\User\Documents\MYDOCUMENTS\RSoft\svn\wec3_HEAD\wec\..
\wec\utils\viewutils.py" in wrapper
  40. output = func(request, *args, **kw)
File "C:\Users\User\Documents\MYDOCUMENTS\RSoft\svn\wec3_HEAD\wec\..
\wec\std_backoffice\views\backoffice_ajax.py" in
articoli_tab_dati_articolo
  880. mgartbase.save()
File "c:\python26\lib\site-packages\django\db\models\base.py" in save
  410. self.save_base(force_insert=force_insert,
force_update=force_update)
File "c:\python26\lib\site-packages\django\db\models\base.py" in
save_base
  474. rows =
manager.filter(pk=pk_val)._update(values)
File "c:\python26\lib\site-packages\django\db\models\query.py" in
_update
  444. return query.execute_sql(None)
File "c:\python26\lib\site-packages\django\db\models\sql
\subqueries.py" in execute_sql
  120. cursor = super(UpdateQuery,
self).execute_sql(result_type)
File "c:\python26\lib\site-packages\django\db\models\sql\query.py" in
execute_sql
  2369. cursor.execute(sql, params)
File "c:\python26\lib\site-packages\django\db\backends\util.py" in
execute
  22. sql = self.db.ops.last_executed_query(self.cursor,
sql, params)
File "c:\python26\lib\site-packages\sql_server\pyodbc\operations.py"
in last_executed_query
  137. return super(DatabaseOperations,
self).last_executed_query(cursor, cursor.last_sql, cursor.last_params)
File "c:\python26\lib\site-packages\django\db\backends\__init__.py" in
last_executed_query
  213. u_params = tuple([to_unicode(val) for val in
params])
File "c:\python26\lib\site-packages\django\db\backends\__init__.py" in

  211. to_unicode = lambda s: force_unicode(s,
strings_only=True)
File "c:\python26\lib\site-packages\django\utils\encoding.py" in
force_unicode
  92. raise DjangoUnicodeDecodeError(s, *e.args)

Exception Type: DjangoUnicodeDecodeError at /wec/ajax/articoli/tab/
dati_articolo/10102010/
Exception Value: ('utf8', 'KARATEGI ADIDAS JUNIOR CON CINTURA IN
COTONE 100% citt\xe0l', 54, 56, 'unexpected end of data')



As you can see the error happens in the function "force_unicode"
because it's trying to handle the string in utf-8 (by default, see the
function). If I change that default "utf-8" in "latin1" things go
right. That means that if the caller gave "latin1" (taken by any
setting) as encoding parameter things would be ok, but so it isnt. Of
course I don't want to change django-code, but how can I solve the
problem? am I mistaking anything?
I don't think it's a problem of data since db is latin-1 and the
string is right encoded.

Please help.

Thank you.

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

2010-02-26 Thread Jirka Vejrazka
> But  i m getting following Error after loading admin module in
> setting.py(Please Download attached file from Files Section):

Hi, you have not provided the error message nor any link where we can
see it (as far as I can see), so it's difficult to judge what the
specific problem is...

  Cheers

Jirka

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



Django Problem

2010-02-26 Thread Devang
Hi Everyone,

I m developiing a pastebin site for my LAN and i had follow all steps
of following site:

http://docs.djangoproject.com/en/dev/intro/tutorial01/

http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02

But  i m getting following Error after loading admin module in
setting.py(Please Download attached file from Files Section):

So please give anyy suggestion or solution for this error ASAP.. and
also give any pastebin alternative with all steps to develop that
appliccation.

Thank You.

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



Redirecting to a different view after posting a form

2010-02-26 Thread hota990
www.financecollection.blogspot.com
www.financecollection.blogspot.com
www.financecollection.blogspot.com
www.financecollection.blogspot.com
www.financecollection.blogspot.com
www.financecollection.blogspot.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.



Re: present FileField in a form outside the admin

2010-02-26 Thread kirian
AdminFileWidget does the trick ;-)

On Feb 26, 11:50 am, kirian  wrote:
> Hi,
>
> I want to present a model.FileField outside the admin in a form. It
> should behave like the nicely automatically created FileFields in the
> admin.
>
> So set a  with the actual value and present a fileselect  button.
>
> If a output the form as a table form.as_table i just get the
> fileselect button.
>
> Anybody an idea how this works?

-- 
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: form.has_changed always true?

2010-02-26 Thread Jirka Vejrazka
Hi,

  if I digress from the has_changed() problem, you mentioned you
wanted to send email after a user profile has changed. Assuming that
the profile is a model in the database, you might consider tying your
logic to the model rather than the form.

  The post_save signal tied to the profile-related model might just do
the trick for you.

  Cheers

Jirka

On 07/01/2010, Alastair Campbell  wrote:
> Hi everyone,
>
> I've been looking for a simple way to send an email when a user
> updates their profile.
>
> After some digging I found form.has_changed() which appears to fit the
> bill. However, it always seems to return true, so I could end up
> bombarding our elderly admin lady with lots of useless emails.
>
> I'm using a simple model form (with a sub-set of the available
> fields), rendered in the default manner, no hidden fields or anything.
> If I open the page, hit save, if form.has_changed(): runs.
>
> Is there anything else that might cause has_changed to be true?
>
> Perhaps this is why has_changed() isn't mentioned in the documentation?
>
> I kinda hope I'm being stupid on this one, I'd rather not get into a
> long comparison function!
>
> -Alastair
>

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



present FileField in a form outside the admin

2010-02-26 Thread kirian
Hi,

I want to present a model.FileField outside the admin in a form. It
should behave like the nicely automatically created FileFields in the
admin.

So set a  with the actual value and present a fileselect  button.

If a output the form as a table form.as_table i just get the
fileselect button.

Anybody an idea how this works?

-- 
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: Thread safe language switching?

2010-02-26 Thread Jarek Zgoda

Wiadomość napisana w dniu 2010-02-16, o godz. 22:12, przez Plovarna:

I just developing my first aplication with internationalization. I  
need to get all verbose_name values of the model for each language  
defined in settings.LANGUAGES. I do it by this code defined inside  
model method :


   current_lang = get_language()
   names = {}
   for lang in settings.LANGUAGES:
   activate(lang[0])
   class_name = unicode(self.__class__._meta.verbose_name)
   names.append(class_name)
   deactivate()
   activate(current_lang)

My question is: Is this approach thread safe? Is there any other way  
how to get verbose_name of the model for each defined language?



From the code it looks like this is thread safe, thread-local seems  
to be used to store the translation catalog.


--
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl

--
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: Redirecting to a different view after posting a form

2010-02-26 Thread bruno desthuilliers


On Feb 25, 11:22 pm, Timothy Kinney  wrote:
> I have taken a, perhaps, unorthodox tact for my admin views. I use
> myproject/urls.py to grab the url and redirect to
> myapp.admin_views.samurai_detail
>
> urls.py catches url patterns such as:
> r'^admin/myapp/samurai/(?P.*)/add_item/$'
> r'^admin/myapp/samurai/(?P.*)/$


These are the patterns, but not the full url definitions. Mine looks
like:


url(r"albums/create/$",
views.album_edit,
name="album_create"
),

url(r"albums/(?P[0-9]+)/$",
views.album_details,
name="album_details"
),

url(r"albums/(?P[0-9]+)/edit/$",
views.album_edit,
name="album_edit"
),


In views, you'll have:

def album_details(request, album_id):
   # code here

def album_edit(request, album_id=None):
   # code here

With this, I can call reverse with the url name appropriate kwargs:

# url displaying album n°33 details:
reverse('album_details', kwargs={'album_id':33})

# url for editing album n°42:
reverse('album_edit',  kwargs={'album_id':33})

# url for creating a new album:
reverse('album_create')

Then it's just a matter of passing the url to HttpResponseRedirect.

> The HttpResponseRedirect is supposed to go from
> admin_views.add_item_to_samurai (after a successful request.POST) to
> admin_views.samurai_detail
>
> How would I craft the reverse() for that?

cf above.

-- 
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: Hierarchical data containing different models

2010-02-26 Thread bruno desthuilliers
On Feb 26, 12:41 am, Marco Rogers  wrote:
> Couple of things.
>
> bruno, your save example should maybe look call the superclass save
> first.  Otherwise parent may not have been set yet.

Model.save only do what the name imply : save the instance state (=>
instance attributes values) to the database. It doesn't set the
instance attributes. And if you call the superclass save() method
before doing the test, then the test is useless - the object is
already saved.

> Also, the issue I see with this is how do you know find out which type
> of Node you have so you can query the right model?  For instance when
> you query Node.objects.filter(parent_id=parent_id) you'll get a list
> of Node objects.  But they will not have any of the properties there
> were put on the Group and Item subclasses.

Indeed. Note that the problem at least partly due to the relational
model itself, and there's no easy, obvious solution.

>  Because the Node class
> doesn't know about them.  This is a problem I've had with django for a
> while now and i would love to see a solution that addresses it.

If you only have 2 Node subclasses then there's a very simple Q
solution:

class Node(models.Model):
   # other code here
   def downcast(self):
   try:
   return self.group
   except Group.DoesNotExist:
   return self.item


This somehow breaks encapsulation since the base class should not have
knowledge of its subclasses, but in the OP example it should not be a
major problem. And it's indeed not totally transparent. There are
other, more involved solutions - some of them including the
ContentType framework and some trickery with managers and querysets -
but most of them partly break with latest version of the ORM (much to
my regret). As I said, SQL is pretty lacking when it comes to
heterogenous hierarchies.

Anyway: the example I gave was not supposed to be a full working
solution - just a possible starting point.

-- 
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: Set language on per page basis

2010-02-26 Thread Tor Nordam
Thanks a lot, this seems to work like a charm.

On Feb 25, 10:45 am, Ian Lewis  wrote:
> In process_request you have access to the request object which knows
> the current path (request.path). You can use that to determine which
> language to show the page in.
>
> Or if you are determining the language based on a url parameter you
> can look at request.GET
>
> Ian
>
>
>
> On Thu, Feb 25, 2010 at 8:24 AM, Tor Nordam  wrote:
> > After doing some further research, I have found the following:
>
> > By writing a small piece of custom middleware, I can change the value
> > of HTTP_ACCEPT_LANGUAGE. If I add this line to a process_request()
>
> > request.META['HTTP_ACCEPT_LANGUAGE'] = 'no'
>
> > then the webpage will be displayed with Norwegian translation.
> > However, I want to set the language based on which page the user is
> > trying to view, and process_request() doesn't know this. On the other
> > hand, if I use process_view(), I am able to determine what the
> > language should be, as process_view() gets passed for example the
> > arguments from the url. However, when I add the same line as above to
> > process_view(), nothing happens to the language.
>
> > Is there an easy way to do this?
>
> > On Feb 24, 9:59 pm, Tor Nordam  wrote:
> >> Thank you for your reply,
>
> >> Using the {% trans %} method is indeed what I intend to do. But the
> >> problem is how to set the language on a page basis, rather than as an
> >> installation-wide setting, or a user-selectable setting.
>
> >> On Feb 24, 6:55 pm, Timothy Kinney  wrote:
>
> >> > I believe you want to use the {% *trans* %} template 
> >> > method.http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/
>
> >> > -Tim
>
> >> > On Wed, Feb 24, 2010 at 7:18 AM, Tor Nordam  wrote:
> >> > > I'm currently developing a project for making course webpages at my
> >> > > university. Essentially, each course would be an instance of the model
> >> > > Course, and each course would then get it's own webpage. However, as
> >> > > some courses are taught in Norwegian, and some in English, I want to
> >> > > use django's internationalisation framework, and I want to be able to
> >> > > set the language for each course separately. So I want to use
> >> > > different languages, but I don't want the person viewing the webpage
> >> > > to be able to select the language himself.
>
> >> > > As far as I can tell, the standard ways to set the language is either
> >> > > to use one setting for you entire project, or to select language based
> >> > > on the end users preferences. Is there an easy way to do what I want?
>
> >> > > --
> >> > > 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 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> ===
> 株式会社ビープラウド  イアン・ルイス
> 〒150-0012
> 東京都渋谷区広尾1-11-2アイオス広尾ビル604
> email: ianmle...@beproud.jp
> TEL:03-5795-2707
> FAX:03-5795-2708http://www.beproud.jp/
> ===

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



test_cookie_worked() fails although cookie is set

2010-02-26 Thread Timothy Kinney
Following: http://www.djangobook.com/en/2.0/chapter14/

I used the request.session.set_test_cookie() method when I pass the
login form. I then use the request.session.test_cookie_worked() method
to see if the cookie was set.

My view is setup to tell me when the test_cookie_worked() method
fails, and it always shows that it fails. However, if I go into
Firefox and search for the cookie it is there.

What's going on?

** views.py **

def login_view(request, user=None):
if request.method == 'POST': # If the form has been submitted...
if request.session.test_cookie_worked():
request.session.delete_test_cookie()

form = LoginForm(request.POST) # A form bound to the POST
data
if form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password']

user = authenticate(username=username,
password=password)

if user is not None:
if user.is_active:
login(request, user)
u =
User.objects.get(username__exact=request.POST['username'])
request.session['user'] = u.username
return HttpResponseRedirectView("logged in")

else:
return HttpResponse("Your account is
inactive.")

elif user is None:
return render_to_response('login.html',
  {'error_message': 'You failed to
authenticate.'})
else:
return render_to_response('login.html', {'form': form,
'error_message': 'Invalid form. Did you leave one
of the fields blank?'})
else:
   return HttpResponse("Cookies are required to login.")
else:
form = LoginForm() # An unbound form
request.session.set_test_cookie()
return render_to_response('login.html', {'form': form,
'error_message': 'Login please'})

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