Re: am I understanding sessions correctly?

2011-12-28 Thread Chris Curvey
Thanks for the thoughts, Stuart.

On Dec 23, 2:08 pm, Stuart Laughlin <stu...@bistrotech.net> wrote:
> On Dec 22, 9:01 am, ChrisCurvey<ccur...@gmail.com> wrote:
>
> > The short version:  when processing a request, does Django *always*
> > collect session information from the session store before starting the
> > view?
>
> Yes. However note that django only saves to the session database when
> the session has been modified. It doesn't seem like that's affecting
> you, but I can't be sure.

So long as Django is auto-saving and auto-fetching, I think I should
be OK.  I guess I could set up something to monitor the database
activity.

>
> http://www.djangobook.com/en/2.0/chapter14/
>
> > The long version:
>
> > i have an application that makes heavy use ofAJAX.  When a user
> > changes something on the page, the page fires anAJAXPOST to apply
> > the changes to the database, then a series ofAJAXGETs to refresh
> > other portions of the page.
>
> You say, "then a series ofAJAXGETs" but when is "then"? Presumably
> in the post's callback function? Because otherwise you have no
> guarantee that the POST completes before the GETs fire.

The query is fired from jQuery, and here's my code.  (I realize this
is getting a little far from being Django-specific)

  $.ajax({url: "/hold_time_cost/" ,
  data: {tran_num : $(this).attr('tran_num'),
 value : checked,
 file_number : file_number},
  type: "POST",
  async: false,
  cache: false,
  complete: function(request, status) {
get_unbilled_costs(file_number);
get_held_costs(file_number);
  }
});

>
>
> > Some of the GETs are expensive, so I have some process_response()
> > middleware that caches the HTML generated by the GET in the Django
> > session.  (It's the standard database session store.)  I also have
> > some process_request() middleware that either returns the cached HTML
> > if it can, or invalidates the cache on any POST.
>
> > Just to add to the fun, I have a four identical Django/mod_wsgi
> > instances running behind a round-robin load balancer.  So the POST
> > request might get handled by Django1, the first GET by Django2, the
> > second GET by Django3, and so on.
>
> > My problem is that sometimes the results of the POST are not visible
> > in the results of the GET.  The problem is intermittent, which is
> > leading me to point the finger at my cacheing strategy.  My assumption
> > was that Django would reload the session from the database every time
> > before starting my view code, but I'm wondering if that is not true
> > (or if there is some other issue that I'm not thinking about).
>
> Yes, your caching seems a likely culprit, and so does the asynchronous
> nature of youAJAX(but it seems like you've got a handle on that
> part). I haven't thought through the load balancer bit yet, but
> presumably they are all using the same cache / database / session
> store..?

I'm wondering if maybe I should futz with using the
django.contrib.sessions.backends.cached_db for a session engine.

>
> --Stuart

-- Chris

-- 
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: Why when upload PDFs, Django says the content type is "application/text"?

2011-12-25 Thread Chris Seberino


On Dec 25, 7:53 am, Ivo Brodien  wrote:
> > I was getting "application/pdf" a few days ago with same client,
> > server, browser, etc.
>
> If this really is the case and the code is exactly the same, maybe it depends 
> somehow on the PDF itself? Did you check that?

I used the Linux/Unix file command on the file to confirm it is a PDF
file!

I'm at a loss as to why client thinks it is application/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.



Advice/tips on how make private directory for each user?

2011-12-25 Thread Chris Seberino
I want some files to only be accessible by certain users.

For example, imagine a teacher wanting to distribute graded exams on a
Django server w/o violating any student's privacy.

Is there an easy way to do this?I am aware of the access control
decorator for specific views but not for specific static
directories.

cs

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



Why when upload PDFs, Django says the content type is "application/text"?

2011-12-24 Thread Chris Seberino
I printed the content_type of an uploaded file in Django and noticed
that for PDFs I was getting
"application/text"?

I was getting "application/pdf" a few days ago with same client,
server, browser, etc.

Anyone know what would cause content type to show wrong kind for PDFs?

cs

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



am I understanding sessions correctly?

2011-12-22 Thread Chris Curvey
The short version:  when processing a request, does Django *always*
collect session information from the session store before starting the
view?

The long version:

i have an application that makes heavy use of AJAX.  When a user
changes something on the page, the page fires an AJAX POST to apply
the changes to the database, then a series of AJAX GETs to refresh
other portions of the page.

Some of the GETs are expensive, so I have some process_response()
middleware that caches the HTML generated by the GET in the Django
session.  (It's the standard database session store.)  I also have
some process_request() middleware that either returns the cached HTML
if it can, or invalidates the cache on any POST.

Just to add to the fun, I have a four identical Django/mod_wsgi
instances running behind a round-robin load balancer.  So the POST
request might get handled by Django1, the first GET by Django2, the
second GET by Django3, and so on.

My problem is that sometimes the results of the POST are not visible
in the results of the GET.  The problem is intermittent, which is
leading me to point the finger at my cacheing strategy.  My assumption
was that Django would reload the session from the database every time
before starting my view code, but I'm wondering if that is not true
(or if there is some other issue that I'm not thinking about).

-- 
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: disabling south for running tests

2011-11-26 Thread Chris Northwood
On 25 November 2011 23:59, Gelonida N <gelon...@gmail.com> wrote:
> Hi,
>
> As for testing the database is created from scratch and as migrations
> are not really needed in this case I decided to disable south for
> running tests.
>
> I just wondered whether there were alternative /  more elegant ways.

There's a setting built into South which does this:
SOUTH_TESTS_MIGRATE
[http://south.aeracode.org/docs/settings.html#south-tests-migrate]

Regards,

Chris Northwood

-- 
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: How to trace the raw executed sql in Django

2011-11-18 Thread Chris Northwood
>>> On Fri, Nov 18, 2011 at 8:20 AM, Kayode Odeyemi <drey...@gmail.com> wrote:
>>> > Hello friends,
>>> >
>>> > I'm having a deep Django-MySQLDB error and I'm doing some debugging to
>>> > trace exactly where the problem is. It seems to me that this is very
>>> > related
>>> > to MySQLDB
>>> > cursor implementaton.
>>> >
>>> > What I want to do is to run the raw sql from the interactive mode like
>>> > this:
>>> >
>>> > import MySQLdb
>>> > db=MySQLdb.connect(passwd="pass",db="dname")
>>> > c=db.cursor()
>>> > max_price=5
>>> > c.execute(RAW_SQL_HERE)

Why not execute the SQL using Django, as documented here?
https://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly

Chris

-- 
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: Why can't "directly" change array elements of model objects in Django shell?

2011-10-07 Thread Chris Seberino


On Oct 7, 10:39 am, Jacob Kaplan-Moss <ja...@jacobian.org> wrote:
> On Fri, Oct 7, 2011 at 10:30 AM, Chris Seberino <cseber...@gmail.com> wrote:
>
> > I've noticed that this doesn't often work in Django shell...
>
> > x = MyModel.objects.all()
> > x[3].some_field = "new value"
> > x[3].save()

> This is because `MyModel.objects.all()` isn't a list; it's a QuerySet.
> That is, `MyModel.objects.all()` *doesn't* hit the database until you
> say `x[3]`, at which point Django performs a query with a LIMIT and

OK.  I understand.  What is easiest way then to *force* my x[3] code
above to hit the database so that
my changes are permanent?

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



Why can't "directly" change array elements of model objects in Django shell?

2011-10-07 Thread Chris Seberino

I've noticed that this doesn't often work in Django shell...

x = MyModel.objects.all()
x[3].some_field = "new value"
x[3].save()

Rather, I must often do this...

temp = x[3]
temp.some_field = "new value"
temp.save()

*Sometimes* the first works and I don't know why.

Please advise.

Chris

-- 
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: Beginner a bit lost - need some pointers please

2011-10-07 Thread Chris G
On Fri, Oct 07, 2011 at 11:40:03AM +0100, Chris G wrote:
> On Fri, Oct 07, 2011 at 11:47:49AM +0530, kenneth gonsalves wrote:
> > On Thu, 2011-10-06 at 10:00 +0100, Chris G wrote:
> > > > this is as simple as it gets
> > > > https://bitbucket.org/lawgon/django-addition/overview
> > > 
> > > Too simple for me, it doesn't run.
> > > 
> > > chris$ python manage.py runserver
> > > Error: No module named addition.addnums 
> > 
> > you did not follow the instructions here:
> > 
> > https://bitbucket.org/lawgon/django-addition/wiki/Home
> 
> Ah, OK, I did look around for some instructions but didn't find them. 
> Thank you, I'll go and play some further!  :-)
> 
Actually my only real problem was that I hadn't renamed django-addition
to addition.  :-)

-- 
Chris Green

-- 
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 question (I hope)

2011-10-07 Thread Chris Czub
Shawn -- what do you recommend instead? A friend and I recently had
this debate. His suggestion was to split off as much behavior into
smaller apps with only a handful of models in the models.py as
possible, but I said that if it's not reusable, it shouldn't be an
app. I still haven't found a solution for organizing large-scale
Django app model structures that I'm happy with.

On Fri, Oct 7, 2011 at 10:43 AM, Shawn Milochik  wrote:
> Make as many files as you want, and make sure you import their classes in
> models.py so they get picked up by syncdb.
> Normally, to do something like this you'd replace the file (in this case
> models.py) with a folder named 'models' containing a file called
> __init__.py, and import all the additional files' models in __init__.py.
> However, there's some "magic" in Django that doesn't consider a folder a
> "Django app" unless it contains a file named models.py.
> Also, I recommend you don't do any of the above, because as soon as you
> start doing things like creating foreign keys and many-to-many relationships
> you're going to have a horrific mess, and probably circular imports.
>
> --
> 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: Beginner a bit lost - need some pointers please

2011-10-07 Thread Chris G
On Fri, Oct 07, 2011 at 11:47:49AM +0530, kenneth gonsalves wrote:
> On Thu, 2011-10-06 at 10:00 +0100, Chris G wrote:
> > > this is as simple as it gets
> > > https://bitbucket.org/lawgon/django-addition/overview
> > 
> > Too simple for me, it doesn't run.
> > 
> > chris$ python manage.py runserver
> > Error: No module named addition.addnums 
> 
> you did not follow the instructions here:
> 
> https://bitbucket.org/lawgon/django-addition/wiki/Home

Ah, OK, I did look around for some instructions but didn't find them. 
Thank you, I'll go and play some further!  :-)

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 10:09:05AM +0100, Cal Leeming [Simplicity Media Ltd] 
wrote:
>    Chris -
>The only thing I can say, is that you've been given some really good
>advice on this thread so far.

Yes, I'm not complaining at all, the feedback has all been very helpful.
I'm just rather impatient when I start trying to use something new.  :-)

So, thank you everyone who has replied, I do appreciate all the help.

 and I will continue through the tutorials.  :-)

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 01:14:37AM -0700, Daniel Roseman wrote:
>  On Wednesday, 5 October 2011 20:55:33 UTC+1, Chris Green wrote:
> 
>  I'm an experienced programmer (started around 1971 or so!) and I've done
>  lots of things over the years, much of my background is in Unix
>  (Solaris).
>  In the last few years I have done quite a lot of web related stuff.
> 
>  I'm trying to get my mind round django.  I have it installed on my
>  unbuntu server, it works, I've worked through tutorials 1 and 2 and a
>  bit of 3.  I can get the admin screens up and the basics of the polls
>  example work.
> 
>  However two rather basic things still elude me:-
> 
>  Where/how do I actually start creating the top level/page of a web
>  site?   Do I just open vi and create some HTML and embed django
>  code?  That seems unlikely but I can't see anywhere that tells me
>  what the code that creates a django site looks like and/or where it
>  resides.   An actual example of a two or three page working django
>  based web site would be a huge help.
> 
>You *really* need to do the tutorial. If you think that "creating HTML and
>embedding Django code" is how it works, then you haven't read it. That's
>not how it works at all.

I was semi joking, I realise that this *isn't* how it works but so far
I'm not at all clear how it does work.

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 11:01:13AM +0530, kenneth gonsalves wrote:
> On Wed, 2011-10-05 at 23:02 +0100, Chris G wrote:
> > OK, so there isn't a single simple answer.  However it would still be
> > really nice to see a complete two or three page django site with a
> > database behind it fully implemented as an example.
> > 
> > 
> 
> this is as simple as it gets
> https://bitbucket.org/lawgon/django-addition/overview

Too simple for me, it doesn't run.

chris$ python manage.py runserver
Error: No module named addition.addnums
chris$ 

My own working through the tutorial does though:-

chris$ python manage.py runserver
Validating models...
0 errors found

Django version 1.2.3, using settings 'djdb1.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.


-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 04:35:49PM -0400, Peter Herndon wrote:
> 
> On Oct 5, 2011, at 3:55 PM, Chris G wrote:
> > 
> > However two rather basic things still elude me:-
> > 
> >Where/how do I actually start creating the top level/page of a web
> >site?   Do I just open vi and create some HTML and embed django
> >code?  That seems unlikely but I can't see anywhere that tells me
> >what the code that creates a django site looks like and/or where it
> >resides.   An actual example of a two or three page working django
> >based web site would be a huge help.
> 
> I've seen a few different patterns in regards to this question. One scenario 
> is where you have a multi-purpose Django site comprised of multiple reusable 
> apps with no obvious top-level entry point, you can create a view "def 
> index(request)", and have it render a template with whatever data you want to 
> send it -- including perhaps no data at all. Then map your index view to '/' 
> in urls.py at the project level, put together a template and you're all set.
> 
> Another option I've seen is if you have a single-purpose site where one app 
> is primary, you map your primary app's start page as your index. An example 
> would be a blog, and you would set up your chronological entries list page as 
> the index.
> 
OK, so there isn't a single simple answer.  However it would still be
really nice to see a complete two or three page django site with a
database behind it fully implemented as an example.

> 
> > 
> >I can't see anywhere that seems to tell me the issues involved with
> >moving from using the built in web server to using apache2 (or
> >whatever, I have apache2 on my system).
> 
> The short version is that the built-in server was built as a 
> just-good-enough-to-use-while-developing solution, and is not sufficient to 
> handle more than a minimal load. The trade-off is that configuring apache2 + 
> mod_wsgi, or nginx + gunicorn, is more complex than just running the 
> devserver.
> 
Sorry, I maybe didn't explain well what I wanted.  I realise that
configuring apache2 to do all this involves more work, what I wanted was
the steps required to go from a working django project under the
built-in server to one that works under apache2.

Someone else has pointed me at 
https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
though which seems to be what I need.

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 03:02:13PM -0500, Javier Guerra Giraldez wrote:
> On Wed, Oct 5, 2011 at 2:55 PM, Chris G <c...@isbd.net> wrote:
> > I'm trying to get my mind round django.  I have it installed on my
> > unbuntu server, it works, I've worked through tutorials 1 and 2 and a
> > bit of 3.  I can get the admin screens up and the basics of the polls
> > example work.
> 
> just finish the tutorial.  seriously, even if you're so experienced,
> it's a much needed introduction.
> 
> about how to write, check the paragraph about the MTV architecture:
> model, view template.  in short, that means: write your models with
> most of the conceptual functionality; then write a view that gathers
> all needed info from the models and calls a template to show it as a
> web page.  templates should have very minimal 'code' embedded, just to
> display the data gathered by the view.
> 
> but please, do the tutorial.
> 
OK, I'll work through the rest of it, thanks.

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 08:58:10PM +0100, Cal Leeming [Simplicity Media Ltd] 
wrote:
>Hi Chris,
>I'm assuming that you don't have any experience with Python??

No/yes, I *do* have Python experience, it's my language of choice for
scripts which require a bit more than basic shell scripting.


>Also - have you read the intro overview, as that pretty much answers your
>questions, unless I'm missing something
>[1]https://docs.djangoproject.com/en/1.3/intro/overview/
>Cal
> 
I've looked at that, but maybe not hard enough.  A quick glance seems to
raise some of the same questions, there are lots of code snippets in
there but it's not *very* clear where they all live or even whether one
has to write them or they're generated by django.  It does seem a bit
clearer at a second reading though so I suspect it will all become clear
eventually. 

-- 
Chris Green

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



Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
I'm an experienced programmer (started around 1971 or so!) and I've done
lots of things over the years, much of my background is in Unix (Solaris).
In the last few years I have done quite a lot of web related stuff.

I'm trying to get my mind round django.  I have it installed on my
unbuntu server, it works, I've worked through tutorials 1 and 2 and a
bit of 3.  I can get the admin screens up and the basics of the polls
example work.

However two rather basic things still elude me:-

Where/how do I actually start creating the top level/page of a web
site?   Do I just open vi and create some HTML and embed django
code?  That seems unlikely but I can't see anywhere that tells me
what the code that creates a django site looks like and/or where it
resides.   An actual example of a two or three page working django
based web site would be a huge help.

I can't see anywhere that seems to tell me the issues involved with
moving from using the built in web server to using apache2 (or
whatever, I have apache2 on my system).

I know that in a few days time when I have got over the initial hump all
the above will seem trivial so sorry to ask, but at the moment I'm
feeling a bit lost!  :-)

-- 
Chris Green

-- 
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: Simple input forms which show more than one row - easy/possible in django?

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 03:13:08PM +, Brett Epps wrote:
> Hi Chris,
> 
> Once you've defined a model for your data, you can use a ModelForm [1] to
> automatically generate a form for that model.
> 
> You might also want to check out the admin site [2], which displays data
> in a tabular format similar to what you describe.
> 
Yes, I'd seen that, can I get the admin forms to work 'outside' as it
were? 

> 1. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
> 2. https://docs.djangoproject.com/en/dev/ref/contrib/admin/
> 
Thanks, it looks as if ModelForm will do most of what I want.

-- 
Chris Green

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



Simple input forms which show more than one row - easy/possible in django?

2011-10-05 Thread Chris G
I want to create a simple data entry form on a web page that shows all
the columns of a database across the page (there aren't many columns,
they will fit!) and a number of rows down the page.

I.e. I want a data entry form that looks like MS Access 'tabular'
format, as follows:-

Col1Row1Col2Row1Col3Row1Col4Row1Col5Row1
Col1Row2Col2Row2Col3Row2Col4Row2Col5Row2
Col1Row3Col2Row3Col3Row3Col4Row3Col5Row3
Col1Row4Col2Row4Col3Row4Col4Row4Col5Row4
Col1Row5Col2Row5Col3Row5Col4Row5Col5Row5
Col1Row6Col2Row6Col3Row6Col4Row6Col5Row6
New DataNew DataNew DataNew DataNew Data


Can django do this easily in a 'ready made' sort of way or do I have to
actually create the form and all its fields?

-- 
Chris Green

-- 
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: 3rd party Apps in Django

2011-08-15 Thread Chris Lawlor
+1 for using virtualenv. Indispensable for working on more than one dingo 
project on the same development machine. If you're developing on Linux or Mac, 
take a look at virtualenvwrapper. It makes working with virtual environments 
practically painless.

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



Django 1.3 admin added methods login requirement

2011-08-12 Thread Chris Fraschetti
I believe that in earlier versions of django if you added a view
method to an admin, and extended the get_urls method that because it
was under the admin it would automatically require at least a log in
(user.is_authenticated()=True.  I have been working with Django 1.3
and have noticed that this is no longer the case?  Has anyone
experienced this and is there a solution such as a decorator to use
since login_required will not work with methods.

-- 
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: How control access to static pages that are *not* part of a Django app?

2011-08-01 Thread Chris Seberino


On Aug 1, 7:11 am, DrBloodmoney  wrote:
> You can look into protecting them with mod_xsendfile for Apache

Thanks.  I'll look into that.  Is there no way to have a view hand off
a page to Apache?
If there was, I could have a view that was password protected and only
when I was in the view would I allow the apache page to be served.

Alternatively, the view could simply load a static file and present
that I suppose somehow.  Not sure.

cs

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



How control access to static pages that are *not* part of a Django app?

2011-07-31 Thread Chris Seberino
My Django app only allows someone to access a /books page, that is
part of the Django app, if they are signed in.

The pages below that URL are just static directory listings of PDFs
all handled by Apache.
For example /books/book_1, /books/book_2, etc.

Because these directory listings aren't handled by Django, they don't
enjoy Django's access controls.  They don't even have a view since
they are just static pages handled by Apache.

Is there any way to somehow prevent access to them unless someone is
signed into my Django app?

chris

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



Help selecting info from across databases in queries.

2011-06-24 Thread Chris McComas
Here are my models:

http://dpaste.com/558411/

I'm wanting to run a query on the Team model that gets every game from
Games where the team's opponent was in the Coaches Poll Top 25.

So, the view is getting:

team = Team.objects.get(pk=team_id)

On this page, it'll display team info (I cut out location, and more
fields in the Team model that are just kind of fluff info), then I
want to display below that every game from the Games table where the
the team played an opponent who has an entry in TeamInfo.coaches that
is less than, or equal to, 25.

I can get all the teams games by:

games = Games.objects.filter( Q(team1__team__team=team) |
Q(team2__team__team=team))

I just don't know how to get the stuff from TeamInfo that I need.
Should I restructure my models?

-- 
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 distinct and ordering

2011-06-24 Thread Chris Matthews
Hi,

I had a problem with using distinct() which was not so distinct. It was because 
I did not specify an order_by() and the underlying ordering column on the model 
was in values().

It also selects my ordering column (SQL needs it for the ordering) and the SQL 
DISTINCT is applied at row level.

It might be unfortunate that Django does not implement distinct(column/s).

Note that Postgres has this constraint: ERROR: SELECT DISTINCT ON expressions 
must match initial ORDER BY expressions.

It would actually be nice if:
  I could select values('town_name', 'province__country__name', 
'province__name').distinct('town_name').
  Then the distinct('town_name') should generate a SQL DISTINCT ON (town_name) 
town_name.
  The generated SQL should also drop the model ordering if the values(column/s) 
and ordering column/s do not match (because of the SQL constraint).

I am not sure if the other databases supports this.

Here is my model & query (we use Postal Code not Zip Code):

class Postal_Code(AbstractCommonAll):
suburb   = models.CharField()
box_code = models.CharField()
street_code  = models.CharField()
town_name= models.CharField()
province = models.ForeignKey(Province)

class Meta:
ordering = ("suburb",)

For brevity I have left out models: Province (which has ForeignKey to Country).

And my statement was:
self.filter(town_name__istartswith='Randfo').values('town_name').distinct() 
- returns multiple rows 'cos it selects suburb for the ordering.


self.filter(town_name__istartswith='Randfo').values('town_name').distinct().order_by('town_name')
 - works 'cos it's the correct way if you use ordering on another column.

self.filter(town_name__istartswith='Randfo').values('town_name').distinct().order_by()
 - this works as I would have expected 'cos it drops the SQL ORDER BY.

So it would be nice to do this:
self.filter(town_name__istartswith='Randfo').values('town_name', 
'province__country__name', 'province__name').distinct('town_name')

Regards

Chris Matthews


-- 
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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-06-23 Thread Chris Calitz
Sounds really cool. I'm definitely in. 

On 22 Jun 2011, at 14:16, "Cal Leeming [Simplicity Media Ltd]" 
 wrote:

> Hi all,
> 
> Some of you may have noticed, in the last few months I've done quite a few 
> posts/snippets about handling large data sets in Django. At the end of this 
> month (after what seems like a lifetime of trial and error), we're finally 
> going to be releasing a new site which holds around 40mil+ rows of data, 
> grows by about 300-500k rows each day, handles 5GB of uploads per day, and 
> can handle around 1024 requests per second on stress test on a moderately 
> spec'd server.
> 
> As the entire thing is written in Django (and a bunch of other open source 
> products), I'd really like to give something back to the community. (stack 
> incls Celery/RabbitMQ/Sphinx SE/PYQuery/Percona 
> MySQL/NGINX/supervisord/debian etc)
> 
> Therefore, I'd like to see if there would be any interest in webcast in which 
> I would explain how we handle such large amounts of data, the trial and error 
> processes we went through, some really neat tricks we've done to avoid 
> bottlenecks, our own approach to smart content filtering, and some of the 
> valuable lessons we have learned. The webcast would be completely free of 
> charge, last a couple of hours (with a short break) and anyone can attend. 
> I'd also offer up a Q session at the end.
> 
> If you're interested, please reply on-list so others can see.
> 
> Thanks
> 
> Cal
> -- 
> 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: Help with Templates and ljust

2011-06-17 Thread Chris McComas
Figured it out. Added this to my Model:

@property
def spacer(self):
return (25-len(str(self.team.name)))*' '

then in my template just added {{ team.spacer }}



On Jun 17, 7:17 pm, Chris McComas <mccomas.ch...@gmail.com> wrote:
> I have this as my template code:
>
> http://dpaste.com/555651/
>
> This is the HTML it is outputting, which makes sense. What I'm trying
> to do is make it so the closing  tag is right after the team name
> and the whitespace from the ljust after it.
>
> http://dpaste.com/555649/

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



Help with Templates and ljust

2011-06-17 Thread Chris McComas
I have this as my template code:

http://dpaste.com/555651/

This is the HTML it is outputting, which makes sense. What I'm trying
to do is make it so the closing  tag is right after the team name
and the whitespace from the ljust after it.

http://dpaste.com/555649/

-- 
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: Unsafe to continue Django session unencrypted? (i.e. login with HTTPS then drop to HTTP after that?)

2011-06-14 Thread Chris Seberino

On Jun 14, 10:47 am, Tom Evans  wrote:
> Yes, of course it is - HTTP is stateless, so how else would sessions
> work if the session id is not transmitted back to the server by the
> browser?

I agree.  Yet, eBay, Google Groups & Godaddy drop down to HTTP after
login.
Why aren't they worred?

cs

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



Unsafe to continue Django session unencrypted? (i.e. login with HTTPS then drop to HTTP after that?)

2011-06-14 Thread Chris Seberino
I have Apache in front of my Django app.  It forces login pages to use
HTTPS but then forces rest of pages to only use HTTP.

Is client browser sending sensitive login or session info in the clear
when I am not using HTTPS?

My nonencrypted pages don't present or ask for sensitive info.  The
only danger would be if sensitive info is being sent behind the scenes
I didn't program myself.

cs

-- 
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: python + BDD (Behaviour)

2011-06-13 Thread Chris Czub
I've had good luck with Lettuce. It's very similar to Cucumber(the
test format is the same) so you should be able to jump right in. The
terrain features they offer are really useful as well.

On Sat, Jun 11, 2011 at 8:58 PM, Mark Curphey  wrote:
> Thanks. Do most Python folks generally use Selenium ?
>
> On Jun 11, 2011, at 12:59 PM, Xavier Ordoquy wrote:
>
>>
>> Le 11 juin 2011 à 21:27, Mark Curphey a écrit :
>>
>>> Similar question: I was looking to see if there is a Python equivalents to 
>>> Cucumber and Capybara ?
>>>
>>> On Jun 11, 2011, at 11:27 AM, Guilherme Silveira Elias wrote:
>>
>> Hi,
>>
>> You can use freshen or lettuce for that.
>> Lettuce has some nice documentation on lettuce.it
>> Freshen seems a bit stalled for now, I currently use this branch: 
>> https://github.com/oesmith/freshen
>>
>> Regards,
>> Xavier.
>>
>> --
>> 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.



Feed Parser, Community Aggregator, Date and Time settings

2011-06-12 Thread Chris McComas
I'm using the Django community aggregator on my site, which uses the
Universal Feed Parser to parse RSS feeds and save them in a database.

I noticed that the date_modified for feeds were actually +5 of my
timezone, which is set to America/Detroit in my Django settings. I'm
on DotCloud and unfortunately I'm not able to set any Environment
Variables (yet, they say they're working on that) and the default
timezone on there is UTC.

I don't mind that the field is saved in the database in the UTC
timezone, that's probably best. What I need to do, and have fought for
two days to do is convert it to Eastern Timezone when displayed on the
site. Also, I use the timesince template tag on a couple pages that
need to do a time since now to the feed item's date_modified both in
Eastern Timezone.

Any ideas? Suggestions?

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



Help with Multiple Databases Master/Slave

2011-06-11 Thread Chris McComas
I have this database setup:

http://dpaste.com/553289/

This is my db router file:

http://dpaste.com/553290/

When I try to run ./manage.py syncdb --database=slave1 it starts to
create the tables, but when it gets to the auth_permission table I get
this error:

django.db.utils.IntegrityError: duplicate key value violates unique
constraint "auth_permission_content_type_id_codename_key"
DETAIL:  Key (content_type_id, codename)=(19, add_registrationprofile)
already exists.

I looked in my master db and there is only one entry for the one
that's throwing the error. Any ideas what I can do? I have the django-
registration app installed and that's where the permission is coming
from.

-- 
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: Help with custom model method for query

2011-06-10 Thread Chris McComas
Bruno,

Thanks. It wasn't exactly working properly, so I just had to
add .order_by('feed__feed_type__order_by') and it seems to be working
properly.




On Jun 10, 3:33 pm, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 10 juin, 17:23, Chris McComas <mccomas.ch...@gmail.com> wrote:
>
> > Sorry for the confusion, this is what I am trying to achieve. It's the
> > FeedType and then FeedItems whose feed (fk) has a (fk) to FeedType.
>
> > The HTML would be:
>
> > {% for feed_type in FeedType %}
> >         {{ feed_type.name
> >         
> >                 {% for FeedItem in Feed in FeedType %}
> >                         {{ feeditem.title }}
> >         
> > {% endfor %}
>
> Ok.
>
> Then you need to correct your view:
>
> # views.py
>
> def news(request, city_id):
>     city = get_object_or_404(City, pk=city_id)
>     feeditems =
> FeedItem.objects.filter(feed__city=city).select_related(depth=2)
>     return render_to_response(
>         "path/to/template.html",
>         dict(city=city, feeditems=feeditems)
>         )
>
> And then in your template:
>
> {% regroup feeditems by feed_type as feeditems_list %}
> 
>   {% for feed_type in feeditems_list %}
>   
>     {{ feed_type.grouper }}
>     
>       {% for entry in feed_type.list %}
>       {{ entry.title }}
>       {% endfor %}
>     
>   
>   {% endfor %}
> 
>
> Obviously untested code, but this should work or, at least, get you
> started.

-- 
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: Help with custom model method for query

2011-06-10 Thread Chris McComas
tethered my phone to my laptop to test it out...have this code in my
template:

{% regroup feeds by feed_type as feed_list %}
{% for feed_type in feed_list %}
{{ feed_type.grouper }}

{% for entry in feed_type.list %}
{{ entry.title }}
{% endfor %}
{% endfor %}

it does the first {% for %} loop perfectly, the second {% for %} loop
gets the Feed from the database for that FeedType, but I need it to
get FeedItems for Feed in FeedType

Thanks for any help

On Jun 10, 8:54 am, Chris McComas <mccomas.ch...@gmail.com> wrote:
> Thanks very much!
>
> The city is passed to the view as an argument.
>
> How would I run the regroup? I'm on the road and not around my laptop
> for a few hours.
>
> would it be:
>
> {% regroup feeds by type as feed_list %}
>         {% for type by feed_list %}
>                 {{ type.name }}
>                 
>                 {% for entry in feed.list %}
>                         {{ entry.title }}
>                 {% endfor %}
>                 
>         {% endfor %}
>
> On Jun 10, 6:21 am, bruno desthuilliers
>
>
>
>
>
>
>
> <bruno.desthuilli...@gmail.com> wrote:
> > On Jun 10, 6:13 am, Chris McComas <mccomas.ch...@gmail.com> wrote:
>
> > > I have this views.py and models.py:
>
> > >http://dpaste.com/552615/
>
> > > On the view what I want to do is display a list of all the feed types
> > > (News, Sports, etc general categories), then then below each of those
> > > feed type headings display the FeedItems for each feed for that city.
>
> > Which city ?
>
> > > Prior to adding the City model it was pretty easy, I was able to just
> > > do this in my template:
>
> > >http://dpaste.com/552616/
>
> > > Maybe it's because it's late and I'm out of coffee, but this is
> > > totally stumping me on how to do this best. Any help would be greatly
> > > appreciated!
>
> > Assuming the city is passed as an argument to the view (dummy code,
> > may have a few errors):
>
> > # views.py
>
> > def news(request, city_id):
> >     city = get_object_or_404(City, pk=city_id)
> >     feeds = Feed.objects.filter(city=city).select_related("type")
> >     return render_to_response(
> >         "path/to/template.html",
> >         dict(city=city, feeds=feeds)
> >         )
>
> > then in you template you just {% regroup %} feeds by 
> > type,cfhttps://docs.djangoproject.com/en/1.3/ref/templates/builtins/#regroup

-- 
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: Help with custom model method for query

2011-06-10 Thread Chris McComas
Thanks very much!

The city is passed to the view as an argument.

How would I run the regroup? I'm on the road and not around my laptop
for a few hours.

would it be:

{% regroup feeds by type as feed_list %}
{% for type by feed_list %}
{{ type.name }}

{% for entry in feed.list %}
{{ entry.title }}
{% endfor %}

{% endfor %}


On Jun 10, 6:21 am, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On Jun 10, 6:13 am, Chris McComas <mccomas.ch...@gmail.com> wrote:
>
> > I have this views.py and models.py:
>
> >http://dpaste.com/552615/
>
> > On the view what I want to do is display a list of all the feed types
> > (News, Sports, etc general categories), then then below each of those
> > feed type headings display the FeedItems for each feed for that city.
>
> Which city ?
>
> > Prior to adding the City model it was pretty easy, I was able to just
> > do this in my template:
>
> >http://dpaste.com/552616/
>
> > Maybe it's because it's late and I'm out of coffee, but this is
> > totally stumping me on how to do this best. Any help would be greatly
> > appreciated!
>
> Assuming the city is passed as an argument to the view (dummy code,
> may have a few errors):
>
> # views.py
>
> def news(request, city_id):
>     city = get_object_or_404(City, pk=city_id)
>     feeds = Feed.objects.filter(city=city).select_related("type")
>     return render_to_response(
>         "path/to/template.html",
>         dict(city=city, feeds=feeds)
>         )
>
> then in you template you just {% regroup %} feeds by 
> type,cfhttps://docs.djangoproject.com/en/1.3/ref/templates/builtins/#regroup

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



Help with custom model method for query

2011-06-09 Thread Chris McComas
I have this views.py and models.py:

http://dpaste.com/552615/

On the view what I want to do is display a list of all the feed types
(News, Sports, etc general categories), then then below each of those
feed type headings display the FeedItems for each feed for that city.

Prior to adding the City model it was pretty easy, I was able to just
do this in my template:

http://dpaste.com/552616/

Maybe it's because it's late and I'm out of coffee, but this is
totally stumping me on how to do this best. Any help would be greatly
appreciated!

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



Re: Parsing feeds that are imported

2011-06-08 Thread Chris McComas
Chris,

Thanks, the django community aggregator is built on top of the
Universal Feed Parser. I figured out the zip codes function of my app.

What I can't figure out is why when I add a m2m model to my
update_feeds.py does not work. As far as I can tell in the
update_feeds doesn't access the Feed model and save it anywhere.

On Jun 7, 10:34 am, Chris Lawlor <lawlor.ch...@gmail.com> wrote:
> I've not used the django community aggregator, so I'm making some
> assumptions about it's functionality. If that app were to emit a
> signal for each feed entry that it processed, it would be fairly
> simple to write a signal handler that would create the associations
> that you want. With this approach, you wouldn't need another cron job,
> your processing would be done at the same time as django community
> aggregator's.
>
> If you do need to do some manual feed parsing, you might try using the
> Universal Feed Parser python module:http://feedparser.org/. It's
> specifically designed for parsing RSS / Atom feeds, and so may be
> somewhat more useful than BeautifulSoup.
>
> On Jun 6, 10:59 pm, Chris McComas <mccomas.ch...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Also, using the update_feeds that's part of the Django Community
> > Aggregator worked initially, but I started over adding a m2m field on
> > the Feed model for Sites. I'll have several "sites" as part of the
> > Django app, like team1.mysite.com, team2.mysite.com, etc.
>
> > When I added that field to the models and tried to run the
> > update_feeds script it did nothing. It didn't import the feeds, didn't
> > throw an error, etc.
>
> > update_feeds:https://github.com/django/djangoproject.com/blob/master/django_websit...
> > my models:http://dpaste.com/551322/
>
> > Thanks,
>
> > On Jun 6, 4:55 pm, Chris McComas <mccomas.ch...@gmail.com> wrote:
>
> > > This could be the wrong place to ask (maybe a BeautifulSoup)
> > > question...
>
> > > I have a Django app that is based around the Django Community
> > > Aggregator, it gets feeds from various sites and displays them on my
> > > site. What I am wanting to do, if possible, is when it gets a feed if
> > > a certain zip code is the feed Title or Summary then I want to create
> > > a entry for that zipcode with that feed?
>
> > > I have a model for the zip codes, so the list to compare should be
> > > pulled from that. There'd be a cron that'd run to do this, so for
> > > example if one of the zip codes is 12345 and one of the feeds it gets
> > > on the hourly cron has 12345 in the summary, then it'd go to the model
> > > linking the two and create/save an entry.
>
> > > Here are the pertinent models:http://dpaste.com/551223/
>
> > > Thanks,

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



Re: VERY cheap django hosting?

2011-06-08 Thread Chris Lawlor
Always Data (http://www.alwaysdata.com) has a free plan, but it is
quite limited (you only get 10 MB disk space).

On Jun 8, 2:39 am, Maksymus007  wrote:
> megiteam.pl is 24PLN which is about 8usd a month:)
>
> Pozdrawiam, Maksymilian Pawlak
> 08-06-2011 08:30 użytkownik "raj"  napisał:> Hey guys,
> > Just wondering if you could give me some hosts that are very cheap for
> > django hosting? Is hostgator any good? I really don't know what to
> > look for in a host. A lot of people are recommending web faction, but
> > its around $9 bucks a month. I was looking in the $5 bucks a month
> > range. Any ideas? Thank you.
> > -Raj
>
> > --
> > 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: Parsing feeds that are imported

2011-06-07 Thread Chris Lawlor


I've not used the django community aggregator, so I'm making some
assumptions about it's functionality. If that app were to emit a
signal for each feed entry that it processed, it would be fairly
simple to write a signal handler that would create the associations
that you want. With this approach, you wouldn't need another cron job,
your processing would be done at the same time as django community
aggregator's.

If you do need to do some manual feed parsing, you might try using the
Universal Feed Parser python module: http://feedparser.org/. It's
specifically designed for parsing RSS / Atom feeds, and so may be
somewhat more useful than BeautifulSoup.

On Jun 6, 10:59 pm, Chris McComas <mccomas.ch...@gmail.com> wrote:
> Also, using the update_feeds that's part of the Django Community
> Aggregator worked initially, but I started over adding a m2m field on
> the Feed model for Sites. I'll have several "sites" as part of the
> Django app, like team1.mysite.com, team2.mysite.com, etc.
>
> When I added that field to the models and tried to run the
> update_feeds script it did nothing. It didn't import the feeds, didn't
> throw an error, etc.
>
> update_feeds:https://github.com/django/djangoproject.com/blob/master/django_websit...
> my models:http://dpaste.com/551322/
>
> Thanks,
>
> On Jun 6, 4:55 pm, Chris McComas <mccomas.ch...@gmail.com> wrote:
>
>
>
>
>
>
>
> > This could be the wrong place to ask (maybe a BeautifulSoup)
> > question...
>
> > I have a Django app that is based around the Django Community
> > Aggregator, it gets feeds from various sites and displays them on my
> > site. What I am wanting to do, if possible, is when it gets a feed if
> > a certain zip code is the feed Title or Summary then I want to create
> > a entry for that zipcode with that feed?
>
> > I have a model for the zip codes, so the list to compare should be
> > pulled from that. There'd be a cron that'd run to do this, so for
> > example if one of the zip codes is 12345 and one of the feeds it gets
> > on the hourly cron has 12345 in the summary, then it'd go to the model
> > linking the two and create/save an entry.
>
> > Here are the pertinent models:http://dpaste.com/551223/
>
> > Thanks,

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



Re: Parsing feeds that are imported

2011-06-06 Thread Chris McComas
Also, using the update_feeds that's part of the Django Community
Aggregator worked initially, but I started over adding a m2m field on
the Feed model for Sites. I'll have several "sites" as part of the
Django app, like team1.mysite.com, team2.mysite.com, etc.

When I added that field to the models and tried to run the
update_feeds script it did nothing. It didn't import the feeds, didn't
throw an error, etc.

update_feeds:
https://github.com/django/djangoproject.com/blob/master/django_website/aggregator/management/commands/update_feeds.py
my models: http://dpaste.com/551322/

Thanks,

On Jun 6, 4:55 pm, Chris McComas <mccomas.ch...@gmail.com> wrote:
> This could be the wrong place to ask (maybe a BeautifulSoup)
> question...
>
> I have a Django app that is based around the Django Community
> Aggregator, it gets feeds from various sites and displays them on my
> site. What I am wanting to do, if possible, is when it gets a feed if
> a certain zip code is the feed Title or Summary then I want to create
> a entry for that zipcode with that feed?
>
> I have a model for the zip codes, so the list to compare should be
> pulled from that. There'd be a cron that'd run to do this, so for
> example if one of the zip codes is 12345 and one of the feeds it gets
> on the hourly cron has 12345 in the summary, then it'd go to the model
> linking the two and create/save an entry.
>
> Here are the pertinent models:http://dpaste.com/551223/
>
> Thanks,

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



Parsing feeds that are imported

2011-06-06 Thread Chris McComas
This could be the wrong place to ask (maybe a BeautifulSoup)
question...

I have a Django app that is based around the Django Community
Aggregator, it gets feeds from various sites and displays them on my
site. What I am wanting to do, if possible, is when it gets a feed if
a certain zip code is the feed Title or Summary then I want to create
a entry for that zipcode with that feed?

I have a model for the zip codes, so the list to compare should be
pulled from that. There'd be a cron that'd run to do this, so for
example if one of the zip codes is 12345 and one of the feeds it gets
on the hourly cron has 12345 in the summary, then it'd go to the model
linking the two and create/save an entry.

Here are the pertinent models: http://dpaste.com/551223/

Thanks,

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



Re: Why errors when restart but goes away after reload again! How fix?

2011-05-22 Thread Chris Seberino
Mateusz

Thanks for the feedback.  Those docs you pointed to were about missing
views.  I checked and my views are not missing.

I looked more closely at the error message and noticed it appears to
be complaining that my models are missing.  I don't know if that
helps.  (see below)  Could it also be a cache problem somehow?  (I
tried clearing my browser cache and still saw the problem).

=
ViewDoesNotExist at /contact

Tried contact in module mvc.controllers.controllers. Error was:
'module' object has no attribute 'models'

Request Method: GET
Request URL:http://phil4.com/contact
Django Version: 1.2.3
Exception Type: ViewDoesNotExist
Exception Value:

Tried contact in module mvc.controllers.controllers. Error was:
'module' object has no attribute 'models'

...etc.
=

-- 
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: Why errors when restart but goes away after reload again! How fix?

2011-05-22 Thread Chris Seberino
On May 21, 6:35 pm, Mateusz Marzantowicz <mmarzantow...@gmail.com>
wrote:
> What server are you using? What is your configuration? Do you have mod_wsgi,
> mod_python or something else? What is your browser, OS, etc. Please do not
> let us guess.

I am using mod_wsgi which uses Apache 2.2.16
I use Firefox on Ubuntu Linux 10.10 (server and client both user this
Ubuntu version)

In my settings.py file I am loading sessions, CSRF and auth
middleware,

Tell me if there is any other info that would be relevant.

Maybe this is a mod_wsgi quirk?

Sincerely,

Chris

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



Why errors when restart but goes away after reload again! How fix?

2011-05-21 Thread Chris Seberino
When I restart my server, I get an error on the first page reload and
then all is fine on the second page reload!

The error is this...

--
ViewDoesNotExist at /blog

Tried blog in module mvc.controllers.controllers. Error was: 'module'
object has no attribute 'models'


I get a similar error not matter what page I try to view first after a
restart.
It goes away on the second reload always.

chris

-- 
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: failing to pass model objects to template for some reason....

2011-05-21 Thread Chris Seberino

On May 21, 5:22 am, Duane Griffin  wrote:
> Is the messaging framework configured (note that it is by default)?

Wow.  I thanks so much!  I never would have caught this!
I renamed Message to Annoucement and now it works!

cs

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



failing to pass model objects to template for some reason....

2011-05-20 Thread Chris Seberino
I have a model class called Message with an attribute called text.

** When I pass a list of these objects called messages to my template,
it doesn't show up.

** When I instead create this derivative called fred, that *does*
work...
 fred = [e.text for e in messages]

Why would fred work fine in template but not messages?


Here is my template code for messages that doesn't show anything on
page..

{% for e in messages %}
{{e.date}}: {{e.text}}
{% endfor %}


Here is the fred code that does work..
{% for e in fred %}
{{e}}
{% endfor %}

cs

-- 
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: weird error with MS Excel 2010 exports

2011-05-20 Thread chris hendrix

hi gabe -


response = 
render_to_response('reports/trackingdump.html',{'trs':trs,})

filename='trackingdump.xls'
response['Content-Disposition'] = 'attachment; filename=' + 
filename
response['Content-Type'] = 'application/vnd.ms-excel; 
charset=utf-8'



that's how we're dumping it to excel... it works fine in open office and 
non ms 2010 versions of excel.


On 05/20/2011 08:17 PM, Gabriel Gunderson wrote:

On Thu, May 19, 2011 at 1:44 PM, Bobby Roberts  wrote:

hi.  Regardless of how we try to export from a view into an excel
file, we get a weird msgbox reading:

"The file you are trying to open, 'filenamehere.xls', is in a
different format than specified by the file extension.  Verify that
the file is not corrupted and is from a trusted source before openin
gthe file.  Do you want to open the file now?"   YES  NO HELP"

What are you doing with your mime types?


Gabe



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



how transfer password hashes between old and new mysql databases for django app?

2011-05-18 Thread Chris Seberino
I am migrating my Django app from an old database to a new one with
DIFFERENT model classes.  How can I copy my passwords/hashes over?

Is there some special way to copy over the hash?  Is that even
possible?

A MySQL command line would be fine.

cs

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



Error when try to do ManyToMany relation with User class...

2011-05-17 Thread Chris Seberino
I have 3 classes that have a ManyToMany relation with the User class.

When I try to do syncdb I get this error

Error: One or more models did not validate:
mvc.course: 'users' has an m2m relation with model User, which has
either not been installed or is abstract.
mvc.homework: 'users' has an m2m relation with model User, which has
either not been installed or is abstract.
mvc.quiz: 'users' has an m2m relation with model User, which has
either not been installed or is abstract.

Not sure how to fix this or what means.

Chris

-- 
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: How change field to "unique" in existing mysql database?

2011-05-14 Thread Chris Seberino
Shawn

Thanks!  Is South just a script that runs?  Can I uninstall after the
conversion if desired?

Or, does it permanently alter a Django app somehow?

cs

On May 14, 10:53 pm, Shawn Milochik  wrote:
> The best way is to use South.
>
> http://south.aeracode.org/
>
> In your current situation, after you install South (pip install then add
> to INSTALLED_APPS, and syncdb to add the South table) you'll just have
> to do this:
>
>      1. manage.py convert_to_south appname #this will set up the basics,
> you'll only do this once
>
>      2. change your model #it should not have changed since the initial
> syncdb until this point
>
>      3. manage.py schemamigration appname name_your_migration --auto
> #create a South migration file
>
>      4. manage.py migrate #apply the South migration file
>
> In the future you'll only need to do steps 2 - 4.
>
> You can also do a datamigration so that, for example, you can do a
> schemamigration, move/change some data, then another schemamigration to
> clean up orphaned fields or whatever.
>
> There's also a south-users mailing list on Google Groups.
>
> Shawn

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



How change field to "unique" in existing mysql database?

2011-05-14 Thread Chris Seberino
I have a typical Django app using MySQL.

I've decided to change a model and make some fields unique=True
AFTER tables and data exist in MySQL.

I noticed that "python manage.py syncdb" doesn't automatically modify
MySQL
database to make desired fields unique now.

Is there some MySQL command line equivalent?
Preferably there is a way to do this from Django shell or other way?

Sincerely,

Chris

-- 
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: Best way to tell if we're in a test

2011-04-29 Thread Chris Czub
I think you might be taking the wrong approach. Rather than having your
application code checking whether or not it's in a test, have your testing
code disable/mock certain behaviors that you don't want exercised(like have
it always return that the user answered the security question correctly or
something).

Python's dynamic nature makes it easy to monkey patch things like this. Look
at the Mock class: http://python-mock.sourceforge.net/

On Fri, Apr 29, 2011 at 12:53 PM, Jody McIntyre wrote:

> What's the best way to tell (from regular code) if we're in a test?  I have
> added extra authentication steps (security questions) that would be
> difficult to deal with in tests where you just want to run
> self.client.login() or post to the login URL.  I've noticed that several
> third party modules, such as django-digest and django-bcrypt, also disable
> parts of their functionality during testing like this:
>
> from django.core import mail
>
> if hasattr(mail, 'outbox'):
> # we are under a test
> else:
> # not under a test
>
> This works, but it's an undocumented side effect so I'm worried it might
> change in a future version.  What's the correct way to tell if we're in a
> test?
>
> Thanks,
> Jody
>
> --
> 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: For any dictionary in a list, does a value exist for a key?

2011-04-19 Thread Chris Roat
Yep - trying to do it in a template.

I can just do the logic within in python - it'll mean redundant info going
into the template, but that's OK.

Thanks for your response,
C


On Mon, Apr 18, 2011 at 9:27 AM, Shawn Milochik  wrote:

> You can do this pretty easily in Python with any():
>
> if any(['foo' in x for x in my_list]):
>#do something
>
> However, I don't know of a way to do it in a template, which is what
> it appears you're asking.
>
> --
> 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: Inline Form Error After Upgrade to Django 1.3

2011-04-18 Thread Chris Spencer
Awesome, that was it. My old code now works again. Thanks!

Chris

On Mon, Apr 18, 2011 at 5:47 PM, akaariai <akaar...@gmail.com> wrote:

> On Apr 19, 12:17 am, Chris Spencer <chriss...@gmail.com> wrote:
> > Thanks. However, changing the line to:
> >
> > if not self.instance.state.adding:
> >
> > results in essentially the same error:
> >
> > AttributeError: 'MyModel' object has no attribute 'state'
>
> Doh, that should of course be ._state. Sorry for the mistake.
>
>  - Anssi
>
> --
> 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: Inline Form Error After Upgrade to Django 1.3

2011-04-18 Thread Chris Spencer
Thanks. However, changing the line to:

if not self.instance.state.adding:

results in essentially the same error:

AttributeError: 'MyModel' object has no attribute 'state'

On Mon, Apr 18, 2011 at 4:48 PM, akaariai <akaar...@gmail.com> wrote:

> On Apr 18, 11:08 pm, Chris <chriss...@gmail.com> wrote:
> > I have an inline form used in my admin that looks up the value for the
> > associated model, and dynamically selects the form field widget that's
> > appropriate for the data. The class looks like:
> >
> > class MyModelInlineForm(ModelForm):
> > attribute_model = ModelChoiceField(queryset=None)
> > def __init__(self,*args,**kwargs):
> > ...do stuff...
> >
> > if not self.instance._adding:
> > attribute = self.instance.attribute_model
> > self.fields['value'] =
> > get_form_field_for_attribute(attribute, self.instance)
> >
> > However, after upgrading to Django 1.3 from 1.2.3, viewing any admin
> > pages using this form throws the exception:
> >
> > AttributeError: 'MyModel' object has no attribute '_adding'
> >
> > I can't find any documentation on the instance._adding attribute, or
> > how it would have changed since 1.2.3. I've been digging through the
> > code, but I'm quite stuck. How do I resolve this?
>
> If I am not mistaken this attribute has been moved: instance._adding -
> > instance.state.adding. See django/db/models/base.py ModelState class
> and Model.__init__ method.
>
>  - Anssi
>
> --
> 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.



Inline Form Error After Upgrade to Django 1.3

2011-04-18 Thread Chris
I have an inline form used in my admin that looks up the value for the
associated model, and dynamically selects the form field widget that's
appropriate for the data. The class looks like:

class MyModelInlineForm(ModelForm):
attribute_model = ModelChoiceField(queryset=None)
def __init__(self,*args,**kwargs):
...do stuff...

if not self.instance._adding:
attribute = self.instance.attribute_model
self.fields['value'] =
get_form_field_for_attribute(attribute, self.instance)

However, after upgrading to Django 1.3 from 1.2.3, viewing any admin
pages using this form throws the exception:

AttributeError: 'MyModel' object has no attribute '_adding'

I can't find any documentation on the instance._adding attribute, or
how it would have changed since 1.2.3. I've been digging through the
code, but I'm quite stuck. How do I resolve this?

Regards,
Chris

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



For any dictionary in a list, does a value exist for a key?

2011-04-18 Thread Chris Roat
Does a function or construct exist to easily do the following?

my_list = [{'id': 'foo'}, {'id': 'bar', 'other': 'baz'}]
{% is my_id_value in my_list.id %}  // True if my_id_value is 'foo' or 'bar'

Thanks!




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



Re: satchmo currency

2011-04-15 Thread Chris Moffitt
First off, you'll probably get better responses on the Satchmo list.

Secondly, changing languages doesn't change currency symbols, which should
make sense. 1 Euro is not equal to 1 Dollar. If we were to change symbols,
we'd also need to do a currency conversion. It's not impossible by any means
just not something that is done out of the box.

-Chris

On Thu, Apr 14, 2011 at 11:31 PM, ug Charlie <ug.char...@gmail.com> wrote:

> Hello, I just make a satchmo shop. 3 languages.
>
> But the currency make me stuck.
>
> I just want the site change the currency when changing the language.
>
> In satchmo settings.py, it is like
>
> L10N_SETTINGS = {
>'currency_formats' : {
>'EURO' : {
>'symbol': u'€ ',
>'positive' : u"€ %(val)0.2f",
>'negative': u"€ (%(val)0.2f)",
>'decimal' : ','
>},
>'USD' : {
>'symbol': u'$ ',
>'positive' : u"$%(val)0.2f",
>'negative': u"$(%(val)0.2f)",
>'decimal' : ','
>},
>},
>'default_currency' : 'EURO',
>'show_admin_translations': True,
>'allow_translation_choice': True,
> }
>
> I do not really know how to do 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.



Re: How pass custom data to login template? (Seems only some like 'next' param are allowed!?)

2011-04-11 Thread Chris Seberino
Perhaps can wrap the default login view by calling it in my own view?
I really just need to add a few elements to dict I assume gets emitted
by it.

cs

On Apr 11, 5:00 am, bruno desthuilliers
 wrote:
> On 11 avr, 01:20, ChrisSeberino wrote:
>
> > How pass custom data to login template?  (Seems only some like 'next'
> > param are allowed!?)
>
> > The reason for this problem is the Django auth system doesn't ask user
> > to write the view for login page.
>
> django_auth provides a default "login" view, but you're free to
> provide your own.

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



How pass custom data to login template? (Seems only some like 'next' param are allowed!?)

2011-04-10 Thread Chris Seberino
How pass custom data to login template?  (Seems only some like 'next'
param are allowed!?)

The reason for this problem is the Django auth system doesn't ask user
to
write the view for login page.

cs

-- 
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: How adjust Django form input elements generated so they don't have "/>" at end and hence will VALIDATE?

2011-04-08 Thread Chris Seberino
Sorry n/m.  Apparently this is a long running discussion.  I just
found the
start of a big part of it...

http://groups.google.com/group/django-developers/browse_thread/thread/bbf75f0eeaf9fa64/59822bbce1e0be22?#59822bbce1e0be22

cs

On Apr 9, 12:08 am, Chris Seberino <cseber...@gmail.com> wrote:
> By the wayby "validate" I meant to say that I want it be be *valid
> HTML*.
>
> cs
>
> On Apr 9, 12:06 am, Chris Seberino <cseber...@gmail.com> wrote:
>
> > I'm using Django authentication for myhttp://phil4.com/sign_inpage.
>
> > You notice all the Django form input elements generated on that page
> > don't validate
> > (They have a "/>" at the end rather than just ">".)
>
> > How fix!?
>
> > cs

-- 
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: How adjust Django form input elements generated so they don't have "/>" at end and hence will VALIDATE?

2011-04-08 Thread Chris Seberino
By the wayby "validate" I meant to say that I want it be be *valid
HTML*.

cs

On Apr 9, 12:06 am, Chris Seberino <cseber...@gmail.com> wrote:
> I'm using Django authentication for myhttp://phil4.com/sign_inpage.
>
> You notice all the Django form input elements generated on that page
> don't validate
> (They have a "/>" at the end rather than just ">".)
>
> How fix!?
>
> cs

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



How adjust Django form input elements generated so they don't have "/>" at end and hence will VALIDATE?

2011-04-08 Thread Chris Seberino
I'm using Django authentication for my http://phil4.com/sign_in page.

You notice all the Django form input elements generated on that page
don't validate
(They have a "/>" at the end rather than just ">".)

How fix!?

cs

-- 
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: Django app for data management and visualization

2011-04-08 Thread Chris Matthews
Hi Marwan,

Another option that I'll investigate is Google Chart Tools / Image Charts (aka 
Chart API) see http://code.google.com/apis/chart/
Regards
Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Marwan Al-Sabbagh
Sent: 07 April 2011 09:59
To: django-users@googlegroups.com
Subject: Re: Django app for data management and visualization

Hi Chris,
  thanks so much for all the information and the links, Its really
helpful. I really like xlwt it's easy, fast, and powerful. I'll most
likely start with allowing the user to export a table of results to an
excel sheet where they can do whatever additional calculations,
formatting, or analysis they want.
  I'm very interested in dealing with charts and graphs but I must say
at this stage its more of a bonus then something our users are
demanding. I'll keep you guys updated on my progress and would love to
get all your feedback on the direction I'm taking and if it's
something that any of you can use on your projects. looking forward to
it.

cheers,
Marwan

On Thu, Apr 7, 2011 at 9:50 AM, Chris Matthews <ch...@bbd.co.za> wrote:
> Hi Marwan,
>
> I am considering an "Excel Export" button wherever I have a table (or 
> jQuery-UI grid).
>
> If you just want data sheets, before writing something, consider this:
> xlwt 0.7.2 Library to create spreadsheet files compatible with MS Excel 
> 97/2000/XP/2003 XLS files, on any platform, with Python 2.3 to 2.6
> http://pypi.python.org/pypi/xlwt
>
> Example (using xwlt) to do export_selected_objects 
> http://davidmburke.com/tag/django/
>
> Xwlt does not do graphs.
>
> There is probably a lot on graphs but I just saw this:
> http://www.gnuplot.info/ and then also a Python interface 
> http://gnuplot-py.sourceforge.net/
>
> Or
> http://sourceforge.net/projects/django-dataplot/
>
>
> For a interesting take on spreadsheets:
> Use Django and jQuery to create a spreadsheet application 
> http://www.ibm.com/developerworks/web/library/wa-django/?ca=drs-
>
> http://www.spreadsheetgear.com/ seemed cool but you net .Net and it will cost 
> you (not sure if it will save you some money).
>
> Regards
> Chris
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Marwan Al-Sabbagh
> Sent: 06 April 2011 16:59
> To: django-users@googlegroups.com
> Subject: Re: Django app for data management and visualization
>
> this sounds very interesting to me too. I'm working at a financial
> institution and I'm facing a similar challenge of allowing the users
> to generate ad hoc reports and export those reports to excel. I've
> already implemented this requirement in PHP and I'm in the process of
> migrating these reporting systems to django. I'm very interested to
> see how you plan to do excel exports. I'll also be righting a library
> within the next two months to do that, because I haven't found
> anything that meets our requirements. If it's something you are
> interested in please shoot me an email.
>  as far as importing data from excel sheets into a database check out
> www.python-excel.org and specifically their xlrd package that lets you
> read excel files and traverse the cells. You could use this to extract
> values and populate your database.
>
> Marwan
>
> On Tue, Apr 5, 2011 at 7:03 PM, Gianluca Riccardi
> <riccardi.gianl...@gmail.com> wrote:
>>
>>
>> On 5 Apr, 17:06, alessio c <viandant...@gmail.com> wrote:
>>> Ciao,
>>
>> ciao Alessio,
>>
>>>
>>> yes I do. I need more basic stuff then that and I need tables. Think of this
>>> as tentative to reduce Excel use (which is killing me).
>>>
>>> I can use matplotlib or openflash if I want to go really fancy. However, now
>>> I need to set up the framework. After that, I have a platform from which I
>>> can run all my scripts.
>>>
>>> Let's say I have a database with invoice data from different subsidiaries. I
>>> want to be able to: 1) create different views (subsidiary level, macro
>>> level, invoice level, first 10 invoice, first 10 customers, etc.); 2) upload
>>> data from different formats (because people are lazy and it is impossible to
>>> impose a single format); 3) allow some users to upload data (to avoid them
>>> to send me excel files by email, this is a huge feature...); 4) allow some
>>> other users (managers) to access and download online reports (tables and
>>> graphs).
>>>
>>> Theoretically, when I get this right I am hoping to start a project on git.
>>> The main idea is to create a shared reporting tool.
>>
>>

RE: Django app for data management and visualization

2011-04-07 Thread Chris Matthews
Hi Marwan,

I am considering an "Excel Export" button wherever I have a table (or jQuery-UI 
grid).

If you just want data sheets, before writing something, consider this:
xlwt 0.7.2 Library to create spreadsheet files compatible with MS Excel 
97/2000/XP/2003 XLS files, on any platform, with Python 2.3 to 2.6
http://pypi.python.org/pypi/xlwt

Example (using xwlt) to do export_selected_objects 
http://davidmburke.com/tag/django/

Xwlt does not do graphs.

There is probably a lot on graphs but I just saw this:
http://www.gnuplot.info/ and then also a Python interface 
http://gnuplot-py.sourceforge.net/

Or
http://sourceforge.net/projects/django-dataplot/


For a interesting take on spreadsheets:
Use Django and jQuery to create a spreadsheet application 
http://www.ibm.com/developerworks/web/library/wa-django/?ca=drs-

http://www.spreadsheetgear.com/ seemed cool but you net .Net and it will cost 
you (not sure if it will save you some money).

Regards
Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Marwan Al-Sabbagh
Sent: 06 April 2011 16:59
To: django-users@googlegroups.com
Subject: Re: Django app for data management and visualization

this sounds very interesting to me too. I'm working at a financial
institution and I'm facing a similar challenge of allowing the users
to generate ad hoc reports and export those reports to excel. I've
already implemented this requirement in PHP and I'm in the process of
migrating these reporting systems to django. I'm very interested to
see how you plan to do excel exports. I'll also be righting a library
within the next two months to do that, because I haven't found
anything that meets our requirements. If it's something you are
interested in please shoot me an email.
  as far as importing data from excel sheets into a database check out
www.python-excel.org and specifically their xlrd package that lets you
read excel files and traverse the cells. You could use this to extract
values and populate your database.

Marwan

On Tue, Apr 5, 2011 at 7:03 PM, Gianluca Riccardi
<riccardi.gianl...@gmail.com> wrote:
>
>
> On 5 Apr, 17:06, alessio c <viandant...@gmail.com> wrote:
>> Ciao,
>
> ciao Alessio,
>
>>
>> yes I do. I need more basic stuff then that and I need tables. Think of this
>> as tentative to reduce Excel use (which is killing me).
>>
>> I can use matplotlib or openflash if I want to go really fancy. However, now
>> I need to set up the framework. After that, I have a platform from which I
>> can run all my scripts.
>>
>> Let's say I have a database with invoice data from different subsidiaries. I
>> want to be able to: 1) create different views (subsidiary level, macro
>> level, invoice level, first 10 invoice, first 10 customers, etc.); 2) upload
>> data from different formats (because people are lazy and it is impossible to
>> impose a single format); 3) allow some users to upload data (to avoid them
>> to send me excel files by email, this is a huge feature...); 4) allow some
>> other users (managers) to access and download online reports (tables and
>> graphs).
>>
>> Theoretically, when I get this right I am hoping to start a project on git.
>> The main idea is to create a shared reporting tool.
>
> sounds like your going to have some fun ;) good luck, especially if
> you can get rid of dealing with spreadsheets and automate it I'm sure
> users will be happier(you at first;)
>
> if You start a public git repo i'd like to read your progresses
>
> regards,
> Gianluca Riccardi
>
> --
> 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: using a models fields

2011-04-05 Thread Chris Matthews
Hi Jay,

I am no Geo expert but if you use the CharField then you can specify N/E/S/W 
(North/East/South/West) or + and - to control latitude & longitude. With the 
DecimalField you can only use the + and -.

BTW, Marty Alchin's book Pro Django (Chapter 5 page 118), shows a nice example 
to validate user input for latitude & longitude. He actually use the 
DecimalField and extends it with a clean method, checking that latitude values 
to fall in -90 to 90 & longitude values to fall in -180 to 180.

Regards
Chris


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of bishwendu kundu
Sent: 05 April 2011 02:41
To: django-users@googlegroups.com
Subject: Re: using a models fields

You can try saving the data as 
latitude=models.DecimalField(max_digits=7,decimal_places=4).Same for the 
longitude field.Here the max_digits takes into account both decimal and 
non-decimal places.All the data can be given in string form as it will be 
automatically converted to proper format as specified in your models for 
storing in database. I guess you will be using some criteria to extract data 
from the database...so,code can look like

list_of_XYZ()=XYZ.objects.filter(criteria)
for i in list_of_XYZ:
i.latitude,i.longitude ,i.zoomlevel
On Tue, Apr 5, 2011 at 1:45 AM, jay K. 
<jay.developer2...@gmail.com<mailto:jay.developer2...@gmail.com>> wrote:
Hello,

I got a couple of fields from a model I want to use

so the models.py looks like this

class XZY():

   latitude = models.CharField()
   longitude = models.CharField(.)
   zoomlevel = models.CharField()

I want to retrieve the data inside latitude, longitude and zoomlevel
to be able to create a static map for different locations, using google maps

How can I retrieve the fields data?

thanks
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@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: Python Decorators

2011-04-05 Thread Chris Matthews
Hi cootetom,

For decorators you must have a look at the excellent articles/tutorials:
http://www.artima.com/weblogs/viewpost.jsp?thread=240808 
http://www.artima.com/weblogs/viewpost.jsp?thread=240845

It covers decorators with (what you want to do) and without parameters.
Regards
Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of cootetom
Sent: 04 April 2011 15:31
To: Django users
Subject: Python Decorators

Hi all, not exactly a django question but here goes... I'm trying to
implement a decorator with one positional argument and one keyword
argument. My wrapper function gets the positional argument just fine
but the keyword argument throws an error "NameError: name 'as_string'
is not defined."

Code is;

def widget(widget_switch, as_string=False):
def decorator(func):
def wrapper(*args, **kwargs):
# logic in here can access the value of 'widget_switch'
but 'as_string' is not defined?
return func(*args, **kwargs)
return wrapper
return decorator

So if I decorate a view function with "@widget('some_widget',
as_string=True)" then the wrapper function is unable to use
'as_string'. I thought this was how python closer worked?

Any ideas?

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



How dynamically set "next" parameter in login template to protected page tried to visit?

2011-04-02 Thread Chris Seberino
My views have the standard decorator to automatically bounce clients
to the login page if they are not logged in

@django.contrib.auth.decorators.login_required

I would like to dynamically set the hidden next parameter in the login
template to the aforementioned page they were trying to access.  That
way, after logging in they will automatically go to that page.

How do this?

Chris

-- 
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: How to check the text field values are in my database or not ?

2011-04-01 Thread Chris Matthews
Hi Nge,

Use pgAdmin that was installed with your postgresql. Open a connection to your 
database->Schema->Public->Tables. Right-click on your table and click on View 
data and then take one of the view options.

You can also open a SQL window and run the SQL select yourself. See pgAdmin's 
help.

Regards
Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Nge Nge
Sent: 01 April 2011 04:30
To: Django users
Subject: How to check the text field values are in my database or not ?

Hi All!

How can I check the text field value in my database ?
For example, I type user name and password from text box on my web
page. Then I want to check these values are in my database or not.
How should I do? I am using postgresql database.


Thanks
Nge Nge

-- 
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: authentication switching mid-session

2011-03-31 Thread Chris Curvey
there's no cacheing in front of the application server, if that's what 
you're asking.  The app server does do some cacheing on its own, but not 
related to sessions or users.

-- 
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: staticfile app question

2011-03-31 Thread Chris Matthews
Hi,
I liked this explanation/convention 
http://forum.webfaction.com/viewtopic.php?id=4345 (I opted for this one).

If you want more consider django-css 
https://github.com/dziegler/django-css#readme (I have not tried this).

Regards
Chris


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of typeshige
Sent: 31 March 2011 01:07
To: Django users
Subject: staticfile app question

Like many people, I'm switching over to use a static directory to
serve site media. Overall, it works extremely well, but I have a
question about one aspect of it.

I have a CSS file that includes urls. I was wondering about the
possibility of the staticfile app inserting the proper STATIC_URL as
it's being collected.

For example, things like:

#container-head {
background: transparent url('/static/img/bg/cap/head-inner-
bg.gif') 50% 0 no-repeat;
}

Would it be a bad idea to write like this:

#container-head {
background: transparent url('{{ STATIC_URL }}img/bg/cap/head-inner-
bg.gif') 50% 0 no-repeat;
}

the collectstatic command could insert the right url as it is being
copied?

-- 
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: multiline TextField

2011-03-31 Thread Chris Matthews
By using the Textarea widget:

class SomeForm(forms.Form):
description = forms.CharField(widget=forms.Textarea())

Regards
Chris


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of electrocoder
Sent: 31 March 2011 00:18
To: Django users
Subject: multiline TextField

Hi. I write blog application. I want multiline TextField.
Sample : paragraph or tab or return
thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
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: model manager and request

2011-03-31 Thread Chris Matthews
Hi,

1) My need for getting the current user is that I want the following columns on 
all tables: created, created_by, updated and updated_by.

So I defined this abstract class which I inherit from on all models:

class AbstractCommonAll(models.Model):
r''' All our tables will be defined with this class. We always want to know 
who
created it and when it was done. The same goes for who updated it and when 
it was done.

We could either have:
1 A char field for the user.
2 A foreign key to the user table.

If we take option 2 then we must define users for our batch jobs as well 
and all the queries
and updates will have to link to the user table. So let us just implement 
option 1 for now.
We can always change this at a later stage.
'''
created= models.DateTimeField(editable=False, help_text='When this row 
was created')
created_by = models.CharField(max_length=20, editable=False, help_text='Who 
created this row')
updated= models.DateTimeField(editable=False, help_text='When this row 
was updated')
updated_by = models.CharField(max_length=20, editable=False, help_text='Who 
updated this row')

class Meta:
abstract = True

def save(self):
if not self.id:
self.created = datetime.today()
self.created_by = 'user' # we should get this from 
request.User.username 
self.updated = datetime.today()
self.updated_by = 'user' # we should get this from request.User.username

super(AbstractCommonAll, self).save()

I am still going to implement getting the request.User.username as per ProJango 
by Marty Alchin Chapter 11 (page 253 onwards). I could do it in a view but then 
I still need it in the saves via admin. I should probably allocate a user for 
the batch programs and let them sign on so that they may have authenticated 
access and I suspect that I should make this batch user name available to 
AbstractCommonAll.save() because there will not be a request structure 
available.


2) For Audit/History records see the book ProJango by Marty Alchin Chapter 11 
(page 263 onwards) and 
http://qr7.com/2010/10/django-simple-history-ftw/ by Corey Bertram.
It handles the Historical records.

There is a possible error (depending upon your naming convention) when the 
indexes for the history tables are created:
sql_indexes_for_field() in 
/Python26/lib/site-packages/django/db/backends/creation.py creates the database 
index with name being model name + column name. This causes a problem for this 
implementation of history. 
The error is: Failed to install index for myapp.historical_Line model: relation 
" myapp_historical_line_type_id" already exists

It happens when the one modelname + foreignkey column name + '_id' is the same 
as the referenced modelname + '_id', as in the following example:

class Line_Type(models.Model):
name = models.CharField(max_length=50, unique=True)
description = models.CharField(max_length=100)

class Line(models.Model):
type= models.ForeignKey(Line_Type)


So the indexes created would be:
CREATE INDEX " myapp_historical_line*_type_id" ON " myapp_historical_line" 
("type_id");
CREATE INDEX " myapp_historical_line_type*_id" ON " 
myapp_historical_line_type" ("id");
 * is on the model/column name border.

To bypass this error I renamed my linked field (I thought that it would be more 
difficult to have sql_indexes_for_field changed [put a specified literal e.g. 
'_x_' between model & column names]) as follows:

class Line(models.Model):
line_type= models.ForeignKey(Line_Type)

(PS: I prefixed 'zz' to the history table names so that pgAdmin lists them at 
the end of, or after, the 'real' tables).

Regards
Chris


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Tony
Sent: 30 March 2011 22:27
To: Django users
Subject: Re: model manager and request

yeah, shawn said the exact dilemma I am having.  I am working with a
plugged in app and dont want to change its code and mess with its
views and create a new fork, it just seems like small thing to make a
change for (and I would probably mess something else up).

On Mar 30, 11:58 am, Shawn Milochik <sh...@milochik.com> wrote:
> Jacob,
>
> This sort of thing comes up so frequently on this list that we've all
> seen those answers dozens of times, although not usually in so concise
> a manner.
>
> My question, to which there seems to be no answer, is what a good
> approach to do something that I know (from spending a long time on
> this list) is also in high demand: Storing audit information.
>
> Simple requirement:
>     Store datetime.now(), request.user, and changes to a model
> automatically on post_save.
>
> Problem:
>     The "correct" solut

authentication switching mid-session

2011-03-30 Thread Chris Curvey
When my Django system is under heavy load (system CPU > 90%), I start
getting complaints from users that their authentication changes in the
middle of a session.  For example:

1) Bob logs in to the site.  The site says "Hello Bob" at the top of
each page.
2) Bob uses the site for a while without incident
3) Bob notices that the top of the page now says "Hello Steve".

The problem is intermittent, and I can't duplicate it (but I have seen
it with my own eyes).  I'm running Django 1.2.5 on Windows, with
SessionMiddleware installed.  I have django.contrib.sessions in my
INSTALLED_APPS, and I believe that I'm using database-backed sessions,
with a MySQL database.

The only "odd" thing that I'm doing is that I have four instances of
Apache running, with my Django app running via mod_wsgi in each of
them.  There is another apache server in front that does load-
balancing, so multiple requests from a single user may get routed to
different apache instances (which is what I want, to get maximum
throughput on Ajax calls).  But I thought that having the sessions be
database-backed would deal with this (multiple session requests can
hit the database at the same time).

Any thoughts?  I'm sorry this is such a lousy, unrepeatable case.

P.S.  I have looked at http://code.djangoproject.com/ticket/1180,
which says that this issue has been fixed, but I can't tell if this is
the same issue or not.

-- 
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: ANN: Django 1.3 released

2011-03-23 Thread Chris Matthews
Thanks it was.
Chrome consistently downloaded it with only 799,034 bytes. I used Windows 
Internet Explorer which downloaded 6,504,003 bytes and the SHA1 is correct and 
7Zip is happy with it. 
PS: I am not punting Internet Explorer ;-)

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Russell Keith-Magee
Sent: 23 March 2011 12:47
To: django-users@googlegroups.com
Subject: Re: ANN: Django 1.3 released

On Wed, Mar 23, 2011 at 6:25 PM, Chris Matthews <ch...@bbd.co.za> wrote:
> I must add my SHA1 on Django-1.3.tar.gz is
> 63e62f9a4834c1c8dbb591aac4ef2b1b84c5ea63 (on all of the downloads I did).
>

In which case, there's something going screwy with your downloads. The
correct SHA1 for Django-1.3.tar.gz, as documented [1] is:

f8814d5e1412bb932318db5130260da5bf053ff7

[1] http://media.djangoproject.com/pgp/Django-1.3.checksum.txt

A number of people validated this independently during the release
process, and I've just revalidated it. There's obviously something
going wrong with your download.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
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: ANN: Django 1.3 released

2011-03-23 Thread Chris Matthews
I must add my SHA1 on Django-1.3.tar.gz is 
63e62f9a4834c1c8dbb591aac4ef2b1b84c5ea63 (on all of the downloads I did).

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Chris Matthews
Sent: 23 March 2011 12:20
To: django-users@googlegroups.com
Subject: RE: ANN: Django 1.3 released

Well done! Thanks for all the hard work.
I downloaded my version from http://www.djangoproject.com/download/ and Chrome 
says it comes from http://media.djangoproject.com/releases/1.3/Django-1.3.tar.gz

7zip says "Data error in Django-1.3.tar' File is broken". I have downloaded it 
a few times with the same result.



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sultan Imanhodjaev
Sent: 23 March 2011 12:02
To: django-users@googlegroups.com
Subject: Re: ANN: Django 1.3 released

Wow!!! Congratulations people, thanks to developers!
On Wed, Mar 23, 2011 at 3:59 PM, Marco 
<chopin1...@gmail.com<mailto:chopin1...@gmail.com>> wrote:
so happy
On Wed, Mar 23, 2011 at 5:34 PM, bruno desthuilliers 
<bruno.desthuilli...@gmail.com<mailto:bruno.desthuilli...@gmail.com>> wrote:
On 23 mar, 07:15, James Bennett 
<ubernost...@gmail.com<mailto:ubernost...@gmail.com>> wrote:
> It's here!
>
> Django 1.3 has been officially released.
Yay great ! Congrats guys.

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



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



--
Kind regards,
Sultan Imanhodjaev
+996 779 230 968
--
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: ANN: Django 1.3 released

2011-03-23 Thread Chris Matthews
Well done! Thanks for all the hard work.
I downloaded my version from http://www.djangoproject.com/download/ and Chrome 
says it comes from http://media.djangoproject.com/releases/1.3/Django-1.3.tar.gz

7zip says "Data error in Django-1.3.tar' File is broken". I have downloaded it 
a few times with the same result.



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sultan Imanhodjaev
Sent: 23 March 2011 12:02
To: django-users@googlegroups.com
Subject: Re: ANN: Django 1.3 released

Wow!!! Congratulations people, thanks to developers!
On Wed, Mar 23, 2011 at 3:59 PM, Marco 
> wrote:
so happy
On Wed, Mar 23, 2011 at 5:34 PM, bruno desthuilliers 
> wrote:
On 23 mar, 07:15, James Bennett 
> wrote:
> It's here!
>
> Django 1.3 has been officially released.
Yay great ! Congrats guys.

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



--
LinuX
Violin
Canon EOS
--
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.



--
Kind regards,
Sultan Imanhodjaev
+996 779 230 968
--
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: How make CSRF middleware emit html4 rather than xhtml1.0 (closing tags issue) so will validate?

2011-03-21 Thread Chris Seberino

Ian

Thanks for the reply.  Your solution makes perfect sense.  My forms
are
automatically generated by Django via Form classes.  So I can't
embed this suggested input element in any form element present in my
template.
Where should I put this code in since there is no form element?

cs

>
>     
>         
>     
>
> (Note the '{{', '}}' delimiters, rather than '{%', '%}')
>
> A more complicated, but more reusable way to do it would be to write
> your own template tag (it's really simple, you can use the CSRF-token
> code indjango/template/defaulttags.py as a starting point) which
> would render whatever markup you need.
>
> --
> Regards,
> Ian Clelland
> 

-- 
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: /admin weirdness

2011-03-17 Thread chris hendrix
admin  models are registered in models.py for each app.  Some people say 
to use an admin.py file but I've never had to do that before.  currently 
using:


Django 1.2.3 (mod_wsgi 3.2/Python 2.6) and hosting at webfaction

There's nothing special about the model view.  Here's one of them:




from datetime import datetime
from Client.models import Record as CRecord

class Record (models.Model):
id = models.AutoField (primary_key=True)
title = models.CharField (max_length=128, blank=False)
date = models.BigIntegerField (blank=False)
client_id = models.ForeignKey(CRecord,db_index=True, blank=False)
specialEventDate = models.IntegerField (blank=False)
comments = models.TextField (blank=False)
al_number = models.CharField (max_length=128, blank=False)
lastOpened = models.BigIntegerField (blank=False)
whenSubmitted = models.BigIntegerField (blank=False)
source = models.CharField (max_length=255, blank=False)

class RecordAdmin(admin.ModelAdmin):
def Client_Firstname(self, obj):
return obj.client_id.firstName

def Client_Lastname(self, obj):
return obj.client_id.lastName

def OrderDate(self, obj):
return datetime.fromtimestamp(obj.date)

def DateSubmitted(self, obj):
return datetime.fromtimestamp(obj.whenSubmitted)

list_display = 
('id','Client_Firstname','Client_Lastname','client_id','OrderDate','DateSubmitted')
search_fields = 
['client_id__firstName','client_id__lastName','client_id__id','title','status','comments','source']


admin.site.register(Record,RecordAdmin)





any ideas?

On 03/17/2011 03:50 PM, Casey Greene wrote:
Where are you registering your models for the admin site and what does 
that code look like?


Casey

On 03/17/2011 03:14 PM, chris hendrix wrote:

yeah the urls file looks fine... it only happens randomly but seems tied
to DEBUG=False for some reason... not sure why that would make a 
difference.




On 03/17/2011 03:09 PM, werefr0g wrote:

Hi Bobby,

Maybe some mistake on your url.py, for example if you have an app
named "app" and a model named "model", you'll try to get this url to
add a new "model"

/admin/app/model/add/

Usually, you'll write your urls.py like this:

(r'^app/', include('app.urls')),
(r'^admin/', include(admin.site.urls)),

If you forget the "^" before app/, the url for adding a new model will
match the regex 'app/', and the admin will be shorcut, Just a guess
against the material you brought ;)

Regards,

--
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: /admin weirdness

2011-03-17 Thread chris hendrix
yeah the urls file looks fine... it only happens randomly but seems tied 
to DEBUG=False for some reason... not sure why that would make a difference.




On 03/17/2011 03:09 PM, werefr0g wrote:

Hi Bobby,

Maybe some mistake on your url.py, for example if you have an app 
named "app" and a model named "model", you'll try to get this url to 
add a new "model"


/admin/app/model/add/

Usually, you'll write your urls.py like this:

(r'^app/', include('app.urls')),
(r'^admin/', include(admin.site.urls)),

If you forget the "^" before app/, the url for adding a new model will 
match the regex 'app/', and the admin will be shorcut, Just a guess 
against the material you brought ;)


Regards,

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



How make CSRF middleware emit html4 rather than xhtml1.0 (closing tags issue) so will validate?

2011-03-14 Thread Chris Seberino
My Django app's html won't validate because CSRF middleware adds
hidden
tags like this...



The only problem is the slash "/>" at the end.

How make Django templates not automatically add hidden tags that won't
validate?

Thanks!

cs

-- 
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: Satchmo Error - Invalid block tag: 'thumbnail', expected 'else' or 'endif'

2011-03-10 Thread chris hendrix

yeah we've followed all the instructions


On 03/10/2011 08:00 AM, pols wrote:

try re-installing thumbnail
easy_install  sorl-thumbnail==3.2.5



--
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: Satchmo Error - Invalid block tag: 'thumbnail', expected 'else' or 'endif'

2011-03-10 Thread chris hendrix

both of these are done and we're still getting the error.

On 03/10/2011 04:32 AM, pols wrote:

Check in settings.py installed apps for the entry
'satchmo_utils.thumbnail', If not istalled add this.If you are using
new version you may need to add {% endthumbnail %} in the templates
before closing endif



--
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: Tracking Row changes

2011-02-24 Thread Chris Matthews
Hi Andre,

Also have a look at:
http://code.google.com/p/django-history-tables/
and
http://qr7.com/2010/10/django-simple-history-ftw/ by Corey Bertram based on 
book ProJango by Marty Alchin Chapter 11 (page 263 onwards)

Regards
Chris
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Andre Terra
Sent: 25 February 2011 00:56
To: elijah rutschman
Cc: django-users@googlegroups.com
Subject: Re: Tracking Row changes

Thanks a lot! Will look into it first thing tomorrow.

Meanwhile, if anyone has other suggestions, keep them coming, please. Thanks in 
advance!


Sincerely,
André
On Thu, Feb 24, 2011 at 6:15 PM, elijah rutschman 
<elij...@gmail.com<mailto:elij...@gmail.com>> wrote:
On Thu, Feb 24, 2011 at 2:54 PM, Andre Terra 
<andrete...@gmail.com<mailto:andrete...@gmail.com>> wrote:
> Hello everyone,
> I'd like to log user changes to MyModel in an app I'm writing. What are some
> third-party solutions that you recommend for this?
django-activity-stream might meet your needs.
https://github.com/justquick/django-activity-stream

Regards,
Elijah

--
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: field choices() as queryset?

2011-02-24 Thread Chris Matthews
Typo
choices.append((item.name, item.name))
should be
choices.append((item.id, item.name))

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Ramirez
Sent: 24 February 2011 14:10
To: django-users@googlegroups.com
Subject: Re: field choices() as queryset?


On Thursday, February 24, 2011 03:53:03 am galago wrote:

> I need to make a form, which have 1 select and 1 text input. Select must be

> taken from database.

> model looks like this:

> class Province(models.Model):

> name = models.CharField(max_length=30)

> slug = models.SlugField(max_length=30)

>

> def __unicode__(self):

> return self.name

>

> It's rows to this are added only by admin, but all users can see it in

> forms.

> I want to make a ModelForm from that. I made something like this:

> class ProvinceForm(ModelForm):

> class Meta:

> CHOICES = Province.objects.all()

>

> model = Province

> fields = ('name',)

> widgets = {

> 'name': Select(choices=CHOICES),

> }

>

> but it doesn't work. The select tag is not displayed in html. What did I

> wrong?

I haven't done this one in a while, but you need to make the CHOICES a tuple or 
a list[1], not a queryset (unless there has been changes in this specific area).

something like this:

def make_choices():

choices = []

for item in Province.objects.all()

choices.append((item.name, item.name))

return choices

# your form stuff

...

widgets = { 'name': Select(choices=make_choices()), }

The first value is the value stored, the second one is the human readable form 
in the tuple.

Mike

[1] http://docs.djangoproject.com/en/1.2/ref/models/fields/#field-choices

--

Banacek's Eighteenth Polish Proverb:

The hippo has no sting, but the wise man would rather be sat upon

by the bee.
--
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: urls.py and views.generic issue

2011-02-22 Thread Chris Matthews
Hi Antti,



1) Your day match is for \w{1,2} which will match one or 2 digits but also word 
characters because \w is same as [a-zA-Z0-9_] (see re documentation).



(r'(?P\d{4})/(?P[a-z]{3})/(?Pw{1,2})/(?P[-w]+)/$'

Should be

(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{1,2})/(?P[-w]+)/$'



2) The slash before the [ is wrong. See http://docs.python.org/library/re.html 
[] is used to match a set/range of characters.

 (?P\[a-z]{3})"



 
(r'^(?P\d{4})/(?P\[a-z]{3})/(?P\w{1,2})/(?P\[-w]+)/$',

 (r'^(?P\d{4})/(?P\[a-z]{3})/(?P\w{1,2})/$',

 (r'^(?P\d{4})/(?P\[a-z]{3})/$',



3) The list.html is shown because it matches:

(r'^blog/', include('anttipetaisto.blog.urls')),

and then

(r'^$','archive_index', dict(info_dict, template_name='blog/list.html')),





What URL do you enter when you get the error?



Regards

Chris



-Original Message-

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Antti

Sent: 23 February 2011 06:56

To: Django users

Subject: Re: urls.py and views.generic issue



Thanks jnns for the response.  I tried adding the backslash but it

still doesn't match. Would I need to put a different character after

the other entries in the expression? What I mean would there be a

different character used in "(?P\[a-z]{3})" ?  Also one more

note if I type in http://127.0.0.1:8000/blog/ then the page loads

using the list.html template as it should.   I have included the main

urls.py as well as the blog urls.py



-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Antti
Sent: 23 February 2011 06:48
To: Django users
Subject: Re: urls.py and views.generic issue



Hello Chris, thanks for the response. I don't know where that space is

coming from.  When I type in http://127.0.0.1:8000/blog/ a page loads

using the list.html template as it should. Would that mean that the

space might be fine because the main urls.py is calling the blog

urls.py?



I have a main urls.py and then I have a blog urls.py. The files are as

below and the space is added somewhere along the lines.



Main urls.py



from django.conf.urls.defaults import *



# Uncomment the next two lines to enable the admin:

from django.contrib import admin



admin.autodiscover()



urlpatterns = patterns('',

# Example:

# (r'^anttipetaisto/', include('anttipetaisto.foo.urls')),



# Uncomment the admin/doc line below to enable admin

documentation:

 (r'^admin/doc/', include('django.contrib.admindocs.urls')),



# Uncomment the next line to enable the admin:

 (r'^admin/', include(admin.site.urls)),

 (r'^tags/(?P[a-zA-Z0-9_.-]+)/$',

'anttipetaisto.tag_views.tag_detail'),

 (r'^blog/', include('anttipetaisto.blog.urls')),

 (r'^static_files/(?P.*)$', 'django.views.static.serve',

{'document_root': '/home/antti/django/anttipetaisto/static_files'}),





Blog urls.py



from django.conf.urls.defaults import *

from anttipetaisto.blog.models import Entry

from tagging.views import tagged_object_list



info_dict = {

'queryset': Entry.objects.filter(status=1),

'date_field': 'pub_date',

}



urlpatterns = patterns('django.views.generic.date_based',

 (r'(?P\d{4})/(?P[a-z]{3})/(?Pw{1,2})/(?P[-

w]+)/$', 'object_detail', dict(info_dict, slug_field='slug',

template_name='blog/detail.html')),

 (r'^(?P\d{4})/(?P\[a-z]{3})/(?P\w{1,2})/(?

P\[-w]+)/$', 'object_detail', dict(info_dict,

template_name='blog/list.html')),

 (r'^(?P\d{4})/(?P\[a-z]{3})/(?P\w{1,2})/

$','archive_day',dict(info_dict,template_name='blog/list.html')),

 (r'^(?P\d{4})/(?P\[a-z]{3})/$','archive_month',

dict(info_dict, template_name='blog/list.html')),

 (r'^(?P\d{4})/$','archive_year', dict(info_dict,

template_name='blog/list.html')),

 (r'^$','archive_index', dict(info_dict, template_name='blog/

list.html')),

)



On Feb 20, 10:47 pm, Chris Matthews <ch...@bbd.co.za> wrote:

> It also seems that the space preceding the caret ^ should not be there

>

> So

>

> ^blog/ ^(?P\d{4})/$

>

> Should be

>

> ^blog/^(?P\d{4})/$

>

>

>

>

>

>

>

> -Original Message-

> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of jnns

> Sent: 20 February 2011 03:07

> To: Django users

> Subject: Re: urls.py and views.generic issue

>

> Hi Antti,

>

> the url patterns in the tutorial are not correct. The regular

>

> expressions are not using character classes but merely plain

>

> characters.

>

> ^blog/ ^(?Pd{4})/$

>

> should be

>

> ^blog/ ^(?P\d{4})/$

>

> Mind the backslash in \d{4}. This way we're matching for a sequence of

>

> four digits and not for a sequence of four "d"s.

>

> Regards,

>

> jnns

>

> On Feb 20, 12:57 am, Antti <ahpetai...@gmai

Re: I'm having problem showing from the value a sub-sub model.

2011-02-22 Thread Chris
sorry your right, I didn't receive any notification so I thought it
wasn't posted.
I've answered in the original thread

On Feb 21, 2:00 pm, Shawn Milochik  wrote:
> Why are you re-posting this? You posted it over the weekend. I
> replied. If my reply didn't help, tell us the new problem you're
> having.

-- 
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: How to display value from a sub model in the template

2011-02-21 Thread Chris
The default (from the doc F00_set so: )
playerVital_set
and playerSkills_set

So I want the first set for each of them ...

(sorry for the double post by the way)

On Feb 20, 9:10 pm, Shawn Milochik  wrote:
> What are the related_name values you gave to the foreign key fields of
> your related models?

-- 
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'm having problem showing from the value a sub-sub model.

2011-02-21 Thread Chris
Greetings,

I'm having problem showing from the value a sub model.
I have a main model (team) I'm displaying the information, a team
contain a list players and these are listed in the page too.
So far so good, but here where its doesn't work, players have skill
and vital and I can't get to show them in the team page.

The relation between player and PlayerVital is one to one while the
relation with PlayerSkills a foreing key in the playerSkill model
mainly because skill evolve in time and we need to keep track of
that.
I tried many systax in the view but  nothing seem to work.
It seem something obvious but I can't manage to find it in the doc.

Any pointers would be helpfull.
thanks,
Chris



Here my model
class Team(models.Model):
team_name = models.CharField(max_length=200)
city = models.CharField(max_length=200) #propably FK later
def __unicode__(self):
return self.team_name


class Player(models.Model):
teamKey = models.ForeignKey(Team, blank=True, null=True)
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200)
def fullname(self):
return u'%s %s' % (self.first_name, self.last_name)
def __unicode__(self):
return self.fullname()

class PlayerVital(models.Model):
playerKey = models.OneToOneField(Player, primary_key=True)
POSITION = (
('G', 'Goaler'),
('D', 'Defense'),
('C', 'Center'),
('LW', 'Left Wing'),
('RW', 'Right Wing'),
)
position=models.CharField(max_length=2, choices=POSITION) #C/RW/LW/
D/G
height= models.IntegerField()
weight= models.IntegerField()
nationality = models.CharField(max_length=200)#propably FK later

class PlayerSkills(models.Model):
skill_at_date = models.DateField('skill_date')
playerKey = models.ForeignKey(Player)
SKILL_RANGE = zip( range(0,100), range(0,100))
speed=models.IntegerField(default=50, choices=SKILL_RANGE,
blank=True)
strength=models.IntegerField(default=50, choices=SKILL_RANGE,
blank=True)
endurance=models.IntegerField(default=50, choices=SKILL_RANGE,
blank=True)

Here the template
{{ object.team_name }}

{% if error_message %}{{ error_message }}{%
endif %}

{% csrf_token %}



Player Name


Position


speed


height


{% for player in object.player_set.all %}


{{ player.fullname }}  


{{ player.playerVitals_set.position }}


 
{{ player.player_set.speed }} a  


{{ playerVitals.height }}



{% endfor %}



-- 
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: urls.py and views.generic issue

2011-02-20 Thread Chris Matthews
It also seems that the space preceding the caret ^ should not be there

So

^blog/ ^(?P\d{4})/$

Should be

^blog/^(?P\d{4})/$





-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of jnns
Sent: 20 February 2011 03:07
To: Django users
Subject: Re: urls.py and views.generic issue



Hi Antti,



the url patterns in the tutorial are not correct. The regular

expressions are not using character classes but merely plain

characters.



^blog/ ^(?Pd{4})/$

should be

^blog/ ^(?P\d{4})/$



Mind the backslash in \d{4}. This way we're matching for a sequence of

four digits and not for a sequence of four "d"s.



Regards,

jnns



On Feb 20, 12:57 am, Antti  wrote:

> The problem:

>

> I can't seem to get most of my urls that I type in my browser to math

> a url in my urls.py file.  I am currently doing Web Monkey's Blog

> Tutorial (http://www.webmonkey.com/2010/02/Get_Started_With_Django/)

> To date everything has worked but when I try to use the urls from the

> blog urls.py I get the following error:

>

> Using the URLconf defined in anttipetaisto.urls, Django tried these

> URL patterns, in this order:

>

> ^admin/doc/

> ^admin/

> ^blog/ (?Pd{4})/(?P[a-z]{3})/(?Pw{1,2})/(?P[-w]

> +)/$

> ^blog/ ^(?Pd{4})/(?P[a-z]{3})/(?Pw{1,2})/(?P[-

> w]+)/$

> ^blog/ ^(?Pd{4})/(?P[a-z]{3})/(?Pw{1,2})/$

> ^blog/ ^(?Pd{4})/(?P[a-z]{3})/$

> ^blog/ ^(?Pd{4})/$

> ^blog/ ^$

> ^tags/(?P[a-zA-Z0-9_.-]+)/$

> ^static_files/(?P.*)$

>

> The current URL, blog/2011/jan/20/things-learned-finland/, didn't

> match any of these.

>

> What I don't understand why this is saying that isn't a url match.

> Shouldn't it match the third one down?

>

> Thanks

>

> Antti



--

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.



How to display value from a sub model in the template

2011-02-20 Thread Chris
Hi !
 I have template page I'm trying to list all the player of a team, The
player model have 2 sub-model: playerVital and playerSkill.
The model playerVital has a one to one relation ship with the player
model and player skill have a foreign key to the player model.
 How can I show the value of the sub model when looping players in the
team object?
Showing value of the player model work fine but not the sub model.
I tried various syntax but nothing seem to work.

Thanks,
Chris

Here are the model and the template i'm building :
model.py
class Team(models.Model):
team_name = models.CharField(max_length=200)
def __unicode__(self):
return self.team_name

class Player(models.Model):
teamKey = models.ForeignKey(Team, blank=True, null=True)
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200)
def fullname(self):
return u'%s %s' % (self.first_name, self.last_name)
def __unicode__(self):
return self.fullname()

class PlayerVital(models.Model):
playerKey = models.OneToOneField(Player, primary_key=True)
position=models.CharField(max_length=2, choices=POSITION) #C/RW/LW/
D/G
hand= models.CharField(max_length=10, choices=HAND) #Left/Right
height= models.IntegerField()
weight= models.IntegerField()
nationality = models.CharField(max_length=200)


class PlayerSkills(models.Model):
SKILL_RANGE = zip( range(0,100), range(0,100))
playerKey = models.ForeignKey(Player)
skill_at_date = models.DateField('skill_date')
speed=models.IntegerField(default=50, choices=SKILL_RANGE,
blank=True)
strength=models.IntegerField(default=50, choices=SKILL_RANGE,
blank=True)
endurance=models.IntegerField(default=50, choices=SKILL_RANGE,
blank=True)

template :
{{ object.team_name }}

{% if error_message %}{{ error_message }}{%
endif %}

{% csrf_token %}



Player Name


Position


speed


height


{% for player in object.player_set.all %}


{{ player.fullname }}  


{{ player.playerVitals.position }} 

 
{{ player.playerSkill.speed }}


{{ player.height }}   


{% endfor %}




-- 
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: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
Then you probably want:
id_list = [int(x) for x in data.keys()]

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of balu
Sent: 18 February 2011 13:56
To: Django users
Subject: Re: list indices must be integers not unicode

Thank you Chris Matthews for your reply.

I'm working on a online examination system. I could able to generate
some random questions from a data base containg hundreds of questions.
So when ever a user answer and submit those random questions a
dictionary contating a "Question_id and Answer" pair will be send as a
request.


Now I have to get those dictionary keys first, i.e., the Question_id
and then I have to cross  check the values i.e., the values with the
database values.

On Feb 18, 4:37 pm, Chris Matthews <ch...@bbd.co.za> wrote:
> Oh and you probably wanted:
>
>     if request.method=="POST":
>
>         data = request.POST
>
>        id_list = [int(x) for x in data.values()]
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Chris Matthews
> Sent: 18 February 2011 13:34
> To: django-users@googlegroups.com
> Subject: RE: list indices must be integers not unicode
>
> Hi Balu,
>
> Numeric data from the form must be converted to int. I suspect you wanted to 
> index data; not id_list.
>
>     if request.method=="POST":
>
>         data = request.POST
>
>         temp_list = data.keys()
>
>         id_list = []
>
>        for i in temp_list:
>
>              id_list.append(id_list[i])
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> Should
>
> id_list.append(id_list[i])
>
> Not be
>
> id_list.append(data[i])
>
>
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of balu
> Sent: 18 February 2011 13:24
> To: Django users
> Subject: list indices must be integers not unicode
>
> Hi all :)
>
> I'm processing a user submitted form. In that the user will answer a
>
> series of multiple choice questions. Depending on the question "id"
>
> which are submitted I'll find the compare the values and increment the
>
> score to count his marks.
>
> The question ids are  keys from the dictionary request.POST. But it is
>
> showing an error the list indices must be integers not unicode. I
>
> wrote the code as follows.
>
> // In the view function
>
>     if request.method=="POST":
>
>         data = reques.POST
>
>         temp_list = data.keys()
>
>         id_list = []
>
>        for i in temp_list:
>
>              id_list.append(id_list[i])
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> --
>
> 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 
> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.- Hide quoted text -
>
> - Show quoted 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.

-- 
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: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
Oh and you probably wanted:

if request.method=="POST":

data = request.POST

   id_list = [int(x) for x in data.values()]



   questions = MyModel.objects.filter(id__in = id_list)


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Chris Matthews
Sent: 18 February 2011 13:34
To: django-users@googlegroups.com
Subject: RE: list indices must be integers not unicode


Hi Balu,



Numeric data from the form must be converted to int. I suspect you wanted to 
index data; not id_list.





if request.method=="POST":

data = request.POST

temp_list = data.keys()

id_list = []



   for i in temp_list:

 id_list.append(id_list[i])



   questions = MyModel.objects.filter(id__in = id_list)



Should

id_list.append(id_list[i])

Not be

id_list.append(data[i])





-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of balu
Sent: 18 February 2011 13:24
To: Django users
Subject: list indices must be integers not unicode



Hi all :)



I'm processing a user submitted form. In that the user will answer a

series of multiple choice questions. Depending on the question "id"

which are submitted I'll find the compare the values and increment the

score to count his marks.



The question ids are  keys from the dictionary request.POST. But it is

showing an error the list indices must be integers not unicode. I

wrote the code as follows.





// In the view function



if request.method=="POST":

data = reques.POST

temp_list = data.keys()

id_list = []



   for i in temp_list:

 id_list.append(id_list[i])



   questions = MyModel.objects.filter(id__in = id_list)



--

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: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
Hi Balu,



Numeric data from the form must be converted to int. I suspect you wanted to 
index data; not id_list.





if request.method=="POST":

data = request.POST

temp_list = data.keys()

id_list = []



   for i in temp_list:

 id_list.append(id_list[i])



   questions = MyModel.objects.filter(id__in = id_list)



Should

id_list.append(id_list[i])

Not be

id_list.append(data[i])





-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of balu
Sent: 18 February 2011 13:24
To: Django users
Subject: list indices must be integers not unicode



Hi all :)



I'm processing a user submitted form. In that the user will answer a

series of multiple choice questions. Depending on the question "id"

which are submitted I'll find the compare the values and increment the

score to count his marks.



The question ids are  keys from the dictionary request.POST. But it is

showing an error the list indices must be integers not unicode. I

wrote the code as follows.





// In the view function



if request.method=="POST":

data = reques.POST

temp_list = data.keys()

id_list = []



   for i in temp_list:

 id_list.append(id_list[i])



   questions = MyModel.objects.filter(id__in = id_list)



--

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: How to Auto fill fields on Save in Django Admin?

2011-02-16 Thread Chris Matthews
Hi Matteius,

You must set blank=True in the model so that the form can be returned to you 
with those fields empty and then you fill it in the save().

pub_date = models.DateTimeField(blank=True)
author = models.ForeignKey(User, blank=True, verbose_name='Author')

Also read up on editable=False

Regards
Chris
-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Matteius
Sent: 17 February 2011 08:47
To: Django users
Subject: How to Auto fill fields on Save in Django Admin?

I have an Announcement model that has two fields I want to auto-fill
in when they are left blank (they are required fields with normal
defaults).  I have the following Code (simplified data listing for
this post)  THe Problem is that when I go to save an Announement
in the admin with either of those fields blank it returns to the Add/
Edit Form with "This field is required." despite my code to try and
fill that in.  Clearly I'm missing how to do this, any advice?

class Announcement(models.Model):
""" Represents an Announcement in the classcomm system. """

# Data Model Fields
pub_date = models.DateTimeField()
author = models.ForeignKey(User, verbose_name='Author')

def clean(self):
""" Implement auto fill pub_date. """
if not self.pub_date:
self.pub_date = datetime.today()
super(Announcement, self).clean()
# EndDef

def save(self):
""" Implement auto fill pub_date. """
if not self.pub_date:
self.pub_date = datetime.today()
super(Announcement, self).save()
# EndDef
# EndClass

Then in admin.py I have:

class AnnouncementAdmin(admin.ModelAdmin):
""" Admin customizations for Announcement Models. """
fieldsets = (
(None, {
'fields': ('headline', 'department', 'course', 'content')
}),
('Advanced options', {
'classes': ('collapse',),
'fields': ('author', 'pub_date', 'make_global')
}),
)

def save_model(self, request, obj, form, change):
""" Autofill in author when blank on save models. """
obj.author = request.user
obj.save()
# EndDef

def save_formset(self, request, form, formset, change):
""" Autofill in author when blank on save formsets. """
instances = formset.save(commit=False)
for instance in instances:
instance.author = request.user
instance.save()
formset.save_m2m()
# EndDef
# EndClass


Regards,
Matt

-- 
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: how can I filter related (foreign key) objects?

2011-02-16 Thread Chris Matthews
Hi Serek,



Try this

def doMagic(self):

date = '2010-05-04'

#//here I need to take 10 conencted Bbb objects whcich data is less 
then date

previous10days = Bbb.objects.filter(date__lt=date).order_by('data')



Also read up about managers 
http://docs.djangoproject.com/en/1.2/topics/db/managers/ in case you should 
consider using it (depending upon how much magic is required from your 
function).



Regards

Chris



-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of serek
Sent: 17 February 2011 00:51
To: Django users
Subject: how can I filter related (foreign key) objects?



Hi



I have not idea how to describe my problem, so I show pice of code:





class Aaa(models.Model):

name = models.CharField(max_length=200, unique=True)

is_active = models.BooleanField()



class Meta:

ordering = ('name',)



def doMagic(self):

  date = '2010-05-04'

  //here I need to take 10 conencted Bbb objects whcich data is less

then date

previous10days = self.bbb_set.filter(Bbb.date <

date).order_by('data')





class Bbb(models.Model):

date = models.DateField()

value = models.DecimalField(max_digits=7, decimal_places=2)

aaa = models.ForeignKey(Aaa)



a = Aaa()

a.doMagic throw error that Bbb.date is undefined - what can be 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.


-- 
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: form select box how to (help needed)

2011-02-16 Thread Chris Matthews
Hi Bobby,

See 
http://adil.2scomplement.com/2008/05/django-add-choices-to-form-fields-on-runtime/

Try something like the following:

# Define your choices
LOCATION_CHOICES = ((1,'location1'),
(2,'location2'),
(3,'location3'),
(4,'location4'),
   )

LOCATION_CHOICES_PUBLIC = ((1,'location1'),
(2,'location2'),
(3,'location3'),
   )

Example 1
-
class ProfileForm(forms.Form):
class Meta:
model = Profile

locations = forms.ChoiceField(required=True)

def __init__(self, *args, **kwargs):
# This is a bit of a hack
if 'user_type' in kwargs and kwargs['user_type'] == 'public':
public = True
# We do not want to pass our kwarg to super
del kwargs['user_type']
else:
public = False

super(ProfileForm, self).__init__(*args, **kwargs)

if 'user_type' in kwargs and kwargs['user_type'] == 'public':
self.fields['locations'].choices = LOCATION_CHOICES_PUBLIC
else:
self.fields['locations'].choices = LOCATION_CHOICES

In your module use
form = ProfileForm(user_type='public')
or
form = ProfileForm()

Example 2
-
class ProfileForm(forms.Form):
class Meta:
model = Profile

# the limited choices are our default
locations = forms.ChoiceField(choices = LOCATION_CHOICES_PUBLIC, 
required=True)

In your module
form = ProfileForm()
if not public:
form.fields['locations'].choices = LOCATION_CHOICES


Example 2 is a bit 'cleaner'/neater I think.

Regards
Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Bobby Roberts
Sent: 16 February 2011 15:14
To: Django users
Subject: Re: form select box how to (help needed)

i have no idea what this means is there an example anywhere?

On Feb 16, 12:43 am, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> On Tue, 2011-02-15 at 19:05 -0800, Bobby Roberts wrote:
> > I can't load it through the "CHOICES" parameter in my forms field...
> > how can I do this?
>
> override __init__ in your form and populate there
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

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



<    1   2   3   4   5   6   7   8   9   10   >