Re: simple command line ./manage.py shell puzzle

2022-04-21 Thread Larry Martell
On Thu, Apr 21, 2022 at 1:06 PM cseb...@gmail.com  wrote:
>
> Why does this fail?...
>
> % echo "import datetime ; [datetime for e in [1, 2]]" > test
>
> % ./manage.py shell < test
>
> Traceback (most recent call last):
>   File "./manage.py", line 8, in 
> django.core.management.execute_from_command_line(sys.argv)
>   File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
> line 381, in execute_from_command_line
> utility.execute()
>   File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
> 323, in run_from_argv
> self.execute(*args, **cmd_options)
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
> 364, in execute
> output = self.handle(*args, **options)
>   File 
> "/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", 
> line 92, in handle
> exec(sys.stdin.read())
>   File "", line 1, in 
>   File "", line 1, in 
> NameError: name 'datetime' is not defined

What do you expect to happen?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4%3D5kn5_ka%3DvDxXyt5P8cNWvEmHHg2%2BtWTUzNcRSWcHhg%40mail.gmail.com.


Re: simple command line ./manage.py shell puzzle

2022-04-21 Thread Larry Martell
On Thu, Apr 21, 2022 at 2:53 PM cseb...@gmail.com  wrote:
>
> The script should quietly exist without error.
>
> I actually have a longer script that is the real workhorse.
> I just made this tiny one to showcase the issue.
>
> I can past
>
> import datetime ; [datetime for e in [1, 2]]
>
> into a regular Python3 shell as well as the Django shell and all is fine.

$ python3
Python 3.8.10 (v3.8.10:3d8993a744, May  3 2021, 08:55:58)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime ; [datetime for e in [1, 2]]
[,
]

It does not do anything.

>
> The problem I think has something to do with how I inject
> it into the Django shell via "< test".
>
> cs
> On Thursday, April 21, 2022 at 12:18:04 PM UTC-5 larry.mart...@gmail.com 
> wrote:
>>
>> On Thu, Apr 21, 2022 at 1:06 PM cseb...@gmail.com  wrote:
>> >
>> > Why does this fail?...
>> >
>> > % echo "import datetime ; [datetime for e in [1, 2]]" > test
>> >
>> > % ./manage.py shell < test
>> >
>> > Traceback (most recent call last):
>> > File "./manage.py", line 8, in 
>> > django.core.management.execute_from_command_line(sys.argv)
>> > File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
>> > line 381, in execute_from_command_line
>> > utility.execute()
>> > File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
>> > line 375, in execute
>> > self.fetch_command(subcommand).run_from_argv(self.argv)
>> > File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
>> > 323, in run_from_argv
>> > self.execute(*args, **cmd_options)
>> > File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
>> > 364, in execute
>> > output = self.handle(*args, **options)
>> > File 
>> > "/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", 
>> > line 92, in handle
>> > exec(sys.stdin.read())
>> > File "", line 1, in 
>> > File "", line 1, in 
>> > NameError: name 'datetime' is not defined
>>
>> What do you expect to happen?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/c4a36ffb-8c7a-477f-9d26-f6b898178d91n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY43-xRez5dXzhQ0RxU3BVp1Dx8YARKRr7V9f1hyJSHfuA%40mail.gmail.com.


Re: variable inside a template

2022-06-16 Thread Larry Martell
On Thu, Jun 16, 2022 at 4:09 AM luca72.b...@gmail.com
 wrote:
>
> Hello i have a list like:
> mylist =  ['1,png','2.png',3.jpj']
> in the template i do as follow:
> {% for o in mylist %}
> 
> {% if "png" in o %}
> {{ o }}
> 
> {% else %}
> {{o}}
> 
> {% endif %}
> {% endfor %}
> in the template i see the file name but it never render, if i loock the 
> source code i see that in the   class="">
> So i never get the correct file name.
> How is the correct way to get the name of the variable o inside the img tag
> Thanks

mylist has 1,png not 1.png
   ^
Could that be the issue?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7j%2BRAqTN15MLtAch3f2JbC8-h_nL3o1rE0%2Br06THLm8Q%40mail.gmail.com.


Lost connection to MySQL server during query

2022-06-17 Thread Larry Martell
I have a standalone python script (i.e. not part of a web app) that
makes use of the ORM. I call djago.setup(), make some queries, then
call a function that can take 8 hours or more to run. When the
function returns I want to make more queries, but they fail with 'Lost
connection to MySQL server during query'. My DB wait_timeout is set to
8 hours and if the function returns in less than 8 hours I don't get
the error, so I thought I understood what was going on.

But then I read about CONN_MAX_AGE which we do not set. If that is not
set it should default to 0, which should mean that it gets a new
connection for each request so we should not get the Lost connection
message. Does that not work when using djago.setup()?

Further reading I saw said to call close_old_connections() or
connection.close() before calling the long running function. What is
the difference between these 2 and is one a better practice than the
other?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4tBWRsLBW5URC%3DNcBgmuFhMaSxTO_y1rGf8HUD80B3Rw%40mail.gmail.com.


getting unique id

2022-11-23 Thread Larry Martell
I have an app that needs to get a unique ID. Many threads run at the
same time that need one. I would like the IDs to be sequential. When I
need a unique ID I do this:

with transaction.atomic():
max_batch_id =
JobStatus.objects.select_for_update(nowait=False).aggregate(Max('batch_id'))
json_dict['batch_id'] = max_batch_id['batch_id__max'] + 1
status_row = JobStatus(**json_dict)
status_row.save()

But multiple jobs are getting the same ID. Why does the code not work
as I expect? What is a better way to accomplish what I need?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY54vF6ZK7yy--15hy1u5vxJ%2Bq9Zp_ODGfAX973gPYpecw%40mail.gmail.com.


Re: getting unique id

2022-11-23 Thread Larry Martell
On Wed, Nov 23, 2022 at 1:43 PM Shaheed Haque  wrote:
>
> Are all the threads in the same Python process?

No

> Or the same machine?

No

> Do they have to persist across process (or machine) restarts?

Yes.

Playing around with using F() but still don't have it working as desired.

> On Wed, 23 Nov 2022, 16:57 Larry Martell,  wrote:
>>
>> I have an app that needs to get a unique ID. Many threads run at the
>> same time that need one. I would like the IDs to be sequential. When I
>> need a unique ID I do this:
>>
>> with transaction.atomic():
>> max_batch_id =
>> JobStatus.objects.select_for_update(nowait=False).aggregate(Max('batch_id'))
>> json_dict['batch_id'] = max_batch_id['batch_id__max'] + 1
>> status_row = JobStatus(**json_dict)
>> status_row.save()
>>
>> But multiple jobs are getting the same ID. Why does the code not work
>> as I expect? What is a better way to accomplish what I need?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7A_zk%3DxJ3vg8csCSFPamkjtzm6fRGbzNjru1e2aJfa3A%40mail.gmail.com.


Re: getting unique id

2022-11-23 Thread Larry Martell
On Wed, Nov 23, 2022 at 3:01 PM Thomas Lockhart  wrote:
>
> Why not use the existing Django AutoField?

Because I have multiple rows with the same batch_id, and also I would
like the batch_ids to be sequential.

The use case is a batch job dashboard. Users run jobs that spawn many
sub jobs. The jobs all record their status in the JobStatus table. The
batch dashboard shows all the sub jobs grouped under their parent job.
The parent job creates a row with a new batch_id, and that is passed
to the sub jobs. They all record their status using that same batch
id, but each in its own row.

> > On Nov 23, 2022, at 8:56 AM, Larry Martell  wrote:
> >
> > I have an app that needs to get a unique ID. Many threads run at the
> > same time that need one. I would like the IDs to be sequential. When I
> > need a unique ID I do this:
> >
> > with transaction.atomic():
> >max_batch_id =
> > JobStatus.objects.select_for_update(nowait=False).aggregate(Max('batch_id'))
> >json_dict['batch_id'] = max_batch_id['batch_id__max'] + 1
> >status_row = JobStatus(**json_dict)
> >status_row.save()
> >
> > But multiple jobs are getting the same ID. Why does the code not work
> > as I expect? What is a better way to accomplish what I need?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY547umxs6E34c4sO7DqSLA1vuOf%2B7FsJDJOGVsR8SmZqw%40mail.gmail.com.


Re: AttributeError: module 'django.db.models' has no attribute 'PointField'

2022-11-27 Thread Larry Martell
On Sun, Nov 27, 2022 at 2:40 PM Ilyas Modni  wrote:
>
> AttributeError: module 'django.db.models' has no attribute 'PointField'

Are you importing:

from django.contrib.gis.db import models

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6VyNv5RdQ5UbA2N2j9W2OKN0B0vg0gjS_kuphmAmd8xg%40mail.gmail.com.


Re: getting unique id

2022-11-28 Thread Larry Martell
On Wed, Nov 23, 2022 at 3:11 PM Larry Martell  wrote:
>
> On Wed, Nov 23, 2022 at 3:01 PM Thomas Lockhart  
> wrote:
> >
> > Why not use the existing Django AutoField?
>
> Because I have multiple rows with the same batch_id, and also I would
> like the batch_ids to be sequential.
>
> The use case is a batch job dashboard. Users run jobs that spawn many
> sub jobs. The jobs all record their status in the JobStatus table. The
> batch dashboard shows all the sub jobs grouped under their parent job.
> The parent job creates a row with a new batch_id, and that is passed
> to the sub jobs. They all record their status using that same batch
> id, but each in its own row.
>
> > > On Nov 23, 2022, at 8:56 AM, Larry Martell  
> > > wrote:
> > >
> > > I have an app that needs to get a unique ID. Many threads run at the
> > > same time that need one. I would like the IDs to be sequential. When I
> > > need a unique ID I do this:
> > >
> > > with transaction.atomic():
> > >max_batch_id =
> > > JobStatus.objects.select_for_update(nowait=False).aggregate(Max('batch_id'))
> > >json_dict['batch_id'] = max_batch_id['batch_id__max'] + 1
> > >status_row = JobStatus(**json_dict)
> > >status_row.save()
> > >
> > > But multiple jobs are getting the same ID. Why does the code not work
> > > as I expect? What is a better way to accomplish what I need?

I ended up using another table to get the batch_ids from. It works,
but I still wonder how to make it work without a second table.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY57mQ%2Bp19gPf21AuhwXi66yatSY10gdSWuGk9s5XZx-HQ%40mail.gmail.com.


filtering queryset in CreateAPIView view

2022-12-28 Thread Larry Martell
I have a CreateAPIView view with this code in the serializer:

class AssignWorkItemSerializer(serializers.Serializer, WorkitemSerializerMixin):
assigneeIds = serializers.ListSerializer(
child=serializers.PrimaryKeyRelatedField(

queryset=get_user_model().objects.filter(userrole__role__name='analyst')
),
source='assignees'
)

This is failing because that query returns multiple rows. I want to
filter that queryset at run time by something that is available to me
in the request. Is there a way to do that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY46gZEjH9YNajSx%2B2uSSzozC7S_up9KY%3DB655p4zFL-Yg%40mail.gmail.com.


Re: Server Error 500 Nginx when DEBUG=False

2023-01-29 Thread Larry Martell
On Sun, Jan 29, 2023 at 9:14 AM ALBERT ASHABA AHEEBWA <
ashabaaheebwaalb...@gmail.com> wrote:

> So I was able to successfully host my first ever Django app on linode.
> After the excitement had won off, I started testing the routes, everything
> was running fine except for two routes.
>
> SERVER ERROR (500)
>
> These two views are sharing a template and I much doubt that is the cause.
> Since they are pointing to different routes.
>
> There's nothing in the /var/log/nginx/error.log file that is helpful.
>
> Everything is working as expected when DEBUG=True.
>
> Please help point me in the right direction.
>

Check the uwsgi and Django logs. Also you can try using runserver and
seeing if any errors are shown there. If that does not yield anything
useful, set a breakpoint and step through the code until you find where the
error is coming from.

>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6n_2CgcScNXtR8TwH_r8r2hMM6otQoVX8Or%2BkfsW617A%40mail.gmail.com.


List validator

2023-02-27 Thread Larry Martell
I have this defined in my serializer:

case_status = serializers.ListField(
child=serializers.CharField(
allow_blank=True,
max_length=512,
allow_null=True,
required=False,
default="''",
),
source='casestatus',
required=False,
allow_empty=True,
)

When this data is received:

(Pdb) request.data


The casestatus field is not picked up:

(Pdb) serializer.validated_data
OrderedDict([('patientid', 0), ('pk', 0), ('patientname', "''"),
('dobstart', "''"), ('dobend', "''"), ('scanstart', "''"), ('scanend',
"''"), ('workitemstr', "''"), ('institutionid', 0), ('page_size', 10),
('sortByDateCreated', 'true')])

Can anyone see what I am doing wrong here?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6-wEO-vVDn_mhb8t0-w2C5vXyw-08EeuUeiAPmMK_oqw%40mail.gmail.com.


Re: Unable to write to database

2023-05-22 Thread Larry Martell
On Sun, May 21, 2023 at 10:54 AM William Nash (Bill)  wrote:
>
> I'm new to django and I'm trying to learn as I program a small website for my 
> scuba diving business.   I'm running into a error that when I try to add a 
> diver the database does not update.  When I goto 
> http://localhost:8000/add_diver/add_diver/  I'm able to add a diver.

This is confusing - you said you get an error when you try and add a
diver to the database but when you goto
http://localhost:8000/add_diver/add_diver/ it works. In the case where
you get an error, how are you adding it? Please post your code and
tell us what the error you get is.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7%3DcadzuWCt_7aRhmBYO2ZuAzPBbDjatLaCKVNM6xSS7g%40mail.gmail.com.


Re: Django date time picker

2023-05-29 Thread Larry Martell
On Mon, May 29, 2023 at 1:14 PM Thomas Mutavi  wrote:
>
> Hello, how  can i implement a form with several date fields which have date 
> and time picker in django?

You can use the jQuery UI datetimepicker.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY72xpH90NiaJMQCWeziz%3DqPZcnDPZewBVt3BHMSjVcowQ%40mail.gmail.com.


Connection reset by peer on file upload if JWT expires

2023-06-02 Thread Larry Martell
We have a django app and it supports a file upload request. The entire
upload comprises multiple requests. We are authenticating with JWT and
we have logic to handle a 401 and in that case use the refresh token
to get a new access token and resend the failed request. However if
the token expires between 2 requests of the same upload the 401
response never makes it to the client. In the logs I found that before
nginx gets the response we get this error:

2023/06/02 16:23:11 [error] 1924925#1924925: *75 readv() failed (104:
Connection reset by peer) while reading upstream, client: xx.xx.xx.xx,
server: foo.com, request: "POST /api/upload/ HTTP/1.1", upstream:
"uwsgi://unix:///bar/foo/our_app/app.sock:", host: "foo.com",
referrer: "http://foo.com:8082/";

This causes the client to get an empty response body and the browser
throws a ERR_CONTENT_LENGTH_MISMATCH error. The entire upload takes
under 10 minutes and we have all the timeouts set to 100 minutes:

uwsgi_read_timeout 6000;
uwsgi_connect_timeout 6000;
uwsgi_send_timeout 6000;
send_timeout 6000;
proxy_read_timeout 6000;
proxy_send_timeout 6000;

What is causing the socket to get closed? How can I prevent that? Are
there other timeouts I could set? Any logging that I can enable to see
why the socket is getting closed? Is there a way to detect this in
code so it can be retried?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6ShL02Hhnfbc-uGTsMdKBNV8ij6kom7n9hJndwpRQGwg%40mail.gmail.com.


uwsgi

2023-06-04 Thread Larry Martell
I normally deploy my django apps using nginx and uwsgi. I recently
found that the uwsgi mailing list is defunct, and I read this on the
uwsgi github page:

Note: The project is in maintenance mode (only bugfixes and updates
for new languages apis). Do not expect quick answers on github issues.

Are folks still deploying new apps with uwsgi, or have people switched
to Gunicorn or something else?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4h8Jc4_Cd7Vf2w-8ExjfUnu0W2i-GknCuxOznk6V_V3A%40mail.gmail.com.


Re: best resources for learning django

2012-03-02 Thread Larry Martell
On Fri, Mar 2, 2012 at 2:00 PM, Jonathan Holloway
 wrote:
> I sympathise with you.  I'm following the 1.3 online docs and hacking a site
> together at the moment.
>
> an up to date book would be awesome !!!
>
> I found looking at example projects on Github very useful.
>
> Cheers,
> Jon.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

I think both of these books are excellent:

http://www.amazon.com/gp/product/143021936X/
http://www.amazon.com/Pro-Django-Experts-Voice-Development/dp/1430210478/

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



Re: Live search

2012-03-08 Thread Larry Martell
On Wed, Mar 7, 2012 at 5:57 AM, Karen Tracey  wrote:
> On Mon, Mar 5, 2012 at 11:25 AM, larry.mart...@gmail.com
>  wrote:
>> I'm fairly new to django, still working on my first project.
>>
>> I have a page with some selection fields and a button. The user clicks
>> the button, I run a query, and display the result set on the page.
>> Works fine.
>>
>> Now I was to add a live search field to allow the user to further
>> winnow down the result set. As they type in this field, the displayed
>> result set will be filtered and re-displayed. But I can't figure out
>> how to return control to my code as they type in that field. I assume
>> I'll have to write some javascript code to get the events and collect
>> the entered text, but how do I then pass that to my python code that
>> would have the result set available to it? Or am I thinking about this
>> wrong - do I have to do it all in javascript?
>>
>
> Further narrowing down the set you've already fetched would most
> easily be done just with javascript. If you don't need any additional
> data from the server then going back to the server for further
> processing just complicates things.

I have a table that gets created in a django view from code like this:

   {% for row in page.object_list %}

{% for value in row %}
{% if value %}{{ value }}{% endif %}
{% endfor %}

   {% endfor %}

>From my javascript code, how can I access the data in the table? Do I
have to tag the cells in the table with an id or class when I create
them? Or is there some other way to do this?

Thanks!
-larry

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



Re: Getting URL from within a template

2012-03-13 Thread Larry Martell
On Tue, Mar 13, 2012 at 11:26 AM, Xavier Ordoquy  wrote:
> Hi
>
> Le 13 mars 2012 à 18:11, larry.mart...@gmail.com a écrit :
>
>> From within a template can I find out the URL that caused the template
>> to be invoked?
>
> You usually should have the request object in your template. See 
> https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.path
>  to get the url.
>

But how do I access that in the template? I tried HttpRequest.path and
{{ HttpRequest.path }} and neither gives me the URL.

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



Re: Getting URL from within a template

2012-03-13 Thread Larry Martell
On Tue, Mar 13, 2012 at 11:58 AM, Xavier Ordoquy  wrote:
>
> Le 13 mars 2012 à 18:40, Larry Martell a écrit :
>
>> On Tue, Mar 13, 2012 at 11:26 AM, Xavier Ordoquy  
>> wrote:
>>> Hi
>>>
>>> Le 13 mars 2012 à 18:11, larry.mart...@gmail.com a écrit :
>>>
>>>> From within a template can I find out the URL that caused the template
>>>> to be invoked?
>>>
>>> You usually should have the request object in your template. See 
>>> https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.path
>>>  to get the url.
>>>
>>
>> But how do I access that in the template? I tried HttpRequest.path and
>> {{ HttpRequest.path }} and neither gives me the URL.
>
> {{ request.path }}
> just make sure you have RequestContext if you use render_to_response.

This is displaying a path, but not the URL I need. It gives
/report//EventsTable/ when the URL that's clicked on is:

http://127.0.0.1/report/EventsTable/?date_time=3y&submit_preview=Generate+Report&event_type=RecipeCreated&_filterValue=dev

I'm after all the arguments. Is there a way to get them?

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



Getting URL from within a template

2012-03-13 Thread Larry Martell
On Tue, Mar 13, 2012 at 12:38 PM, Furbee  wrote:
> I think you want to actually get these in the view code and pass them to
the
> template as named variables. For example:
>
> return render_to_response('page.htm',
> {'date_time': request.GET['date_time'], 'submit_preview':
> request.GET['submit_preview'], 'event_type': request.GET['event_type'],
> 'filterValue':
> request.GET['_filterValue']}, context_instance=RequestContext(request))
>
> From the template, now, the different variables are available. {{
date_time
> }}, {{ submit_preview }}, {{ event_type }}, {{ filterValue }}. That's how
I
> would handle it at least.

The URL gets created dynamically by jQuery code in a template. Not all
these fields are always present. Also, render_to_response is not used. (I'm
fairly new to both django and this job, and I just grepped through the
entire code base and it wasn't found.)

>
> Furbee
>
> On Tue, Mar 13, 2012 at 11:27 AM, Larry Martell 
> wrote:
>>
>> On Tue, Mar 13, 2012 at 11:58 AM, Xavier Ordoquy 
>> wrote:
>> >
>> > Le 13 mars 2012 à 18:40, Larry Martell a écrit :
>> >
>> >> On Tue, Mar 13, 2012 at 11:26 AM, Xavier Ordoquy 
>> >> wrote:
>> >>> Hi
>> >>>
>> >>> Le 13 mars 2012 à 18:11, larry.mart...@gmail.com a écrit :
>> >>>
>> >>>> From within a template can I find out the URL that caused the
>> >>>> template
>> >>>> to be invoked?
>> >>>
>> >>> You usually should have the request object in your template. See
>> >>>
https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.path
>> >>> to get the url.
>> >>>
>> >>
>> >> But how do I access that in the template? I tried HttpRequest.path and
>> >> {{ HttpRequest.path }} and neither gives me the URL.
>> >
>> > {{ request.path }}
>> > just make sure you have RequestContext if you use render_to_response.
>>
>> This is displaying a path, but not the URL I need. It gives
>> /report//EventsTable/ when the URL that's clicked on is:
>>
>>
>>
http://127.0.0.1/report/EventsTable/?date_time=3y&submit_preview=Generate+Report&event_type=RecipeCreated&_filterValue=dev
>>
>> I'm after all the arguments. Is there a way to get them?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
Sent from my iPhone

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



Re: Getting URL from within a template

2012-03-13 Thread Larry Martell
On Tue, Mar 13, 2012 at 2:19 PM, Furbee  wrote:
> Hi Larry,
>
> render_to_response is one of many ways to return an HttpResponse to send to
> the client. Wherever your view does the return, you can pass these GET
> variables.
>
> However, if they are being generated by jQuery, dynamically, you should be
> using jQuery/javascript to read them and deal with them. This should be
> client side javascript code. To read the current URL string in jQuery, I
> found a nice little article
> at http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html which
> should demonstrate how to get these in javascript on the client-side
> browser.

I was able to get the entire URL with {{ request.get_full_path }}

But thanks for the link - looks like it could be very useful in the future.


> On Tue, Mar 13, 2012 at 11:57 AM, Larry Martell 
> wrote:
>>
>> On Tue, Mar 13, 2012 at 12:38 PM, Furbee  wrote:
>> > I think you want to actually get these in the view code and pass them to
>> > the
>> > template as named variables. For example:
>> >
>> >     return render_to_response('page.htm',
>> > {'date_time': request.GET['date_time'], 'submit_preview':
>> > request.GET['submit_preview'], 'event_type': request.GET['event_type'],
>> > 'filterValue':
>> > request.GET['_filterValue']}, context_instance=RequestContext(request))
>> >
>> > From the template, now, the different variables are available. {{
>> > date_time
>> > }}, {{ submit_preview }}, {{ event_type }}, {{ filterValue }}. That's
>> > how I
>> > would handle it at least.
>>
>> The URL gets created dynamically by jQuery code in a template. Not all
>> these fields are always present. Also, render_to_response is not used. (I'm
>> fairly new to both django and this job, and I just grepped through the
>> entire code base and it wasn't found.)
>>
>>
>> >
>> > Furbee
>> >
>> > On Tue, Mar 13, 2012 at 11:27 AM, Larry Martell
>> > 
>> > wrote:
>> >>
>> >> On Tue, Mar 13, 2012 at 11:58 AM, Xavier Ordoquy 
>> >> wrote:
>> >> >
>> >> > Le 13 mars 2012 à 18:40, Larry Martell a écrit :
>> >> >
>> >> >> On Tue, Mar 13, 2012 at 11:26 AM, Xavier Ordoquy
>> >> >> 
>> >> >> wrote:
>> >> >>> Hi
>> >> >>>
>> >> >>> Le 13 mars 2012 à 18:11, larry.mart...@gmail.com a écrit :
>> >> >>>
>> >> >>>> From within a template can I find out the URL that caused the
>> >> >>>> template
>> >> >>>> to be invoked?
>> >> >>>
>> >> >>> You usually should have the request object in your template. See
>> >> >>>
>> >> >>> https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.path
>> >> >>> to get the url.
>> >> >>>
>> >> >>
>> >> >> But how do I access that in the template? I tried HttpRequest.path
>> >> >> and
>> >> >> {{ HttpRequest.path }} and neither gives me the URL.
>> >> >
>> >> > {{ request.path }}
>> >> > just make sure you have RequestContext if you use render_to_response.
>> >>
>> >> This is displaying a path, but not the URL I need. It gives
>> >> /report//EventsTable/ when the URL that's clicked on is:
>> >>
>> >>
>> >>
>> >> http://127.0.0.1/report/EventsTable/?date_time=3y&submit_preview=Generate+Report&event_type=RecipeCreated&_filterValue=dev
>> >>
>> >> I'm after all the arguments. Is there a way to get them?
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Dj

Re: Getting URL from within a template

2012-03-13 Thread Larry Martell
On Tue, Mar 13, 2012 at 3:33 PM, Furbee  wrote:
> Good deal, but if you send the page to the client, then jQuery updates the
> URL, the {{ request.get_full_path }} is still only able to have the original
> URL that was requested. Once the page is sent to the client, Django/Python
> is done and cannot manipulate the page, unless you are using AJAX to get
> updated details.

When the URL that gets updated by jQuery is clicked on, it goes back
to Django/Python and the {{ request.get_full_path }} gets updated.


> On Tue, Mar 13, 2012 at 2:23 PM, Larry Martell 
> wrote:
>>
>> On Tue, Mar 13, 2012 at 2:19 PM, Furbee  wrote:
>> > Hi Larry,
>> >
>> > render_to_response is one of many ways to return an HttpResponse to send
>> > to
>> > the client. Wherever your view does the return, you can pass these GET
>> > variables.
>> >
>> > However, if they are being generated by jQuery, dynamically, you should
>> > be
>> > using jQuery/javascript to read them and deal with them. This should be
>> > client side javascript code. To read the current URL string in jQuery, I
>> > found a nice little article
>> >
>> > at http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html which
>> > should demonstrate how to get these in javascript on the client-side
>> > browser.
>>
>> I was able to get the entire URL with {{ request.get_full_path }}
>>
>> But thanks for the link - looks like it could be very useful in the
>> future.
>>
>>
>> > On Tue, Mar 13, 2012 at 11:57 AM, Larry Martell
>> > 
>> > wrote:
>> >>
>> >> On Tue, Mar 13, 2012 at 12:38 PM, Furbee  wrote:
>> >> > I think you want to actually get these in the view code and pass them
>> >> > to
>> >> > the
>> >> > template as named variables. For example:
>> >> >
>> >> >     return render_to_response('page.htm',
>> >> > {'date_time': request.GET['date_time'], 'submit_preview':
>> >> > request.GET['submit_preview'], 'event_type':
>> >> > request.GET['event_type'],
>> >> > 'filterValue':
>> >> >
>> >> > request.GET['_filterValue']}, context_instance=RequestContext(request))
>> >> >
>> >> > From the template, now, the different variables are available. {{
>> >> > date_time
>> >> > }}, {{ submit_preview }}, {{ event_type }}, {{ filterValue }}. That's
>> >> > how I
>> >> > would handle it at least.
>> >>
>> >> The URL gets created dynamically by jQuery code in a template. Not all
>> >> these fields are always present. Also, render_to_response is not used.
>> >> (I'm
>> >> fairly new to both django and this job, and I just grepped through the
>> >> entire code base and it wasn't found.)
>> >>
>> >>
>> >> >
>> >> > Furbee
>> >> >
>> >> > On Tue, Mar 13, 2012 at 11:27 AM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >>
>> >> >> On Tue, Mar 13, 2012 at 11:58 AM, Xavier Ordoquy
>> >> >> 
>> >> >> wrote:
>> >> >> >
>> >> >> > Le 13 mars 2012 à 18:40, Larry Martell a écrit :
>> >> >> >
>> >> >> >> On Tue, Mar 13, 2012 at 11:26 AM, Xavier Ordoquy
>> >> >> >> 
>> >> >> >> wrote:
>> >> >> >>> Hi
>> >> >> >>>
>> >> >> >>> Le 13 mars 2012 à 18:11, larry.mart...@gmail.com a écrit :
>> >> >> >>>
>> >> >> >>>> From within a template can I find out the URL that caused the
>> >> >> >>>> template
>> >> >> >>>> to be invoked?
>> >> >> >>>
>> >> >> >>> You usually should have the request object in your template. See
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.path
>> >> >> >>> to get the url.
>> >> >> >>>
>> >> >> >>
>> >> >> >> But how do I acc

Re: Django making box

2012-03-13 Thread Larry Martell
On Tue, Mar 13, 2012 at 3:34 PM, Sophia  wrote:
> Thanks for the help, actually it should be run just on my computer not the
> client.

In this context the client is the browser.

>
> On Tuesday, March 13, 2012 1:54:00 PM UTC-7, Javier Guerra wrote:
>>
>> On Tue, Mar 13, 2012 at 3:37 PM, Sophia  wrote:
>> > Thanks all for helping, as I told I read that tutorial, but my
>> > supervisor
>> > said that I should do that with Django. He didn't mention about learning
>> > JavaScript, but is it impossible just with Django?
>>
>> django runs on the server.  if you want to do some client processing
>> you need code running on the client, typically Javascript.
>>
>> of course that code is served from a Django app, and modifying a
>> django-handled page and form, so the project in a whole is still 'done
>> with Django'.
>>
>> --
>> Javier
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/IRJ8PvQXRdEJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Getting URL from within a template

2012-03-13 Thread Larry Martell
On Tue, Mar 13, 2012 at 3:53 PM, Furbee  wrote:
> Gotcha, I was unclear. You can have jQuery modify the URL without actually
> requesting the page from the webserver, I thought that was what you meant.
> This comes in handy when you want to use javascript to update the URL
> without requesting a new page from the server in case the user hits F5 or
> refreshes the page, it will request the updated URL instead of the original.
>
> So, you can do this as you mentioned, or you can parse the request.GET
> dictionary and return them as variables to the template from the view.

There's a 'live filtering' function on the page. It's text field with
a keyup event handler. Each time the field gets updated the data
currently on the screen is filtered, and the URL is updated to include
the current filter string so that when the user pages forward or
backwards through the data (which is a return back to the server), the
filter string can get passed back into the template so it can apply
the filtering on the new data set


> On Tue, Mar 13, 2012 at 2:42 PM, Larry Martell 
> wrote:
>>
>> On Tue, Mar 13, 2012 at 3:33 PM, Furbee  wrote:
>> > Good deal, but if you send the page to the client, then jQuery updates
>> > the
>> > URL, the {{ request.get_full_path }} is still only able to have the
>> > original
>> > URL that was requested. Once the page is sent to the client,
>> > Django/Python
>> > is done and cannot manipulate the page, unless you are using AJAX to get
>> > updated details.
>>
>> When the URL that gets updated by jQuery is clicked on, it goes back
>> to Django/Python and the {{ request.get_full_path }} gets updated.
>>
>>
>> > On Tue, Mar 13, 2012 at 2:23 PM, Larry Martell 
>> > wrote:
>> >>
>> >> On Tue, Mar 13, 2012 at 2:19 PM, Furbee  wrote:
>> >> > Hi Larry,
>> >> >
>> >> > render_to_response is one of many ways to return an HttpResponse to
>> >> > send
>> >> > to
>> >> > the client. Wherever your view does the return, you can pass these
>> >> > GET
>> >> > variables.
>> >> >
>> >> > However, if they are being generated by jQuery, dynamically, you
>> >> > should
>> >> > be
>> >> > using jQuery/javascript to read them and deal with them. This should
>> >> > be
>> >> > client side javascript code. To read the current URL string in
>> >> > jQuery, I
>> >> > found a nice little article
>> >> >
>> >> >
>> >> > at http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html which
>> >> > should demonstrate how to get these in javascript on the client-side
>> >> > browser.
>> >>
>> >> I was able to get the entire URL with {{ request.get_full_path }}
>> >>
>> >> But thanks for the link - looks like it could be very useful in the
>> >> future.
>> >>
>> >>
>> >> > On Tue, Mar 13, 2012 at 11:57 AM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >>
>> >> >> On Tue, Mar 13, 2012 at 12:38 PM, Furbee 
>> >> >> wrote:
>> >> >> > I think you want to actually get these in the view code and pass
>> >> >> > them
>> >> >> > to
>> >> >> > the
>> >> >> > template as named variables. For example:
>> >> >> >
>> >> >> >     return render_to_response('page.htm',
>> >> >> > {'date_time': request.GET['date_time'], 'submit_preview':
>> >> >> > request.GET['submit_preview'], 'event_type':
>> >> >> > request.GET['event_type'],
>> >> >> > 'filterValue':
>> >> >> >
>> >> >> >
>> >> >> > request.GET['_filterValue']}, context_instance=RequestContext(request))
>> >> >> >
>> >> >> > From the template, now, the different variables are available. {{
>> >> >> > date_time
>> >> >> > }}, {{ submit_preview }}, {{ event_type }}, {{ filterValue }}.
>> >> >> > That's
>> >> >> > how I
>> >> >> > would handle it at least.
>> >> >>
>> >> >> The URL gets create

Re: Getting URL from within a template

2012-03-14 Thread Larry Martell
On Tue, Mar 13, 2012 at 4:25 PM, Furbee  wrote:
> Aha! Very nice. As a sidebar, you said you pass the filter string back to
> the template so it can apply filtering on the new data set. This makes me
> think that filtering is being done on the entire data set from the browser,
> instead of the server. Maybe I misunderstood, but if so, I would suggest
> filtering the data on Django's end and simply returning the filtered
> QuerySet. This may make the page load faster and would be scalable for
> larger lists where lots of records are being filtered by the client browser.

On the web page the user enters some selection criteria and clicks a
button. Then on the server side a db query is run and just some number
of rows are sent to back to the client (a subset of the full result
set). Then they can winnow down that subset of data using the live
filtering field. As they type or delete from that field the data they
see changes accordingly. The web page has links to get the next or
previous page of data. That goes back to the server for the next
subset and the page gets redrawn. But they wanted the filter text the
user had entered before clicking on next or prev to be applied to the
new page of data.


>
>
> On Tue, Mar 13, 2012 at 3:01 PM, Larry Martell 
> wrote:
>>
>> On Tue, Mar 13, 2012 at 3:53 PM, Furbee  wrote:
>> > Gotcha, I was unclear. You can have jQuery modify the URL without
>> > actually
>> > requesting the page from the webserver, I thought that was what you
>> > meant.
>> > This comes in handy when you want to use javascript to update the URL
>> > without requesting a new page from the server in case the user hits F5
>> > or
>> > refreshes the page, it will request the updated URL instead of the
>> > original.
>> >
>> > So, you can do this as you mentioned, or you can parse the request.GET
>> > dictionary and return them as variables to the template from the view.
>>
>> There's a 'live filtering' function on the page. It's text field with
>> a keyup event handler. Each time the field gets updated the data
>> currently on the screen is filtered, and the URL is updated to include
>> the current filter string so that when the user pages forward or
>> backwards through the data (which is a return back to the server), the
>> filter string can get passed back into the template so it can apply
>> the filtering on the new data set
>>
>>
>> > On Tue, Mar 13, 2012 at 2:42 PM, Larry Martell 
>> > wrote:
>> >>
>> >> On Tue, Mar 13, 2012 at 3:33 PM, Furbee  wrote:
>> >> > Good deal, but if you send the page to the client, then jQuery
>> >> > updates
>> >> > the
>> >> > URL, the {{ request.get_full_path }} is still only able to have the
>> >> > original
>> >> > URL that was requested. Once the page is sent to the client,
>> >> > Django/Python
>> >> > is done and cannot manipulate the page, unless you are using AJAX to
>> >> > get
>> >> > updated details.
>> >>
>> >> When the URL that gets updated by jQuery is clicked on, it goes back
>> >> to Django/Python and the {{ request.get_full_path }} gets updated.
>> >>
>> >>
>> >> > On Tue, Mar 13, 2012 at 2:23 PM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >>
>> >> >> On Tue, Mar 13, 2012 at 2:19 PM, Furbee 
>> >> >> wrote:
>> >> >> > Hi Larry,
>> >> >> >
>> >> >> > render_to_response is one of many ways to return an HttpResponse
>> >> >> > to
>> >> >> > send
>> >> >> > to
>> >> >> > the client. Wherever your view does the return, you can pass these
>> >> >> > GET
>> >> >> > variables.
>> >> >> >
>> >> >> > However, if they are being generated by jQuery, dynamically, you
>> >> >> > should
>> >> >> > be
>> >> >> > using jQuery/javascript to read them and deal with them. This
>> >> >> > should
>> >> >> > be
>> >> >> > client side javascript code. To read the current URL string in
>> >> >> > jQuery, I
>> >> >> > found a nice little article
>> >> >> >
>> >> >> >
>> >> >> >
>> >&

Re: Getting URL from within a template

2012-03-14 Thread Larry Martell
On Tue, Mar 13, 2012 at 4:26 PM, Furbee  wrote:
> Oh, you are filtering in the template, using Django, sorry. I thought you
> meant you pass it to the template and use jQuery to filter. My bad. :-)

I am filtering in the template using jQuery.

>
> Cheers
>
>
> On Tue, Mar 13, 2012 at 3:25 PM, Furbee  wrote:
>>
>> Aha! Very nice. As a sidebar, you said you pass the filter string back to
>> the template so it can apply filtering on the new data set. This makes me
>> think that filtering is being done on the entire data set from the browser,
>> instead of the server. Maybe I misunderstood, but if so, I would suggest
>> filtering the data on Django's end and simply returning the filtered
>> QuerySet. This may make the page load faster and would be scalable for
>> larger lists where lots of records are being filtered by the client browser.
>>
>>
>> On Tue, Mar 13, 2012 at 3:01 PM, Larry Martell 
>> wrote:
>>>
>>> On Tue, Mar 13, 2012 at 3:53 PM, Furbee  wrote:
>>> > Gotcha, I was unclear. You can have jQuery modify the URL without
>>> > actually
>>> > requesting the page from the webserver, I thought that was what you
>>> > meant.
>>> > This comes in handy when you want to use javascript to update the URL
>>> > without requesting a new page from the server in case the user hits F5
>>> > or
>>> > refreshes the page, it will request the updated URL instead of the
>>> > original.
>>> >
>>> > So, you can do this as you mentioned, or you can parse the request.GET
>>> > dictionary and return them as variables to the template from the view.
>>>
>>> There's a 'live filtering' function on the page. It's text field with
>>> a keyup event handler. Each time the field gets updated the data
>>> currently on the screen is filtered, and the URL is updated to include
>>> the current filter string so that when the user pages forward or
>>> backwards through the data (which is a return back to the server), the
>>> filter string can get passed back into the template so it can apply
>>> the filtering on the new data set
>>>
>>>
>>> > On Tue, Mar 13, 2012 at 2:42 PM, Larry Martell
>>> > 
>>> > wrote:
>>> >>
>>> >> On Tue, Mar 13, 2012 at 3:33 PM, Furbee  wrote:
>>> >> > Good deal, but if you send the page to the client, then jQuery
>>> >> > updates
>>> >> > the
>>> >> > URL, the {{ request.get_full_path }} is still only able to have the
>>> >> > original
>>> >> > URL that was requested. Once the page is sent to the client,
>>> >> > Django/Python
>>> >> > is done and cannot manipulate the page, unless you are using AJAX to
>>> >> > get
>>> >> > updated details.
>>> >>
>>> >> When the URL that gets updated by jQuery is clicked on, it goes back
>>> >> to Django/Python and the {{ request.get_full_path }} gets updated.
>>> >>
>>> >>
>>> >> > On Tue, Mar 13, 2012 at 2:23 PM, Larry Martell
>>> >> > 
>>> >> > wrote:
>>> >> >>
>>> >> >> On Tue, Mar 13, 2012 at 2:19 PM, Furbee 
>>> >> >> wrote:
>>> >> >> > Hi Larry,
>>> >> >> >
>>> >> >> > render_to_response is one of many ways to return an HttpResponse
>>> >> >> > to
>>> >> >> > send
>>> >> >> > to
>>> >> >> > the client. Wherever your view does the return, you can pass
>>> >> >> > these
>>> >> >> > GET
>>> >> >> > variables.
>>> >> >> >
>>> >> >> > However, if they are being generated by jQuery, dynamically, you
>>> >> >> > should
>>> >> >> > be
>>> >> >> > using jQuery/javascript to read them and deal with them. This
>>> >> >> > should
>>> >> >> > be
>>> >> >> > client side javascript code. To read the current URL string in
>>> >> >> > jQuery, I
>>> >> >> > found a nice little article
>>> >> >> >
>>> >> >> >
>>> >> >> >
>

usage of url template tag

2012-03-20 Thread Larry Martell
I'm trying to generate a URL that looks something like this:

/report/faloom/EventLog/?message=EventSearchString&tool_ids=13&field_1=Tool&field_2=Time&field_3=Module&field_4=Message&submit_preview=Generate+Report

I have the values for the arguments (message, tool_ids, etc)  available to me.

My urlconf has:

(r'^report/$', motor.ui.views.index)

If I put this in my template:

{% url motor.ui.views.index %}

I get:

/report/

What do I use as arguments with the url tag to get the URL I want?
I've tried many, many different things, but no matter what, I get a
NoReverseMatch exception.

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



Re: usage of url template tag

2012-03-21 Thread Larry Martell
On Tue, Mar 20, 2012 at 11:04 PM, Daniel Roseman  wrote:
> On Tuesday, 20 March 2012 15:27:27 UTC-7, larry@gmail.com wrote:
>>
>> I'm trying to generate a URL that looks something like this:
>>
>>
>> /report/faloom/EventLog/?message=EventSearchString&tool_ids=13&field_1=Tool&field_2=Time&field_3=Module&field_4=Message&submit_preview=Generate+Report
>>
>> I have the values for the arguments (message, tool_ids, etc)  available to
>> me.
>>
>> My urlconf has:
>>
>> (r'^report/$', motor.ui.views.index)
>>
>> If I put this in my template:
>>
>> {% url motor.ui.views.index %}
>>
>> I get:
>>
>> /report/
>>
>> What do I use as arguments with the url tag to get the URL I want?
>> I've tried many, many different things, but no matter what, I get a
>> NoReverseMatch exception.
>
>
> This question makes no sense at all. Your URL is just "/report/". You can
> add the  GET parameters manually, since they aren't matched in a URLconf,
> but where is the 'faloom/EventLog' bit supposed to be coming from? There is
> no URL that matches that.

I'm very new to django. The rest of the URL comes from the index
function in views.py. I wasn't sure if it violated the DRY principle
to hardcode it.

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



using forloop.counter to access data

2012-03-21 Thread Larry Martell
This is probably a stupid newbie question 

I want to access a column of data in a row using forloop.counter, but
I cannot get it to work.

In my test code, if I display {{ forloop.counter }} I get 2
If I display {{ headers.0.2 }} I get ToolType
But if I display {{ headers.0.forloop.counter }} I get nothing

What is the proper syntax for 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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: using forloop.counter to access data

2012-03-21 Thread Larry Martell
On Wed, Mar 21, 2012 at 7:53 AM, James  wrote:
>
>
> On Wednesday, March 21, 2012 8:47:23 AM UTC-4, larry@gmail.com wrote:
>>
>> This is probably a stupid newbie question 
>>
>> I want to access a column of data in a row using forloop.counter, but
>> I cannot get it to work.
>>
>> In my test code, if I display {{ forloop.counter }} I get 2
>> If I display {{ headers.0.2 }} I get ToolType
>> But if I display {{ headers.0.forloop.counter }} I get nothing
>>
>> What is the proper syntax for this?
>
>
> the forloop.counter and friends will simply give you information about the
> iteration, it won't give you any information about the data in the queryset

Yes, I realize that. I am using it withing a loop to try an access a
specific item of data. The code I showed was just an example from one
iteration of the loop.

> (I'm assuming this is what you mean when you say column).
>
> Here are the
> docs https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#for
>
>  If you want to access the column of data, assuming it's referenced from a
> model, just the attribute of that model. If you passed in a list to the
> template, you just use the django "dot" look-up syntax.

Perhaps my question wasn't clear. I have a list called headers. From
within a for loop I want the n'th item from the first row. In the loop
I am trying to access {{ headers.0.forloop.counter }} but I get no
value from that. But if I hard code the number (as a test), e.g.:  {{
headers.0.2 }} then I do get the 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: using forloop.counter to access data

2012-03-21 Thread Larry Martell
On Wed, Mar 21, 2012 at 8:32 AM, Tom Evans  wrote:
> On Wed, Mar 21, 2012 at 12:47 PM, Larry Martell  
> wrote:
>> This is probably a stupid newbie question 
>>
>> I want to access a column of data in a row using forloop.counter, but
>> I cannot get it to work.
>>
>> In my test code, if I display {{ forloop.counter }} I get 2
>> If I display {{ headers.0.2 }} I get ToolType
>> But if I display {{ headers.0.forloop.counter }} I get nothing
>>
>> What is the proper syntax for this?
>>
>
> The preferred solution is to structure your data better in your view
> so that writing the template to render the data is straightforward.

This is a very large existing app, and I am new at this job. That have
a table of data and they want me to make some of the data in the table
into links that take them to a more detailed view of the data. The
functionality to provide this more detailed view of the data already
exist in the app. So I am just trying to construct the href. As I
iterate through the table data, I need info from the header to build
the href.

>
> The pragmatic solution is to use a custom filter to access your
> current data structures:
>
> http://stackoverflow.com/questions/2024660/django-sort-dict-in-template

OK, but is there some reason {{ headers.0.forloop.counter } does not
work when forloop.counter has a value of 2, yet {{ headers.0.2 }}
does work?

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



Re: usage of url template tag

2012-03-21 Thread Larry Martell
On Wed, Mar 21, 2012 at 2:06 PM, Daniel Roseman  wrote:
> On Wednesday, 21 March 2012 03:01:23 UTC-7, larry@gmail.com wrote:
>>
>>
>> I'm very new to django. The rest of the URL comes from the index
>> function in views.py. I wasn't sure if it violated the DRY principle
>> to hardcode it.
>
>
> Fine, but you can't reverse a URL that does not exist. If you tried to
> access "/report/faloom/EventLog/" in your browser, you would get a 404
> because you have no URLconf that matches it. So there's no point in
> outputting that URL in your template.

That's not true. My urlpatterns has:

(r'^report/(\w+)/(\w+)/$', motor.core.reports.views.view)

so /report/faloom/EventLog/ get routed to the view function in
motor/core/report/views.py, which renters the page.

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



Re: using forloop.counter to access data

2012-03-21 Thread Larry Martell
On Wed, Mar 21, 2012 at 12:52 PM, James  wrote:
>
>
> On Wednesday, March 21, 2012 10:41:08 AM UTC-4, larry@gmail.com wrote:
>>
>> On Wed, Mar 21, 2012 at 7:53 AM, James <> wrote:
>> >
>> >
>> > On Wednesday, March 21, 2012 8:47:23 AM UTC-4, larry@gmail.com
>> > wrote:
>> >>
>> >> This is probably a stupid newbie question 
>> >>
>> >> I want to access a column of data in a row using forloop.counter, but
>> >> I cannot get it to work.
>> >>
>> >> In my test code, if I display {{ forloop.counter }} I get 2
>> >> If I display {{ headers.0.2 }} I get ToolType
>> >> But if I display {{ headers.0.forloop.counter }} I get nothing
>> >>
>> >> What is the proper syntax for this?
>> >
>> >
>> > the forloop.counter and friends will simply give you information about
>> > the
>> > iteration, it won't give you any information about the data in the
>> > queryset
>>
>> Yes, I realize that. I am using it withing a loop to try an access a
>> specific item of data. The code I showed was just an example from one
>> iteration of the loop.
>>
>> > (I'm assuming this is what you mean when you say column).
>> >
>> > Here are the
>> >
>> > docs https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#for
>> >
>> >  If you want to access the column of data, assuming it's referenced from
>> > a
>> > model, just the attribute of that model. If you passed in a list to the
>> > template, you just use the django "dot" look-up syntax.
>>
>> Perhaps my question wasn't clear. I have a list called headers. From
>> within a for loop I want the n'th item from the first row. In the loop
>> I am trying to access {{ headers.0.forloop.counter }} but I get no
>> value from that. But if I hard code the number (as a test), e.g.:  {{
>> headers.0.2 }} then I do get the value.
>
>  With regards to your reply:
>
>
>>  Yes, I realize that. I am using it withing a loop to try an access a
>> specific item of data. The code I showed was just an example from one
>> iteration of the loop.
>
>
> You can't use forloop and friends in the manner you attempting to use it.
> It's The reason is, headers.0 has no attribute named "forloop"
>
> The best that you could do here, in this situation, is to create a custom
> filter and pass it forloop.counter as variable like so:
> {{ headers.0|forloop.counter }} You will of course have to write that filter
> out first, register it, and install it in the template.
>
> I'm still not sure if this is the right approach. Why not just iterate over
> the list itself, if you want to print the nth item within the list?

That would be really inefficient, as the table can have thousands of
rows, with 30 columns each. I'd have to iterate through the header row
for each column in each row to get the value to put into the href.

> Or,
> structure the list/queryset from the view such that you don't have to do
> such acrobatics.
>
>>  But if I hard code the number (as a test), e.g.:  {{
>> headers.0.2 }} then I do get the value.
>
>
> This works because headers.0 has an attribute that works by way of the
> django dot look up. See Tom Evan's post regarding this.
>
> It seems to me that you have a list of lists (and not a single list). In
> which case, you can just iterate over the first list and iterate over the
> second list. If you need some control flow, just use the standard if / else
> conditions. But, maybe I'm missing something?

Yes, I think you are. I have 2 header rows, and thousands of data
rows. For each column in each data row I have to construct a href. One
of the parameters in the href comes from the first header row. The
header rows get processed first, then the data rows (to build the
table). So by the time I am processing the data I don't have the
header any more. I should probably just do this in javascript.

> Even easier would be to use django's introspect feature and create models
> based on the tables in the DB, query the DB using the models and create
> querysets. Then you can access and display the data in a more
> coherent manner.
>
> see the docs here for
> introspection: https://docs.djangoproject.com/en/dev/howto/legacy-databases/?from=olddocs


That already is the case. I am trying to add functionality to an existing app.

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



Adding link to admin page

2012-03-25 Thread Larry Martell
I have a client that has an app built with django. On every page of
their app is a link to their admin site. They tell me the admin site
is generated entirely by django, and they've never customized it
before. On the very first line of the admin page it says:

Django administration  Welcome, admin. Change password / Log out

They want me to add a link to that line, to the left of "Django
administration" that will take them back to the page they were on when
they clicked on the link to get them to the admin site.

So I have 2 issues here:

1) How do I override that line to add the link? It appears that page
is generated by contrib/admin/templates/admin/base.html, and I tried
to override it by following the directions at
https://docs.djangoproject.com/en/1.2/ref/contrib/admin/#overriding-admin-templates,
but whatever I do seems to have no effect.

2) How can I get the link of the page of the app they came from? It's
not simply just going back one page, as they could have navigated all
over the place of the admin site before clicking the "Back to app"
link.

Thanks!
-larry

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



Re: Adding link to admin page

2012-03-26 Thread Larry Martell
On Mon, Mar 26, 2012 at 4:37 PM, Mike Dewhirst  wrote:
> On 27/03/2012 9:16am, larry.mart...@gmail.com wrote:
>>
>> On Mar 25, 3:29 pm, Larry Martell  wrote:
>>>
>>> I have a client that has an app built with django. On every page of
>>> their app is a link to their admin site. They tell me the admin site
>>> is generated entirely by django, and they've never customized it
>>> before. On the very first line of the admin page it says:
>>>
>>> Django administration          Welcome, admin. Change password / Log out
>>>
>>> They want me to add a link to that line, to the left of "Django
>>> administration" that will take them back to the page they were on when
>>> they clicked on the link to get them to the admin site.
>>>
>>> So I have 2 issues here:
>>>
>>> 1) How do I override that line to add the link? It appears that page
>>> is generated by contrib/admin/templates/admin/base.html, and I tried
>>> to override it by following the directions
>>> athttps://docs.djangoproject.com/en/1.2/ref/contrib/admin/#overriding-a...,
>>> but whatever I do seems to have no effect.
>>>
>>> 2) How can I get the link of the page of the app they came from? It's
>>> not simply just going back one page, as they could have navigated all
>>> over the place of the admin site before clicking the "Back to app"
>>> link.
>>>
>>> Thanks!
>>> -larry
>>
>> Is there anyone that can provide some assistance with overriding
>> base_site.html? I copied django/contrib/admin/templates/admin/
>> base_site.html to my projects's templates/admin dir, but changes to it
>> are not getting picked up. I also tried adding that to TEMPLATE_DIRS
>> (there was nothing in it before). In urlpatterns I have: (r'^admin/',
>> include(admin.site.urls)) - does that need to change?
>
>
> Check https://docs.djangoproject.com/en/1.4/ref/settings/#template-loaders
>
> Basically, django uses the first template it finds so if it finds the "real"
> one in site-packages first, it stops looking. Try reversing the sequence of
> loaders in your settings.py

Thanks. Perhaps that's related to the problem. TEMPLATE_LOADERS has this:

TEMPLATE_LOADERS = (
'appmngr.load_app_template',
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)

Where the first entry is a custom template loader that doesn't appear
to know how to load something from my apps templates/admin dir. Are
the other 2 entries 'standard' loaders that would look for my
base_site.html (since I put full path to it in TEMPLATE_DIRS)?

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



Re: Adding link to admin page

2012-03-26 Thread Larry Martell
On Mon, Mar 26, 2012 at 7:25 PM, Mike Dewhirst  wrote:
> On 27/03/2012 10:16am, Larry Martell wrote:
>>
>> On Mon, Mar 26, 2012 at 4:37 PM, Mike Dewhirst
>>  wrote:
>>>
>>> On 27/03/2012 9:16am, larry.mart...@gmail.com wrote:
>>>>
>>>> On Mar 25, 3:29 pm, Larry Martell    wrote:
>>>>>
>>>>> I have a client that has an app built with django. On every page of
>>>>> their app is a link to their admin site. They tell me the admin site
>>>>> is generated entirely by django, and they've never customized it
>>>>> before. On the very first line of the admin page it says:
>>>>>
>>>>> Django administration          Welcome, admin. Change password / Log
>>>>> out
>>>>>
>>>>> They want me to add a link to that line, to the left of "Django
>>>>> administration" that will take them back to the page they were on when
>>>>> they clicked on the link to get them to the admin site.
>>>>>
>>>>> So I have 2 issues here:
>>>>>
>>>>> 1) How do I override that line to add the link? It appears that page
>>>>> is generated by contrib/admin/templates/admin/base.html, and I tried
>>>>> to override it by following the directions
>>>>>
>>>>> athttps://docs.djangoproject.com/en/1.2/ref/contrib/admin/#overriding-a...,
>>>>> but whatever I do seems to have no effect.
>>>>>
>>>>> 2) How can I get the link of the page of the app they came from? It's
>>>>> not simply just going back one page, as they could have navigated all
>>>>> over the place of the admin site before clicking the "Back to app"
>>>>> link.
>>>>>
>>>>> Thanks!
>>>>> -larry
>>>>
>>>> Is there anyone that can provide some assistance with overriding
>>>> base_site.html? I copied django/contrib/admin/templates/admin/
>>>> base_site.html to my projects's templates/admin dir, but changes to it
>>>> are not getting picked up. I also tried adding that to TEMPLATE_DIRS
>>>> (there was nothing in it before). In urlpatterns I have: (r'^admin/',
>>>> include(admin.site.urls)) - does that need to change?
>>>
>>>
>>> Check
>>> https://docs.djangoproject.com/en/1.4/ref/settings/#template-loaders
>>>
>>> Basically, django uses the first template it finds so if it finds the
>>> "real"
>>> one in site-packages first, it stops looking. Try reversing the sequence
>>> of
>>> loaders in your settings.py
>>
>> Thanks. Perhaps that's related to the problem. TEMPLATE_LOADERS has this:
>>
>> TEMPLATE_LOADERS = (
>>     'appmngr.load_app_template',
>>     'django.template.loaders.filesystem.load_template_source',
>>     'django.template.loaders.app_directories.load_template_source',
>> )
>>
>> Where the first entry is a custom template loader that doesn't appear
>> to know how to load something from my apps templates/admin dir. Are
>> the other 2 entries 'standard' loaders that would look for my
>> base_site.html (since I put full path to it in TEMPLATE_DIRS)?
>>
> Here is mine ...
>
>    'django.template.loaders.filesystem.Loader',
>    'django.template.loaders.app_directories.Loader',
>
> ... it looks like your settings.py is using the template API
> load_template_source() for some reason. If you didn't do that yourself, I'd
> suggest you experiment by putting my two Loaders ahead of your three and see
> what happens.

No, I didn't set any of this up. It's an existing app, and I'm new to
both the job and to django. There's only one other developer working
on the project, and he's part time and doesn't always respond to my
questions.

In any case, I tried that and it had no effect. Thanks for trying.

-larry

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



Re: Adding link to admin page

2012-03-27 Thread Larry Martell
On Mon, Mar 26, 2012 at 9:19 PM, Mike Dewhirst  wrote:
> Larry
>
> Here is a working setup ...
>
> From settings.py
> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
> #
> # if templates are not found here look in app_name/templates
> TEMPLATE_DIRS = (
>    os.path.join(SRC_ROOT, 'templates/').replace('\\','/'),
> )
>
> # List of callables that know how to import templates from various sources.
> TEMPLATE_LOADERS = (
>    # filesystem ahead of app_directories looks in project before django
>    'django.template.loaders.filesystem.Loader',
>    'django.template.loaders.app_directories.Loader',
> )
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>    'django.contrib.auth.context_processors.auth',
>    'django.core.context_processors.debug',
>    'django.core.context_processors.i18n',
>    'django.core.context_processors.media',
>    'django.core.context_processors.static',
>    'django.contrib.messages.context_processors.messages',
> )
> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
> # # #
>
> ... where SRC_ROOT is the directory containing settings.py.
>
> So my templates directory seems much the same as yours like this ...
>
> SRC_ROOT/templates/admin/base_site.html
>
> ... and inside base_site.html I have ...
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> {% extends "admin/base.html" %}
> {# admin/base.html is in site-packages/django/contrib/admin/templates/admin
> #}
> {% load i18n %}
> {% block title %}{{ title }} | {% trans 'Ssds' %}{% endblock %}
> {% block extrastyle %}{% endblock %}
> {% block branding %}
> {% trans 'http://www.myproj.com.au";>MyProj
> Administration' %}
> {% endblock %}
> {% block nav-global %}{% endblock %}
> {% block extrahead %}{% endblock %}
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
> ... and you can see where I tested a link inside {% block branding %} and I
> can confirm it works.
>
> Hth

I found my problem - I was putting the full path to the dir with my
base_site.html in TEMPLATE_DIRS (e.g. SRC_ROOT/templates/admin/). When
I removed the last dir and changed it to SRC_ROOT/templates/ it then
picked up my file.

Thanks very much Mike, I really appreciate all your help.

-larry


> On 27/03/2012 12:46pm, Larry Martell wrote:
>>
>> On Mon, Mar 26, 2012 at 7:25 PM, Mike Dewhirst
>>  wrote:
>>>
>>> On 27/03/2012 10:16am, Larry Martell wrote:
>>>>
>>>> On Mon, Mar 26, 2012 at 4:37 PM, Mike Dewhirst
>>>>  wrote:
>>>>>
>>>>> On 27/03/2012 9:16am, larry.mart...@gmail.com wrote:
>>>>>>
>>>>>> On Mar 25, 3:29 pm, Larry Martell      wrote:
>>>>>>>
>>>>>>> I have a client that has an app built with django. On every page of
>>>>>>> their app is a link to their admin site. They tell me the admin site
>>>>>>> is generated entirely by django, and they've never customized it
>>>>>>> before. On the very first line of the admin page it says:
>>>>>>>
>>>>>>> Django administration          Welcome, admin. Change password / Log
>>>>>>> out
>>>>>>>
>>>>>>> They want me to add a link to that line, to the left of "Django
>>>>>>> administration" that will take them back to the page they were on
>>>>>>> when
>>>>>>> they clicked on the link to get them to the admin site.
>>>>>>>
>>>>>>> So I have 2 issues here:
>>>>>>>
>>>>>>> 1) How do I override that line to add the link? It appears that page
>>>>>>> is generated by contrib/admin/templates/admin/base.html, and I tried
>>>>>>> to override it by following the directions
>>>>>>>
>>>>>>>
>>>>>>> athttps://docs.djangoproject.com/en/1.2/ref/contrib/admin/#overriding-a...,
>>>>>>> but whatever I do seems to have no effect.
>>>>>>>
>>>>>>> 2) How can I get the link of the page of the app they came from? It's
>>>>>>> not simply just going back one page, as they could have navigated all
>>>>>>> over the place of the admin site before clicking the "Back to app"
>>>>>>> link.
>>>>>>

Upgrading django on a mac

2012-04-07 Thread Larry Martell
I'm on a mac, running Mac OS X Version 10.5.8 (Leopard). I was running
django -r 13034 that I got from SVN. I am trying to upgrade to 1.4
from git. After I upgrade, python can no longer find django. Here's
what I did:

$ cd /usr/local/lib/python2.6/dist-packages
$ sudo mv django/ django-13034
$ sudo git clone https://github.com/django/django.git django
$ python
Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named django

If I switch back:

$ sudo mv django django1.4
$ sudo mv django-13034/ django

It again finds it:

$ python
Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> ^D

Anyone know what's wrong?

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



Re: Upgrading django on a mac

2012-04-07 Thread Larry Martell
On Sat, Apr 7, 2012 at 3:46 PM, Jonathan Baker
 wrote:
> I'm guessing that your $PATH is configured to look for django in it's old
> location, and not the new one.

No it's not that (the new location is the same as the old). But I
figured it out - the django python package is apparently a
subdirectory of the git repository. I did this:

mv django django.git
ln -s django.git/django django

And now it's finding it.


>
> On Sat, Apr 7, 2012 at 3:33 PM, Larry Martell 
> wrote:
>>
>> I'm on a mac, running Mac OS X Version 10.5.8 (Leopard). I was running
>> django -r 13034 that I got from SVN. I am trying to upgrade to 1.4
>> from git. After I upgrade, python can no longer find django. Here's
>> what I did:
>>
>> $ cd /usr/local/lib/python2.6/dist-packages
>> $ sudo mv django/ django-13034
>> $ sudo git clone https://github.com/django/django.git django
>> $ python
>> Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
>> [GCC 4.0.1 (Apple Inc. build 5490)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import django
>> Traceback (most recent call last):
>>  File "", line 1, in 
>> ImportError: No module named django
>>
>> If I switch back:
>>
>> $ sudo mv django django1.4
>> $ sudo mv django-13034/ django
>>
>> It again finds it:
>>
>> $ python
>> Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
>> [GCC 4.0.1 (Apple Inc. build 5490)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import django
>> >>> ^D
>>
>> Anyone know what's wrong?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Jonathan D. Baker
> Web Developer
> http://jonathandbaker.com
> 303.257.4144
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Upgrading django on a mac

2012-04-09 Thread Larry Martell
On Mon, Apr 9, 2012 at 4:53 PM, William Deegan  wrote:
> Larry,
>
> Why not use virtualenv? Or buildout?

I am not familiar with either one of those. I use my mac for
development for a specific client. I need my environment to match
their's as much as possible. They had been using -r 13034 from SVN and
they just upgraded to 1.4 from git. So I  wanted to do the same.


> On Apr 7, 2012, at 3:02 PM, Jonathan Baker wrote:
>
> Ah, good to know. Apologies, but I glanced over your original code to
> quickly and thought you renamed the directory. Glad it worked out.
>
> On Sat, Apr 7, 2012 at 3:54 PM, Larry Martell 
> wrote:
>>
>> On Sat, Apr 7, 2012 at 3:46 PM, Jonathan Baker
>>  wrote:
>> > I'm guessing that your $PATH is configured to look for django in it's
>> > old
>> > location, and not the new one.
>>
>> No it's not that (the new location is the same as the old). But I
>> figured it out - the django python package is apparently a
>> subdirectory of the git repository. I did this:
>>
>> mv django django.git
>> ln -s django.git/django django
>>
>> And now it's finding it.
>>
>>
>> >
>> > On Sat, Apr 7, 2012 at 3:33 PM, Larry Martell 
>> > wrote:
>> >>
>> >> I'm on a mac, running Mac OS X Version 10.5.8 (Leopard). I was running
>> >> django -r 13034 that I got from SVN. I am trying to upgrade to 1.4
>> >> from git. After I upgrade, python can no longer find django. Here's
>> >> what I did:
>> >>
>> >> $ cd /usr/local/lib/python2.6/dist-packages
>> >> $ sudo mv django/ django-13034
>> >> $ sudo git clone https://github.com/django/django.git django
>> >> $ python
>> >> Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
>> >> [GCC 4.0.1 (Apple Inc. build 5490)] on darwin
>> >> Type "help", "copyright", "credits" or "license" for more information.
>> >> >>> import django
>> >> Traceback (most recent call last):
>> >>  File "", line 1, in 
>> >> ImportError: No module named django
>> >>
>> >> If I switch back:
>> >>
>> >> $ sudo mv django django1.4
>> >> $ sudo mv django-13034/ django
>> >>
>> >> It again finds it:
>> >>
>> >> $ python
>> >> Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
>> >> [GCC 4.0.1 (Apple Inc. build 5490)] on darwin
>> >> Type "help", "copyright", "credits" or "license" for more information.
>> >> >>> import django
>> >> >>> ^D
>> >>
>> >> Anyone know what's wrong?
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> >
>> >
>> > --
>> > Jonathan D. Baker
>> > Web Developer
>> > http://jonathandbaker.com
>> > 303.257.4144
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Jonathan D. Baker
> Web Developer
> http://jonathandbaker.com
> 303.257.4144
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



executing raw sql

2012-04-30 Thread Larry Martell
I'm trying to execute some raw sql. I found some code that did this:

from django.db import connection
cursor = connection.cursor()
cursor.execute(sql)
data = cursor.fetchall()

But the cursor.execute(sql) is blowing up with:

'Cursor' object has no attribute '_last_executed'

What is the best or proper way for me to execute my raw sql?

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



Re: executing raw sql

2012-04-30 Thread Larry Martell
On Mon, Apr 30, 2012 at 12:46 PM, Larry Martell  wrote:
> I'm trying to execute some raw sql. I found some code that did this:
>
> from django.db import connection
> cursor = connection.cursor()
> cursor.execute(sql)
> data = cursor.fetchall()
>
> But the cursor.execute(sql) is blowing up with:
>
> 'Cursor' object has no attribute '_last_executed'
>
> What is the best or proper way for me to execute my raw sql?

I traced this with the debugger,  and it's blowing up in
django/db/backends/mysql/base.py in this:

def last_executed_query(self, cursor, sql, params):
# With MySQLdb, cursor objects have an (undocumented) "_last_executed"
# attribute where the exact query sent to the database is saved.
# See MySQLdb/cursors.py in the source distribution.
return cursor._last_executed

Could this have something to do with the version of django and/or mysql?

I'm running django 1.5 and MySQL 5.5.19, and MySQLdb 1.2.3. I just
tried this and that does not exist on my system:

$ python
Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> conn = MySQLdb.connect(host, user, passwd, db)
>>> cursor = conn.cursor()
>>> print cursor._last_executed
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Cursor' object has no attribute '_last_executed'
>>> print cursor.__dict__
{'_result': None, 'description': None, 'rownumber': None, 'messages':
[], '_executed': None, 'errorhandler': >, 'rowcount': -1, 'connection': , 'description_flags': None,
'arraysize': 1, '_info': None, 'lastrowid': None, '_warnings': 0}

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



Re: executing raw sql

2012-04-30 Thread Larry Martell
On Mon, Apr 30, 2012 at 2:32 PM, Larry Martell  wrote:
> On Mon, Apr 30, 2012 at 12:46 PM, Larry Martell  
> wrote:
>> I'm trying to execute some raw sql. I found some code that did this:
>>
>> from django.db import connection
>> cursor = connection.cursor()
>> cursor.execute(sql)
>> data = cursor.fetchall()
>>
>> But the cursor.execute(sql) is blowing up with:
>>
>> 'Cursor' object has no attribute '_last_executed'
>>
>> What is the best or proper way for me to execute my raw sql?
>
> I traced this with the debugger,  and it's blowing up in
> django/db/backends/mysql/base.py in this:
>
>    def last_executed_query(self, cursor, sql, params):
>        # With MySQLdb, cursor objects have an (undocumented) "_last_executed"
>        # attribute where the exact query sent to the database is saved.
>        # See MySQLdb/cursors.py in the source distribution.
>        return cursor._last_executed
>
> Could this have something to do with the version of django and/or mysql?
>
> I'm running django 1.5 and MySQL 5.5.19, and MySQLdb 1.2.3. I just
> tried this and that does not exist on my system:
>
> $ python
> Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
> [GCC 4.0.1 (Apple Inc. build 5490)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import MySQLdb
>>>> conn = MySQLdb.connect(host, user, passwd, db)
>>>> cursor = conn.cursor()
>>>> print cursor._last_executed
> Traceback (most recent call last):
>  File "", line 1, in 
> AttributeError: 'Cursor' object has no attribute '_last_executed'
>>>> print cursor.__dict__
> {'_result': None, 'description': None, 'rownumber': None, 'messages':
> [], '_executed': None, 'errorhandler':  Connection.defaulterrorhandler of <_mysql.connection open to
> 'localhost' at 889810>>, 'rowcount': -1, 'connection':  0x62f630 to Connection at 0x889810>, 'description_flags': None,
> 'arraysize': 1, '_info': None, 'lastrowid': None, '_warnings': 0}

I've found that cursor._last_executed doesn't exist until a query has
been executed (it's not initialized to None)

But in django I am doing this:

from django.db import connection
cursor = connection.cursor()
cursor.execute(sql)

and it's getting the error, so that would mean that the sql isn't
getting executed for some reason. I'll have to investigate that
avenue.

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



Re: executing raw sql

2012-04-30 Thread Larry Martell
On Mon, Apr 30, 2012 at 6:26 PM, Dennis Lee Bieber
 wrote:
> On Mon, 30 Apr 2012 15:29:08 -0600, Larry Martell
>  declaimed the following in
> gmane.comp.python.django.user:
>
>>
>> But in django I am doing this:
>>
>> from django.db import connection
>> cursor = connection.cursor()
>> cursor.execute(sql)
>>
>> and it's getting the error, so that would mean that the sql isn't
>> getting executed for some reason. I'll have to investigate that
>> avenue.
>
>        You still haven't show us what "sql" contains... Given your three
> statements I'd expect to get an error message since "sql" itself is
> undefined.

I figured out the problem. I had %s in my sql, and they was getting
treated as a format specifier. When I built the sql I did put in '%%',
but I had to put in 4 '' for it to work.

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



Getting checkbox value in controller

2012-05-01 Thread Larry Martell
I have a template that creates a text entry field and a checkbox. When
the checkbox is unchecked, the text field is disabled and cleared,
when it's checked, it's enabled, and the user may or may not have
typed in it. In my controller I need to distinguish between the 2
cases when the checkbox is unchecked, and then the checkbox is checked
but the text field is blank. I can get the value of the text field,
but not of the checkbox. Is there some way to do this? I've googled
this, and this has been asked a few times on stackoverflow, but none
of the solutions seem to work for me.

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



Re: Git migration

2012-05-03 Thread Larry Martell
On Thu, May 3, 2012 at 9:42 PM, Stanwin Siow  wrote:
> Hello there,
>
> Just wanted to enquire about a project that i have been working on.
>
> It was previously hosted on an svn repository however my supervisor then
> decided to migrate it to GIT.
>
> my question here would be do i need to reinstall the external modules that i
> used in my django project like django-registration and django-paypal in GIT?
>
> Or would the functionalities be the same?
>
> I'm asking this is because i discovered a break in the program after the
> migration.
>
> Any help or advice is appreciated.
>
> Thanks in advance!

This may or may not be applicable to your situation. We had be using
django from SVN with  -r 13034. When we switched to django from git,
version 1.2 worked, but 1.4 did not. We had to make quite a few
changes to get 1. 4 to work. In the end it wasn't that bad, but it
wasn't seamless.

-larry

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



1.4 on git

2012-05-05 Thread Larry Martell
Last month I set up a system and when I cloned django from git I got
version 1.4. Now I an setting up another system, and when I clone
django from git I get 1.5, and my app is failing. How I can get 1.4? I
see a django-nonrel / django-1.4 but it says "Work in progress 1.4
port, DON'T USE"

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



Re: 1.4 on git

2012-05-06 Thread Larry Martell
On Sat, May 5, 2012 at 9:30 PM, Rivsen  wrote:
> Simply, you can see what git index in your first system, run "git log" and
> remember the first row of commit( need only remember the first six or eight
> like this 'commit 42198ad13560c46070223e095f787dff5bd8a918'  ).
>
> Then checkout this commit in your second system, run 'git checkout 42198ad1'
> and you will get the same code status between two system.
>
> ps. 42198ad1 is a example, not real

On system 1 (the one with 1.4):

# git log
commit 6fbf282ac2b467bd71f807cad45e12a86aa371bd
Author: claudep 
Date:   Fri Mar 23 19:44:52 2012 +

On system 2 (which has 1.5 installed):

# git checkout 6fbf282
error: pathspec '6fbf282' did not match any file(s) known to git

Also tried it with the entire commit string:

# git checkout 6fbf282ac2b467bd71f807cad45e12a86aa371bd
fatal: reference is not a tree: 6fbf282ac2b467bd71f807cad45e12a86aa371bd


> 2012/5/6 Ramiro Morales 
>>
>> On Sat, May 5, 2012 at 8:42 PM, Larry Martell 
>> wrote:
>> > Last month I set up a system and when I cloned django from git I got
>> > version 1.4. Now I an setting up another system, and when I clone
>> > django from git I get 1.5, and my app is failing. How I can get 1.4? I
>> > see a django-nonrel / django-1.4 but it says "Work in progress 1.4
>> > port, DON'T USE"
>>
>> The github.com/django/django repository is now the official Django
>> development repository, we migrated from SVN a week ago.
>>
>> Problem is that we've only migrated the development mainline. We are
>> working to also migrate the release tags (1.4, 1.3, ...) and the
>> post-release maintenance branches. The plan is to have it ready in a
>> couple of days.
>>
>> The repository that previously was at github.com/django/django is called
>> now github.com/django/django-old and it has the 1.4 tag. You can clone
>> from it if you can't wait.
>>
>> Regards,
>>
>> --
>> Ramiro Morales
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: 1.4 on git

2012-05-06 Thread Larry Martell
On Sat, May 5, 2012 at 7:06 PM, Ramiro Morales  wrote:
> On Sat, May 5, 2012 at 8:42 PM, Larry Martell  wrote:
>> Last month I set up a system and when I cloned django from git I got
>> version 1.4. Now I an setting up another system, and when I clone
>> django from git I get 1.5, and my app is failing. How I can get 1.4? I
>> see a django-nonrel / django-1.4 but it says "Work in progress 1.4
>> port, DON'T USE"
>
> The github.com/django/django repository is now the official Django
> development repository, we migrated from SVN a week ago.
>
> Problem is that we've only migrated the development mainline. We are
> working to also migrate the release tags (1.4, 1.3, ...) and the
> post-release maintenance branches. The plan is to have it ready in a
> couple of days.
>
> The repository that previously was at github.com/django/django is called
> now github.com/django/django-old and it has the 1.4 tag. You can clone
> from it if you can't wait.

i cloned from django-old, and I get 1.5 alpha (which does not work for me):

>>> django.VERSION
(1, 5, 0, 'alpha', 0)

My working system has:

>>> django.VERSION
(1, 4, 0, 'final', 0)

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



Re: 1.4 on git

2012-05-06 Thread Larry Martell
On Sun, May 6, 2012 at 12:54 PM, Ramiro Morales  wrote:
> You will need to read the Git documentation because we are in Git territory 
> now.
>
> )ou got the latest development code by default but remember that when
> you clone you get (most of) the development history and it is
> available locally.
>
> You need to get a checkout of the commit pointed to by the '1.4' tag.
> IIRC you can achieve that with::
>
>  git checkout 1.4

Ok, Thanks. I'll try that next time. I ended up just scp-ing the
django dir from my working system.


> On 5/6/12, Larry Martell  wrote:
>> On Sat, May 5, 2012 at 7:06 PM, Ramiro Morales  wrote:
>>> On Sat, May 5, 2012 at 8:42 PM, Larry Martell 
>>> wrote:
>>>> Last month I set up a system and when I cloned django from git I got
>>>> version 1.4. Now I an setting up another system, and when I clone
>>>> django from git I get 1.5, and my app is failing. How I can get 1.4? I
>>>> see a django-nonrel / django-1.4 but it says "Work in progress 1.4
>>>> port, DON'T USE"
>>>
>>> The github.com/django/django repository is now the official Django
>>> development repository, we migrated from SVN a week ago.
>>>
>>> Problem is that we've only migrated the development mainline. We are
>>> working to also migrate the release tags (1.4, 1.3, ...) and the
>>> post-release maintenance branches. The plan is to have it ready in a
>>> couple of days.
>>>
>>> The repository that previously was at github.com/django/django is called
>>> now github.com/django/django-old and it has the 1.4 tag. You can clone
>>> from it if you can't wait.
>>
>> i cloned from django-old, and I get 1.5 alpha (which does not work for me):
>>
>>>>> django.VERSION
>> (1, 5, 0, 'alpha', 0)
>>
>> My working system has:
>>
>>>>> django.VERSION
>> (1, 4, 0, 'final', 0)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
> --
> Sent from my mobile device
>
> Ramiro Morales
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



derived fields and getattr

2012-05-23 Thread Larry Martell
I was asked to make a mod to a large django app that I didn't write.
They wanted me to add a derived field to a query, e.g. select
col1-col2 from table ...

I did that and it works, but in some other part of the code it calls
getattr(object, field) and when field == col1-col2 it blows up
with"object has no attribute 'col1-col2'"

Is there some way I can make getattr work for the derived field?

TIA!
-larry

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



Re: derived fields and getattr

2012-05-24 Thread Larry Martell
On Thu, May 24, 2012 at 2:27 AM, bruno desthuilliers
 wrote:
> On May 23, 10:39 pm, Larry Martell  wrote:
>> I was asked to make a mod to a large django app that I didn't write.
>> They wanted me to add a derived field to a query, e.g. select
>> col1-col2 from table ...
>
> I assume you're talking about using queryset.extra ?

No I build the query myself.

>> I did that and it works, but in some other part of the code it calls
>> getattr(object, field) and when field == col1-col2 it blows up
>> with"object has no attribute 'col1-col2'"
>
> Are you sure the instance on which it failed was retrieved using the
> appropriate query ?

That could be the case. What happens is the data set returned creates
a chart. The points on the chart are clickable links that drill down
and generate a more detailed chart. It's in that secondary chart that
the error occurs. But OTOH, getattr does retrieve the attributes of
the actual columns from the initial query, so it much be the same
instance.

> Can you post the relevant parts of your code ? (here or via dpaste ?)

Unfortunately, no. It's a lot of code with a ton of inherited classes.

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



Re: derived fields and getattr

2012-05-24 Thread Larry Martell
On Thu, May 24, 2012 at 9:29 AM, bruno desthuilliers
 wrote:
> On May 24, 3:44 pm, Larry Martell  wrote:
>> On Thu, May 24, 2012 at 2:27 AM, bruno desthuilliers
>>
>>  wrote:
>> > On May 23, 10:39 pm, Larry Martell  wrote:
>> >> I was asked to make a mod to a large django app that I didn't write.
>> >> They wanted me to add a derived field to a query, e.g. select
>> >> col1-col2 from table ...
>>
>> > I assume you're talking about using queryset.extra ?
>>
>> No I build the query myself.
>
> Are you using the ORM at all ?

Oh yes. Just this particular query is complicated and more easily
directly created.

>> >> I did that and it works, but in some other part of the code it calls
>> >> getattr(object, field) and when field == col1-col2 it blows up
>> >> with"object has no attribute 'col1-col2'"
>>
>> > Are you sure the instance on which it failed was retrieved using the
>> > appropriate query ?
>>
>> That could be the case. What happens is the data set returned creates
>> a chart. The points on the chart are clickable links that drill down
>> and generate a more detailed chart. It's in that secondary chart that
>> the error occurs. But OTOH, getattr does retrieve the attributes of
>> the actual columns from the initial query, so it much be the same
>> instance.
>
> Except that, very obviously, it isn't.

Correct. I dug into it more, and it's completely different query and context.

>> > Can you post the relevant parts of your code ? (here or via dpaste ?)
>>
>> Unfortunately, no. It's a lot of code with a ton of inherited classes.
>
> Uhu. Real life vs example code, as usual. So all you can do is trace
> your code using the logging module (or print statements) and the
> debugger.

I got this to work by adding the derived field to the drill down query
with queryset.extra, and then it was available with getattr. The only
issue I had was they wanted the derived field displayed with a name
(not col1-col2). In the first query I was able to easily do this. But
in the drill down query I had to do:

extra(select={self.field_name : self.field_name})

I couldn't use the display name or the getattr failed. But then it was
displaying with 'col1-col2'. So then I had to explicitly test for it
and set the display name:

if field_name == 'col1-col2': display_name = 'Delta'
else: display_name = field_name

Which will quickly get very ugly when they want more derived fields
added (which I know they will).

But I'll deal with that when the time comes.

Thanks for your help.

-larry

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



Re: derived fields and getattr

2012-05-25 Thread Larry Martell
On Fri, May 25, 2012 at 2:24 AM, bruno desthuilliers
 wrote:
>
> On May 24, 11:50 pm, Larry Martell  wrote:
>> I got this to work by adding the derived field to the drill down query
>> with queryset.extra, and then it was available with getattr. The only
>> issue I had was they wanted the derived field displayed with a name
>> (not col1-col2). In the first query I was able to easily do this. But
>> in the drill down query I had to do:
>>
>> extra(select={self.field_name : self.field_name})
>
> The QuerySet.extra() "select" params is a mapping of
> "attribute_name":"SQL clause", so you could just write:
>
>  extra(select={"Delta" : "col1 - col2"})
>
> of for somethin more generic:
>
>  extra(select={self.display_name: self.sql_clause})
>
> or if more than one extra field involved:
>
>
>  extra(select=self.extra_fields)
>
>
> where extra_fields = {"displayname1":"sql clause 1", "displayname2",
> "sql clause 2"}

Yes, I realize that.

>> I couldn't use the display name or the getattr failed.
>
> ???

When I first did:

extra(select={"Delta" : self.field_name})

Then getattr(self.field_name) failed with "object has no attribute
'col1-col2'". When I changed it to:

extra(select={self.field_name : self.field_name})

Then the getattr worked.

>> But then it was
>> displaying with 'col1-col2'. So then I had to explicitly test for it
>> and set the display name:
>>
>>             if field_name == 'col1-col2': display_name = 'Delta'
>>             else: display_name = field_name
>
>
>
> If you need display names that you don't want to use as field names
> (or if you want translatable display names etc), you can maintain a
> mapping of fieldname:display_name and then just do a dict lookup, ie:
>
>    display_name = display_names.get(field_name, field_name)
>
>
> Can't really help more here without seeing the actual code, but from
> years of experience with Python, I really doubt you have to write
> something as ugly as the above snippet ;)

Yes, I've been writing python for years too, and I realize I can put
in a dict. But it still has to be in 2 places - the code that
implements the first query that generates the chart, and the code that
does the drill down query when they click on a point. The drill down
code does not get passed the display name 'Delta' just the field as
'col1-col2'

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



Re: derived fields and getattr

2012-05-25 Thread Larry Martell
On Fri, May 25, 2012 at 6:42 AM, bruno desthuilliers
 wrote:
> On May 25, 2:32 pm, Larry Martell  wrote:
>> On Fri, May 25, 2012 at 2:24 AM, bruno desthuilliers
>>
>> >> I couldn't use the display name or the getattr failed.
>>
>> > ???
>>
>> When I first did:
>>
>> extra(select={"Delta" : self.field_name})
>>
>> Then getattr(self.field_name) failed with "object has no attribute
>> 'col1-col2'".
>
> Obviously - the attribute name is then "Delta", not self.field_name
> (which is rather a misleading name since it's really an sql clause,
> not a field name).

Like I said in my original post, I didn't write this app. I'm new at
this client, and I'm just tweaking it. It is a field on the screen
that the user can select (from a list of data base columns), and
that's how it get passed into the python code (as field_name).

>> Yes, I've been writing python for years too,
>
> Sorry, that's not always the case for peoples posting here.

NP. There's always more to learn.

>> and I realize I can put
>> in a dict. But it still has to be in 2 places - the code that
>> implements the first query that generates the chart, and the code that
>> does the drill down query when they click on a point.
>
> You can eventually define the dict in one place and use it from both,
> but once again it's hard to say without seeing the real code :-|

The way this app is structured, they are 2 different classes. I could
put the mapping in a database table, or create a method in the
database object's class (i.e. the table that both use) that has the
dict and provides the mapping. Yeah, that's the ticket! Thanks for
getting my brain going.

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



admin hangs deleting multiple users

2012-06-08 Thread Larry Martell
In my admin site, if I select multiple users, then select 'Delete
selected users' and click 'Go', it hangs. I can delete one user at a
time with no issues. There is nothing logged anywhere - not in any
apache log nor in the mysql log. Where can I look for more info to
debug this?

-larry

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



dropping ForeignKey not reflected in admin

2012-06-15 Thread Larry Martell
I have a table that had a ForeignKey reference. In the admin screen
for adding to this table there was a dropdown for that column. I want
to get rid of that ForeignKey. I changed models.py and removed the
ForeignKey column, bounced apache and altered the table and removed
that column. In the admin screen it still has the dropdown for that
column. If I try and add a row it silently fails. If I try and display
the rows from the table it says there are none, even thought there
are. I even tried dropping the table and running syncdb. It created
the table without the ForeignKey column, but yet the admin screen
still has the dropdown for that column. What am I doing wrong here?

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



Re: dropping ForeignKey not reflected in admin

2012-06-15 Thread Larry Martell
On Fri, Jun 15, 2012 at 1:13 PM, vikalp sahni  wrote:
> strange, I hope you are checking the right model and right admin.
>
> Can you check you have traces for that field on your admin.py

Turns out there are 2 tables with very similar names, and I was
looking at the admin for the wrong table.


> On Fri, Jun 15, 2012 at 11:37 PM, Larry Martell 
> wrote:
>>
>> I have a table that had a ForeignKey reference. In the admin screen
>> for adding to this table there was a dropdown for that column. I want
>> to get rid of that ForeignKey. I changed models.py and removed the
>> ForeignKey column, bounced apache and altered the table and removed
>> that column. In the admin screen it still has the dropdown for that
>> column. If I try and add a row it silently fails. If I try and display
>> the rows from the table it says there are none, even thought there
>> are. I even tried dropping the table and running syncdb. It created
>> the table without the ForeignKey column, but yet the admin screen
>> still has the dropdown for that column. What am I doing wrong here?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Render time

2012-06-25 Thread Larry Martell
This is not strictly a django question, but I'm hoping someone here
has solved this and can help me. I have a client that has a django app
that collects a bunch of server side statistics on the users
activities - e.g. what reports they run, the number of rows returned,
how long the query took, etc. Now they want me to add to that how long
the browser takes to render the page after it gets the data. So I have
3 issues here:

1) How  can I even calculate that?
2) How I can return it back to the server?
3) Since the database table is updated with the other statistics
before the data is sent to the browser, assuming I could calculate the
render time and send it back, how could I find the row and update with
that info?

If anyone has already done something like this, or anyone has any
advise on how I could do it (especially item #1), I'd really
appreciate them sharing it with me.

TIA!
-larry

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



Re: Render time

2012-06-25 Thread Larry Martell
On Mon, Jun 25, 2012 at 5:56 AM, bruno desthuilliers
 wrote:
> On Monday, June 25, 2012 1:34:08 PM UTC+2, larry@gmail.com wrote:
>>
>>  Now they want me to add to that how long
>> the browser takes to render the page
>
>
> How would server code ever know this ?

My assumption is that it would be collected or calculated on the
client side and sent back to the server. But I have no clue how that
could be done (or even if it could be done).

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



Using now in an if

2012-06-25 Thread Larry Martell
I'm trying to use now in an if like this:

{% if value|date:"Ymd" ==  now "Ymd" %}

This is failing with: 'Unused '"Ymd"' at end of if expression.'

If I quote it:

{% if value|date:"Ymd" ==  'now "Ymd"' %}

I don't get the syntax error, but the if does not evaluate to true
when the dates match.

I need to see if the date in {{ value }} is `today' - how can I do that?

-larry

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



Re: Using now in an if

2012-06-25 Thread Larry Martell
On Mon, Jun 25, 2012 at 6:26 AM, Daniel Roseman  wrote:
>
> On Monday, 25 June 2012 13:05:24 UTC+1, larry@gmail.com wrote:
>>
>> I'm trying to use now in an if like this:
>>
>> {% if value|date:"Ymd" ==  now "Ymd" %}
>>
>> This is failing with: 'Unused '"Ymd"' at end of if expression.'
>>
>> If I quote it:
>>
>> {% if value|date:"Ymd" ==  'now "Ymd"' %}
>>
>> I don't get the syntax error, but the if does not evaluate to true
>> when the dates match.
>>
>> I need to see if the date in {{ value }} is `today' - how can I do that?
>>
>> -larry
>
>
> Write a custom "is_today" filter. Two lines of code.

Thanks for the reply. I ended up doing what I needed in python on the sever.

So I guess there is no way to use now in an if?

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



Re: Render time

2012-06-26 Thread Larry Martell
On Mon, Jun 25, 2012 at 6:56 AM, Melvyn Sopacua  wrote:
> On 25-6-2012 14:00, Larry Martell wrote:
>> On Mon, Jun 25, 2012 at 5:56 AM, bruno desthuilliers
>>  wrote:
>>> On Monday, June 25, 2012 1:34:08 PM UTC+2, larry@gmail.com wrote:
>>>>
>>>>  Now they want me to add to that how long
>>>> the browser takes to render the page
>>>
>>>
>>> How would server code ever know this ?
>>
>> My assumption is that it would be collected or calculated on the
>> client side and sent back to the server. But I have no clue how that
>> could be done (or even if it could be done).
>>
>
> The issue is what your client's definitions are.
> A browser starts rendering as soon it receives data. Is that your
> starting point?
> If your definition is that "as soon as all data is received" and until
> browser has fully displayed things, this is a bit more difficult. First,
> there's no event for this. The closest approximation is
> "DOMContentLoaded", which is used by JQuery's documentready. The
> difference between "all data received" and "DOM parsing done" is the cpu
> cycles it takes to parse the main DOM tree. Since your clients already
> are asking for fractions of seconds in the common case, this is significant.
>
> Secondly, window.onload is your stoptime event, but this doesn't fire
> until /everything/ is loaded. This means any networking problems with
> content have to time out, but for the end user, everything displays
> correctly. In fact, a user can click on to the next page before this
> even fires.
>
> So, reliably, you can't really do this and your best approximation is
> the event firing times for window.onload minus DOMContentLoaded, or
> JQuery's $(document).ready [1].
> You can embed the row id for your statistics as a JavaScript variable in
> your template.
> And finally, you'd send the calculation back using Ajax requests,
> something you'll find plenty of howto's for on the web.
>
> [1]
> <http://stackoverflow.com/questions/799981/document-ready-equivalent-without-jquery>

Thanks for the reply Melvyn. I'll be investigating these solutions.

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



Re: Render time

2012-06-26 Thread Larry Martell
On Mon, Jun 25, 2012 at 9:04 PM, Andy McKay  wrote:
>> Now they want me to add to that how long
>> the browser takes to render the page after it gets the data.
>
> You can use the navigation timing API:
>
> https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
>
> We use this in conjuction with graphite and django-statsd to produce
> graphs of hour long our sites takes to render.
>
> http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/
>
> And some more links:
>
> https://github.com/andymckay/django-statsd
> http://django-statsd.readthedocs.org/en/latest/#front-end-timing-integration
> http://graphite.wikidot.com/

Great! Thanks very much Andy. I'll look into these and let everyone
know what I ultimately do.

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



javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Larry Martell
I have a django template that has some javascript/jQuery code in it
that defines some keyup event handers. If a user goes to the URL
directly the javascript is executed, and the event handers all work
fine. There is also a field that they can type in that triggers the
same URL request to be sent via ajax. When they do this, it seems that
the html is rendered, but the javascript is not executed. I discovered
this by noticing that the page was rendered, but none of the
javascript event handers were being called. I proved this by adding:



alert('here we are');


to the template, and the alert doesn't show when the request comes
from ajax. But if I go to the URL directly it does.

Is this a known issue? Is there some way I can get my javascript code
to run to install my event handlers when the request comes from ajax?

TIA!
-larry

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



Re: Render time

2012-06-29 Thread Larry Martell
On Mon, Jun 25, 2012 at 9:04 PM, Andy McKay  wrote:
>> Now they want me to add to that how long
>> the browser takes to render the page after it gets the data.
>
> You can use the navigation timing API:
>
> https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
>
> We use this in conjuction with graphite and django-statsd to produce
> graphs of hour long our sites takes to render.
>
> http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/
>
> And some more links:
>
> https://github.com/andymckay/django-statsd
> http://django-statsd.readthedocs.org/en/latest/#front-end-timing-integration
> http://graphite.wikidot.com/

Thanks Andy. Super cool, and pretty much just what I was looking for.
Seems to work fine in FF and Chrome, but in Safari I don't seem to
have access to the performance.timing data. Should that be there or do
I have do something to load or enable it?

-larry

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Larry Martell
On Fri, Jun 29, 2012 at 4:51 PM, Jani Tiainen  wrote:
> It's known limitation of your ajax request and has nothing to do with Django
> nor templates. Or well it might do.

Not really sure what you mean here. Are you saying this is a known
problem, and I should not expect it to work?

> Most of the javascript frameworks can extract script and inject it correctly
> to current DOM. Since you mention jquery I guess that you're using that for
> ajax queries so make sure that your $.ajax() has dataType attribute to set
> as 'html'. It should (according to docs) parse script parts correctly.

Yes, it does. The request is sent like this:

$.ajax({
url: url,
data: $form.serialize(),
dataType: 'html',
success: function (html, textStatus) {
$report
.html($('#report', html).html())
.css({
opacity: 1.0
});
style_preview_table();
}

And I have verified that all the non javascript portions of the
template are executed, but none of the javascript ones are.



>
> On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell 
> wrote:
>>
>> I have a django template that has some javascript/jQuery code in it
>> that defines some keyup event handers. If a user goes to the URL
>> directly the javascript is executed, and the event handers all work
>> fine. There is also a field that they can type in that triggers the
>> same URL request to be sent via ajax. When they do this, it seems that
>> the html is rendered, but the javascript is not executed. I discovered
>> this by noticing that the page was rendered, but none of the
>> javascript event handers were being called. I proved this by adding:
>>
>>
>>    
>>    alert('here we are');
>>    
>>
>> to the template, and the alert doesn't show when the request comes
>> from ajax. But if I go to the URL directly it does.
>>
>> Is this a known issue? Is there some way I can get my javascript code
>> to run to install my event handlers when the request comes from ajax?
>>
>> TIA!
>> -larry
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Larry Martell
On Fri, Jun 29, 2012 at 4:54 PM, Jani Tiainen  wrote:
> I meant that if for some reason Django sends incorrect content type from a
> view or something like that your javascript framework might guess
> incorrectly your ajax request content type and not parse script tags.

Is there a way I can test to see if this is occurring?


>
>
> On Sat, Jun 30, 2012 at 1:51 AM, Jani Tiainen  wrote:
>>
>> It's known limitation of your ajax request and has nothing to do with
>> Django nor templates. Or well it might do.
>>
>> Most of the javascript frameworks can extract script and inject it
>> correctly to current DOM. Since you mention jquery I guess that you're using
>> that for ajax queries so make sure that your $.ajax() has dataType attribute
>> to set as 'html'. It should (according to docs) parse script parts
>> correctly.
>>
>>
>> On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell 
>> wrote:
>>>
>>> I have a django template that has some javascript/jQuery code in it
>>> that defines some keyup event handers. If a user goes to the URL
>>> directly the javascript is executed, and the event handers all work
>>> fine. There is also a field that they can type in that triggers the
>>> same URL request to be sent via ajax. When they do this, it seems that
>>> the html is rendered, but the javascript is not executed. I discovered
>>> this by noticing that the page was rendered, but none of the
>>> javascript event handers were being called. I proved this by adding:
>>>
>>>
>>>    
>>>    alert('here we are');
>>>    
>>>
>>> to the template, and the alert doesn't show when the request comes
>>> from ajax. But if I go to the URL directly it does.
>>>
>>> Is this a known issue? Is there some way I can get my javascript code
>>> to run to install my event handlers when the request comes from ajax?
>>>
>>> TIA!
>>> -larry
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>>
>> --
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-30 Thread Larry Martell
On Sat, Jun 30, 2012 at 11:54 AM, Psamathos  wrote:
> If your web server is in fact serving the content with the incorrect
> Content-Type header (You can verify this by inspecting the response in the
> Net tab of Firebug or Chrome) jQuery can convert the response regardless of
> the content-type if you specify a two space-separated values in your
> dataType. Try dataType: "text html" in your $.ajax function.

I've been poking around with the debugger. For reference, here's the code:

var $form = $('form.roll');
url = $form.attr('action');

var $report = $('#report');

$.ajax({
url: url,
data: $form.serialize(),
dataType: 'html',
success: function (html, textStatus) {
$report
.html($('#report', html).html())
.css({
opacity: 1.0
});
style_preview_table();
}


The html variable passed into the success function contains the entire
page, including the javascript. I tried doing:

$report.html(html)

But the parts of the page that were not the results (i.e. #report) all
were duplicated (the page was displayed within the page). But even
there, the javascript wasn't included in the page, even though is was
in the html variable.

$('#report', html).html() contained just the html, without the
javascript. What I need is some way to get both the javascript and the
html of $('#report') and then pass that into $report.html(). Are there
javascript or jQuery methods that will allow me to do that?

Alternatively I could extract the javascript from the html variable
passed into the success function. But then how would I make that part
of  $report.html()?

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



Re: javascript in django template not executed when request is sent via ajax

2012-07-01 Thread Larry Martell
On Fri, Jun 29, 2012 at 2:45 PM, Larry Martell  wrote:
> I have a django template that has some javascript/jQuery code in it
> that defines some keyup event handers. If a user goes to the URL
> directly the javascript is executed, and the event handers all work
> fine. There is also a field that they can type in that triggers the
> same URL request to be sent via ajax. When they do this, it seems that
> the html is rendered, but the javascript is not executed. I discovered
> this by noticing that the page was rendered, but none of the
> javascript event handers were being called. I proved this by adding:
>
>
>     
>     alert('here we are');
>     
>
> to the template, and the alert doesn't show when the request comes
> from ajax. But if I go to the URL directly it does.
>
> Is this a known issue? Is there some way I can get my javascript code
> to run to install my event handlers when the request comes from ajax?

Just in case anyone is interested, I finally got this working.

I added a class to the javascript code, e.g.:


Re: Fw: PLEASE HELP

2012-07-02 Thread Larry Martell
On Mon, Jul 2, 2012 at 11:45 AM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Emily,
>
> Please refrain from sending chain/spam emails to the list, this isn't
> acceptable.
>
> Also - on a site note, you really shouldn't be giving out your entire
> mailbox by cc'ing everyone, this isn't very good practice at all.

I have a feeling that was caused by a virus or having her email hacked.

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



Controlling access

2012-07-03 Thread Larry Martell
I have a client that asked me to add some new functionality to their
app, and then they said 'This new functionality should be controlled
in Django admin so that only the admin user can see it.' Is there a
way to control this in Django admin? I know in the python code i can
check to see if they're the admin user or not and allow or disallow
access, but what they're saying makes it seem I can just do it admin.

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



Re: Controlling access

2012-07-03 Thread Larry Martell
On Tue, Jul 3, 2012 at 11:49 AM, Robert Steckroth
 wrote:
> Yes, I have seen some very impressive admin media controls for websites with
> larger projects
> having wordpress like functionality. However, there are not easy or cheap to
> make.
> I recommend checking open-souce projects for a good start.

But there's nothing inherently built into Django admin that supports
this, correct?

>
>
> On Tue, Jul 3, 2012 at 1:39 PM, Larry Martell 
> wrote:
>>
>> I have a client that asked me to add some new functionality to their
>> app, and then they said 'This new functionality should be controlled
>> in Django admin so that only the admin user can see it.' Is there a
>> way to control this in Django admin? I know in the python code i can
>> check to see if they're the admin user or not and allow or disallow
>> access, but what they're saying makes it seem I can just do it admin.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Bust0ut, Surgemcgee: Systems Engineer ---
> PBDefence.com
> BudTVNetwork.com
> RadioWeedShow.com
> "Bringing entertainment to Unix"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Controlling access

2012-07-03 Thread Larry Martell
On Tue, Jul 3, 2012 at 11:55 AM, Robert Steckroth
 wrote:
> Django is a very open-ended framework. The admin system is built around
> developer/user customization.


Yes, I realize that. But I was asking if there was something that just
worked (i.e. like foreign key references do). I don't think so, but my
client seems to.


>
>
>
> On Tue, Jul 3, 2012 at 1:51 PM, Larry Martell 
> wrote:
>>
>> On Tue, Jul 3, 2012 at 11:49 AM, Robert Steckroth
>>  wrote:
>> > Yes, I have seen some very impressive admin media controls for websites
>> > with
>> > larger projects
>> > having wordpress like functionality. However, there are not easy
>> > or cheap to
>> > make.
>> > I recommend checking open-souce projects for a good start.
>>
>> But there's nothing inherently built into Django admin that supports
>> this, correct?
>>
>> >
>> >
>> > On Tue, Jul 3, 2012 at 1:39 PM, Larry Martell 
>> > wrote:
>> >>
>> >> I have a client that asked me to add some new functionality to their
>> >> app, and then they said 'This new functionality should be controlled
>> >> in Django admin so that only the admin user can see it.' Is there a
>> >> way to control this in Django admin? I know in the python code i can
>> >> check to see if they're the admin user or not and allow or disallow
>> >> access, but what they're saying makes it seem I can just do it admin.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> >
>> >
>> > --
>> > Bust0ut, Surgemcgee: Systems Engineer ---
>> > PBDefence.com
>> > BudTVNetwork.com
>> > RadioWeedShow.com
>> > "Bringing entertainment to Unix"
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Bust0ut, Surgemcgee: Systems Engineer ---
> PBDefence.com
> BudTVNetwork.com
> RadioWeedShow.com
> "Bringing entertainment to Unix"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Controlling access

2012-07-03 Thread Larry Martell
On Tue, Jul 3, 2012 at 12:31 PM, Larry Martell  wrote:
> On Tue, Jul 3, 2012 at 11:55 AM, Robert Steckroth
>  wrote:
>> Django is a very open-ended framework. The admin system is built around
>> developer/user customization.
>
>
> Yes, I realize that. But I was asking if there was something that just
> worked (i.e. like foreign key references do). I don't think so, but my
> client seems to.

Apparently there is. Stepping through their app I found that it calls
has_perm in contrib/auth/models.py, which calls has_perm in
contrib/auth/backends.py, and this controls what specific
functionality each user has access to.


>> On Tue, Jul 3, 2012 at 1:51 PM, Larry Martell 
>> wrote:
>>>
>>> On Tue, Jul 3, 2012 at 11:49 AM, Robert Steckroth
>>>  wrote:
>>> > Yes, I have seen some very impressive admin media controls for websites
>>> > with
>>> > larger projects
>>> > having wordpress like functionality. However, there are not easy
>>> > or cheap to
>>> > make.
>>> > I recommend checking open-souce projects for a good start.
>>>
>>> But there's nothing inherently built into Django admin that supports
>>> this, correct?
>>>
>>> >
>>> >
>>> > On Tue, Jul 3, 2012 at 1:39 PM, Larry Martell 
>>> > wrote:
>>> >>
>>> >> I have a client that asked me to add some new functionality to their
>>> >> app, and then they said 'This new functionality should be controlled
>>> >> in Django admin so that only the admin user can see it.' Is there a
>>> >> way to control this in Django admin? I know in the python code i can
>>> >> check to see if they're the admin user or not and allow or disallow
>>> >> access, but what they're saying makes it seem I can just do it admin.
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> >> Groups
>>> >> "Django users" group.
>>> >> To post to this group, send email to django-users@googlegroups.com.
>>> >> To unsubscribe from this group, send email to
>>> >> django-users+unsubscr...@googlegroups.com.
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/group/django-users?hl=en.
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Bust0ut, Surgemcgee: Systems Engineer ---
>>> > PBDefence.com
>>> > BudTVNetwork.com
>>> > RadioWeedShow.com
>>> > "Bringing entertainment to Unix"
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "Django users" group.
>>> > To post to this group, send email to django-users@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > django-users+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/django-users?hl=en.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>>
>> --
>> Bust0ut, Surgemcgee: Systems Engineer ---
>> PBDefence.com
>> BudTVNetwork.com
>> RadioWeedShow.com
>> "Bringing entertainment to Unix"
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.

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



Re: Render time

2012-07-05 Thread Larry Martell
On Mon, Jun 25, 2012 at 9:04 PM, Andy McKay  wrote:
>> Now they want me to add to that how long
>> the browser takes to render the page after it gets the data.
>
> You can use the navigation timing API:
>
> https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
>
> We use this in conjuction with graphite and django-statsd to produce
> graphs of hour long our sites takes to render.
>
> http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/
>
> And some more links:
>
> https://github.com/andymckay/django-statsd
> http://django-statsd.readthedocs.org/en/latest/#front-end-timing-integration
> http://graphite.wikidot.com/

Andy-

I'm trying to use the Navigation Timing package to measure how long a
page takes to be rendered. So that would be loadEventEnd-responseEnd,
however I am finding that loadEventEnd is always 0 for me, even though
I am accessing it from within a window.onload function, e.g:

window.onload = function() {
var t = performance.timing;
var render_time = parseInt(t['loadEventEnd']) - parseInt(t['responseEnd']);
}

What do I have to wait for before loadEventEnd gets set?


Thanks!
-larry

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



Re: Render time

2012-07-05 Thread Larry Martell
On Thu, Jul 5, 2012 at 10:48 PM, Andy McKay  wrote:
>> I'm trying to use the Navigation Timing package to measure how long a
>> page takes to be rendered.
>
> So you don't want to include all the lookups? Just the "rendering" part?

Not sure what you mean by "lookups." I want to include everything
between when the server sends the data, to when the page is completely
generated (I'm using "rendered" to mean that). I'm trying to get a
metric on the delay the user experiences.

>> So that would be loadEventEnd-responseEnd,
>> however I am finding that loadEventEnd is always 0 for me, even though
>> I am accessing it from within a window.onload function, e.g:
>>
>> window.onload = function() {
>> var t = performance.timing;
>> var render_time = parseInt(t['loadEventEnd']) - 
>> parseInt(t['responseEnd']);
>> }
>>
>> What do I have to wait for before loadEventEnd gets set?
>
> Stupid question, but when does the onload event occur, before or after
> loadEventEnd?

>From looking at
https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#processing-model
it seems that that loadEventEnd gets set when the onload event
completes. And from my testing it seems that window.onload fires
before that

> Running it in a console as I type this email, it gives me a non-zero value.

Yes, in a console I see that too. But programatically, I cannot seem
to capture loadEventEnd after it's set.

How did you do it in what you describe at
http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/?

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



Returning nothing from a view

2012-07-06 Thread Larry Martell
I have a situation where I'm sending an ajax request to a function
that updates a row in database. I then want to return control to the
browser, with no changes to the page that was up. I am not returning
anything from the function, and it's working the way I want, however I
get an error in the browser's console:

Failed to load resource: the server responded with a status of 500
(INTERNAL SERVER ERROR)


Is there some was to avoid this error?

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



Re: Returning nothing from a view

2012-07-06 Thread Larry Martell
On Fri, Jul 6, 2012 at 2:47 PM, Tomas Neme  wrote:
> Just return an empty response, with a 200 OK code:
>
> return HttpResponse("")
>
> I'm not sure whether you can omit the ""

Thanks.  I did this:

return HttpResponse(status=201)


> On Fri, Jul 6, 2012 at 5:44 PM, Larry Martell  wrote:
>> I have a situation where I'm sending an ajax request to a function
>> that updates a row in database. I then want to return control to the
>> browser, with no changes to the page that was up. I am not returning
>> anything from the function, and it's working the way I want, however I
>> get an error in the browser's console:
>>
>> Failed to load resource: the server responded with a status of 500
>> (INTERNAL SERVER ERROR)
>>
>>
>> Is there some was to avoid this error?
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Render time

2012-07-07 Thread Larry Martell
On Mon, Jun 25, 2012 at 9:04 PM, Andy McKay  wrote:
>> Now they want me to add to that how long
>> the browser takes to render the page after it gets the data.
>
> You can use the navigation timing API:
>
> https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
>
> We use this in conjuction with graphite and django-statsd to produce
> graphs of hour long our sites takes to render.
>
> http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/
>
> And some more links:
>
> https://github.com/andymckay/django-statsd
> http://django-statsd.readthedocs.org/en/latest/#front-end-timing-integration
> http://graphite.wikidot.com/

I have this working for our pages that execute all the javascript as
part of the page generation (i.e. all contained in or called from the
django template). But we have pages that have an onchange function
that gets triggered by something done in the template. In those the
loadEventEnd gets set before the onchange function runs. Any idea how
I can get the time the onchange function takes included in the
navigation timing?

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



Detecting browser type after login

2012-07-31 Thread Larry Martell
I've only been working with django for 6 months, and I'm not really
clear on how the login process works.

I have a client that has a login screen created by a template. It has
a submit button with:



In their urls file they have:

(r'^accounts/login/$', login)

In their views file they call login(request)

What they want is, after the user has successfully logged in, I need
to detect which browser they are using, and depending on which it is,
potentially pop up a dialog box. I can't figure out where that code
would live. I'm not asking how to detect the browser type, but rather,
where that javascript code would go, and how I would cause it to get
invoked after the login.

TIA!
-larry

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



Re: Detecting browser type after login

2012-08-01 Thread Larry Martell
On Tue, Jul 31, 2012 at 8:05 PM, Larry Martell  wrote:
> I've only been working with django for 6 months, and I'm not really
> clear on how the login process works.
>
> I have a client that has a login screen created by a template. It has
> a submit button with:
>
> 
>
> In their urls file they have:
>
> (r'^accounts/login/$', login)
>
> In their views file they call login(request)
>
> What they want is, after the user has successfully logged in, I need
> to detect which browser they are using, and depending on which it is,
> potentially pop up a dialog box. I can't figure out where that code
> would live. I'm not asking how to detect the browser type, but rather,
> where that javascript code would go, and how I would cause it to get
> invoked after the login.

Someone suggested getting the browser type on the server side, and
then adding a variable to my response and check it in the template. I
like this solution, however I cannot figure out how to add the
variable to the response. After the successful login, the code calls
HttpResponseRedirect. How can I can I add a variable to that?

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



Re: Detecting browser type after login

2012-08-01 Thread Larry Martell
On Wed, Aug 1, 2012 at 1:36 PM, Kurtis Mullins  wrote:
> Is the "Dialog Box" going to be presented using Javascript? If so, why not
> use Javascript for this functionality? I'd typically only use this type of
> functionality to serve pages when javascript isn't enabled or you need to
> show various templates based upon the type of browser (for example, a Mobile
> browser). Just a suggestion.

Yes, the dialog will be generated with javascript. My initial approach
was to do this all on the client side, but I was not able to figure
out how to fit that into the app (which was my original question).

Here's how it's structured:

Login screen is generated with django template
User clicks on submit
django login() is called, then a function from our views is called
that returns HttpResponseRedirect.

They want the dialog to pop up on top of the login screen before the
redirect. I don't know where the code that does this would live or how
it would get invoked.

As far as to why they want this, it doesn't really support IE, and
they want to alert the user to that if that's what they're using. It's
a custom app, not for public use.


>
> On Wed, Aug 1, 2012 at 3:11 PM, Larry Martell 
> wrote:
>>
>> On Tue, Jul 31, 2012 at 8:05 PM, Larry Martell 
>> wrote:
>> > I've only been working with django for 6 months, and I'm not really
>> > clear on how the login process works.
>> >
>> > I have a client that has a login screen created by a template. It has
>> > a submit button with:
>> >
>> > 
>> >
>> > In their urls file they have:
>> >
>> > (r'^accounts/login/$', login)
>> >
>> > In their views file they call login(request)
>> >
>> > What they want is, after the user has successfully logged in, I need
>> > to detect which browser they are using, and depending on which it is,
>> > potentially pop up a dialog box. I can't figure out where that code
>> > would live. I'm not asking how to detect the browser type, but rather,
>> > where that javascript code would go, and how I would cause it to get
>> > invoked after the login.
>>
>> Someone suggested getting the browser type on the server side, and
>> then adding a variable to my response and check it in the template. I
>> like this solution, however I cannot figure out how to add the
>> variable to the response. After the successful login, the code calls
>> HttpResponseRedirect. How can I can I add a variable to that?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Detecting browser type after login

2012-08-01 Thread Larry Martell
On Wed, Aug 1, 2012 at 1:38 PM, Kurtis Mullins  wrote:
> Sorry for the double-message. Anyways, if you do want to do what that other
> person recommended, simply find the View that the user is redirected to
> after logging in. Then, modify the "context data" of that view to dump
> whatever data to the template. And then do some magic in the template based
> upon that context data. In short, put this logic in the view the user is
> sent to after they've logged in.

What view they are redirected to is not consistent. It depends on what
the user is permissioned for and what features the customer has paid
for. But I may be able to do this in some common part of the code.
Thanks.


> On Wed, Aug 1, 2012 at 3:36 PM, Kurtis Mullins 
> wrote:
>>
>> Is the "Dialog Box" going to be presented using Javascript? If so, why not
>> use Javascript for this functionality? I'd typically only use this type of
>> functionality to serve pages when javascript isn't enabled or you need to
>> show various templates based upon the type of browser (for example, a Mobile
>> browser). Just a suggestion.
>>
>>
>> On Wed, Aug 1, 2012 at 3:11 PM, Larry Martell 
>> wrote:
>>>
>>> On Tue, Jul 31, 2012 at 8:05 PM, Larry Martell 
>>> wrote:
>>> > I've only been working with django for 6 months, and I'm not really
>>> > clear on how the login process works.
>>> >
>>> > I have a client that has a login screen created by a template. It has
>>> > a submit button with:
>>> >
>>> > 
>>> >
>>> > In their urls file they have:
>>> >
>>> > (r'^accounts/login/$', login)
>>> >
>>> > In their views file they call login(request)
>>> >
>>> > What they want is, after the user has successfully logged in, I need
>>> > to detect which browser they are using, and depending on which it is,
>>> > potentially pop up a dialog box. I can't figure out where that code
>>> > would live. I'm not asking how to detect the browser type, but rather,
>>> > where that javascript code would go, and how I would cause it to get
>>> > invoked after the login.
>>>
>>> Someone suggested getting the browser type on the server side, and
>>> then adding a variable to my response and check it in the template. I
>>> like this solution, however I cannot figure out how to add the
>>> variable to the response. After the successful login, the code calls
>>> HttpResponseRedirect. How can I can I add a variable to that?
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Detecting browser type after login

2012-08-01 Thread Larry Martell
On Wed, Aug 1, 2012 at 1:52 PM, Larry Martell  wrote:
> On Wed, Aug 1, 2012 at 1:38 PM, Kurtis Mullins  
> wrote:
>> Sorry for the double-message. Anyways, if you do want to do what that other
>> person recommended, simply find the View that the user is redirected to
>> after logging in. Then, modify the "context data" of that view to dump
>> whatever data to the template. And then do some magic in the template based
>> upon that context data. In short, put this logic in the view the user is
>> sent to after they've logged in.
>
> What view they are redirected to is not consistent. It depends on what
> the user is permissioned for and what features the customer has paid
> for. But I may be able to do this in some common part of the code.
> Thanks.

Another issue with this is that I only want to display the pop up
once, immediately after they login. I don't think I can tell if that's
the case in the view, only in the code that is called after login().

>
>
>> On Wed, Aug 1, 2012 at 3:36 PM, Kurtis Mullins 
>> wrote:
>>>
>>> Is the "Dialog Box" going to be presented using Javascript? If so, why not
>>> use Javascript for this functionality? I'd typically only use this type of
>>> functionality to serve pages when javascript isn't enabled or you need to
>>> show various templates based upon the type of browser (for example, a Mobile
>>> browser). Just a suggestion.
>>>
>>>
>>> On Wed, Aug 1, 2012 at 3:11 PM, Larry Martell 
>>> wrote:
>>>>
>>>> On Tue, Jul 31, 2012 at 8:05 PM, Larry Martell 
>>>> wrote:
>>>> > I've only been working with django for 6 months, and I'm not really
>>>> > clear on how the login process works.
>>>> >
>>>> > I have a client that has a login screen created by a template. It has
>>>> > a submit button with:
>>>> >
>>>> > 
>>>> >
>>>> > In their urls file they have:
>>>> >
>>>> > (r'^accounts/login/$', login)
>>>> >
>>>> > In their views file they call login(request)
>>>> >
>>>> > What they want is, after the user has successfully logged in, I need
>>>> > to detect which browser they are using, and depending on which it is,
>>>> > potentially pop up a dialog box. I can't figure out where that code
>>>> > would live. I'm not asking how to detect the browser type, but rather,
>>>> > where that javascript code would go, and how I would cause it to get
>>>> > invoked after the login.
>>>>
>>>> Someone suggested getting the browser type on the server side, and
>>>> then adding a variable to my response and check it in the template. I
>>>> like this solution, however I cannot figure out how to add the
>>>> variable to the response. After the successful login, the code calls
>>>> HttpResponseRedirect. How can I can I add a variable to that?
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "Django users" group.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> django-users+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/django-users?hl=en.
>>>>
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.

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



Re: Detecting browser type after login

2012-08-01 Thread Larry Martell
On Wed, Aug 1, 2012 at 1:56 PM, Larry Martell  wrote:
> On Wed, Aug 1, 2012 at 1:52 PM, Larry Martell  wrote:
>> On Wed, Aug 1, 2012 at 1:38 PM, Kurtis Mullins  
>> wrote:
>>> Sorry for the double-message. Anyways, if you do want to do what that other
>>> person recommended, simply find the View that the user is redirected to
>>> after logging in. Then, modify the "context data" of that view to dump
>>> whatever data to the template. And then do some magic in the template based
>>> upon that context data. In short, put this logic in the view the user is
>>> sent to after they've logged in.
>>
>> What view they are redirected to is not consistent. It depends on what
>> the user is permissioned for and what features the customer has paid
>> for. But I may be able to do this in some common part of the code.
>> Thanks.
>
> Another issue with this is that I only want to display the pop up
> once, immediately after they login. I don't think I can tell if that's
> the case in the view, only in the code that is called after login().

So what I ended up doing was to add a session-cookie with the
popup-information. I can then access in the base template, but the
issue I am having now is that they want the popup to be on top of the
login screen, and it's displaying on a blank screen, after the login
screen is cleared. ARHG!

>
>>
>>
>>> On Wed, Aug 1, 2012 at 3:36 PM, Kurtis Mullins 
>>> wrote:
>>>>
>>>> Is the "Dialog Box" going to be presented using Javascript? If so, why not
>>>> use Javascript for this functionality? I'd typically only use this type of
>>>> functionality to serve pages when javascript isn't enabled or you need to
>>>> show various templates based upon the type of browser (for example, a 
>>>> Mobile
>>>> browser). Just a suggestion.
>>>>
>>>>
>>>> On Wed, Aug 1, 2012 at 3:11 PM, Larry Martell 
>>>> wrote:
>>>>>
>>>>> On Tue, Jul 31, 2012 at 8:05 PM, Larry Martell 
>>>>> wrote:
>>>>> > I've only been working with django for 6 months, and I'm not really
>>>>> > clear on how the login process works.
>>>>> >
>>>>> > I have a client that has a login screen created by a template. It has
>>>>> > a submit button with:
>>>>> >
>>>>> > 
>>>>> >
>>>>> > In their urls file they have:
>>>>> >
>>>>> > (r'^accounts/login/$', login)
>>>>> >
>>>>> > In their views file they call login(request)
>>>>> >
>>>>> > What they want is, after the user has successfully logged in, I need
>>>>> > to detect which browser they are using, and depending on which it is,
>>>>> > potentially pop up a dialog box. I can't figure out where that code
>>>>> > would live. I'm not asking how to detect the browser type, but rather,
>>>>> > where that javascript code would go, and how I would cause it to get
>>>>> > invoked after the login.
>>>>>
>>>>> Someone suggested getting the browser type on the server side, and
>>>>> then adding a variable to my response and check it in the template. I
>>>>> like this solution, however I cannot figure out how to add the
>>>>> variable to the response. After the successful login, the code calls
>>>>> HttpResponseRedirect. How can I can I add a variable to that?
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups
>>>>> "Django users" group.
>>>>> To post to this group, send email to django-users@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> django-users+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/django-users?hl=en.
>>>>>
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.

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



Re: Detecting browser type after login

2012-08-01 Thread Larry Martell
On Wed, Aug 1, 2012 at 3:57 PM, Larry Martell  wrote:
> On Wed, Aug 1, 2012 at 1:56 PM, Larry Martell  wrote:
>> On Wed, Aug 1, 2012 at 1:52 PM, Larry Martell  
>> wrote:
>>> On Wed, Aug 1, 2012 at 1:38 PM, Kurtis Mullins  
>>> wrote:
>>>> Sorry for the double-message. Anyways, if you do want to do what that other
>>>> person recommended, simply find the View that the user is redirected to
>>>> after logging in. Then, modify the "context data" of that view to dump
>>>> whatever data to the template. And then do some magic in the template based
>>>> upon that context data. In short, put this logic in the view the user is
>>>> sent to after they've logged in.
>>>
>>> What view they are redirected to is not consistent. It depends on what
>>> the user is permissioned for and what features the customer has paid
>>> for. But I may be able to do this in some common part of the code.
>>> Thanks.
>>
>> Another issue with this is that I only want to display the pop up
>> once, immediately after they login. I don't think I can tell if that's
>> the case in the view, only in the code that is called after login().
>
> So what I ended up doing was to add a session-cookie with the
> popup-information. I can then access in the base template, but the
> issue I am having now is that they want the popup to be on top of the
> login screen, and it's displaying on a blank screen, after the login
> screen is cleared. ARHG!

So it would appear there is no way to send data from django to the
browser that updates the page without first clearing it. Is that true?


>>>> On Wed, Aug 1, 2012 at 3:36 PM, Kurtis Mullins 
>>>> wrote:
>>>>>
>>>>> Is the "Dialog Box" going to be presented using Javascript? If so, why not
>>>>> use Javascript for this functionality? I'd typically only use this type of
>>>>> functionality to serve pages when javascript isn't enabled or you need to
>>>>> show various templates based upon the type of browser (for example, a 
>>>>> Mobile
>>>>> browser). Just a suggestion.
>>>>>
>>>>>
>>>>> On Wed, Aug 1, 2012 at 3:11 PM, Larry Martell 
>>>>> wrote:
>>>>>>
>>>>>> On Tue, Jul 31, 2012 at 8:05 PM, Larry Martell 
>>>>>> wrote:
>>>>>> > I've only been working with django for 6 months, and I'm not really
>>>>>> > clear on how the login process works.
>>>>>> >
>>>>>> > I have a client that has a login screen created by a template. It has
>>>>>> > a submit button with:
>>>>>> >
>>>>>> > 
>>>>>> >
>>>>>> > In their urls file they have:
>>>>>> >
>>>>>> > (r'^accounts/login/$', login)
>>>>>> >
>>>>>> > In their views file they call login(request)
>>>>>> >
>>>>>> > What they want is, after the user has successfully logged in, I need
>>>>>> > to detect which browser they are using, and depending on which it is,
>>>>>> > potentially pop up a dialog box. I can't figure out where that code
>>>>>> > would live. I'm not asking how to detect the browser type, but rather,
>>>>>> > where that javascript code would go, and how I would cause it to get
>>>>>> > invoked after the login.
>>>>>>
>>>>>> Someone suggested getting the browser type on the server side, and
>>>>>> then adding a variable to my response and check it in the template. I
>>>>>> like this solution, however I cannot figure out how to add the
>>>>>> variable to the response. After the successful login, the code calls
>>>>>> HttpResponseRedirect. How can I can I add a variable to that?
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google Groups
>>>>>> "Django users" group.
>>>>>> To post to this group, send email to django-users@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> django-users+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/django-users?hl=en.
>>>>>>
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "Django users" group.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> django-users+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/django-users?hl=en.

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



Re: Major Trouble Understanding Sessions Documentation

2012-08-02 Thread Larry Martell
On Thu, Aug 2, 2012 at 7:06 AM, Gregory Thompson Jr.
 wrote:
> I'd like to pass form data from one view to another.
>
> Here's my attempt:
>
> #Models.py
> from django import forms
>
> class Textizer(forms.Form):
> to_textize = forms.CharField(max_length=100)
>
> def __unicode__(self):
> return self.to_textize
>
> #views.py
> from textize.models import Textizer
> from django.http import HttpResponseRedirect
> from django.shortcuts import render_to_response
> from django.core.context_processors import csrf
>
> def index(request):
> if request.method == 'POST':
> form = Textizer(request.POST)
>
> if form.is_valid():
> request.session['text'] = form.cleaned_data['to_textize']
> return HttpResponseRedirect('/results')
>
> else:
> form = Textizer()
>
> c = {'form': form}
> c.update(csrf(request))
> return render_to_response('C:/Documents and
> Settings/quansai/projects/textsite/templates/index.html', c)
>
> def results(request):
> text = request.session.get('text', None)
> c = {'text' : text}
> return render_to_response('C:/Documents and
> Settings/quansai/projects/textsite/templates/results.html', c)
>
>
> I really don't understand the following, and I've read the documentation
> over and over.  I've been on this for two days:
>
> How to initiate a session
> How sessions are checked
> How to retrieve form data from one page to handle the data on another.

In your template you can access the session variables as request.session.text.

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



Re: Detecting browser type after login

2012-08-02 Thread Larry Martell
On Thu, Aug 2, 2012 at 8:18 AM, Kurtis Mullins  wrote:
> Hey Larry,

Thanks for the reply Kurtis.

> Okay, let me make sure I understand this correctly. This is, essentially,
> the flow of control you'd like to implement:
>
> 1. User signs in successfully
> 2. User is redirected to some other (any other) page
> 3. User is presented with a one-time only popup

Yes, that is correct. The popup would be displayed only if they are running IE.

> The simple way to implement something *similar* to this would be using the
> Django Messaging Framework. Of course, this framework will not (without a
> huge hack) do exactly what you want. However, you could most likely take the
> basis of the Messaging Framework and implement similar functionality,
> yourself.
>
> Without looking myself, I imagine you'd have a data structure that would be
> stored in the user's session and a custom template tag which would look for
> this particular data. If that custom template tag finds the data, it does
> *something* (display popup, or whatever logic you may need specialized
> there). Then, simply put this custom template tag (or possibly variants of
> this tag) on your templates which may need to provide this functionality.
>
> Here's a link for the messaging framework, just in case your not familiar
> with it:  https://docs.djangoproject.com/en/dev/ref/contrib/messages/  --
> Again, that's not the proper use of the messages framework but at an
> abstract level I picture it following a similar path.

Thanks. I'm not familiar with the messaging framework. I'll look into that.

> To try and clear up some of the questions/issues you mentioned specifically,
> read below.
>
> On Wed, Aug 1, 2012 at 9:44 PM, Larry Martell 
> wrote:
>>
>> >>
>> >> Another issue with this is that I only want to display the pop up
>> >> once, immediately after they login. I don't think I can tell if that's
>> >> the case in the view, only in the code that is called after login().
>
>
> Using the technique described above, this would happen programmatically
> because the template tag would simply "pop" or delete your data after it is
> used. The next time the template tag looks for that same data, it won't be
> there; unless the user logs in again.
>
>>
>> >
>> > So what I ended up doing was to add a session-cookie with the
>> > popup-information. I can then access in the base template, but the
>> > issue I am having now is that they want the popup to be on top of the
>> > login screen, and it's displaying on a blank screen, after the login
>> > screen is cleared. ARHG!
>
>
> Sorry but I'm not quite following you here. Can you give us more information
> about your "blank screen"? Also, could you clarify what you mean by "the
> login screen is cleared"?


When the user is redirected to a page, and that code sends a response
to the browser, it clears the page, and renders the new content. I
have this working using the session data to pass the browser type from
the code that does the redirect to the template, but when the popup is
displayed the login screen is gone. It displays between when the page
is cleared and the new content is rendered.

>
>>
>>
>> So it would appear there is no way to send data from django to the
>> browser that updates the page without first clearing it. Is that true?
>
>
> I'm a bit vague on this one, as well. However, there is no way to send data
> from django to the browser after the page has loaded. I'm not sure what you
> mean by "without first clearing it". You could always use AJAX but I don't
> think that's the problem at hand, here.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Detecting browser type after login

2012-08-02 Thread Larry Martell
On Thu, Aug 2, 2012 at 9:13 AM, Andreas Schosser  wrote:
> Hi Larry
>
>> They want the dialog to pop up on top of the login screen before the
>> redirect. I don't know where the code that does this would live or how
>> it would get invoked.
>>
>> As far as to why they want this, it doesn't really support IE, and
>> they want to alert the user to that if that's what they're using. It's
>> a custom app, not for public use.
>
> So why don't you catch the form.submit event with JavaScript and notify
> the user about any issues with his browser.
> Then you could either prevent them from proceeding or call the
> form.submit within your JavaScript code.

They want the popup displayed after the user has successfully logged
in. That requires a trip to the server.

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



Re: Detecting browser type after login

2012-08-02 Thread Larry Martell
On Thu, Aug 2, 2012 at 9:24 AM, Kurtis Mullins  wrote:
> Sorry I didn't catch this part. You could modify your "Login" view to check
> the user agent and if it's an incompatible browser, and simply return a
> template that tells them their browser is unsupported. I'd do this before
> they even hit the Login Form just to be courteous to the user. But this
> modification would to be done in the Login view or whichever view(s) present
> the Login Form.
>
> If you want to implement this site-wide, simply make your own custom
> middleware that looks for this user agent and display the fore-mentioned
> template.
>
> The JavaScript idea mentioned by Andreas would be a great solution as well.

The want the user to be able to continue to use the app. The popup is
just to advise them that some features may not work. So I have to
still pass them through to whatever they're getting redirected to, and
not just stop.

>
>
> On Thu, Aug 2, 2012 at 11:13 AM, Andreas Schosser 
> wrote:
>>
>> Hi Larry
>>
>> > They want the dialog to pop up on top of the login screen before the
>> > redirect. I don't know where the code that does this would live or how
>> > it would get invoked.
>> >
>> > As far as to why they want this, it doesn't really support IE, and
>> > they want to alert the user to that if that's what they're using. It's
>> > a custom app, not for public use.
>>
>> So why don't you catch the form.submit event with JavaScript and notify
>> the user about any issues with his browser.
>> Then you could either prevent them from proceeding or call the
>> form.submit within your JavaScript code.
>>
>> No server side logic is necessary but of course it only works with
>> JavaScript enabled.
>>
>> Greetings
>> Andreas
>>
>> --
>> state of mind ()
>>
>> http://www.state-of-mind.de
>>
>> Franziskanerstraße 15  Telefon +49 89 3090 4664
>> 81669 München  Telefax +49 89 3090 4666
>>
>> Amtsgericht MünchenPartnerschaftsregister PR 563
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Detecting browser type after login

2012-08-03 Thread Larry Martell
On Thu, Aug 2, 2012 at 8:15 PM, Melvyn Sopacua  wrote:
> On 1-8-2012 21:52, Larry Martell wrote:
>> On Wed, Aug 1, 2012 at 1:38 PM, Kurtis Mullins  
>> wrote:
>>> Sorry for the double-message. Anyways, if you do want to do what that other
>>> person recommended, simply find the View that the user is redirected to
>>> after logging in. Then, modify the "context data" of that view to dump
>>> whatever data to the template. And then do some magic in the template based
>>> upon that context data. In short, put this logic in the view the user is
>>> sent to after they've logged in.
>>
>> What view they are redirected to is not consistent. It depends on what
>> the user is permissioned for and what features the customer has paid
>> for. But I may be able to do this in some common part of the code.
>
> Add a UserProfile field "just_logged_in", type Boolean.
> The only place that field gets set to True is in the login view. Don't
> forget to save the profile in that view.
> Create a small that sets the field back to False and saves the profile
> that can be invoked by an AJAX call.
> In your base_site.html template use:
>  {% if user.get_user_profile.just_logged_in %}
> to include a javascript bit, that generates the popup /and/ calls the
> view that resets the just_logged_in field.

Thanks for the reply Melvyn. But after all this work and research
they've decided now that they want the popup displayed before the user
logs in. This greatly simplifies things, as I can do it all from the
login template. Thanks all for the help.

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



Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
We have a django app that requires the users to login. For some
testing we want to do, we want to disable this so the app can be run
without logging in. Is there some way to easily do this? I've tried
commenting out all the @login_required decorations, but then I was
getting a 403. I tried commenting out the 'if not
controller.has_access' lines, but then I was getting 'Report.owner"
must be a "User" instance.' Before I hack up the code any more, is
there some way to just globally disable the need to login?

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins  wrote:
> If any of your templates/views depend upon a request.user object, you'll run
> into issues because that will not exist without "logging in". I'm not sure
> of a good way around this off-hand without knowing more about your site.
> Sorry!

Yes, they do depend on a request.user object. Can I hard code the
initialization of it?

>
> On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
> wrote:
>>
>> We have a django app that requires the users to login. For some
>> testing we want to do, we want to disable this so the app can be run
>> without logging in. Is there some way to easily do this? I've tried
>> commenting out all the @login_required decorations, but then I was
>> getting a 403. I tried commenting out the 'if not
>> controller.has_access' lines, but then I was getting 'Report.owner"
>> must be a "User" instance.' Before I hack up the code any more, is
>> there some way to just globally disable the need to login?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins  wrote:
> I don't see why not.

I've been trying to do that, but it's still complaining.

> Are you running unit tests (testing scripts) or are you
> just using the browser for testing?

I'm trying to do performance measuring. I have a list of all the urls
accessed over the past few months by a client, along with metrics on
their execution times. I want to run all those on a new server we've
set up and collect metrics and compare them. I have a python script
that uses urllib2 but, I can't run anything without logging in. I've
tried to login from python, but I get a 403. I also tried using the
requests module - that doesn't give me the 403, but doesn't log me in
- it just returns the login page as if the login failed.

>
> On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
> wrote:
>>
>> On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins 
>> wrote:
>> > If any of your templates/views depend upon a request.user object, you'll
>> > run
>> > into issues because that will not exist without "logging in". I'm not
>> > sure
>> > of a good way around this off-hand without knowing more about your site.
>> > Sorry!
>>
>> Yes, they do depend on a request.user object. Can I hard code the
>> initialization of it?
>>
>> >
>> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
>> > wrote:
>> >>
>> >> We have a django app that requires the users to login. For some
>> >> testing we want to do, we want to disable this so the app can be run
>> >> without logging in. Is there some way to easily do this? I've tried
>> >> commenting out all the @login_required decorations, but then I was
>> >> getting a 403. I tried commenting out the 'if not
>> >> controller.has_access' lines, but then I was getting 'Report.owner"
>> >> must be a "User" instance.' Before I hack up the code any more, is
>> >> there some way to just globally disable the need to login?
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
 wrote:
> We are using a middleware to enforce a user login:
>
> class AutoAuthMiddleware(object):
> """
> Middleware for testing purpose only.
> Can enforce the user login.
> """
>
> def process_request(self, request):
> enforce_user = request.GET.get("enforce_user", None)
> if hasattr(request, "user") and not enforce_user:
> return
>
> user = User.objects.filter(username = enforce_user)


I'm getting: 'NameError: "global name 'User' is not defined"' on the
above line. This is the same issue I was running into when I was
trying to hard code the initialization of a request.user object. Where
is that defined?


> if user:
> backend = get_backends()[0]
> user = user[0]
> user.backend = "%s.%s" % (backend.__module__,
> backend.__class__.__name__) #fake authentication
> login(request, user)
>
> You can add that to your testing environnement MIDDLEWARE_CLASSES.
>
> Then you can just go to any url and add ?enforce_user=
>
>
>
> On 05/09/12 17:56, Larry Martell wrote:
>
> On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins 
> wrote:
>
> I don't see why not.
>
> I've been trying to do that, but it's still complaining.
>
> Are you running unit tests (testing scripts) or are you
> just using the browser for testing?
>
> I'm trying to do performance measuring. I have a list of all the urls
> accessed over the past few months by a client, along with metrics on
> their execution times. I want to run all those on a new server we've
> set up and collect metrics and compare them. I have a python script
> that uses urllib2 but, I can't run anything without logging in. I've
> tried to login from python, but I get a 403. I also tried using the
> requests module - that doesn't give me the 403, but doesn't log me in
> - it just returns the login page as if the login failed.
>
> On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
> wrote:
>
> On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins 
> wrote:
>
> If any of your templates/views depend upon a request.user object, you'll
> run
> into issues because that will not exist without "logging in". I'm not
> sure
> of a good way around this off-hand without knowing more about your site.
> Sorry!
>
> Yes, they do depend on a request.user object. Can I hard code the
> initialization of it?
>
> On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
> wrote:
>
> We have a django app that requires the users to login. For some
> testing we want to do, we want to disable this so the app can be run
> without logging in. Is there some way to easily do this? I've tried
> commenting out all the @login_required decorations, but then I was
> getting a 403. I tried commenting out the 'if not
> controller.has_access' lines, but then I was getting 'Report.owner"
> must be a "User" instance.' Before I hack up the code any more, is
> there some way to just globally disable the need to login?
>
> --
> You received this message because you are subscribed to the Google
> Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google
> Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
Thanks - but now I'm getting

NameError: "global name 'get_backends' is not defined"


On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
 wrote:
> Looks like you just need a quick:
>
> from django.contrib.auth.models import User
>
> towards the top :)
>
>
> On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
> wrote:
>>
>> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>>  wrote:
>> > We are using a middleware to enforce a user login:
>> >
>> > class AutoAuthMiddleware(object):
>> > """
>> > Middleware for testing purpose only.
>> > Can enforce the user login.
>> > """
>> >
>> > def process_request(self, request):
>> > enforce_user = request.GET.get("enforce_user", None)
>> > if hasattr(request, "user") and not enforce_user:
>> > return
>> >
>> > user = User.objects.filter(username = enforce_user)
>>
>>
>> I'm getting: 'NameError: "global name 'User' is not defined"' on the
>> above line. This is the same issue I was running into when I was
>> trying to hard code the initialization of a request.user object. Where
>> is that defined?
>>
>>
>> > if user:
>> > backend = get_backends()[0]
>> > user = user[0]
>> > user.backend = "%s.%s" % (backend.__module__,
>> > backend.__class__.__name__) #fake authentication
>> > login(request, user)
>> >
>> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
>> >
>> > Then you can just go to any url and add ?enforce_user=
>> >
>> >
>> >
>> > On 05/09/12 17:56, Larry Martell wrote:
>> >
>> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
>> > 
>> > wrote:
>> >
>> > I don't see why not.
>> >
>> > I've been trying to do that, but it's still complaining.
>> >
>> > Are you running unit tests (testing scripts) or are you
>> > just using the browser for testing?
>> >
>> > I'm trying to do performance measuring. I have a list of all the urls
>> > accessed over the past few months by a client, along with metrics on
>> > their execution times. I want to run all those on a new server we've
>> > set up and collect metrics and compare them. I have a python script
>> > that uses urllib2 but, I can't run anything without logging in. I've
>> > tried to login from python, but I get a 403. I also tried using the
>> > requests module - that doesn't give me the 403, but doesn't log me in
>> > - it just returns the login page as if the login failed.
>> >
>> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
>> > wrote:
>> >
>> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
>> > 
>> > wrote:
>> >
>> > If any of your templates/views depend upon a request.user object, you'll
>> > run
>> > into issues because that will not exist without "logging in". I'm not
>> > sure
>> > of a good way around this off-hand without knowing more about your site.
>> > Sorry!
>> >
>> > Yes, they do depend on a request.user object. Can I hard code the
>> > initialization of it?
>> >
>> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
>> > wrote:
>> >
>> > We have a django app that requires the users to login. For some
>> > testing we want to do, we want to disable this so the app can be run
>> > without logging in. Is there some way to easily do this? I've tried
>> > commenting out all the @login_required decorations, but then I was
>> > getting a 403. I tried commenting out the 'if not
>> > controller.has_access' lines, but then I was getting 'Report.owner"
>> > must be a "User" instance.' Before I hack up the code any more, is
>> > there some way to just globally disable the need to login?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more optio

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
The code is what Anthony posted, and the traceback is simply:


Traceback:
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/handlers/base.py"
in get_response
  89. response = middleware_method(request)
File "/usr/local/motor/motor/../motor/middleware.py" in process_request
  29. backend = get_backends()[0]

Exception Type: NameError at /report/CDSEM/RawFile/
Exception Value: global name 'get_backends' is not defined


And I was under the impression that his middleware code would
eliminate the need to disable all login_required decorators, etc.


On Wed, Sep 5, 2012 at 1:48 PM, Amyth Arora  wrote:
> could you post the traceback and the respective code. Most probably you'll
> need to disable all login_required decorators and also disable your user
> login based template tags in all the templates for it to work properly.
>
>
> On Wed, Sep 5, 2012 at 10:36 PM, Larry Martell 
> wrote:
>>
>> Thanks - but now I'm getting
>>
>> NameError: "global name 'get_backends' is not defined"
>>
>>
>> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>>  wrote:
>> > Looks like you just need a quick:
>> >
>> > from django.contrib.auth.models import User
>> >
>> > towards the top :)
>> >
>> >
>> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
>> > wrote:
>> >>
>> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>> >>  wrote:
>> >> > We are using a middleware to enforce a user login:
>> >> >
>> >> > class AutoAuthMiddleware(object):
>> >> > """
>> >> > Middleware for testing purpose only.
>> >> > Can enforce the user login.
>> >> > """
>> >> >
>> >> > def process_request(self, request):
>> >> > enforce_user = request.GET.get("enforce_user", None)
>> >> > if hasattr(request, "user") and not enforce_user:
>> >> > return
>> >> >
>> >> > user = User.objects.filter(username = enforce_user)
>> >>
>> >>
>> >> I'm getting: 'NameError: "global name 'User' is not defined"' on the
>> >> above line. This is the same issue I was running into when I was
>> >> trying to hard code the initialization of a request.user object. Where
>> >> is that defined?
>> >>
>> >>
>> >> > if user:
>> >> > backend = get_backends()[0]
>> >> > user = user[0]
>> >> > user.backend = "%s.%s" % (backend.__module__,
>> >> > backend.__class__.__name__) #fake authentication
>> >> > login(request, user)
>> >> >
>> >> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
>> >> >
>> >> > Then you can just go to any url and add ?enforce_user=
>> >> >
>> >> >
>> >> >
>> >> > On 05/09/12 17:56, Larry Martell wrote:
>> >> >
>> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
>> >> > 
>> >> > wrote:
>> >> >
>> >> > I don't see why not.
>> >> >
>> >> > I've been trying to do that, but it's still complaining.
>> >> >
>> >> > Are you running unit tests (testing scripts) or are you
>> >> > just using the browser for testing?
>> >> >
>> >> > I'm trying to do performance measuring. I have a list of all the urls
>> >> > accessed over the past few months by a client, along with metrics on
>> >> > their execution times. I want to run all those on a new server we've
>> >> > set up and collect metrics and compare them. I have a python script
>> >> > that uses urllib2 but, I can't run anything without logging in. I've
>> >> > tried to login from python, but I get a 403. I also tried using the
>> >> > requests module - that doesn't give me the 403, but doesn't log me in
>> >> > - it just returns the login page as if the login failed.
>> >> >
>> >> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell
>> >> > 
>> >> > wrote

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
I have no idea how that would be done (neither extracting the token
nor passing it via urllib). I'm googling this, but if you know and
want to share, that would be great.

On Wed, Sep 5, 2012 at 1:50 PM, Kurtis Mullins  wrote:
> Actually, I've got another idea for you. You mentioned you wanted to simply
> access using urllib. Maybe you could create a small script to extract a CSRF
> token from the login page, login with a known (test) user, and continue
> passing and extracting the CSRF token as needed?
>
>
> On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell 
> wrote:
>>
>> Thanks - but now I'm getting
>>
>> NameError: "global name 'get_backends' is not defined"
>>
>>
>> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>>  wrote:
>> > Looks like you just need a quick:
>> >
>> > from django.contrib.auth.models import User
>> >
>> > towards the top :)
>> >
>> >
>> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
>> > wrote:
>> >>
>> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>> >>  wrote:
>> >> > We are using a middleware to enforce a user login:
>> >> >
>> >> > class AutoAuthMiddleware(object):
>> >> > """
>> >> > Middleware for testing purpose only.
>> >> > Can enforce the user login.
>> >> > """
>> >> >
>> >> > def process_request(self, request):
>> >> > enforce_user = request.GET.get("enforce_user", None)
>> >> > if hasattr(request, "user") and not enforce_user:
>> >> > return
>> >> >
>> >> > user = User.objects.filter(username = enforce_user)
>> >>
>> >>
>> >> I'm getting: 'NameError: "global name 'User' is not defined"' on the
>> >> above line. This is the same issue I was running into when I was
>> >> trying to hard code the initialization of a request.user object. Where
>> >> is that defined?
>> >>
>> >>
>> >> > if user:
>> >> > backend = get_backends()[0]
>> >> > user = user[0]
>> >> > user.backend = "%s.%s" % (backend.__module__,
>> >> > backend.__class__.__name__) #fake authentication
>> >> > login(request, user)
>> >> >
>> >> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
>> >> >
>> >> > Then you can just go to any url and add ?enforce_user=
>> >> >
>> >> >
>> >> >
>> >> > On 05/09/12 17:56, Larry Martell wrote:
>> >> >
>> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
>> >> > 
>> >> > wrote:
>> >> >
>> >> > I don't see why not.
>> >> >
>> >> > I've been trying to do that, but it's still complaining.
>> >> >
>> >> > Are you running unit tests (testing scripts) or are you
>> >> > just using the browser for testing?
>> >> >
>> >> > I'm trying to do performance measuring. I have a list of all the urls
>> >> > accessed over the past few months by a client, along with metrics on
>> >> > their execution times. I want to run all those on a new server we've
>> >> > set up and collect metrics and compare them. I have a python script
>> >> > that uses urllib2 but, I can't run anything without logging in. I've
>> >> > tried to login from python, but I get a 403. I also tried using the
>> >> > requests module - that doesn't give me the 403, but doesn't log me in
>> >> > - it just returns the login page as if the login failed.
>> >> >
>> >> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >
>> >> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
>> >> > 
>> >> > wrote:
>> >> >
>> >> > If any of your templates/views depend upon a request.user object,
>> >> > you'll
>> >> > run
>> >> > into issues because that will not exist without "logging in". I'm no

  1   2   3   4   5   6   >