Monday, January 31, 2011

switch to apache

Alright, im not really sure how to explain this but here goes. I just
got Django running on apache. I got apache to work in the same way
that the development server does. The only problem is that when I
modify a django file (a template or a view or anything) Django/apache
doesn't seem to notice the change, but sometimes it does notice the
change but reverts back to the old file and what not. Can anyone help
me out with this? Also, I need to write a small chat client thing
using django and openfire, does anyone have any experience donig
that? Thanks alot guys!!

Ethan Yandow

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

Re: Selecting related objects with condition

The easiest way would be to get a list of all closed work items, ordered
by user:

context['work'] = Work.objects.filter(whatever).order_by('user')

{% for work_item in work %}
{% ifchanged %}Display {{work_item.user}}{% endifchanged %}
Display {{ work_item }}
{% endfor %}

--
Michael <mhall119@gmail.com>

On Mon, 2011-01-31 at 18:45 +0100, Martin Tiršel wrote:
> Hello,
>
> I have a model:
>
> class Work(models.Model):
> ...
> user = models.ForeignKey(
> User
> )
> closed = models.DateTimeField(
> blank=True
> )
>
> ...
>
> Now, I want to print all users and for each user all Works closed between
> a specific date. If I don't need the "closed between" condition, I would
> do:
>
> view.py:
>
> ...
> context['users'] = User.objects.all()
> ...
>
> template.html:
>
> {% for user in users %}
> {% for work in user.work_set.all %}
> ...
> {% endfor%}
> {% endfor %}
>
> But what I have to do, if I need condition to select specific work
> records? I have only one idea how to do this - load all users, iterate
> through each user and extract his works and make a list of dictionaries
> with {'user':..., 'works':...} items. But I have a feeling that this is
> not the "right" way and Django has something to solve this kind of
> problems too :)
>
> Thanks,
> Martin
>

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

Re: tutorial part 4: ImportError

**some corrections from my previous post
By "model" I mean "view" and in #1, index.html gets changed to poll_list.html
Sorry!

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

Re: tutorial part 4: ImportError

Hi group,

I've noticed a few things in the tutorial documentation for 1.2 on page http://docs.djangoproject.com/en/1.2/intro/tutorial04/ under the section "Use generic views: Less code is better":

1.  It instructs the user to rename both the detail.html and list.html pages to poll_*.html, but it doesn't say to rename the results.html file to poll_results.html, which in turn in polls/urls.py, the template_name='polls/results.html' seems to need to be changed to template_name='polls/poll_results.html' to be properly used by the generic views. 

2. Also, in polls/views.py, in the vote model, poll_id needs to be changed to object_id in the signature, although the instructions only say to change these references in the templates and in the render_to_response call (it may have been implied to change the vote model signature when the author says that 'The object_detail() generic view expects the ID value captured from the URL to be called "object_id", so we've changed poll_id to object_id for the generic views.', - if this is the case then ignore this one :) 

3. Also in polls/urls.py in the import line "from django.conf.urls.defaults import *" seems to be an unused import

Can someone check to make sure that I am correct on this list?  Maybe I am off-base on some of this.  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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: tutorial part 4: ImportError

Ok, right after my last post the content seems to have been corrected!  Nice!  Please disregard my previous post.  Thank you for the documentation update!

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

Re: tutorial part 4: ImportError

I accidentally previously sent this post just to Rob - sorry about that Rob!

I know that this is a couple months old, but the documentation does seem to be incorrect.  I am using 1.2.4, and am on the correct tutorial page (http://docs.djangoproject.com/en/1.2/intro/tutorial04/), and the import statement in the section "Use generic views: Less code is better" does indeed state "from django.views.generic import DetailView, ListView", with a description of the DetailView and ListView classes below it.  Just wanted to make sure I wasn't missing something.  Great tutorial so far, though! :)


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

Re: caching of Models (not the cache middleware)

The behavior seems to have reverted after a couple days. I suspect
that the connection to mysql is being renegotiated, during which it
loses the autocommit setting.

This seems like it should be a setting in django, so if it
renegotiates it will set autocommit again.

Another solution might be to explicitly commit after every select.

On Fri, Jan 28, 2011 at 6:51 PM, Karen Tracey <kmtracey@gmail.com> wrote:
> On Fri, Jan 28, 2011 at 9:45 PM, Brian Craft <bcboy@thecraftstudio.com>
> wrote:
>>
>> Digging into the problem I'm having with a standalone django script,
>> the problem seems to be that django doesn't see updates to the
>> database unless it writes to the database.
>
> Sounds a lot like:
> http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d/
>
> Karen
> --
> http://tracey.org/kmt/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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

Re: ANN: Server upgrade on djangoproject.com

On Jan 31, 2011, at 9:15 AM, Shawn Milochik wrote:

>
> I was using my iPhone at the time. I probably should have checked it on a desktop browser before replying to the thread. Sorry 'bout that.
>

On the iPhone, use two fingers to scroll to the cut-off text in the code box.


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

Re: flatpages templatetags missing

I had my settings.py exactly like you suggested.

I realized that the template tag loadflatpages is available in the
Trunk, and not available in 1.2.3 or 1.2.4

I was confused because the documentation for 1.2.3 talks about the
load flatpages tag (and there is a disclaimer there that says
"available in development version", which I didn't pay attention to)

On Jan 31, 2:21 am, GSV <svyatoslav.zhurov...@gmail.com> wrote:
> MIDDLEWARE_CLASSES = (
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
>     'django.middleware.csrf.CsrfViewMiddleware',
>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>     'django.contrib.messages.middleware.MessageMiddleware',
>     'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
> )
>
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'django.contrib.messages',
>     # Uncomment the next line to enable the admin:
>     'django.contrib.admin',
>     # Uncomment the next line to enable admin documentation:
>     'django.contrib.admindocs',
>     'django.contrib.flatpages',
> )
>
> TEMPLATE_DIRS = (
>         '/var/www/html/tamada2/templates',
> )
>
> template for flatpages: /var/www/html/tamada2/templates/flatpages/
> default.html
>
> ###
> {% extends "base.xhtml" %}
>
> {% block content %}
> <p class="about-text">{{flatpage.content}}</p>
>
> {% endblock %}
>
> On 31 янв, 08:10, Adi <aditya.rus...@gmail.com> wrote:
>
> > Hi:
> > I am trying to use flatpages in my app, and i set up the settings.py
> > correct, and I am able to create the flatpages using the admin site.
>
> > However, when in my app I try to load the template tags for flatpages
> > using:
> > {% load flatpages %}
>
> > I get a
> > TemplateSyntaxError
> > Exception Value:
>
> > 'flatpages' is not a valid tag library: Template library flatpages not
> > found, tried
> > django.templatetags.flatpages,django_extensions.templatetags.flatpages,django.contrib.admin.templatetags.flatpages,django.contrib.webdesign.templatetags.flatpages
>
> > I then looked to see the django distribution installed (1.2.3 final)
> > on my computer and noticed that django.contrib.flatpages did not have
> > a templatetags module under that.
>
> > I looked up the code repository for 1.2.3 and 1.2.4 and both don't
> > have the templatetags directory.
>
> > What am I doing wrong ? What is missing ?

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

Selecting related objects with condition

Hello,

I have a model:

class Work(models.Model):
...
user = models.ForeignKey(
User
)
closed = models.DateTimeField(
blank=True
)

...

Now, I want to print all users and for each user all Works closed between
a specific date. If I don't need the "closed between" condition, I would
do:

view.py:

...
context['users'] = User.objects.all()
...

template.html:

{% for user in users %}
{% for work in user.work_set.all %}
...
{% endfor%}
{% endfor %}

But what I have to do, if I need condition to select specific work
records? I have only one idea how to do this - load all users, iterate
through each user and extract his works and make a list of dictionaries
with {'user':..., 'works':...} items. But I have a feeling that this is
not the "right" way and Django has something to solve this kind of
problems too :)

Thanks,
Martin

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

Re: Django Admin select boxes



On Mon, Jan 31, 2011 at 12:06 PM, Tom Evans <tevans.uk@googlemail.com> wrote:
On Mon, Jan 31, 2011 at 4:51 PM, Bjorn Meyer <bjorn.m.meyer@gmail.com> wrote:
> Hi all, I am hoping that someone might be able to point me in the right
> direction for the following problem. I have been searching for a few days now
> and haven't been able to find a way to accomplish this. I have found some
> solutions that are close, but only work on editing an entry, not on add.
> I have models for the following:
> Each have a foreign key to the model above it.
> Country
> Prov/State
> City
> Region
> Community
> Is there a way in the Django admin to filter the values in the select boxes
> based on the selection in the previous select box? eg: I select Canada in the
> country select box, then in the Prov/State select box I am only presented with
> the Provinces. Once that is selected, the City select box only presents cities
> within the Province selected. etc...
> Is this possible?
>

A qualified yes; Of course it is possible, but it's not simply a
question of saying 'Hey django-admin, these fields are related, so do
AJAX goodness', you would need to write it mostly yourself, including
a custom form that adds the additional fields (I assume that you would
only record the low level item, eg 'Community'), adding web service
calls so you can populate those fields, etc etc.

Cheers

Tom

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

I just ran across this article from a delicious feed:  Its a little tutorial about using Django and ajax to do just what you are asking.

http://www.nerdydork.com/dynamic-filtered-drop-down-choice-fields-with-django.html


--
Joel Goldstick

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

Model Forms Customization

I think I've read most of the documentation on Model Forms, but I
haven't seen much on how to customize them, other than changing the
order in which fields are displayed, or not displaying some fields at
all. The one ModelForm which I've done so far does not look very good
as it is automatically generated. If they can't be customized very
easily or very much then I'm not sure I see any big advantage in using
them as opposed to just using regular forms, that I can more easily
customize. Am I missing something or have I not read enough of the
documentation?

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

Re: ANN: Server upgrade on djangoproject.com

On Jan 31, 2011, at 12:12 PM, Jacob Kaplan-Moss wrote:

> On Mon, Jan 31, 2011 at 2:40 AM, Shawn Milochik <shawn@milochik.com> wrote:
>> I'm seeing the code samples being cut off in the docs as well.
>> http://docs.djangoproject.com/en/dev/topics/signals/
>> See sample under:
>> Preventing duplicate signals
>
> It's working for me (Chrome/Safari OSX), so it's probably a
> browser-specific thing. Can you tell me which browser your using on
> what platform, and give it a try with a different browser or two just
> to make sure?
>
> Thanks,
>
> Jacob
>
> --

I was using my iPhone at the time. I probably should have checked it on a desktop browser before replying to the thread. Sorry 'bout that.

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

Re: ANN: Server upgrade on djangoproject.com

On Mon, Jan 31, 2011 at 2:40 AM, Shawn Milochik <shawn@milochik.com> wrote:
> I'm seeing the code samples being cut off in the docs as well.
> http://docs.djangoproject.com/en/dev/topics/signals/
> See sample under:
> Preventing duplicate signals

It's working for me (Chrome/Safari OSX), so it's probably a
browser-specific thing. Can you tell me which browser your using on
what platform, and give it a try with a different browser or two just
to make sure?

Thanks,

Jacob

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

Re: Django Admin select boxes

On Mon, Jan 31, 2011 at 4:51 PM, Bjorn Meyer <bjorn.m.meyer@gmail.com> wrote:
> Hi all, I am hoping that someone might be able to point me in the right
> direction for the following problem. I have been searching for a few days now
> and haven't been able to find a way to accomplish this. I have found some
> solutions that are close, but only work on editing an entry, not on add.
> I have models for the following:
> Each have a foreign key to the model above it.
> Country
> Prov/State
> City
> Region
> Community
> Is there a way in the Django admin to filter the values in the select boxes
> based on the selection in the previous select box? eg: I select Canada in the
> country select box, then in the Prov/State select box I am only presented with
> the Provinces. Once that is selected, the City select box only presents cities
> within the Province selected. etc...
> Is this possible?
>

A qualified yes; Of course it is possible, but it's not simply a
question of saying 'Hey django-admin, these fields are related, so do
AJAX goodness', you would need to write it mostly yourself, including
a custom form that adds the additional fields (I assume that you would
only record the low level item, eg 'Community'), adding web service
calls so you can populate those fields, etc etc.

Cheers

Tom

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

Re: Facebook session problems.

Its definitely a django thing. It does it on explorer as well. Somehow
the session information is lost. Maybe because it goes out to facebook
to get the log in. I used firebug and I can see the facebook cookies
as well as those for my site.

On Jan 31, 9:33 am, Aljoša Mohorović <aljosa.mohoro...@gmail.com>
wrote:
> On Mon, Jan 31, 2011 at 2:59 PM, CrabbyPete <pete.do...@gmail.com> wrote:
> > I am loosing the django session.
>
> try setting the P3P on response:
> response['P3P:CP'] = "IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi
> HIS OUR IND CNT"
> it probably wont help but it fixes this issue with explorer so it doesn't hurt.
>
> test if you can use cookies, most session issues in iframe apps are
> cookie related.
> also, try using a different browser just to figure out if it's browser
> related or if it's server-side problem.
>
> Aljosa Mohorovic

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

Django Admin select boxes

Hi all, I am hoping that someone might be able to point me in the right
direction for the following problem. I have been searching for a few days now
and haven't been able to find a way to accomplish this. I have found some
solutions that are close, but only work on editing an entry, not on add.
I have models for the following:
Each have a foreign key to the model above it.
Country
Prov/State
City
Region
Community
Is there a way in the Django admin to filter the values in the select boxes
based on the selection in the previous select box? eg: I select Canada in the
country select box, then in the Prov/State select box I am only presented with
the Provinces. Once that is selected, the City select box only presents cities
within the Province selected. etc...
Is this possible?

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

Re: mis-named setting? SESSION_EXPIRE_AT_BROWSER_CLOSE

> You can't stop the user from closing the browser, or switching to another
> tab, with JS. And you shouldn't try to stop them navigating away - this
> sort of thing is only likely to annoy them intensely.

Taking this to the extreme - what do you want to happen if a person using
your site has a powercut? Or pulls out their network connection? This
will not run any site-close javascript.

We had a designer request similar functionality in a Struts app years ago
- it's really annoying and goes wrong often and we vowed never to do it
again.

How about looking at RabbitMQ or XMPP for presence?

Tim.


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

Re: working django with existing database

On Jan 31, 3:29 am, arief nur andono <ariefnurand...@gmail.com> wrote:
> oh please...
>
> i need only to query the table, have no access to modified the table
>
> why there is no way query the database and then make the output as object??

You don't need to modify the table. That was just a recommendation.
I also suggested changing the precision (max_digits) and scale
(decimal_places) in your models file to match what is actually used in
your data. If you have no idea what to use, then
DecimalField(max_digits=38, decimal_places=19) is *probably* safe.

If updating the models is going to be too laborious, then you should
probably look at a different ORM. I don't know whether SQLAlchemy
will do a better job introspecting your database, but it's worth a
shot and can be used in conjunction with TurboGears or Pylons.

Cheers,
Ian

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

Re: visually cut off code on djangoproject.com after upgrade?

On Mon, Jan 31, 2011 at 4:11 PM, Shawn Milochik <shawn@milochik.com> wrote:
> Could have been the browser I was using. I'm not seeing the issue there now on Chrome.
>
> Shawn
>

I don't think they've been updated yet. I'm using this page:

http://docs.djangoproject.com/en/1.2/howto/static-files/

as a test to see when the docs are correctly labelled again.
Staticfiles doesn't exist in 1.2, so if that page has content, the
docs are still stuffed.

Cheers

Tom

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

Re: visually cut off code on djangoproject.com after upgrade?

On Jan 31, 2011, at 11:05 AM, creecode wrote:

> Hello Shawn,
>
> I'm not seeing <

...

Could have been the browser I was using. I'm not seeing the issue there now on Chrome.

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

Re: visually cut off code on djangoproject.com after upgrade?

Hello Shawn,

On Jan 31, 12:40 am, Shawn Milochik <sh...@milochik.com> wrote:

> I'm seeing the code samples being cut off in the docs as well.
>
> http://docs.djangoproject.com/en/dev/topics/signals/
>
> See sample under:
> Preventing duplicate signals

I'm not seeing <
https://docs.google.com/leaf?id=0B2mWx-jMqJNcODUyMDI4ZmItZTFhMC00Y2VmLTljNGUtOWQ3NGRlZDY0Zjc3&sort=name&layout=list&num=50
> a problem there but perhaps I've missed it.

This is what I saw <
https://docs.google.com/leaf?id=0B2mWx-jMqJNcNGM0YjY4ZTItNGNjMy00MmExLWEzNzAtMzgwOTdmOTI4Y2Rj&sort=name&layout=list&num=50
> when I reported my problem.

Toodle-looooooooo............
creecode

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

Re: django and mysql connection problem

thnkz....it helped...

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

Re: mis-named setting? SESSION_EXPIRE_AT_BROWSER_CLOSE

On Monday, January 31, 2011 3:06:29 PM UTC, Ivan Uemlianin wrote:
Dear Tom

Thanks for your comment.

My use case is a "presence"-type system.  When a user logs out their
status change is sent out to all other logged-in users (using comet).
If they just close the browser this doesn't happen.  I'm mulling over
two possible solutions:

(a) some bit of javascript that will logout the user if they close the
browser or navigate away from the site (but I don't know if you can do
the former with js; and the latter to work properly if they have other
tabs still on the site).  It requires javascript, but it's a fairly
javascript-heavy site anyway.

(b) something using SESSION_COOKIE_AGE.  Set it to a few minutes and
have something running that will logout any users with expired
sessions (and delete the session too).  Unfortunately the javascript
GET requests for the comet don't go through django, so they won't keep
the session alive.  Setting SESSION_COOKIE_AGE too low will risk
logging out against users' wishes, but setting it to much more than a
few minutes will render this solution useless.  This solution doesn't
feel right at all.

If (a) is possible I think I'll go with that.

Best

Ivan

You can't stop the user from closing the browser, or switching to another tab, with JS. And you shouldn't try to stop them navigating away - this sort of thing is only likely to annoy them intensely.

Instead, the best alternative that I've seen proposed is some sort of regular 'ping' - as long as the user has the page open, some Javascript contacts your server every minute or so, to let it know they're still there. Then you know that your 'active' users are those who have pinged in the last minute.
--
DR.

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

Re: django and mysql connection problem

On Monday, January 31, 2011 2:45:55 PM UTC, cuteangel wrote:

its my first project with django..i already tried the connection with
sqlite.but now m using django's connection with mysql n m getting
following error...

D:\project\wogma>manage.py syncdb
Traceback (most recent call last):
  File "D:\project\wogma\manage.py", line 11, in <module>
    execute_manager(settings)

  File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
340, in execute_manager
    utility.execute()

  File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 192,
 in run_from_argv
    self.execute(*args, **options.__dict__)

  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 218,
 in execute
    self.validate()

  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 246,
 in validate
    num_errors = get_validation_errors(s, app)

  File "C:\Python26\lib\site-packages\django\core\management
\validation.py", lin
e 65, in get_validation_errors
    connection.validation.validate_field(e, opts, f)

  File "C:\Python26\lib\site-packages\django\db\backends\mysql
\validation.py", l
ine 8, in validate_field
    db_version = connection.get_server_version()

  File "C:\Python26\lib\site-packages\django\db\backends\mysql
\base.py", line 27
7, in get_server_version
    self.cursor()

  File "C:\Python26\lib\site-packages\django\db\backends\__init__.py",
line 56,
in cursor
    cursor = self._cursor(settings)

  File "C:\Python26\lib\site-packages\django\db\backends\mysql
\base.py", line 26
2, in _cursor
    self.connection = Database.connect(**kwargs)

  File "C:\Python26\lib\site-packages\MySQLdb\__init__.py", line 81,
in Connect
    return Connection(*args, **kwargs)
  File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line
188, in __in
it__
    super(Connection, self).__init__(*args, **kwargs2)

_mysql_exceptions.OperationalError: (1049, "Unknown database 'd:/
project/wogma/w
ogma'")

i did the commands in mysql as follows..i already created the wogma
database just using create database n i granted the priviliges..in
mysql. whts the prb??

You already have correct answers for this question on Stackoverflow. What did you hope to get from posting it here too?
--
DR. 

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

Re: mis-named setting? SESSION_EXPIRE_AT_BROWSER_CLOSE

Dear Tom

Thanks for your comment.

My use case is a "presence"-type system. When a user logs out their
status change is sent out to all other logged-in users (using comet).
If they just close the browser this doesn't happen. I'm mulling over
two possible solutions:

(a) some bit of javascript that will logout the user if they close the
browser or navigate away from the site (but I don't know if you can do
the former with js; and the latter to work properly if they have other
tabs still on the site). It requires javascript, but it's a fairly
javascript-heavy site anyway.

(b) something using SESSION_COOKIE_AGE. Set it to a few minutes and
have something running that will logout any users with expired
sessions (and delete the session too). Unfortunately the javascript
GET requests for the comet don't go through django, so they won't keep
the session alive. Setting SESSION_COOKIE_AGE too low will risk
logging out against users' wishes, but setting it to much more than a
few minutes will render this solution useless. This solution doesn't
feel right at all.

If (a) is possible I think I'll go with that.

Best

Ivan


On Jan 31, 2:42 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Mon, Jan 31, 2011 at 2:21 PM, Ivan Uemlianin <i...@llaisdy.com> wrote:
> > Dear All
>
> > Is the setting SESSION_EXPIRE_AT_BROWSER_CLOSE mis-named?  As far as I
> > can tell the setting doesn't influence the session expiry at all
> > (e.g., what happens to the django_session table on the server).  What
> > this setting seems to affect is the expiry of the *cookie* in the
> > browser.
>
> > I'm looking into a way for django to detect users no longer on the
> > site (i.e. authenticated users who rather than logout, have navigated
> > away from the site or closed their browser).  From the name, I had
> > thought this setting would be useful.  It looks like it'll be useful
> > for the client side, but for the server side it's irrelevant surely?
> > A clearer name would be something like
> > SESSION_COOKIE_EXPIRE_AT_BROWSER_CLOSE.
>
> > Best wishes
>
> > Ivan
>
> The result of the session cookie expiring is that the session key
> stored in that cookie is no longer retained by the browser, and
> effectively, the session has expired. Whilst I see your point, it's a
> bit pedantic and unlikely to be changed.
>
> The only way to determine if the user is still active if they do not
> actively log out is to treat them as logged in if they have an 'active
> session'. How you define 'active session' is up to you; I treat any
> unexpired session as active, and set settings.SESSION_COOKIE_AGE to
> something appropriate (2 week long sessions do not appeal to me).
> I can then answer the question "How many distinct sessions are
> currently active" (not "How many distinct users are currently active",
> nor "How many users are currently using the site").
>
> Cheers
>
> Tom

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

Re: django and mysql connection problem

On Mon, Jan 31, 2011 at 2:45 PM, cuteangel <gunjandhole@gmail.com> wrote:
>
> its my first project with django..i already tried the connection with
> sqlite.but now m using django's connection with mysql n m getting
> following error...
>
> ....
> _mysql_exceptions.OperationalError: (1049, "Unknown database 'd:/
> project/wogma/w
> ogma'")
>
> i did the commands in mysql as follows..i already created the wogma
> database just using create database n i granted the priviliges..in
> mysql. whts the prb??
>

You are specifying the DB name incorrectly for the mysql driver. It
should just be the name of the database as created in mysql, not the
path to some file/folder.

Cheers

Tom

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

Re: Django session gets confused behind proxy, already logged in

On Mon, Jan 31, 2011 at 1:15 PM, Stefan <escee.live@gmail.com> wrote:
> Hi,
>
> Currently we're having some issues with a user of our product who uses
> a proxy on their internal network.
>
> According to their system administrator the proxy is open to port 80
> and 443, and doesn't do anything with cookies and such, only blocks
> out some sites.
>
> The problem: when user X logs in to our application, user Y also gets
> logged in on a computer who didn't use out application before (but is
> behind the same proxy)?! This shouldn't be possible (django default
> auth app is used)?
>
> We're using is Apache, Nginx, Django 1.0 and Postgresql. Also note
> that it does work when ran with runserver, but not with nginx.
>
> This only occurs with this user with the proxy, on other networks, it
> does work.
>
> Anyone experienced this before? If so, how'd you solve it?
>
> Thanks in advance!
>
> Stefan
>

When the second browser behind the proxy requests the site, is it
actually requesting and receiving pages from your app, or is it
receiving cached content from one of the proxies?
I think one of the components in your full stack (Apache/nginx)
emitting headers that say this content is cache-able, that runserver
does not do, and their proxy is caching the content locally in the
full stack scenario.

Cheers

Tom

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

django and mysql connection problem

its my first project with django..i already tried the connection with
sqlite.but now m using django's connection with mysql n m getting
following error...

D:\project\wogma>manage.py syncdb
Traceback (most recent call last):
File "D:\project\wogma\manage.py", line 11, in <module>
execute_manager(settings)

File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
340, in execute_manager
utility.execute()

File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)

File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 192,
in run_from_argv
self.execute(*args, **options.__dict__)

File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 218,
in execute
self.validate()

File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 246,
in validate
num_errors = get_validation_errors(s, app)

File "C:\Python26\lib\site-packages\django\core\management
\validation.py", lin
e 65, in get_validation_errors
connection.validation.validate_field(e, opts, f)

File "C:\Python26\lib\site-packages\django\db\backends\mysql
\validation.py", l
ine 8, in validate_field
db_version = connection.get_server_version()

File "C:\Python26\lib\site-packages\django\db\backends\mysql
\base.py", line 27
7, in get_server_version
self.cursor()

File "C:\Python26\lib\site-packages\django\db\backends\__init__.py",
line 56,
in cursor
cursor = self._cursor(settings)

File "C:\Python26\lib\site-packages\django\db\backends\mysql
\base.py", line 26
2, in _cursor
self.connection = Database.connect(**kwargs)

File "C:\Python26\lib\site-packages\MySQLdb\__init__.py", line 81,
in Connect
return Connection(*args, **kwargs)
File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line
188, in __in
it__
super(Connection, self).__init__(*args, **kwargs2)

_mysql_exceptions.OperationalError: (1049, "Unknown database 'd:/
project/wogma/w
ogma'")

i did the commands in mysql as follows..i already created the wogma
database just using create database n i granted the priviliges..in
mysql. whts the prb??

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

Re: mis-named setting? SESSION_EXPIRE_AT_BROWSER_CLOSE

On Mon, Jan 31, 2011 at 2:21 PM, Ivan Uemlianin <ivan@llaisdy.com> wrote:
> Dear All
>
> Is the setting SESSION_EXPIRE_AT_BROWSER_CLOSE mis-named?  As far as I
> can tell the setting doesn't influence the session expiry at all
> (e.g., what happens to the django_session table on the server).  What
> this setting seems to affect is the expiry of the *cookie* in the
> browser.
>
> I'm looking into a way for django to detect users no longer on the
> site (i.e. authenticated users who rather than logout, have navigated
> away from the site or closed their browser).  From the name, I had
> thought this setting would be useful.  It looks like it'll be useful
> for the client side, but for the server side it's irrelevant surely?
> A clearer name would be something like
> SESSION_COOKIE_EXPIRE_AT_BROWSER_CLOSE.
>
> Best wishes
>
> Ivan
>

The result of the session cookie expiring is that the session key
stored in that cookie is no longer retained by the browser, and
effectively, the session has expired. Whilst I see your point, it's a
bit pedantic and unlikely to be changed.

The only way to determine if the user is still active if they do not
actively log out is to treat them as logged in if they have an 'active
session'. How you define 'active session' is up to you; I treat any
unexpired session as active, and set settings.SESSION_COOKIE_AGE to
something appropriate (2 week long sessions do not appeal to me).
I can then answer the question "How many distinct sessions are
currently active" (not "How many distinct users are currently active",
nor "How many users are currently using the site").

Cheers

Tom

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

Filtered drop down choice django

I am trying to create a dynamic filtered drop down choice fields,i gone through below blog but it confusing,can any one suggest easy way to do this in django.

http://www.nerdydork.com/dynamic-filtered-drop-down-choice-fields-with-django.html

Thanks in advance :)

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

Issue with Foriegnkey in django

i AM trying to create a from which is linked with foriegnkey.

Model.py

    enter code here
    model
.py

class CreateD(models.Model):
    id
=models.IntegerField(primary_key=True)
    db
= models.CharField(max_length=50, blank=True)
    iss  
= models.CharField(max_length=100, blank=True)
    status
= models.CharField(max_length=2, blank=True ,default='A')
   
class Meta:
        db_table
= u'add_d'

   
def __unicode__(self):
       
return u'%s %s' % (self.db,self.iss)


class Assignment(models.Model):
    id
= models.IntegerField(primary_key=True)
    assign_to
= models.CharField(max_length=50, blank=True)
    db_name
= models.ForeignKey(CreateDb,related_name='set__dbname')
    issue_type
= models.ForeignKey(CreateDb,related_name='set_issuetype')
    date
= models.DateTimeField(null=True, blank=True)
   
class Meta:
        db_table
= u'assignment'
   
def __unicode__(self):
       
return u'%s %s' % (self.db_name,self.issue_type)

form.py

class AssignmentForm(ModelForm):

class Meta:
    model
= Assignment
    exclude
= ('id','date','assign_to')

assign.html

   {{forms.as_p}}


Data in the sql :
   id  db iss
   
1   A   AB
   
2   B   BA




Output genrated from html page is

   db_name    
: A AB (choice field)
                B BA
   issue_type
: A AB (choice field)
                B BA


Actually i Need a output like below in html:

    db_name    
: A (choice field)
                 B
   issue_type
: AB (choice field)
                BA

Please help me on this ...........

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

Re: Facebook session problems.

On Mon, Jan 31, 2011 at 2:59 PM, CrabbyPete <pete.douma@gmail.com> wrote:
> I am loosing the django session.

try setting the P3P on response:
response['P3P:CP'] = "IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi
HIS OUR IND CNT"
it probably wont help but it fixes this issue with explorer so it doesn't hurt.

test if you can use cookies, most session issues in iframe apps are
cookie related.
also, try using a different browser just to figure out if it's browser
related or if it's server-side problem.

Aljosa Mohorovic

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

mis-named setting? SESSION_EXPIRE_AT_BROWSER_CLOSE

Dear All

Is the setting SESSION_EXPIRE_AT_BROWSER_CLOSE mis-named? As far as I
can tell the setting doesn't influence the session expiry at all
(e.g., what happens to the django_session table on the server). What
this setting seems to affect is the expiry of the *cookie* in the
browser.

I'm looking into a way for django to detect users no longer on the
site (i.e. authenticated users who rather than logout, have navigated
away from the site or closed their browser). From the name, I had
thought this setting would be useful. It looks like it'll be useful
for the client side, but for the server side it's irrelevant surely?
A clearer name would be something like
SESSION_COOKIE_EXPIRE_AT_BROWSER_CLOSE.

Best wishes

Ivan

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

Re: Facebook session problems.

I am loosing the django session.

On Jan 31, 8:44 am, "christian.posta" <christian.po...@gmail.com>
wrote:
> Which session are you losing?
> The django authenticated session, or the facebook session?
>
> On Jan 29, 10:30 pm, CrabbyPete <pete.do...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I managed to log into facebook using the graph api, I store the FB id
> > and tie it to a User, like this
>
> > class FacebookUser(models.Model):
> >     user            = models.ForeignKey(User)
> >     fb_uid          = models.CharField( max_length=100, blank = True,
> > unique = True )
> >     access_token    = models.CharField( max_length=100, blank = True,
> > null   = True )
>
> >     def __unicode__(self):
> >         if self.user.username == u'':
> >             return str(self.pk)
> >         return self.user.username
>
> > after I get the user I do the following:
> > user = auth.authenticate(username=user.username, password=password)
> >     if user is not None and user.is_active:
> >         auth.login(request, user)
>
> > I log in and all is good except I loose the session if I go to another
> > web site and come back.
>
> > Any help or advice greatly appreciated.

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

Re: Facebook session problems.

Which session are you losing?
The django authenticated session, or the facebook session?

On Jan 29, 10:30 pm, CrabbyPete <pete.do...@gmail.com> wrote:
> I managed to log into facebook using the graph api, I store the FB id
> and tie it to a User, like this
>
> class FacebookUser(models.Model):
>     user            = models.ForeignKey(User)
>     fb_uid          = models.CharField( max_length=100, blank = True,
> unique = True )
>     access_token    = models.CharField( max_length=100, blank = True,
> null   = True )
>
>     def __unicode__(self):
>         if self.user.username == u'':
>             return str(self.pk)
>         return self.user.username
>
> after I get the user I do the following:
> user = auth.authenticate(username=user.username, password=password)
>     if user is not None and user.is_active:
>         auth.login(request, user)
>
> I log in and all is good except I loose the session if I go to another
> web site and come back.
>
> Any help or advice greatly appreciated.

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

Re: pyodbc & FreeTDS: Can I work with NVARCHAR column on MSSQL2008

Hi,

I have expirience with pymssql and mssql server, and that works fine (utf-8).

FreeTDS docs says:

"FreeTDS is not fully compatible with multi-byte character sets such as UCS-2. You must use an ASCII-extension charset (e.g., UTF-8, ISO-8859-*)[2].
Great care should be taken testing applications using these encodings. Specifically, many applications do not expect the number of characters returned to exceed the column size (in bytes). "

Did You try utf-8?

Cheers


On Mon, Jan 31, 2011 at 1:39 PM, Orgil <orgilhp@gmail.com> wrote:
Hello.
I have FreeTDS, pyodbc-2.1.8, python-2.6, ubuntu-10.4.
I also have MSSQL2008 database server on Windows7.

My question is: Can I get unicode data from nvarchar column on
Mssql2008 database using pyodbc?
To do this, what does other library or configuration need me?

I use FreeTDS driver to connect with mssql by pyodbc. But I don't know
version of FreeTDS.
How to know the version of FreeTDS?

My current state is, I can connect with mssql. But I can not get
unicode data!
My code is:
-----------------------
       import pyodbc
       conn =
pyodbc.connect(r'DRIVER={FreeTDS};SERVER=10.0.0.61\mssql2008;DATABASE=eoffice_clone;UID=erp;PWD=123;CHARSET=UCS-2;')
       crms = conn.cursor()
       crms.execute("SELECT cc_Name FROM tblHR_CodeClass")
       for line in crms:
           print 'cc_Name:', str(line.cc_Name)
       conn.close()
-----------------------
Expected result is 'cc_Name: Аймаг, хот', but instead
'cc_Name: ?????, ???' comes.

Please, share your experience!

regards,
Orgil

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


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

Django session gets confused behind proxy, already logged in

Hi,

Currently we're having some issues with a user of our product who uses
a proxy on their internal network.

According to their system administrator the proxy is open to port 80
and 443, and doesn't do anything with cookies and such, only blocks
out some sites.

The problem: when user X logs in to our application, user Y also gets
logged in on a computer who didn't use out application before (but is
behind the same proxy)?! This shouldn't be possible (django default
auth app is used)?

We're using is Apache, Nginx, Django 1.0 and Postgresql. Also note
that it does work when ran with runserver, but not with nginx.

This only occurs with this user with the proxy, on other networks, it
does work.

Anyone experienced this before? If so, how'd you solve it?

Thanks in advance!

Stefan

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

pyodbc & FreeTDS: Can I work with NVARCHAR column on MSSQL2008

Hello.
I have FreeTDS, pyodbc-2.1.8, python-2.6, ubuntu-10.4.
I also have MSSQL2008 database server on Windows7.

My question is: Can I get unicode data from nvarchar column on
Mssql2008 database using pyodbc?
To do this, what does other library or configuration need me?

I use FreeTDS driver to connect with mssql by pyodbc. But I don't know
version of FreeTDS.
How to know the version of FreeTDS?

My current state is, I can connect with mssql. But I can not get
unicode data!
My code is:
-----------------------
import pyodbc
conn =
pyodbc.connect(r'DRIVER={FreeTDS};SERVER=10.0.0.61\mssql2008;DATABASE=eoffice_clone;UID=erp;PWD=123;CHARSET=UCS-2;')
crms = conn.cursor()
crms.execute("SELECT cc_Name FROM tblHR_CodeClass")
for line in crms:
print 'cc_Name:', str(line.cc_Name)
conn.close()
-----------------------
Expected result is 'cc_Name: Аймаг, хот', but instead
'cc_Name: ?????, ???' comes.

Please, share your experience!

regards,
Orgil

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

Re: Redirect with current data

On 2011-01-31, at 06:36 , Antônio Ribeiro wrote:
> Hello guys!
>
> I've been wondering about this all night and i've already made a search on
> google and everything, but I didn't get a straight answer.
>
> Is there a way to make a redirect and send data from my current request to
> the other page.
>
> I mean, I could use the render_to_response to call another template and
> render the content I want.
> But I just want to know if it's possible to redirect to other view with the
> data coming from the current request.
>
Depends what you mean by "data". You're not very clear on that. If it's GET data, then it's trivial, just create the new URL with the data set as url parameters and you're done. If you want to POST a redirect, then things are more tricky: original HTTP semantics don't support POST redirects, not without warning the UA.

> I know it's odd, but this would send a 302 HTTP code to the User-Agent, I
> think that would be the right way.
Nope. HTTP 302 is generally implemented using HTTP 303 semantics ("See Other", which mandates GETing the Location uri). What you want is a 307 redirect (Temporary Redirect, the original meaning for 302 but not the way it was generally implemented), which will reissue the request using the same method (POST if the original was POST) but should warn the user.

Though I don't know if the POST payload will be carried through. I'd expect it, but considering Firefox drops all request headers on a redirect it wouldn't surprise me if it dropped the request body as well.

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

Re: Redirect with current data

Maybe this will help you: http://docs.djangoproject.com/en/dev/topics/http/shortcuts/


Op 31-jan-2011, om 06:36 heeft Antônio Ribeiro het volgende geschreven:

> Hello guys!
>
> I've been wondering about this all night and i've already made a search on google and everything, but I didn't get a straight answer.
>
> Is there a way to make a redirect and send data from my current request to the other page.
>
> I mean, I could use the render_to_response to call another template and render the content I want.
> But I just want to know if it's possible to redirect to other view with the data coming from the current request.
>
> I know it's odd, but this would send a 302 HTTP code to the User-Agent, I think that would be the right way.
>
> Sorry for my horrible english.
> It's been years since I wrote something that long in English.
>
> Thanks in advance!
>
> --
> Antonio Ribeiro
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Met vriendelijke groeten,

Jonas Geiregat
jonas@geiregat.org


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

Seeing tracebacks of unhandled exceptions in AJAX requests

Hi,

I really like Django's technical error page (the one you get when a view raises an uncaught exception and DEBUG is true). However, when an AJAX request causes an error, the technical error page reaches the AJAX error handler, instead of being displayed in the browser.

To solve this problem, I wrote django-ajaxerrors - simple middleware that is designed to be used when the server is running on the same GUI desktop as the developer is using (as is most commonly the case when developing with the devserver). When an unhandled exception passes through ajaxerrors, a technical error page is generated and a new browser tab is opened, pointing at the error page (using Python stdlib's webbrowser module).

I released django-ajaxerrors under the MIT license; if you're interested, you can see its GitHub page here, its PyPI page here, and a short blog post I published about it here (the blog post includes instructions for downloading a demo site with ajaxerrors installed in it, so you can see if it's useful for you in like 3 minutes).

I hope someone will find it useful, and I'll be happy to hear any comments or address questions.

 - Yaniv

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

Re: loading the external css file

Aha !!

Is there a notice of this somewhere obvious on the website that I
missed?

Thanks again!

--
Ben

On Jan 31, 11:38 am, Łukasz Rekucki <lreku...@gmail.com> wrote:
> On 31 January 2011 12:17, Ben Dembroski <i...@ionraystudios.com> wrote:
>
> > Hi all,
>
> > I was having the same trouble (using version 1.2).  I double checked
> > that I was looking at the correct documentation:
>
> >http://docs.djangoproject.com/en/1.2/howto/static-files/
>
> Django 1.2 doesn't have (never did and won't have) the static-files.
> The on-line docs are currently a bit broken after the recent
> switchover of djangoproject.com to the new server. All of 1.2 docs
> that are online, are actually 1.3 docs with wrong header. Either use
> 1.1 docs, or build yourself a localversion (this has extra advantage
> of being available even if your internet fails) until the problem is
> fixed.
>
> --
> Łukasz Rekucki

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

Re: loading the external css file

On 31 January 2011 12:17, Ben Dembroski <info@ionraystudios.com> wrote:
> Hi all,
>
> I was having the same trouble (using version 1.2).  I double checked
> that I was looking at the correct documentation:
>
> http://docs.djangoproject.com/en/1.2/howto/static-files/

Django 1.2 doesn't have (never did and won't have) the static-files.
The on-line docs are currently a bit broken after the recent
switchover of djangoproject.com to the new server. All of 1.2 docs
that are online, are actually 1.3 docs with wrong header. Either use
1.1 docs, or build yourself a localversion (this has extra advantage
of being available even if your internet fails) until the problem is
fixed.

--
Łukasz Rekucki

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

Re: loading the external css file

Hi all,

I was having the same trouble (using version 1.2). I double checked
that I was looking at the correct documentation:

http://docs.djangoproject.com/en/1.2/howto/static-files/

and it does indicate that I should be truing to use
django.contrib.staticfiles .

Should I instead be using the docs for version 1.1 ?

Many thanks,
Ben

On Jan 3, 7:28 pm, Chris Lawlor <lawlor.ch...@gmail.com> wrote:
> If you don't have astaticfilesmodule, you most likely aren't using
> Django 1.3. Make sure you select the correct version of Django when
> viewing the docs, as things are often done differently in older
> versions, but the doc pages usually default to the latest SVN release.
>
> On Dec 27 2010, 10:43 pm, Bithu <bithin2...@gmail.com> wrote:
>
> > When i was trying to set my static files. When i added the
> > 'django.contrib.staticfiles' into INSTALLED_APP in my setting.py the
> > development server was not running showing anerror Error:Nomodule
> >namedstaticfiles.
>
> > On Dec 27, 7:07 pm, Chris Lawlor <lawlor.ch...@gmail.com> wrote:
>
> > > Django doesn't server static files (like your CSS file) by default -
> > > but you can configure the development server to do so:http://docs.djangoproject.com/en/dev/howto/static-files/
>
> > > Note that this has changed a lot in Django 1.3, so be sure to view the
> > > correct version of that page for the version of Django that you are
> > > using.
>
> > > In production, you should almost always configure another server to
> > > serve static files.
>
> > > On Dec 27, 8:29 am, Bithu <bithin2...@gmail.com> wrote:
>
> > > > When i was trying to load an external stylesheet it was not working.
> > > > But the internal css is working nicely.
>
> > > > What should i do to link my .css file to my html template which is
> > > > inside my template folder.

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

Re: working django with existing database

errr...what do you think

i read at http://code.activestate.com/recipes/285262-create-objects-from-variable-class-names/

class Bunch(dict):
    def __init__(self,**kw):
            dict.__init__(self,kw)
            self.__dict__ = self

fruit = Bunch(apples=1, pears=2)
print fruit.apples
print fruit.pears

why doesn't we could use something like this to store data output from database to object??


2011/1/31 Adrian Bool <aid@logic.org.uk>

Arief,

Just do a search and replace in your text file along the lines of,

search for,

max_digits=0, decimal_places=-127

replace,

max_digits=10, decimal_places=2

And Django should be happy.

aid

On 31 Jan 2011, at 10:29, arief nur andono wrote:

oh please...

i need only to query the table, have no access to modified the table

why there is no way query the database and then make the output as object??

2011/1/31 Ian <ian.g.kelly@gmail.com>
On Jan 31, 12:20 am, arief nur andono <ariefnurand...@gmail.com>
wrote:
> class TempJmlGangguanPyl(models.Model):
>     singkatpyl = models.CharField(max_length=4, blank=True)
>     singkatgrd = models.CharField(max_length=4, blank=True)
>     jumlah_gangguan = models.DecimalField(null=True, max_digits=0,
> decimal_places=-127, blank=True)
>     lama_gangguan = models.DecimalField(null=True, max_digits=0,
> decimal_places=-127, blank=True)
>     class Meta:
>         db_table = u'temp_jml_gangguan_pyl'

It appears that your numeric columns are all decimal-precision
floating-point (i.e. "FLOAT" or "NUMBER" with no precision or scale
specified), which is a bit of a corner case.  The basic problem is
that Django core has no field for this.  DecimalField can only handle
fixed-point, and FloatField uses binary precision.  If these columns
are actually used to store fixed-point data, you could manually update
the generated models (or preferably the original schema) with the
actual precision and scale of the data.  If they are truly floating-
point, then you would probably need to write a custom DecimalField
class.  I wouldn't recommend changing them to FloatField in any case,
because that could result in a loss of precision.

A similar problem can be encountered with "NUMBER(p, s)" columns where
s < 0 or s > p.  Both these scenarios are perfectly valid in Oracle,
but are (somewhat arbitrarily) disallowed by the DecimalField
validation.

I'll make a note of this.  At the very least, there should be a more
descriptive error message for when this comes up.

Ian

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



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

Adrian Bool



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

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

Re: working django with existing database


Arief,

Just do a search and replace in your text file along the lines of,

search for,

max_digits=0, decimal_places=-127

replace,

max_digits=10, decimal_places=2

And Django should be happy.

aid

On 31 Jan 2011, at 10:29, arief nur andono wrote:

oh please...

i need only to query the table, have no access to modified the table

why there is no way query the database and then make the output as object??

2011/1/31 Ian <ian.g.kelly@gmail.com>
On Jan 31, 12:20 am, arief nur andono <ariefnurand...@gmail.com>
wrote:
> class TempJmlGangguanPyl(models.Model):
>     singkatpyl = models.CharField(max_length=4, blank=True)
>     singkatgrd = models.CharField(max_length=4, blank=True)
>     jumlah_gangguan = models.DecimalField(null=True, max_digits=0,
> decimal_places=-127, blank=True)
>     lama_gangguan = models.DecimalField(null=True, max_digits=0,
> decimal_places=-127, blank=True)
>     class Meta:
>         db_table = u'temp_jml_gangguan_pyl'

It appears that your numeric columns are all decimal-precision
floating-point (i.e. "FLOAT" or "NUMBER" with no precision or scale
specified), which is a bit of a corner case.  The basic problem is
that Django core has no field for this.  DecimalField can only handle
fixed-point, and FloatField uses binary precision.  If these columns
are actually used to store fixed-point data, you could manually update
the generated models (or preferably the original schema) with the
actual precision and scale of the data.  If they are truly floating-
point, then you would probably need to write a custom DecimalField
class.  I wouldn't recommend changing them to FloatField in any case,
because that could result in a loss of precision.

A similar problem can be encountered with "NUMBER(p, s)" columns where
s < 0 or s > p.  Both these scenarios are perfectly valid in Oracle,
but are (somewhat arbitrarily) disallowed by the DecimalField
validation.

I'll make a note of this.  At the very least, there should be a more
descriptive error message for when this comes up.

Ian

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



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

Adrian Bool