Re: Django 1.3 to 1.4

2012-07-11 Thread JJ Zolper
Or I thought it would be okay until I saw these errors when trying to run 
my server:

Traceback (most recent call last):
  File "manage.py", line 14, in 
execute_manager(settings)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 459, in execute_manager
utility.execute()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 217, in execute
translation.activate('en-us')
  File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", 
line 105, in activate
return _trans.activate(language)
  File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 194, in activate
_active.value = translation(language)
  File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 183, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 160, in _fetch
app = import_module(appname)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
line 35, in import_module
__import__(name)
  File 
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", 
line 3, in 
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
  File 
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/helpers.py", 
line 2, in 
from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
  File 
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/util.py", line 
1, in 
from django.db import models
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 
40, in 
backend = load_backend(connection.settings_dict['ENGINE'])
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 
34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 
92, in __getitem__
backend = load_backend(db['ENGINE'])
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 
51, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'postgresql_psycopg2' isn't an 
available database backend.
Try using django.db.backends.postgresql_psycopg2 instead.
Error was: No module named postgresql_psycopg2.base


On Wednesday, July 11, 2012 10:40:30 PM UTC-4, JJ Zolper wrote:
>
> I made the mistake of not deleting the previous django files before I 
> installed django 1.4
>
> When I run:
>
> >>> import django
> >>> print(django.get_version())
> 1.4
>
> I see that. I'm sure I'm going beyond naive here but I just didn't want to 
> assume that my django would be fine if I didn't uninstall 1.3 first?
>
> I was able to run:
>
> python -c "import sys; sys.path = sys.path[1:]; import django; 
> print(django.__path__)"
>
> "If you previously installed Django using python setup.py install, 
> uninstalling is as simple as deleting the django directory from your 
> Pythonsite-packages. To find the directory you need to remove, you can 
> run the following at your shell prompt (not the interactive Python prompt):"
>
> and read that ^ but when I tried to delete the "django" directory returned 
> errors when I tried to remove it in the "dist-packages" directory.
>
> On the Django site and in the quote above it says "site-packages" but 
> there is nothing in that for me.
>
> I'm probably fine just wanted to post this.
>
> Thanks,
>
> JJ
>

-- 
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/-/zHizEb0Z-80J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 to 1.4

2012-07-11 Thread JJ Zolper
I made the mistake of not deleting the previous django files before I 
installed django 1.4

When I run:

>>> import django
>>> print(django.get_version())
1.4

I see that. I'm sure I'm going beyond naive here but I just didn't want to 
assume that my django would be fine if I didn't uninstall 1.3 first?

I was able to run:

python -c "import sys; sys.path = sys.path[1:]; import django; 
print(django.__path__)"

"If you previously installed Django using python setup.py install, 
uninstalling is as simple as deleting the django directory from your Python
site-packages. To find the directory you need to remove, you can run the 
following at your shell prompt (not the interactive Python prompt):"

and read that ^ but when I tried to delete the "django" directory returned 
errors when I tried to remove it in the "dist-packages" directory.

On the Django site and in the quote above it says "site-packages" but there 
is nothing in that for me.

I'm probably fine just wanted to post this.

Thanks,

JJ

-- 
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/-/HavKSz5MKLkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: App authoring: setup

2012-07-11 Thread Demian Brecht
Perhaps I wasn't clear.. When I mentioned installing, I meant installing
the Django app in a virtualenv through a setup script so that the project
has visibility to it (not installing the example project itself).

Was just curious if there was another method I was unaware of is all really.

Thanks for the link to tox. I'd forgotten about that for this particular
project.

On Wed, Jul 11, 2012 at 6:58 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Thu, Jul 12, 2012 at 9:00 AM, Demian Brecht 
> wrote:
> > Only a couple small problems with that:
> >
> > * No sample code for people utilizing the app in their own projects
>
> Really? You can't do what every other popular Django app on github
> does, and put an examples directory in your repository that isn't
> installed as part of setup.py?
>
> > * Unit testing environment is a little more unorthodox to set up - rather
> > than just using the example project's settings (and manage.py test
> > app_name), I'd have to do the configuration manually (AFAIK, I haven't
> > looked into this too much).
>
> A little more unorthodox, but not that hard to do. This is what Tox is
> designed to do.
>
> http://tox.testrun.org/latest/
>
> 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: App authoring: setup

2012-07-11 Thread Russell Keith-Magee
On Thu, Jul 12, 2012 at 9:00 AM, Demian Brecht  wrote:
> Only a couple small problems with that:
>
> * No sample code for people utilizing the app in their own projects

Really? You can't do what every other popular Django app on github
does, and put an examples directory in your repository that isn't
installed as part of setup.py?

> * Unit testing environment is a little more unorthodox to set up - rather
> than just using the example project's settings (and manage.py test
> app_name), I'd have to do the configuration manually (AFAIK, I haven't
> looked into this too much).

A little more unorthodox, but not that hard to do. This is what Tox is
designed to do.

http://tox.testrun.org/latest/

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.



Re: Form 'POST' to a database

2012-07-11 Thread JJ Zolper
I was able to make it work!

from django.core.context_processors import csrf
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.http import HttpResponse
from django.shortcuts import render_to_response
from MadTrak.manageabout.models import AboutMadtrak, AboutMadtrakForm

def about(request):
AboutMadtrakInstance = AboutMadtrak()
result = AboutMadtrakForm(request.POST, instance=AboutMadtrakInstance)
result.save()
return HttpResponse('It worked?!? Of course it did. I knew that.')

def about_form(request):
return render_to_response('about_form.html', context_instance = 
RequestContext(request))

I ended up looking at ModelForms and trying that since I was having issues.

So does this method handle all validation and security issues for me?

Or do I still need a "result.is_valid()" among other things?


On Wednesday, July 11, 2012 11:51:19 AM UTC-4, Andre Schemschat wrote:
>
> Hey,
>>>
>>
> yeah, it basicly is. Just a very, very basic example (And sorry if i could 
> highlight this as code, i didnt find something in the format-menu :/ ).
> Of course you should validate your input first. And if you just want to 
> edit a Model within a form, you should check on the ModelForm-Class 
> https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> def vote(request, poll_id):
> try:
> obj = YourModel.objects.get(pk=poll_id)
> obj.attributea = request.POST['attributea']
> obj.attributeb = request.POST['attributeb']
> obj.save()
> return HttpResponse(validparamshere)
> except ObjectDoesNotExist:
> return HttpResponse(show_some_error)
>
>
On Wednesday, July 11, 2012 1:09:32 PM UTC-4, Dennis Lee Bieber wrote:
>
> On Wed, 11 Jul 2012 08:36:39 -0700 (PDT), JJ Zolper 
>  declaimed the following in 
> gmane.comp.python.django.user: 
>
>
> > So originally: 
> > 
> > selected_choice = p.choice_set.get(pk=request.POST['choice']) 
> > 
> If I understand this (I've not run the tutorial, and only browsed 
> the now-outdated print books), this statement is using the value from 
> the "choice" field of the submitted form as the primary key to retrieve 
> a record (model instance) from the database. 
>
> pseudo-SQL 
> select * from choice_set where pk = "request.POST['choice']" 
>
> > this requests the submitted choice from the POST data and 
> > 
> > The part that says: 
> > 
> > selected_choice.votes += 1 
> > selected_choice.save() 
> > 
> > Actually saves the choice to the database? 
> > 
> This then increments the votes field of the record (model 
> instance) 
> retrieved from the database, and then saves the record back. 
>
> p-SQL 
> update choice_set set 
> votes = votes + 1 
> where pk = selected_choice.pk 
>
> {I don't know if Django is smart enough to only update the changed 
> field, or if it updates the entire record} 
> -- 
> Wulfraed Dennis Lee Bieber AF6VN 
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ 
>
>

-- 
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/-/j_BacnSqm4QJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 'POST' to a database

2012-07-11 Thread JJ Zolper
I was able to make it work!

from django.core.context_processors import csrf
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.http import HttpResponse
from django.shortcuts import render_to_response
from MadTrak.manageabout.models import AboutMadtrak, AboutMadtrakForm

def about(request):
AboutMadtrakInstance = AboutMadtrak()
result = AboutMadtrakForm(request.POST, instance=AboutMadtrakInstance)
result.save()
return HttpResponse('It worked?!? Of course it did. I knew that.')

def about_form(request):
return render_to_response('about_form.html', context_instance = 
RequestContext(request))

I ended up looking at ModelForms and trying that since I was having issues.

So does this method handle all validation and security issues for me?

Or do I still need a "result.is_valid()" among other things?


On Wednesday, July 11, 2012 11:51:19 AM UTC-4, Andre Schemschat wrote:
>
> Hey,
>>>
>>
> yeah, it basicly is. Just a very, very basic example (And sorry if i could 
> highlight this as code, i didnt find something in the format-menu :/ ).
> Of course you should validate your input first. And if you just want to 
> edit a Model within a form, you should check on the ModelForm-Class 
> https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> def vote(request, poll_id):
> try:
> obj = YourModel.objects.get(pk=poll_id)
> obj.attributea = request.POST['attributea']
> obj.attributeb = request.POST['attributeb']
> obj.save()
> return HttpResponse(validparamshere)
> except ObjectDoesNotExist:
> return HttpResponse(show_some_error)
>
>
On Wednesday, July 11, 2012 2:50:21 PM UTC-4, Jani Tiainen wrote:
>
> Django makes always (at least currently) full record update (iow: there is 
> no dirty flag for fields).
>
> Example given is "poor" in the sense that it uses directly POST data. I 
> strongly would suggest leveraging modelforms when ever possible - it saves 
> time and nerves. You get all the validation and other goodies for free.
>
> On Wed, Jul 11, 2012 at 8:09 PM, Dennis Lee Bieber 
> wrote:
>
>> On Wed, 11 Jul 2012 08:36:39 -0700 (PDT), JJ Zolper
>>  declaimed the following in
>> gmane.comp.python.django.user:
>>
>>
>> > So originally:
>> >
>> > selected_choice = p.choice_set.get(pk=request.POST['choice'])
>> >
>> If I understand this (I've not run the tutorial, and only browsed
>> the now-outdated print books), this statement is using the value from
>> the "choice" field of the submitted form as the primary key to retrieve
>> a record (model instance) from the database.
>>
>> pseudo-SQL
>> select * from choice_set where pk = "request.POST['choice']"
>>
>> > this requests the submitted choice from the POST data and
>> >
>> > The part that says:
>> >
>> > selected_choice.votes += 1
>> > selected_choice.save()
>> >
>> > Actually saves the choice to the database?
>> >
>> This then increments the votes field of the record (model 
>> instance)
>> retrieved from the database, and then saves the record back.
>>
>> p-SQL
>> update choice_set set
>> votes = votes + 1
>> where pk = selected_choice.pk
>>
>> {I don't know if Django is smart enough to only update the changed
>> field, or if it updates the entire record}
>> --
>> Wulfraed Dennis Lee Bieber AF6VN
>> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> -- 
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/oskdpdjwHkgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 'POST' to a database

2012-07-11 Thread JJ Zolper
I was able to make it work!

from django.core.context_processors import csrf
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.http import HttpResponse
from django.shortcuts import render_to_response
from MadTrak.manageabout.models import AboutMadtrak, AboutMadtrakForm

def about(request):
AboutMadtrakInstance = AboutMadtrak()
result = AboutMadtrakForm(request.POST, instance=AboutMadtrakInstance)
result.save()
return HttpResponse('It worked?!? Of course it did. I knew that.')

def about_form(request):
return render_to_response('about_form.html', context_instance = 
RequestContext(request))

I ended up looking at ModelForms and trying that since I was having issues.

So does this method handle all validation and security issues for me?

Or do I still need a "result.is_valid()" among other things?


On Wednesday, July 11, 2012 11:51:19 AM UTC-4, Andre Schemschat wrote:
>
> Hey,
>>>
>>
> yeah, it basicly is. Just a very, very basic example (And sorry if i could 
> highlight this as code, i didnt find something in the format-menu :/ ).
> Of course you should validate your input first. And if you just want to 
> edit a Model within a form, you should check on the ModelForm-Class 
> https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> def vote(request, poll_id):
> try:
> obj = YourModel.objects.get(pk=poll_id)
> obj.attributea = request.POST['attributea']
> obj.attributeb = request.POST['attributeb']
> obj.save()
> return HttpResponse(validparamshere)
> except ObjectDoesNotExist:
> return HttpResponse(show_some_error)
>
>
>>>

-- 
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/-/JTdViX4I6HEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: App authoring: setup

2012-07-11 Thread Demian Brecht
Only a couple small problems with that:

* No sample code for people utilizing the app in their own projects
* Unit testing environment is a little more unorthodox to set up - rather
than just using the example project's settings (and manage.py test
app_name), I'd have to do the configuration manually (AFAIK, I haven't
looked into this too much).

On Wed, Jul 11, 2012 at 4:39 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:
>
> It seems to me that you've missed an obvious third option -- keep the
> two completely separate.
>
> Consider -- you can install apps using pip. Some of these apps will be
> formal distributions; others are just git/hg repository references.
> The only thing that binds them together is that they're isolated,
> standalone apps that can be deployed into any project you want.
>
> If I've understood your problem statement, it sounds like that's
> exactly what you want to do.
>
>  * Create an app.
>  * git init from the app root
>  * Create a setup.py for your app
>  * In a completely separate directory, create a project
>  * git init in that project
>  * set up requirements for that project that install your app into the
> project
>
> This way, you end up with 2 repositories -- one for your app, and one
> for your project. Your project will have very little content in it --
> it's just an integration layer for the apps (both self-authored and
> external) that you want in your project.
>
> 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: Django Chuck - Your powerful project punch button

2012-07-11 Thread William Deegan
Bastian,

What's the advantage of this over using buildout?

-Bill
On Jun 11, 2012, at 2:44 AM, Bastian Ballmann wrote:

> Hi Django lovers out there,
> 
> for all who didnt attend DjangoCon Europe virtually or physically we
> want to announce our project Django Chuck.
> 
> Here's what's all about:
> 
> Django Chuck is a modular, open source, command-based project build
> system developed by Notch Interactive GmbH, that gives you the power
> to create new projects as fast as pushing on a button.
> 
> In the Django Chuck world, everything is organized within so-called
> modules, which incrementally get compiled into a project. There is
> really nothing that you can't configure or adjust and guess what,
> writing and adjusting your modules is totally easy. On top of that,
> Django Chuck comes with an already impressive amount of built-in
> modules and a bullet proof project structure.
> 
> But Chuck cannot be just used to create a project. It can also checkout
> the source for you and setup everything until the dev server is up and
> running and you're ready to do your development work. Just leave all
> the annoying stuff to Chuck and if there is some task Chuck can't do
> for you at the moment you can add your own command to let Chuck
> configure your continuous integration system, setup your hosting or do
> whatever you might imagine!
> 
> URLs are:
> http://pypi.python.org/pypi/Django%20Chuck/
> http://django-chuck.readthedocs.org
> https://github.com/notch-interactive/django-chuck
> 
> We advice you to use either the pip releases or the github tagged
> downloads otherwise you will use our unstable version an weird things
> might happen ;)
> 
> If you like Django Chuck we are happy to hear from you either on
> github, stackoverflow (with tag django-chuck) or by email
> (ch...@notch-interactive.com).
> 
> Wish you an awesome day
> 
> The Django Chuck team
> -- 
> Bastian Ballmann / Web Developer
> Notch Interactive GmbH / Badenerstrasse 571 / 8048 Zürich
> Phone Phone +41 44 297 17 17 / www.notch-interactive.com
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+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: Django connection pooling using sqlalchemy connection pool

2012-07-11 Thread Russell Keith-Magee
On Thu, Jul 12, 2012 at 3:37 AM, Anand Agarwal  wrote:
> As you know, Django uses new database connection for each request. This
> works well initially. However as the load on the server increases,
> creating/destroying connections to database starts taking significant amount
> of time.  You will find many questions about using some kind of connection
> pooling for Django on sites likeStackOverflow  For example, Django
> persistent database connection.

There is a reason that Django doesn't manage connection pooling --
it's because it's handled quite well by third party tools like pgPool.

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.



Re: App authoring: setup

2012-07-11 Thread Russell Keith-Magee
On Wed, Jul 11, 2012 at 10:39 PM, Demian Brecht  wrote:
> Hi all,
>
> Is there a preferred method to create an app such that the app is the focal
> point and not the project? The app root is SCM root and it intended to be
> published on PyPI. I see one of two way to go about this:
>
> First method (my preferred):
> * Create an app at the root level of a project, using virtualenv
> * git init from the app root
> * Using setuptools (and setup.py for the app), install the app
> * Create an example project in the app directory
>
> Second method:
> * Create a project
> * Create an app for the project
> * git init from the app directory
> * Create a redundant example project
>
> Thoughts?

It seems to me that you've missed an obvious third option -- keep the
two completely separate.

Consider -- you can install apps using pip. Some of these apps will be
formal distributions; others are just git/hg repository references.
The only thing that binds them together is that they're isolated,
standalone apps that can be deployed into any project you want.

If I've understood your problem statement, it sounds like that's
exactly what you want to do.

 * Create an app.
 * git init from the app root
 * Create a setup.py for your app
 * In a completely separate directory, create a project
 * git init in that project
 * set up requirements for that project that install your app into the project

This way, you end up with 2 repositories -- one for your app, and one
for your project. Your project will have very little content in it --
it's just an integration layer for the apps (both self-authored and
external) that you want in your project.

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.



Re: JSONField: which app to choose ?

2012-07-11 Thread Michael Palumbo
Hi Matt,

Correct, using either null=True or blank=True on the field works.
However, I don't get it since I didn't click on "save", I just wanted to 
display the add page containing it. Why does it attempt to validate the 
field at this time and not wait for the form to be sent ? Maybe this is how 
Django works ?

Whatever, I think you can set a default value in the JSONField to avoid the 
error, what do you think ? I think it's handy.
improvement:
def __init__(self, *args, **kwargs):
kwargs['default'] = kwargs.get('default', '{}')
super(JSONField, self).__init__(*args, **kwargs)

It works for me.

Another point: it does not like "extra" comma right ?
{
  "nodes": { "title": "title"*,* }
}
But I guess this is wanted because JSON does not allow it ?


Michael

 

Le mercredi 11 juillet 2012 09:15:23 UTC+2, Matt Schinckel a écrit :
>
> Michael,
>
> I've been able to reproduce it: I'm not quite sure of the best way to deal 
> with it.
>
> One solution is to set either null=True, or blank=True on the field, or 
> set a default.
>
> The trick is, an empty string isn't valid JSON. I guess I've always been 
> using a default (usually of {} or [], depending upon context).
>
> Happy for you to suggest improvements, though.
>
> I believe it's actually related to 
> https://bitbucket.org/schinckel/django-jsonfield/issue/13/integrityerrors-when-using-empty-string
>
> Matt.
>

-- 
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/-/OpX1uuzKTyEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Catching Oracle Errors

2012-07-11 Thread Dan Gentry
Thanks Ian.  I'll see what I can do.


>
>

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



Re: getting variable from __init__ into clean_xxx function

2012-07-11 Thread Leandro Alves
Thanks for sharing, Tomas!!

It's in my todo list now... =)

Leandro
 

On Wednesday, July 11, 2012 6:11:03 PM UTC+2, Tomas Neme wrote:
>
> also this: 
> http://docs.python.org/tutorial/classes.html 
>
> On Wed, Jul 11, 2012 at 12:58 PM, Nikolas Stevenson-Molnar 
>  wrote: 
> > Change nbi_patch to self.nbi_patch, and you should be set. I.e: 
> > 
> > 
> > class PatchForm1(forms.Form): 
> > def __init__(self, *args, **kwargs): 
> > self.nbi_patch = kwargs.pop('nbi_patch', None) 
> > ... 
> > 
> > def clean_release_number(self): 
> > self.nbi_patch #use however you want here 
> > 
> > _Nik 
> > 
> > 
> > On 7/11/2012 8:06 AM, Leandro Alves wrote: 
> > 
> > Hi, 
> > 
> > I'm sending a variable from my views.py and getting it in my forms.py. 
> > 
> > My form looks like this now: 
> > 
> > class PatchForm1(forms.Form): 
> > def __init__(self, *args, **kwargs): 
> > nbi_patch = kwargs.pop('nbi_patch', None) 
> > super(PatchForm1, self).__init__(*args, **kwargs) 
> > 
> > release_number = forms.CharField(label='Release number:') 
> > 
> > def clean_release_number(self): 
> > #nbi_patch = I want to use the nbi_patch var from __init__ here 
> > release_number = self.cleaned_data.get("release_number") 
> > path = os.path.join(nbi_patch, release_number) 
> > if not os.path.exists(path): 
> > raise forms.ValidationError("Hmm... it looks like %s does 
> not 
> > exist in nbi-patch." % release_number ) 
> > return release_number 
> > 
> > I want to use my var nbi_patch from __init__ inside my 
> > clean_release_number() function. Is that possible? 
> > 
> > I tried pass it as a parameter but it didn't work... 
> > 
> > Thanks!!! 
> > 
> > Leandro 
> > -- 
> > 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/-/90_l6B36fHsJ. 
> > To post to this group, send email to django-users@googlegroups.com. 
> > To unsubscribe from this group, 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. 
>
>
>
> -- 
> "The whole of Japan is pure invention. There is no such country, there 
> are no such people" --Oscar Wilde 
>
> |_|0|_| 
> |_|_|0| 
> |0|0|0| 
>
> (\__/) 
> (='.'=)This is Bunny. Copy and paste bunny 
> (")_(") to help him gain world domination. 
>

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



Re: getting variable from __init__ into clean_xxx function

2012-07-11 Thread Leandro Alves
Ahhh... okay... I got it... it worked like a charm now!!! =)

Super thanks!!! 

Leandro


On Wednesday, July 11, 2012 5:58:20 PM UTC+2, Nikolas Stevenson-Molnar 
wrote:
>
>  Change nbi_patch to self.nbi_patch, and you should be set. I.e:
>
> class PatchForm1(forms.Form):
> def __init__(self, *args, **kwargs):
> self.nbi_patch = kwargs.pop('nbi_patch', None)
> ...
>
> def clean_release_number(self):
> self.nbi_patch #use however you want here
>
> _Nik
>
> On 7/11/2012 8:06 AM, Leandro Alves wrote:
>  
> Hi, 
>
>  I'm sending a variable from my views.py and getting it in my forms.py. 
>
>  My form looks like this now: 
>
>  class PatchForm1(forms.Form):
> def __init__(self, *args, **kwargs):
> nbi_patch = kwargs.pop('nbi_patch', None)
> super(PatchForm1, self).__init__(*args, **kwargs)
>
>  release_number = forms.CharField(label='Release number:')
>  
> def clean_release_number(self):
> #nbi_patch =* I want to use the **nbi_patch var from __init__ here
> *
> release_number = self.cleaned_data.get("release_number")
> path = os.path.join(*nbi_patch*, release_number)
> if not os.path.exists(path):
> raise forms.ValidationError("Hmm... it looks like %s does not 
> exist in nbi-patch." % release_number )
> return release_number
>
>  I want to use my var nbi_patch from __init__ inside my 
> clean_release_number() 
> function. Is that possible? 
>  
> I tried pass it as a parameter but it didn't work... 
>
>  Thanks!!!
>
>  Leandro
> -- 
> 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/-/90_l6B36fHsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LnscLSAa1_kJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 connection pooling using sqlalchemy connection pool

2012-07-11 Thread Anand Agarwal
As you know, Django  uses new database
connection for each request. This works well initially. However as the load
on the server increases, creating/destroying connections to database starts
taking significant amount of time.  You will find many questions about
using some kind of connection pooling for Django on sites like
StackOverflow   For example, Django persistent
database connection.


At BootStrapToday  we use
sqlalchemy‘s
connection pooling mechanism with Django for pooling the database
connections. We use variation of approach by Igor
Katson described
in http://dumpz.org/67550/.  Igor’s approach requires patching Django which
we wanted to avoid. Hence we created a small function that we import in one
of __init__.py (or models.py) (i.e. some file which gets imported early in
the application startup).

Here is more detail on how we do it at
BootStrapToday


Regards
Anand
http://bootstraptoday.com

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



Re: Form 'POST' to a database

2012-07-11 Thread Jani Tiainen
Django makes always (at least currently) full record update (iow: there is
no dirty flag for fields).

Example given is "poor" in the sense that it uses directly POST data. I
strongly would suggest leveraging modelforms when ever possible - it saves
time and nerves. You get all the validation and other goodies for free.

On Wed, Jul 11, 2012 at 8:09 PM, Dennis Lee Bieber wrote:

> On Wed, 11 Jul 2012 08:36:39 -0700 (PDT), JJ Zolper
>  declaimed the following in
> gmane.comp.python.django.user:
>
>
> > So originally:
> >
> > selected_choice = p.choice_set.get(pk=request.POST['choice'])
> >
> If I understand this (I've not run the tutorial, and only browsed
> the now-outdated print books), this statement is using the value from
> the "choice" field of the submitted form as the primary key to retrieve
> a record (model instance) from the database.
>
> pseudo-SQL
> select * from choice_set where pk = "request.POST['choice']"
>
> > this requests the submitted choice from the POST data and
> >
> > The part that says:
> >
> > selected_choice.votes += 1
> > selected_choice.save()
> >
> > Actually saves the choice to the database?
> >
> This then increments the votes field of the record (model instance)
> retrieved from the database, and then saves the record back.
>
> p-SQL
> update choice_set set
> votes = votes + 1
> where pk = selected_choice.pk
>
> {I don't know if Django is smart enough to only update the changed
> field, or if it updates the entire record}
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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



Re: Catch or raise exception designissue

2012-07-11 Thread Jani Tiainen
It all depends what is "natural" for end user point of view.

If parameter is something like start or end value I think that the most
convenient thing is to provide some reasonable default if variable is
missing or is incorrect type. Then you may use logging facility to log to
some logger (debug, warn, errror) that value provided was incorrect and was
replaced by default value.

I only do 500-errors when something really critical happens (basically
programming error) in application and request can't proceed.

On Wed, Jul 11, 2012 at 4:47 PM, Andre Schemschat  wrote:

> Hi everybody,
> i'm currently working on my first django-application and stumbled upon a
> design issue, which i cant quite decide how to handle and i thought i may
> ask here, if there are any guidelines as to how to handle this :)
> In my view i have, naturally, some code to process the request and return
> a response. This code needs a get-parameter to operate within boundaries
> and this parameter is always provided within the application (Its an
> ajax-callback).
> The question now is, what to do if the parameter is not provided somehow.
> Should i catch the resulting KeyError (Or any unexpected exception in any
> view for that matter) and just redirect to a safe page, log the error away
> and display a warning to the user or should i just let the error pass (in
> debug show the error info page, in production the 500-page), since it
> shouldnt have happend within the application?
> I'm currently tending towards the second option, because in production
> there is the 500-page, so the user doesnt get to see ugly errors and with
> an error-handling middleware i can log the exceptions and in debug its
> easier to take care of the bug, but i like to hear some opinions from the
> more experienced django-devs in here, cause i'm sure im missing some vital
> point :D
>
> Thanks,
> Andre
>
> --
> 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/-/bQyS-29Lb4QJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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



Re: feeds and get_object()

2012-07-11 Thread geaden
Hello, Eric!
I got an error: get_object() got an unexpected keyword argument 'url', when 
running the cod which is similiar to your code. Do you know what the 
problem is? By the way, I do in on Django 1.4.

Sorry, for not reply but asking a question insted.


On Tuesday, 24 June 2008 06:24:21 UTC+5, Eric Montgomery wrote:
>
> I'm using the syndication framework to generate feeds for my blogging 
> app, and everything is working fine so far.  I have multiple blogs 
> each with their own feeds, but I would like to add a combined feed. 
> The documentation seems to mention that this is possible, but it 
> doesn't provide an example and I'm not sure what's the best way to 
> implement it. 
> Here is the documentation code, which I pretty much directly copied: 
>
> class BeatFeed(Feed): 
> def get_object(self, bits): 
> # In case of "/rss/beats/0613/foo/bar/baz/", or other such 
> clutter, 
> # check that bits has only one member. 
> if len(bits) != 1: 
> raise ObjectDoesNotExist 
> return Beat.objects.get(beat__exact=bits[0]) 
>
> In this case, if len(bits) is not 1, then ObjectDoesNotExist is raised 
> (this would correspond to the url "domain.com/rss/beats/"). 
> I would like to generate a combined feed from all of my blogs, but the 
> only way I can seem to do this is to have get_object() return None, 
> and then check if obj is None in each of my title(), description(), 
> link() and items() methods in order to handle the special case.  It 
> seems to work, but doesn't feel ideal.  If anyone knows a better way 
> to do this, I'd love to know it. 
>
> Thanks, 
> Eric

-- 
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/-/2Wf9aW27pCwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Catching Oracle Errors

2012-07-11 Thread Ian
On Tuesday, July 10, 2012 7:45:58 AM UTC-6, Dan Gentry wrote:
>
> My Django app runs on an Oracle database.
>
> A few times a year, the database is unavailable because of a scheduled 
> process or unplanned downtime. However, I can't see how to catch the error 
> and give a useful message back to the requester. Instead, a 500 error is 
> triggered, and I get an email (or hundreds) showing the exception. One 
> example is:
>
>   File 
> "/opt/UDO/env/events/lib/python2.6/site-packages/django/db/backends/oracle/base.py",
>  line 447, in _cursor
> self.connection = Database.connect(conn_string, **conn_params)
>
> DatabaseError: ORA-01035: ORACLE only available to users with RESTRICTED 
> SESSION privilege
>
> I see a similar error with a different ORA number when the DB is down.
>
> Because the exception is thrown deep within the Django libraries, and can 
> be triggered by any of my views or the built in admin views, I don't know 
> where any exception trapping code would go.
>
> Any suggestions?
>
There's nothing specific to Oracle about this.  First, make sure you've 
read:

https://docs.djangoproject.com/en/1.4/howto/error-reporting/

In your case you might do any of the following:

1) Customize the 500.html server error template to provide a more 
user-friendly message.

2) Customize the server error view, which by default just renders the 
500.html template:
https://docs.djangoproject.com/en/1.4/topics/http/views/#the-500-server-error-view

3) Use a middleware to customize completely how otherwise unhandled errors 
are processed.  You can create a customized 500 (or 503) response and do 
whatever admin notification and other processing you want.

-- 
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/-/r5lfeWa1iAgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 Date formats - Please help

2012-07-11 Thread Houmie
Hi everyone,


class CallsForm(ModelForm):   
class Meta:
model = Conversation
widgets = {
'contact_date': forms.DateInput(),
 }

With a date input like this, my form shows the date like '2012-07-11', 
which seems international to me.

I live in UK and my settings is like the following:

TIME_ZONE = 'Europe/London'
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = True

Eventually I would like to support both British and American date formats.
For the time being since the global language is set as American, I was 
expecting to see the American format.  mm/dd/yyy
But instead I see /mm/dd

How do I fix this in a proper way according to I18N, so that when later my 
users change the language to British English, they get to see the British 
format dd/mm/ without any further hacks?

I would really appreciate your help on this as I am researching since hours 
without any success.

Many Thanks,
Houman

-- 
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/-/QiqKfZYeBVAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 sends two requests

2012-07-11 Thread Jani Tiainen
In one public site we ended up doing both, server side re-submission checks
and client side javascript with timeout re-enable "hack".

We just store magic key to cache which is checked on every submission. If
magic key is missing submission is valid (first one) and key is set if
form was valid:

if request.method == 'POST':
if cache.get('%s.%s' % (request.session.session_key,
data['unique_id'])):
if form.is_valid():
cache.set(('%s.%s' % (request.session.session_key,
data['unique_id']), true) # Block subsequent requests
else:
pass # Output error messages about form
else:
# Key is in the cache, fail
return HttpResponseBadRequest()

On Tue, Jul 10, 2012 at 2:22 PM, jonas peters wrote:

> Thanks, helped me a lot.
>
>
>
> Em segunda-feira, 9 de julho de 2012 17h53min23s UTC-3, Dennis Lee Bieber
> escreveu:
>
>> On Mon, 9 Jul 2012 09:26:15 -0700 (PDT), jonas peters
>>  declaimed the following in
>> gmane.comp.python.django.user:
>>
>> > I have a model and use standard django administration, when a user
>> clicks
>> > the save button it sends the request, it takes time to respond and the
>> user
>> > clicks the save button again and then sends another request, and
>> creating
>> > two records. have some setting in django to avoid this problem? I
>> thought
>> > about locking the save button when it is clicked so the user does not
>> click
>> > more than once to complete the request.
>> >
>> In general (that is, not Django specific), my experience is that
>> potentially slow sites in which an extra submittal would cause problems
>> tend to include a warning message to only click once (the sites I've
>> seen this on tend to be online markets -- where the warning is that
>> double clicking could result in a second order charged to the credit
>> card.
>>
>> The other general solution would be to collect the data, send it
>> to
>> a separate worker thread/process and immediately return a "please wait"
>> type response -- this response should have an automatic redirect (using
>> a cookie to identify the worker) to a page that will either find the
>> worker thread has finished and can return the real next page -- or if
>> the worker is still busy resend the "please wait" page.
>>
>> More specific modes:
>> http://www.turnkeylinux.org/**blog/prevent-double-click-**form-submission
>> (general search: prevent double click form submit
>> http://www.google.com/#hl=en&**sclient=psy-ab=prevent+**
>> double+click+form+submit=**prevent+double+click+form+**
>> submit_l=serp.3..**0i30j0i5i30.8464.23704.0.**
>> 23926.28.25.2.1.1.6.503.4601.**0j21j3j5-1.25.0...0.0.c3W_**
>> 7yOZRzI=1=on.2,or.r_**gc.r_pw.r_qf
>> .,cf.osb=**9da4b66dc5fd8e9a=1044=**748
>> )
>>
>>
>>
>> > Sorry my english Thanks!
>> --
>> Wulfraed Dennis Lee Bieber AF6VN
>> wlfr...@ix.netcom.com
>> HTTP://wlfraed.home.netcom.**com/
>>
>>  --
> 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/-/ZU-HtLFqcp4J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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



Re: getting variable from __init__ into clean_xxx function

2012-07-11 Thread Tomas Neme
also this:
http://docs.python.org/tutorial/classes.html

On Wed, Jul 11, 2012 at 12:58 PM, Nikolas Stevenson-Molnar
 wrote:
> Change nbi_patch to self.nbi_patch, and you should be set. I.e:
>
>
> class PatchForm1(forms.Form):
> def __init__(self, *args, **kwargs):
> self.nbi_patch = kwargs.pop('nbi_patch', None)
> ...
>
> def clean_release_number(self):
> self.nbi_patch #use however you want here
>
> _Nik
>
>
> On 7/11/2012 8:06 AM, Leandro Alves wrote:
>
> Hi,
>
> I'm sending a variable from my views.py and getting it in my forms.py.
>
> My form looks like this now:
>
> class PatchForm1(forms.Form):
> def __init__(self, *args, **kwargs):
> nbi_patch = kwargs.pop('nbi_patch', None)
> super(PatchForm1, self).__init__(*args, **kwargs)
>
> release_number = forms.CharField(label='Release number:')
>
> def clean_release_number(self):
> #nbi_patch = I want to use the nbi_patch var from __init__ here
> release_number = self.cleaned_data.get("release_number")
> path = os.path.join(nbi_patch, release_number)
> if not os.path.exists(path):
> raise forms.ValidationError("Hmm... it looks like %s does not
> exist in nbi-patch." % release_number )
> return release_number
>
> I want to use my var nbi_patch from __init__ inside my
> clean_release_number() function. Is that possible?
>
> I tried pass it as a parameter but it didn't work...
>
> Thanks!!!
>
> Leandro
> --
> 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/-/90_l6B36fHsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



Static File - help, for a question

2012-07-11 Thread Dott. Tegagni Alessandro
Hi!

I do see the static files (images and pdf), I added STATIC_DIRS, the 
directories when I upload that files:

STATICFILES_DIRS = (
'/home/alessandro/Scrivania/progetto/media/photos/custodia/',
'/home/alessandro/Scrivania/progetto/media/definitiva/',
'/home/alessandro/Scrivania/progetto/media/proforma/',
'/home/alessandro/Scrivania/progetto/media/fpdf/',
)


in STATIC_URL:

STATIC_URL = '/static/'


in 

INSTALLED_APPS = (
   

'django.contrib.staticfiles',
 
)

(the permission are 0777)

But When I want to see the image or pdf files, upload, the screen tell 
me:-> 
Page not found

http://127.0.0.1:8000/home/alessandro/Scrivania/progetto/media/photos/custodia/powered_by.png


Any Ideas? Why this Problem?

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



Re: getting variable from __init__ into clean_xxx function

2012-07-11 Thread Nikolas Stevenson-Molnar
Change nbi_patch to self.nbi_patch, and you should be set. I.e:

class PatchForm1(forms.Form):
def __init__(self, *args, **kwargs):
self.nbi_patch = kwargs.pop('nbi_patch', None)
...

def clean_release_number(self):
self.nbi_patch #use however you want here

_Nik

On 7/11/2012 8:06 AM, Leandro Alves wrote:
> Hi,
>
> I'm sending a variable from my views.py and getting it in my forms.py. 
>
> My form looks like this now: 
>
> class PatchForm1(forms.Form):
> def __init__(self, *args, **kwargs):
> nbi_patch = kwargs.pop('nbi_patch', None)
> super(PatchForm1, self).__init__(*args, **kwargs)
>
> release_number = forms.CharField(label='Release number:')
>  
> def clean_release_number(self):
> #nbi_patch =*I want to use the **nbi_patch var from __init__ here*
> release_number = self.cleaned_data.get("release_number")
> path = os.path.join(*nbi_patch*, release_number)
> if not os.path.exists(path):
> raise forms.ValidationError("Hmm... it looks like %s does
> not exist in nbi-patch." % release_number )
> return release_number
>
> I want to use my var nbi_patch from __init__inside
> my clean_release_number() function. Is that possible? 
>  
> I tried pass it as a parameter but it didn't work... 
>
> Thanks!!!
>
> Leandro
> -- 
> 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/-/90_l6B36fHsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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 'POST' to a database

2012-07-11 Thread Andre Schemschat

>
> Hey,
>>
>
yeah, it basicly is. Just a very, very basic example (And sorry if i could 
highlight this as code, i didnt find something in the format-menu :/ ).
Of course you should validate your input first. And if you just want to 
edit a Model within a form, you should check on the ModelForm-Class 
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/

def vote(request, poll_id):
try:
obj = YourModel.objects.get(pk=poll_id)
obj.attributea = request.POST['attributea']
obj.attributeb = request.POST['attributeb']
obj.save()
return HttpResponse(validparamshere)
except ObjectDoesNotExist:
return HttpResponse(show_some_error)


>>

-- 
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/-/uPRAe_zhfcgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 'POST' to a database

2012-07-11 Thread JJ Zolper
I guess on Part 4 is what I need...

So hmmm.

def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the poll voting form.
return render_to_response('polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
}, context_instance=RequestContext(request))
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls.views.results', 
args=(p.id,)))

So originally:

selected_choice = p.choice_set.get(pk=request.POST['choice'])

this requests the submitted choice from the POST data and 

The part that says:

selected_choice.votes += 1
selected_choice.save()

Actually saves the choice to the database?

Is it just two lines? requesting the data form request.POST and then that 
variable.save() to store it in the database?

JJ

On Wednesday, July 11, 2012 12:31:44 AM UTC-4, Lee Hinde wrote:
>
>
> On Jul 10, 2012, at 8:48 PM, JJ Zolper wrote:
>
> I honestly just have a general question.
>
> If I have one database set in my settings file in settings.py and I try to 
> execute a simple HTML Form using 'POST' how do I get that data into my 
> PostgreSQL database?
>
> In my view do I have to interface with my model and thus the model takes 
> care of the rest?
>
> https://docs.djangoproject.com/en/1.4/topics/forms/modelforms/
>
> This link seems to be down the right road I think?
>
> I'm sorry if this question does not make a lot of sense but I really am 
> trying to find some direction as to how once I have a view, model, urlconf, 
> and settings file with a database tied to it (i checked using the import 
> django.db connection/cursor test) how do I get the request.POST data sent 
> to my database?
>
> Thanks,
>
> JJ
>
> I recommend the tutorial. It walks you through the process, soup to nuts.
>
> https://docs.djangoproject.com/en/dev/intro/tutorial01/
>
>

-- 
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/-/WrL0VQrqMvQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: CSRF verification failed. Request aborted.

2012-07-11 Thread JJ Zolper
Thanks so much for the tip!

I had part of the solution there from our other friend but I will add that 
extra protection when I can!

Are you familiar with CSRF? And your solution what the issue you fix is?

Any other insight into the reason for the code would be great!

Thanks again,

JJ

On Wednesday, July 11, 2012 8:31:20 AM UTC-4, skhohlov wrote:
>
> problem in view also : 
>
> def about(request): 
> if request.method == 'POST': 
> return HttpResponseRedirect('/about/') 
> elif request.method == 'GET': 
> return render_to_response('about.html', 
> context_instance=RequestContext(request)) 
> else: 
> raise Http404() 
>
>  this one should be converted to : 
>
> def about(request): 
>if request.method == 'POST': 
> return HttpResponseRedirect('/about/') 
> elif request.method == 'GET': 
> protectedbycsrf= {} 
> protectedbycsrf.update(csrf(request)) 
> return render_to_response('about.html', 
> context_instance=RequestContext(protectedbycsrf)) 
> else: 
> raise Http404() 
>
>
>
> 2012/7/11 Сергей Фурсов : 
> > oops) 
> > 
> > 
> > 2012/7/11 Сергей Фурсов  
> >> 
> >> Some notes about your models: 
> >> 1. why do you create id field manually? Django will do it for you ;) 
> >> 2. why do you explicitly set db_table and db_column? Do you have some 
> >> legacy database? If not, django will do it for you ;) 
> >> 3. move your vision from tables to objects 
> >> 4. call your models in CamelCase notation and in singular form 
> >> 5. try to understand related_name parameter 
> >> 
> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name
>  
> >> 
> >> in my opinion your models should looks like: 
> >> from django.db import models 
> >> 
> >> class Owner(models.Model): 
> >> num = models.IntegerField() 
> >> 
> >> def __unicode__(self): 
> >> return unicode(self.num) 
> >> 
> >> 
> >> class Vehicle(models.Model): 
> >> plate = models.CharField(max_length=80, unique=True) 
> >> owner1 = models.ForeignKey('Owner', null=True, 
> >> related_name='vehicles1', blank=True) 
> >> owner2 = models.ForeignKey('Owner', null=True, 
> >> related_name='vehicles2', blank=True) 
> >> 
> >> def __unicode__(self): 
> >> return self.plate 
> >> 
> >> 
> >> class WebRequest(models.Model): 
> >> owner = models.ForeignKey('Owner') 
> >> vehicle1 = models.ForeignKey(Vehicle, related_name='web_requests1') 
> >> vehicle2 = models.ForeignKey(Vehicle, null=True, 
> >> related_name='web_requests2', blank=True) 
> >> 
> >> 
> >> 
> >> 2012/7/11 Сергей Фурсов  
> >>> 
> >>> Ok, I tried your code, just added in models.py fake owners model to 
> >>> correct foreign key 
> >>> 
> >>> class Owners(models.Model): 
> >>> num = models.IntegerField() 
> >>> 
> >>> def __unicode__(self): 
> >>> return unicode(self.num) 
> >>> 
> >>> and create views.py with three lines of code: 
> >>> 
> >>> def page(request): 
> >>> form = WebrequestsForm(own_id=1) 
> >>> return render_to_response('page.html', {'form': form}) 
> >>> 
> >>> and it works! 
> >>> May be problem in your views.py? 
> >>> 
> >>> 
> >>> 2012/7/10 Сергей Фурсов  
>  
>  as described in error message your view  function have to use 
>  RequestContext for the template, instead of Context. 
>  your view should looks like 
>  
>  def about(request): 
>  if request.method == 'POST': 
>  return HttpResponseRedirect('/about/') 
>  elif request.method == 'GET': 
>  return render_to_response('about.html', 
>  context_instance=RequestContext(request)) 
>  else: 
>  raise Http404() 
>  
>  note that you redirect (HttpResponseRedirect) to url, but render 
>  (render_to_response) template with context 
>  
>  also I changed action for form in tempalte to /about/ to handle POST 
> and 
>  GET requests in same view 
>  
>  hope this helps 
>  
>  2012/7/10 JJ Zolper  
> > 
> > Here is the error I received with debug set to true for Django: 
> > 
> > Forbidden (403) 
> > 
> > CSRF verification failed. Request aborted. 
> > 
> > Help 
> > 
> > Reason given for failure: 
> > 
> > CSRF token missing or incorrect. 
> > 
> > 
> > In general, this can occur when there is a genuine Cross Site 
> Request 
> > Forgery, or when Django's CSRF mechanism has not been used 
> correctly. For 
> > POST forms, you need to ensure: 
> > 
> > The view function uses RequestContext for the template, instead of 
> > Context. 
> > In the template, there is a {% csrf_token %} template tag inside 
> each 
> > POST form that targets an internal URL. 
> > If you are not using CsrfViewMiddleware, then you must 

Re: CSRF verification failed. Request aborted.

2012-07-11 Thread JJ Zolper
1. I don't think I set my id field just name title bio and website.
2. I don't set those two values.
3. not sure..
4. not sure...

I believe you corrected yourself as this post doesn't seem relevant. Not a 
problem!

On Wednesday, July 11, 2012 8:11:46 AM UTC-4, Sergey Fursov wrote:
>
> Some notes about your models:
> 1. why do you create id field manually? Django will do it for you ;)
> 2. why do you explicitly set db_table and db_column? Do you have some 
> legacy database? If not, django will do it for you ;)
> 3. move your vision from tables to objects
> 4. call your models in CamelCase notation and in singular form
> 5. try to understand related_name parameter 
> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name
>
> in my opinion your models should looks like:
> from django.db import models
>
> class Owner(models.Model):
> num = models.IntegerField()
>
> def __unicode__(self):
> return unicode(self.num)
>
>
> class Vehicle(models.Model):
> plate = models.CharField(max_length=80, unique=True)
> owner1 = models.ForeignKey('Owner', null=True, 
> related_name='vehicles1', blank=True)
> owner2 = models.ForeignKey('Owner', null=True, 
> related_name='vehicles2', blank=True)
>
> def __unicode__(self):
> return self.plate
>
>
> class WebRequest(models.Model):
> owner = models.ForeignKey('Owner')
> vehicle1 = models.ForeignKey(Vehicle, related_name='web_requests1')
> vehicle2 = models.ForeignKey(Vehicle, null=True, 
> related_name='web_requests2', blank=True)
>
>
>
> 2012/7/11 Сергей Фурсов 
>
>> Ok, I tried your code, just added in models.py fake owners model to 
>> correct foreign key
>>
>> class Owners(models.Model):
>> num = models.IntegerField()
>>
>> def __unicode__(self):
>> return unicode(self.num)
>>
>> and create views.py with three lines of code:
>>
>> def page(request):
>> form = WebrequestsForm(own_id=1)
>> return render_to_response('page.html', {'form': form})
>>
>> and it works! 
>> May be problem in your views.py?
>>
>>
>> 2012/7/10 Сергей Фурсов 
>>
>>> as described in error message your view  function have to use 
>>> RequestContext
>>>  for 
>>> the template, instead of Context. 
>>> your view should looks like
>>>
>>> def about(request):
>>> if request.method == 'POST':
>>> return HttpResponseRedirect('/about/')
>>> elif request.method == 'GET':
>>> return render_to_response('about.html', 
>>> context_instance=RequestContext(request))
>>> else:
>>> raise Http404()
>>>
>>> note that you redirect (HttpResponseRedirect) to url, but 
>>> render (render_to_response) template with context
>>>
>>> also I changed action for form in tempalte to /about/ to handle POST and 
>>> GET requests in same view
>>>
>>> hope this helps
>>>
>>> 2012/7/10 JJ Zolper 
>>>
 Here is the error I received with debug set to true for Django:

 Forbidden (403)

 CSRF verification failed. Request aborted.
 Help

 Reason given for failure:

 CSRF token missing or incorrect.
 

 In general, this can occur when there is a genuine Cross Site Request 
 Forgery, or when Django's CSRF 
 mechanism
  has 
 not been used correctly. For POST forms, you need to ensure:

- The view function uses 
 RequestContext
  for 
the template, instead of Context. 
- In the template, there is a {% csrf_token %} template tag inside 
each POST form that targets an internal URL.
- If you are not using CsrfViewMiddleware, then you must use 
csrf_protect on any views that use the csrf_token template tag, as 
well as those that accept the POST data. 

 You're seeing the help section of this page because you have DEBUG = 
 True in your Django settings file. Change that to False, and only the 
 initial error message will be displayed.

 You can customize this page using the CSRF_FAILURE_VIEW setting.


 I'm wondering if this is caused because I don't have a redirect page 
 for my 'POST' HTML submit.

 Now my code...

 URLCONF:

 from django.conf.urls.defaults import patterns, include, url

 from MadTrak.manageabout.views import about, about_form


 # Uncomment the next two lines to enable the admin:

 from django.contrib import admin

 admin.autodiscover()


 urlpatterns = patterns('',


 (r'^about_form/', about_form),

 (r'^about/', about),


 # Examples:

 # url(r'^$', 

Re: CSRF verification failed. Request aborted.

2012-07-11 Thread JJ Zolper
Yep it's a problem with my views.py and my template or html page.

My html page needed the csrf token tag: {% csrf_token %}

and my view needed: return render_to_response('about.html', 
context_instance=RequestContext(request)) 

so thanks for the help!!!

On Wednesday, July 11, 2012 7:58:54 AM UTC-4, Sergey Fursov wrote:
>
> Ok, I tried your code, just added in models.py fake owners model to 
> correct foreign key
>
> class Owners(models.Model):
> num = models.IntegerField()
>
> def __unicode__(self):
> return unicode(self.num)
>
> and create views.py with three lines of code:
>
> def page(request):
> form = WebrequestsForm(own_id=1)
> return render_to_response('page.html', {'form': form})
>
> and it works! 
> May be problem in your views.py?
>
>
> 2012/7/10 Сергей Фурсов 
>
>> as described in error message your view  function have to use 
>> RequestContext
>>  for 
>> the template, instead of Context. 
>> your view should looks like
>>
>> def about(request):
>> if request.method == 'POST':
>> return HttpResponseRedirect('/about/')
>> elif request.method == 'GET':
>> return render_to_response('about.html', 
>> context_instance=RequestContext(request))
>> else:
>> raise Http404()
>>
>> note that you redirect (HttpResponseRedirect) to url, but 
>> render (render_to_response) template with context
>>
>> also I changed action for form in tempalte to /about/ to handle POST and 
>> GET requests in same view
>>
>> hope this helps
>>
>> 2012/7/10 JJ Zolper 
>>
>>> Here is the error I received with debug set to true for Django:
>>>
>>> Forbidden (403)
>>>
>>> CSRF verification failed. Request aborted.
>>> Help
>>>
>>> Reason given for failure:
>>>
>>> CSRF token missing or incorrect.
>>> 
>>>
>>> In general, this can occur when there is a genuine Cross Site Request 
>>> Forgery, or when Django's CSRF 
>>> mechanism
>>>  has 
>>> not been used correctly. For POST forms, you need to ensure:
>>>
>>>- The view function uses 
>>> RequestContext
>>>  for 
>>>the template, instead of Context. 
>>>- In the template, there is a {% csrf_token %} template tag inside 
>>>each POST form that targets an internal URL.
>>>- If you are not using CsrfViewMiddleware, then you must use 
>>>csrf_protect on any views that use the csrf_token template tag, as 
>>>well as those that accept the POST data. 
>>>
>>> You're seeing the help section of this page because you have DEBUG = 
>>> True in your Django settings file. Change that to False, and only the 
>>> initial error message will be displayed.
>>>
>>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>>
>>>
>>> I'm wondering if this is caused because I don't have a redirect page for 
>>> my 'POST' HTML submit.
>>>
>>> Now my code...
>>>
>>> URLCONF:
>>>
>>> from django.conf.urls.defaults import patterns, include, url
>>>
>>> from MadTrak.manageabout.views import about, about_form
>>>
>>>
>>> # Uncomment the next two lines to enable the admin:
>>>
>>> from django.contrib import admin
>>>
>>> admin.autodiscover()
>>>
>>>
>>> urlpatterns = patterns('',
>>>
>>>
>>> (r'^about_form/', about_form),
>>>
>>> (r'^about/', about),
>>>
>>>
>>> # Examples:
>>>
>>> # url(r'^$', 'MadTrak.views.home', name='home'),
>>>
>>> # url(r'^MadTrak/', include('MadTrak.foo.urls')),
>>>
>>>
>>> ## url(r'^$', 'MadTrak.views.home', name='home'), with a view named home
>>>
>>> ## url(r'^listen/', 'MadTrak.views.home', name='home'), with a view 
>>> named home
>>>
>>> ## url(r'^home/', 'MadTrak.views.home', name='home'), with a view named 
>>> home
>>>
>>>
>>> # Uncomment the admin/doc line below to enable admin documentation:
>>>
>>> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>>
>>>
>>> # Uncomment the next line to enable the admin:
>>>
>>> url(r'^admin/', include(admin.site.urls)),
>>>
>>> )
>>>
>>>
>>> views.py in my manageabout app:
>>>
>>> from django.http import HttpResponseRedirect
>>>
>>> from django.shortcuts import render_to_response
>>>
>>> from MadTrak.manageabout.models import AboutMadtrak
>>>
>>>
>>> def about_form(request):
>>>
>>> return render_to_response('about_form.html')
>>>
>>>
>>> def about(request):
>>>
>>> if request.method == 'POST':
>>>
>>># do_something_for_post()
>>>
>>> return HttpResponseRedirect('about.html')
>>>
>>> elif request.method == 'GET':
>>>
>>> return render_to_response('/')
>>>
>>> else:
>>>
>>> raise Http404()
>>>
>>>
>>> model where i tried to set up my database to recieve the information 
>>> posted:
>>>
>>> from django.db import models
>>>
>>>
>>> 

Re: CSRF verification failed. Request aborted.

2012-07-11 Thread JJ Zolper
I apologize for not responding sooner!

This line:

return render_to_response('about.html', 
context_instance=RequestContext(request)) 

helped immensely! so in order for the render response method to work it has 
to have some sort of data/context of data passed along with it? I'm still 
trying to think about that.

Also if I add:

{% csrf_token %}


the csrf token right after my form it seems to work like a charm!

I've actually started a new thread under:  Form 'POST' to a 
database
 

because I'm trying to understand exactly how once the html form using POST 
is submitted how that propagates through and into my database.

I think that's the real issue here. This CSRF issue really not that 
important currently because it's just a security/setting issue. It just 
protects againist the issue of data not coming from the context of the 
request and from elsewhere on the internet! Not good but not a major 
priority for me right now.

Thanks,

JJ

On Tuesday, July 10, 2012 2:36:17 AM UTC-4, Sergey Fursov wrote:
>
> as described in error message your view  function have to use 
> RequestContext
>  for 
> the template, instead of Context. 
> your view should looks like
>
> def about(request):
> if request.method == 'POST':
> return HttpResponseRedirect('/about/')
> elif request.method == 'GET':
> return render_to_response('about.html', 
> context_instance=RequestContext(request))
> else:
> raise Http404()
>
> note that you redirect (HttpResponseRedirect) to url, but 
> render (render_to_response) template with context
>
> also I changed action for form in tempalte to /about/ to handle POST and 
> GET requests in same view
>
> hope this helps
>
> 2012/7/10 JJ Zolper 
>
>> Here is the error I received with debug set to true for Django:
>>
>> Forbidden (403)
>>
>> CSRF verification failed. Request aborted.
>> Help
>>
>> Reason given for failure:
>>
>> CSRF token missing or incorrect.
>> 
>>
>> In general, this can occur when there is a genuine Cross Site Request 
>> Forgery, or when Django's CSRF 
>> mechanism
>>  has 
>> not been used correctly. For POST forms, you need to ensure:
>>
>>- The view function uses 
>> RequestContext
>>  for 
>>the template, instead of Context. 
>>- In the template, there is a {% csrf_token %} template tag inside 
>>each POST form that targets an internal URL.
>>- If you are not using CsrfViewMiddleware, then you must use 
>>csrf_protect on any views that use the csrf_token template tag, as 
>>well as those that accept the POST data. 
>>
>> You're seeing the help section of this page because you have DEBUG = True in 
>> your Django settings file. Change that to False, and only the initial 
>> error message will be displayed.
>>
>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>
>>
>> I'm wondering if this is caused because I don't have a redirect page for 
>> my 'POST' HTML submit.
>>
>> Now my code...
>>
>> URLCONF:
>>
>> from django.conf.urls.defaults import patterns, include, url
>>
>> from MadTrak.manageabout.views import about, about_form
>>
>>
>> # Uncomment the next two lines to enable the admin:
>>
>> from django.contrib import admin
>>
>> admin.autodiscover()
>>
>>
>> urlpatterns = patterns('',
>>
>>
>> (r'^about_form/', about_form),
>>
>> (r'^about/', about),
>>
>>
>> # Examples:
>>
>> # url(r'^$', 'MadTrak.views.home', name='home'),
>>
>> # url(r'^MadTrak/', include('MadTrak.foo.urls')),
>>
>>
>> ## url(r'^$', 'MadTrak.views.home', name='home'), with a view named home
>>
>> ## url(r'^listen/', 'MadTrak.views.home', name='home'), with a view named 
>> home
>>
>> ## url(r'^home/', 'MadTrak.views.home', name='home'), with a view named 
>> home
>>
>>
>> # Uncomment the admin/doc line below to enable admin documentation:
>>
>> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>>
>> # Uncomment the next line to enable the admin:
>>
>> url(r'^admin/', include(admin.site.urls)),
>>
>> )
>>
>>
>> views.py in my manageabout app:
>>
>> from django.http import HttpResponseRedirect
>>
>> from django.shortcuts import render_to_response
>>
>> from MadTrak.manageabout.models import AboutMadtrak
>>
>>
>> def about_form(request):
>>
>> return render_to_response('about_form.html')
>>
>>
>> def about(request):
>>
>> if request.method == 'POST':
>>
>># do_something_for_post()
>>
>> return HttpResponseRedirect('about.html')
>>
>> elif request.method == 'GET':
>>
>> return render_to_response('/')
>>
>> else:
>>
>> raise Http404()
>>
>>
>> model 

getting variable from __init__ into clean_xxx function

2012-07-11 Thread Leandro Alves
Hi,

I'm sending a variable from my views.py and getting it in my forms.py. 

My form looks like this now: 

class PatchForm1(forms.Form):
def __init__(self, *args, **kwargs):
nbi_patch = kwargs.pop('nbi_patch', None)
super(PatchForm1, self).__init__(*args, **kwargs)

release_number = forms.CharField(label='Release number:')
 
def clean_release_number(self):
#nbi_patch =* I want to use the **nbi_patch var from __init__ here*
release_number = self.cleaned_data.get("release_number")
path = os.path.join(*nbi_patch*, release_number)
if not os.path.exists(path):
raise forms.ValidationError("Hmm... it looks like %s does not 
exist in nbi-patch." % release_number )
return release_number

I want to use my var nbi_patch from __init__ inside my clean_release_number() 
function. Is that possible? 
 
I tried pass it as a parameter but it didn't work... 

Thanks!!!

Leandro

-- 
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/-/90_l6B36fHsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 'POST' to a database

2012-07-11 Thread JJ Zolper
That's great and everything except I've done all that already.

I've generated my URLconf, template, and model. Registered the model with 
the admin site. Created the table from the model in my postgresql database 
and set up the settings file and used syncdb to connect and make sure I 
have access and all that fun stuff.

Now, I'm trying to understand the idea behind when I have a Form if you 
know what that is and I use the 'POST' html request and I send that data 
through my views.py file and I want that to be sent to my model/database, 
how I'm supposed to actually process that.

Unless I'm supposed to tie my django app into the database python shell I 
don't think that link answers my question. This is the code. I'm trying to 
propagate data through from the template to the view to the model and 
hopefully at sometime soon my database.

Thanks,

JJ

On Wednesday, July 11, 2012 12:31:44 AM UTC-4, Lee Hinde wrote:
>
>
> On Jul 10, 2012, at 8:48 PM, JJ Zolper wrote:
>
> I honestly just have a general question.
>
> If I have one database set in my settings file in settings.py and I try to 
> execute a simple HTML Form using 'POST' how do I get that data into my 
> PostgreSQL database?
>
> In my view do I have to interface with my model and thus the model takes 
> care of the rest?
>
> https://docs.djangoproject.com/en/1.4/topics/forms/modelforms/
>
> This link seems to be down the right road I think?
>
> I'm sorry if this question does not make a lot of sense but I really am 
> trying to find some direction as to how once I have a view, model, urlconf, 
> and settings file with a database tied to it (i checked using the import 
> django.db connection/cursor test) how do I get the request.POST data sent 
> to my database?
>
> Thanks,
>
> JJ
>
> I recommend the tutorial. It walks you through the process, soup to nuts.
>
> https://docs.djangoproject.com/en/dev/intro/tutorial01/
>
>

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



App authoring: setup

2012-07-11 Thread Demian Brecht
Hi all,

Is there a preferred method to create an app such that the app is the focal 
point and not the project? The app root is SCM root and it intended to be 
published on PyPI. I see one of two way to go about this:

First method (my preferred):
* Create an app at the root level of a project, using virtualenv
* git init from the app root
* Using setuptools (and setup.py for the app), install the app
* Create an example project in the app directory

Second method:
* Create a project
* Create an app for the project
* git init from the app directory
* Create a redundant example project

Thoughts?

-- 
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/-/2Gn0ZkKJanYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: map in django

2012-07-11 Thread j_syk
This Gist https://gist.github.com/1027898 is an example of a location Model 
which calls on a helper function when saved to find the lat & long of the 
address when it is saved. 

The original snippet of the function is here- 
http://djangosnippets.org/snippets/2399/

On Wednesday, July 11, 2012 2:35:24 AM UTC-5, Satvir Kaur wrote:
>
> On Wed, Jul 4, 2012 at 9:23 PM, yak-man wrote: 
> > You might try browsing these: 
> > The code from Zain's US PyCon2012 tutorial on making interaxtive maps is 
> also in his github repositories - you might find that interesting. 
> What is link for that??? 
>
>
> -- 
> Satvir Kaur 
> satveerkaur.blogspot.in 
>

-- 
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/-/6Xfx3oUgXvQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: "Cannot convert <QueryDict:" after limiting foreign key

2012-07-11 Thread mapapage

>
> You were completely right in the first place. It worked! It seemed more 
> complex to me as I'm newbie in django :) Sorry for the inconvenience..
>
You really saved me, thank you! 

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



Catch or raise exception designissue

2012-07-11 Thread Andre Schemschat
Hi everybody,
i'm currently working on my first django-application and stumbled upon a 
design issue, which i cant quite decide how to handle and i thought i may 
ask here, if there are any guidelines as to how to handle this :)
In my view i have, naturally, some code to process the request and return a 
response. This code needs a get-parameter to operate within boundaries and 
this parameter is always provided within the application (Its an 
ajax-callback).
The question now is, what to do if the parameter is not provided somehow. 
Should i catch the resulting KeyError (Or any unexpected exception in any 
view for that matter) and just redirect to a safe page, log the error away 
and display a warning to the user or should i just let the error pass (in 
debug show the error info page, in production the 500-page), since it 
shouldnt have happend within the application?
I'm currently tending towards the second option, because in production 
there is the 500-page, so the user doesnt get to see ugly errors and with 
an error-handling middleware i can log the exceptions and in debug its 
easier to take care of the bug, but i like to hear some opinions from the 
more experienced django-devs in here, cause i'm sure im missing some vital 
point :D

Thanks,
Andre

-- 
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/-/bQyS-29Lb4QJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: "Cannot convert <QueryDict:" after limiting foreign key

2012-07-11 Thread Сергей Фурсов
I think that you can replace

if request.method == 'POST':
form = WebrequestsForm(request.POST)

with:

if request.method == 'POST':
form = WebrequestsForm(data=request.POST, own_id=own_id)

as I said in first answer


2012/7/11 mapapage 

> I have a legacy db so I have many restrictions and conventions. Anyway,
>> the associated part of views looks like:
>>
>
> def Webrequests(request, user_id):
>
> try:
> owner = Owners.objects.get(id=user_id)
>
>  except owner.DoesNotExist:
> print "There isnt an owner with such id."
>
> else:
> lname=owner.lname #epwnumia
> fname=owner.fname
> tel=owner.tel1
> fax=owner.fax1
> email=owner.email1
> own_id = user_id
>
>
> if request.method == 'POST':
> form = WebrequestsForm(request.POST)
>
> if form.is_valid():
> form.save()
>
> return render_to_response('success.html', locals(),
> context_instance= RequestContext(request))
> else:
>
> own_id = user_id
>
> form = WebrequestsForm(own_id=own_id, initial = {'email':email,
> 'fax':fax, 'tel':tel, 'own_id':own_id})
>
> return render_to_response('main_Webrequests.html', locals(),
> context_instance= RequestContext(request))
>
> What do u think?
>
>
> --
> 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/-/1myJTSWBIbEJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



django-easy-maps not rendering map when using ajax

2012-07-11 Thread Dhiraj Thakur
 

The error is this "A call to document.write() from an asynchronously-loaded 
external script was ignored." but i haven't used document.write() anywhere 
in my jQuery code 
my template code is this

  {{address}}   
{% load easy_maps_tags %} 
{% easy_map address 725 400 %}

This 
commenton
 SO question proposes a solution but i don't understand it..i have 
the same problem that mentioned on the question except i am doing the same 
thing in Django using easy-maps.

-- 
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/-/K45-gC-or7wJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: "Cannot convert <QueryDict:" after limiting foreign key

2012-07-11 Thread mapapage

>
> I have a legacy db so I have many restrictions and conventions. Anyway, 
> the associated part of views looks like:
>
 
def Webrequests(request, user_id):
  
try:
owner = Owners.objects.get(id=user_id)
   
 except owner.DoesNotExist:
print "There isnt an owner with such id."

else:
lname=owner.lname #epwnumia
fname=owner.fname
tel=owner.tel1
fax=owner.fax1
email=owner.email1
own_id = user_id

   
if request.method == 'POST':
form = WebrequestsForm(request.POST)

if form.is_valid():
form.save()

return render_to_response('success.html', locals(), 
context_instance= RequestContext(request))
else:
   
own_id = user_id
  
form = WebrequestsForm(own_id=own_id, initial = {'email':email, 
'fax':fax, 'tel':tel, 'own_id':own_id}) 
 
return render_to_response('main_Webrequests.html', locals(), 
context_instance= RequestContext(request))

What do u think?
 

-- 
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/-/1myJTSWBIbEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: CSRF verification failed. Request aborted.

2012-07-11 Thread Sergiy Khohlov
problem in view also :

def about(request):
if request.method == 'POST':
return HttpResponseRedirect('/about/')
elif request.method == 'GET':
return render_to_response('about.html',
context_instance=RequestContext(request))
else:
raise Http404()

 this one should be converted to :

def about(request):
   if request.method == 'POST':
return HttpResponseRedirect('/about/')
elif request.method == 'GET':
protectedbycsrf= {}
protectedbycsrf.update(csrf(request))
return render_to_response('about.html',
context_instance=RequestContext(protectedbycsrf))
else:
raise Http404()



2012/7/11 Сергей Фурсов :
> oops)
>
>
> 2012/7/11 Сергей Фурсов 
>>
>> Some notes about your models:
>> 1. why do you create id field manually? Django will do it for you ;)
>> 2. why do you explicitly set db_table and db_column? Do you have some
>> legacy database? If not, django will do it for you ;)
>> 3. move your vision from tables to objects
>> 4. call your models in CamelCase notation and in singular form
>> 5. try to understand related_name parameter
>> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name
>>
>> in my opinion your models should looks like:
>> from django.db import models
>>
>> class Owner(models.Model):
>> num = models.IntegerField()
>>
>> def __unicode__(self):
>> return unicode(self.num)
>>
>>
>> class Vehicle(models.Model):
>> plate = models.CharField(max_length=80, unique=True)
>> owner1 = models.ForeignKey('Owner', null=True,
>> related_name='vehicles1', blank=True)
>> owner2 = models.ForeignKey('Owner', null=True,
>> related_name='vehicles2', blank=True)
>>
>> def __unicode__(self):
>> return self.plate
>>
>>
>> class WebRequest(models.Model):
>> owner = models.ForeignKey('Owner')
>> vehicle1 = models.ForeignKey(Vehicle, related_name='web_requests1')
>> vehicle2 = models.ForeignKey(Vehicle, null=True,
>> related_name='web_requests2', blank=True)
>>
>>
>>
>> 2012/7/11 Сергей Фурсов 
>>>
>>> Ok, I tried your code, just added in models.py fake owners model to
>>> correct foreign key
>>>
>>> class Owners(models.Model):
>>> num = models.IntegerField()
>>>
>>> def __unicode__(self):
>>> return unicode(self.num)
>>>
>>> and create views.py with three lines of code:
>>>
>>> def page(request):
>>> form = WebrequestsForm(own_id=1)
>>> return render_to_response('page.html', {'form': form})
>>>
>>> and it works!
>>> May be problem in your views.py?
>>>
>>>
>>> 2012/7/10 Сергей Фурсов 

 as described in error message your view  function have to use
 RequestContext for the template, instead of Context.
 your view should looks like

 def about(request):
 if request.method == 'POST':
 return HttpResponseRedirect('/about/')
 elif request.method == 'GET':
 return render_to_response('about.html',
 context_instance=RequestContext(request))
 else:
 raise Http404()

 note that you redirect (HttpResponseRedirect) to url, but render
 (render_to_response) template with context

 also I changed action for form in tempalte to /about/ to handle POST and
 GET requests in same view

 hope this helps

 2012/7/10 JJ Zolper 
>
> Here is the error I received with debug set to true for Django:
>
> Forbidden (403)
>
> CSRF verification failed. Request aborted.
>
> Help
>
> Reason given for failure:
>
> CSRF token missing or incorrect.
>
>
> In general, this can occur when there is a genuine Cross Site Request
> Forgery, or when Django's CSRF mechanism has not been used correctly. For
> POST forms, you need to ensure:
>
> The view function uses RequestContext for the template, instead of
> Context.
> In the template, there is a {% csrf_token %} template tag inside each
> POST form that targets an internal URL.
> If you are not using CsrfViewMiddleware, then you must use csrf_protect
> on any views that use the csrf_token template tag, as well as those that
> accept the POST data.
>
> You're seeing the help section of this page because you have DEBUG =
> True in your Django settings file. Change that to False, and only the
> initial error message will be displayed.
>
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>
>
> I'm wondering if this is caused because I don't have a redirect page
> for my 'POST' HTML submit.
>
> Now my code...
>
> URLCONF:
>
> from django.conf.urls.defaults import patterns, include, url
>
> from MadTrak.manageabout.views import about, about_form
>
>
> # Uncomment the next two lines to 

Re: "Cannot convert <QueryDict:" after limiting foreign key

2012-07-11 Thread Сергей Фурсов
Ok, I tried your code, just added in models.py fake owners model to correct
foreign key

class Owners(models.Model):
num = models.IntegerField()

def __unicode__(self):
return unicode(self.num)

and create views.py with three lines of code:

def page(request):
form = WebrequestsForm(own_id=1)
return render_to_response('page.html', {'form': form})

and it works!
May be problem in your views.py?

Some notes about your models:
1. why do you create id field manually? Django will do it for you ;)
2. why do you explicitly set db_table and db_column? Do you have some
legacy database? If not, django will do it for you ;)
3. move your vision from tables to objects
4. call your models in CamelCase notation and in singular form
5. try to understand related_name parameter
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name

in my opinion your models should looks like:
from django.db import models

class Owner(models.Model):
num = models.IntegerField()

def __unicode__(self):
return unicode(self.num)


class Vehicle(models.Model):
plate = models.CharField(max_length=80, unique=True)
owner1 = models.ForeignKey('Owner', null=True,
related_name='vehicles1', blank=True)
owner2 = models.ForeignKey('Owner', null=True,
related_name='vehicles2', blank=True)

def __unicode__(self):
return self.plate


class WebRequest(models.Model):
owner = models.ForeignKey('Owner')
vehicle1 = models.ForeignKey(Vehicle, related_name='web_requests1')
vehicle2 = models.ForeignKey(Vehicle, null=True,
related_name='web_requests2', blank=True)

2012/7/11 mapapage 

> part of models.py with the related fields:
>>
>
> class Vehicles(models.Model):
> id = models.DecimalField(primary_key=True, unique=True,
> max_digits=127, decimal_places=0)
> plate = models.CharField(max_length=80, unique=True)
> own_id1 = models.ForeignKey('Owners', null=True, db_column='own_id1',
> related_name='veh_own_id1', blank=True)
> own_id2 = models.ForeignKey('Owners', null=True,
> db_column='own_id2',related_name='veh_own_id2', blank=True)
>
> def __unicode__(self):
> return self.plate
>
> class Meta:
> db_table = u'vehicles'
>
> class Webrequests(models.Model):
> id = models.DecimalField(primary_key=True, unique=True,
> max_digits=127, decimal_places=0)
> own_id = models.ForeignKey('Owners', db_column='own_id')
> veh_id1 = models.ForeignKey(Vehicles, db_column='veh_id1',
> related_name='veh_id1')
> veh_id2 = models.ForeignKey(Vehicles, null=True, db_column='veh_id2',
> related_name='veh_id2', blank=True)
>
> class Meta:
> db_table = u'webrequests'
>
> forms.py:
> class WebrequestsForm(ModelForm):
>
>
> class Meta:
> model = Webrequests
> fields = ('id', 'own_id', 'veh_id1', 'veh_id2',...)
>
>
> def __init__(self, own_id=None, **kwargs):
> super(WebrequestsForm, self).__init__(**kwargs)
> if own_id:
>
> self.fields['veh_id1'].queryset =
> Vehicles.objects.filter(own_id1=own_id)
>
> self.fields['veh_id2'].queryset =
> Vehicles.objects.filter(own_id2=own_id)
>
> in views.py there's nothing special to see.
>
>  --
> 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/-/47s3ivhWCtMJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: configure apache and mod_python

2012-07-11 Thread Timothy Makobu
Also, If you can, try Ngix + Gunicorn

On Wed, Jul 11, 2012 at 2:38 PM, kenneth gonsalves
wrote:

> On Wed, 2012-07-11 at 01:03 -0300, Carlos Andre wrote:
> > Hi, i'm with a hard problem. also, my apache have a problem he not
> > want be stated, i try use the xamppy and now be sure that problem! As
> > I put apache and mod_python to work?
>
> mod_python is deprecated - please do not use it. Use apache and mod_wsgi
> instead.
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: CSRF verification failed. Request aborted.

2012-07-11 Thread Сергей Фурсов
oops)

2012/7/11 Сергей Фурсов 

> Some notes about your models:
> 1. why do you create id field manually? Django will do it for you ;)
> 2. why do you explicitly set db_table and db_column? Do you have some
> legacy database? If not, django will do it for you ;)
> 3. move your vision from tables to objects
> 4. call your models in CamelCase notation and in singular form
> 5. try to understand related_name parameter
> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name
>
> in my opinion your models should looks like:
> from django.db import models
>
> class Owner(models.Model):
> num = models.IntegerField()
>
> def __unicode__(self):
> return unicode(self.num)
>
>
> class Vehicle(models.Model):
> plate = models.CharField(max_length=80, unique=True)
> owner1 = models.ForeignKey('Owner', null=True,
> related_name='vehicles1', blank=True)
> owner2 = models.ForeignKey('Owner', null=True,
> related_name='vehicles2', blank=True)
>
> def __unicode__(self):
> return self.plate
>
>
> class WebRequest(models.Model):
> owner = models.ForeignKey('Owner')
> vehicle1 = models.ForeignKey(Vehicle, related_name='web_requests1')
> vehicle2 = models.ForeignKey(Vehicle, null=True,
> related_name='web_requests2', blank=True)
>
>
>
> 2012/7/11 Сергей Фурсов 
>
>> Ok, I tried your code, just added in models.py fake owners model to
>> correct foreign key
>>
>> class Owners(models.Model):
>> num = models.IntegerField()
>>
>> def __unicode__(self):
>> return unicode(self.num)
>>
>> and create views.py with three lines of code:
>>
>> def page(request):
>> form = WebrequestsForm(own_id=1)
>> return render_to_response('page.html', {'form': form})
>>
>> and it works!
>> May be problem in your views.py?
>>
>>
>> 2012/7/10 Сергей Фурсов 
>>
>>> as described in error message your view  function have to use
>>> RequestContext
>>>  for
>>> the template, instead of Context.
>>> your view should looks like
>>>
>>> def about(request):
>>> if request.method == 'POST':
>>> return HttpResponseRedirect('/about/')
>>> elif request.method == 'GET':
>>> return render_to_response('about.html',
>>> context_instance=RequestContext(request))
>>> else:
>>> raise Http404()
>>>
>>> note that you redirect (HttpResponseRedirect) to url, but
>>> render (render_to_response) template with context
>>>
>>> also I changed action for form in tempalte to /about/ to handle POST and
>>> GET requests in same view
>>>
>>> hope this helps
>>>
>>> 2012/7/10 JJ Zolper 
>>>
 Here is the error I received with debug set to true for Django:

 Forbidden (403)

 CSRF verification failed. Request aborted.
 Help

 Reason given for failure:

 CSRF token missing or incorrect.


 In general, this can occur when there is a genuine Cross Site Request
 Forgery, or when Django's CSRF 
 mechanism
  has
 not been used correctly. For POST forms, you need to ensure:

- The view function uses 
 RequestContext
  for
the template, instead of Context.
- In the template, there is a {% csrf_token %} template tag inside
each POST form that targets an internal URL.
- If you are not using CsrfViewMiddleware, then you must use
csrf_protect on any views that use the csrf_token template tag, as
well as those that accept the POST data.

 You're seeing the help section of this page because you have DEBUG =
 True in your Django settings file. Change that to False, and only the
 initial error message will be displayed.

 You can customize this page using the CSRF_FAILURE_VIEW setting.


 I'm wondering if this is caused because I don't have a redirect page
 for my 'POST' HTML submit.

 Now my code...

 URLCONF:

 from django.conf.urls.defaults import patterns, include, url

 from MadTrak.manageabout.views import about, about_form


 # Uncomment the next two lines to enable the admin:

 from django.contrib import admin

 admin.autodiscover()


 urlpatterns = patterns('',


 (r'^about_form/', about_form),

 (r'^about/', about),


 # Examples:

 # url(r'^$', 'MadTrak.views.home', name='home'),

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


 ## url(r'^$', 'MadTrak.views.home', name='home'), with a view named home

 ## url(r'^listen/', 'MadTrak.views.home', name='home'), with a 

Re: CSRF verification failed. Request aborted.

2012-07-11 Thread Сергей Фурсов
Some notes about your models:
1. why do you create id field manually? Django will do it for you ;)
2. why do you explicitly set db_table and db_column? Do you have some
legacy database? If not, django will do it for you ;)
3. move your vision from tables to objects
4. call your models in CamelCase notation and in singular form
5. try to understand related_name parameter
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name

in my opinion your models should looks like:
from django.db import models

class Owner(models.Model):
num = models.IntegerField()

def __unicode__(self):
return unicode(self.num)


class Vehicle(models.Model):
plate = models.CharField(max_length=80, unique=True)
owner1 = models.ForeignKey('Owner', null=True,
related_name='vehicles1', blank=True)
owner2 = models.ForeignKey('Owner', null=True,
related_name='vehicles2', blank=True)

def __unicode__(self):
return self.plate


class WebRequest(models.Model):
owner = models.ForeignKey('Owner')
vehicle1 = models.ForeignKey(Vehicle, related_name='web_requests1')
vehicle2 = models.ForeignKey(Vehicle, null=True,
related_name='web_requests2', blank=True)



2012/7/11 Сергей Фурсов 

> Ok, I tried your code, just added in models.py fake owners model to
> correct foreign key
>
> class Owners(models.Model):
> num = models.IntegerField()
>
> def __unicode__(self):
> return unicode(self.num)
>
> and create views.py with three lines of code:
>
> def page(request):
> form = WebrequestsForm(own_id=1)
> return render_to_response('page.html', {'form': form})
>
> and it works!
> May be problem in your views.py?
>
>
> 2012/7/10 Сергей Фурсов 
>
>> as described in error message your view  function have to use
>> RequestContext
>>  for
>> the template, instead of Context.
>> your view should looks like
>>
>> def about(request):
>> if request.method == 'POST':
>> return HttpResponseRedirect('/about/')
>> elif request.method == 'GET':
>> return render_to_response('about.html',
>> context_instance=RequestContext(request))
>> else:
>> raise Http404()
>>
>> note that you redirect (HttpResponseRedirect) to url, but
>> render (render_to_response) template with context
>>
>> also I changed action for form in tempalte to /about/ to handle POST and
>> GET requests in same view
>>
>> hope this helps
>>
>> 2012/7/10 JJ Zolper 
>>
>>> Here is the error I received with debug set to true for Django:
>>>
>>> Forbidden (403)
>>>
>>> CSRF verification failed. Request aborted.
>>> Help
>>>
>>> Reason given for failure:
>>>
>>> CSRF token missing or incorrect.
>>>
>>>
>>> In general, this can occur when there is a genuine Cross Site Request
>>> Forgery, or when Django's CSRF 
>>> mechanism
>>>  has
>>> not been used correctly. For POST forms, you need to ensure:
>>>
>>>- The view function uses 
>>> RequestContext
>>>  for
>>>the template, instead of Context.
>>>- In the template, there is a {% csrf_token %} template tag inside
>>>each POST form that targets an internal URL.
>>>- If you are not using CsrfViewMiddleware, then you must use
>>>csrf_protect on any views that use the csrf_token template tag, as
>>>well as those that accept the POST data.
>>>
>>> You're seeing the help section of this page because you have DEBUG =
>>> True in your Django settings file. Change that to False, and only the
>>> initial error message will be displayed.
>>>
>>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>>
>>>
>>> I'm wondering if this is caused because I don't have a redirect page for
>>> my 'POST' HTML submit.
>>>
>>> Now my code...
>>>
>>> URLCONF:
>>>
>>> from django.conf.urls.defaults import patterns, include, url
>>>
>>> from MadTrak.manageabout.views import about, about_form
>>>
>>>
>>> # Uncomment the next two lines to enable the admin:
>>>
>>> from django.contrib import admin
>>>
>>> admin.autodiscover()
>>>
>>>
>>> urlpatterns = patterns('',
>>>
>>>
>>> (r'^about_form/', about_form),
>>>
>>> (r'^about/', about),
>>>
>>>
>>> # Examples:
>>>
>>> # url(r'^$', 'MadTrak.views.home', name='home'),
>>>
>>> # url(r'^MadTrak/', include('MadTrak.foo.urls')),
>>>
>>>
>>> ## url(r'^$', 'MadTrak.views.home', name='home'), with a view named home
>>>
>>> ## url(r'^listen/', 'MadTrak.views.home', name='home'), with a view
>>> named home
>>>
>>> ## url(r'^home/', 'MadTrak.views.home', name='home'), with a view named
>>> home
>>>
>>>
>>> # Uncomment the admin/doc line below to enable admin documentation:
>>>
>>> # url(r'^admin/doc/', 

Re: CSRF verification failed. Request aborted.

2012-07-11 Thread Сергей Фурсов
Ok, I tried your code, just added in models.py fake owners model to correct
foreign key

class Owners(models.Model):
num = models.IntegerField()

def __unicode__(self):
return unicode(self.num)

and create views.py with three lines of code:

def page(request):
form = WebrequestsForm(own_id=1)
return render_to_response('page.html', {'form': form})

and it works!
May be problem in your views.py?


2012/7/10 Сергей Фурсов 

> as described in error message your view  function have to use
> RequestContext
>  for
> the template, instead of Context.
> your view should looks like
>
> def about(request):
> if request.method == 'POST':
> return HttpResponseRedirect('/about/')
> elif request.method == 'GET':
> return render_to_response('about.html',
> context_instance=RequestContext(request))
> else:
> raise Http404()
>
> note that you redirect (HttpResponseRedirect) to url, but
> render (render_to_response) template with context
>
> also I changed action for form in tempalte to /about/ to handle POST and
> GET requests in same view
>
> hope this helps
>
> 2012/7/10 JJ Zolper 
>
>> Here is the error I received with debug set to true for Django:
>>
>> Forbidden (403)
>>
>> CSRF verification failed. Request aborted.
>> Help
>>
>> Reason given for failure:
>>
>> CSRF token missing or incorrect.
>>
>>
>> In general, this can occur when there is a genuine Cross Site Request
>> Forgery, or when Django's CSRF 
>> mechanism
>>  has
>> not been used correctly. For POST forms, you need to ensure:
>>
>>- The view function uses 
>> RequestContext
>>  for
>>the template, instead of Context.
>>- In the template, there is a {% csrf_token %} template tag inside
>>each POST form that targets an internal URL.
>>- If you are not using CsrfViewMiddleware, then you must use
>>csrf_protect on any views that use the csrf_token template tag, as
>>well as those that accept the POST data.
>>
>> You're seeing the help section of this page because you have DEBUG = True in
>> your Django settings file. Change that to False, and only the initial
>> error message will be displayed.
>>
>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>
>>
>> I'm wondering if this is caused because I don't have a redirect page for
>> my 'POST' HTML submit.
>>
>> Now my code...
>>
>> URLCONF:
>>
>> from django.conf.urls.defaults import patterns, include, url
>>
>> from MadTrak.manageabout.views import about, about_form
>>
>>
>> # Uncomment the next two lines to enable the admin:
>>
>> from django.contrib import admin
>>
>> admin.autodiscover()
>>
>>
>> urlpatterns = patterns('',
>>
>>
>> (r'^about_form/', about_form),
>>
>> (r'^about/', about),
>>
>>
>> # Examples:
>>
>> # url(r'^$', 'MadTrak.views.home', name='home'),
>>
>> # url(r'^MadTrak/', include('MadTrak.foo.urls')),
>>
>>
>> ## url(r'^$', 'MadTrak.views.home', name='home'), with a view named home
>>
>> ## url(r'^listen/', 'MadTrak.views.home', name='home'), with a view named
>> home
>>
>> ## url(r'^home/', 'MadTrak.views.home', name='home'), with a view named
>> home
>>
>>
>> # Uncomment the admin/doc line below to enable admin documentation:
>>
>> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>>
>> # Uncomment the next line to enable the admin:
>>
>> url(r'^admin/', include(admin.site.urls)),
>>
>> )
>>
>>
>> views.py in my manageabout app:
>>
>> from django.http import HttpResponseRedirect
>>
>> from django.shortcuts import render_to_response
>>
>> from MadTrak.manageabout.models import AboutMadtrak
>>
>>
>> def about_form(request):
>>
>> return render_to_response('about_form.html')
>>
>>
>> def about(request):
>>
>> if request.method == 'POST':
>>
>># do_something_for_post()
>>
>> return HttpResponseRedirect('about.html')
>>
>> elif request.method == 'GET':
>>
>> return render_to_response('/')
>>
>> else:
>>
>> raise Http404()
>>
>>
>> model where i tried to set up my database to recieve the information
>> posted:
>>
>> from django.db import models
>>
>>
>> class AboutMadtrak(models.Model):
>>
>> name = models.CharField(max_length=30)
>>
>> title = models.CharField(max_length=60)
>>
>> bio = models.CharField(max_length=200)
>>
>> website = models.URLField()
>>
>>
>> def __unicode__(self):
>>
>>return self.nam
>>
>>
>> my template for the about form submission:
>>
>>
>> 
>>
>> About-Form
>>
>> 
>>
>>
>> 
>>
>> 
>>
>>
>> MadTrak About Page, Yo!
>>
>>
>> 
>>
>>
>>  
>>
>> {% csrf_token %}
>>
>> Name: 
>>
>> Title: 
>>
>> Bio: 
>>
>> Website: 
>>
>> 
>>
>>  
>>
>>
>> 

Re: configure apache and mod_python

2012-07-11 Thread kenneth gonsalves
On Wed, 2012-07-11 at 01:03 -0300, Carlos Andre wrote:
> Hi, i'm with a hard problem. also, my apache have a problem he not
> want be stated, i try use the xamppy and now be sure that problem! As
> I put apache and mod_python to work? 

mod_python is deprecated - please do not use it. Use apache and mod_wsgi
instead.
-- 
regards
Kenneth Gonsalves

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

2012-07-11 Thread mapapage

>
> part of models.py with the related fields:
>
 
class Vehicles(models.Model):
id = models.DecimalField(primary_key=True, unique=True, max_digits=127, 
decimal_places=0)
plate = models.CharField(max_length=80, unique=True)
own_id1 = models.ForeignKey('Owners', null=True, db_column='own_id1', 
related_name='veh_own_id1', blank=True)
own_id2 = models.ForeignKey('Owners', null=True, 
db_column='own_id2',related_name='veh_own_id2', blank=True)
   
def __unicode__(self):
return self.plate 

class Meta:
db_table = u'vehicles' 

class Webrequests(models.Model):
id = models.DecimalField(primary_key=True, unique=True, max_digits=127, 
decimal_places=0)
own_id = models.ForeignKey('Owners', db_column='own_id')
veh_id1 = models.ForeignKey(Vehicles, db_column='veh_id1', 
related_name='veh_id1')
veh_id2 = models.ForeignKey(Vehicles, null=True, db_column='veh_id2', 
related_name='veh_id2', blank=True)
  
class Meta:
db_table = u'webrequests'

forms.py:
class WebrequestsForm(ModelForm):


class Meta:
model = Webrequests
fields = ('id', 'own_id', 'veh_id1', 'veh_id2',...)

   
def __init__(self, own_id=None, **kwargs):
super(WebrequestsForm, self).__init__(**kwargs)
if own_id:
  
self.fields['veh_id1'].queryset = 
Vehicles.objects.filter(own_id1=own_id)

self.fields['veh_id2'].queryset = 
Vehicles.objects.filter(own_id2=own_id)

in views.py there's nothing special to see.

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



configure apache and mod_python

2012-07-11 Thread Carlos Andre
Hi, i'm with a hard problem. also, my apache have a problem he not want be
stated, i try use the xamppy and now be sure that problem!
As I put apache and mod_python to work?
Please help i need this!
I've tried a lot for tutorials that do not explain, those who have used it
wrong!
thanks!

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

2012-07-11 Thread Сергей Фурсов
can you provide your models.py, views.py and forms.py code relative to this
problem, I'll try to help, but I need more info

2012/7/11 mapapage 

> I do it like this: form = WebrequestsForm(own_id=own_id, initial = {...})
>>
> but I think that the prob is not there. Somehow it has to do with what it
> is being returned (and tries to be saved in a decimal field of the form) by
> these:
> self.fields['veh_id1'].**queryset = Vehicles.objects.filter(own_**
> id1=own_id)
> self.fields['veh_id2'].**queryset = Vehicles.objects.filter(own_**
> id2=own_id)
>
> before limiting the choices of the foreign key, I used a charfield (what
> now is being returned from the above querysets) to display the choices but
> what was saved to the form was the id corresponding to that charfield
> (id=another field of the model, not  conversion of the charfiels) and
> everything was working.
> Any idea how to solve it??
>
>  --
> 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/-/qYFInuHRNIsJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: "Cannot convert <QueryDict:" after limiting foreign key

2012-07-11 Thread mapapage

>
> I do it like this: form = WebrequestsForm(own_id=own_id, initial = {...})
>
but I think that the prob is not there. Somehow it has to do with what it 
is being returned (and tries to be saved in a decimal field of the form) by 
these:
self.fields['veh_id1'].queryset = Vehicles.objects.filter(own_id1=own_id)
self.fields['veh_id2'].queryset = Vehicles.objects.filter(own_id2=own_id) 

before limiting the choices of the foreign key, I used a charfield (what 
now is being returned from the above querysets) to display the choices but 
what was saved to the form was the id corresponding to that charfield 
(id=another field of the model, not  conversion of the charfiels) and 
everything was working. 
Any idea how to solve it??

-- 
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/-/qYFInuHRNIsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: "Cannot convert <QueryDict:" after limiting foreign key

2012-07-11 Thread Сергей Фурсов
I can suppose that you call your modelForm's initialization like form =
MyForm(request.POST,  own_instance.id)
but it should looks like  form = MyForm(data=request.POST, own_id=
own_instance.id), because there distinction between positional and keyword
arguments

2012/7/11 Marilena Papageorgiou 

> I have a django modelForm that it was being submitted successfully until I
> added this code in my forms.py:
> def __init__(self, own_id=None, **kwargs):
> super(WebrequestsForm, self).__init__(**kwargs)
> if own_id:
>
> self.fields['veh_id1'].queryset =
> Vehicles.objects.filter(own_id1=own_id)
> self.fields['veh_id2'].queryset =
> Vehicles.objects.filter(own_id2=own_id)
>
> in order to limit the entries of the above foreign keys. After that only
> the related choices appeared in the form, as expected but the form couldn't
> be submitted.
> I get the following error:
>
> Cannot convert  u'vrd_id': [u'1'], u'nod_id2': [u'50'], u'tel': [u'2310566167'], 
> u'directiondb': [u'1'], u'rdateto': [u'1/2/2013'], u'sendmethod': [u'1'], 
> u'fax': [u'2310511559'], u'submitdate': [u'1'], u'email': 
> [u'i...@rdfvfvd.com'], u'veh_id2': [u'878'], u'veh_id1': [u'2978'], 
> u'returnflag': [u'1'], u'reqtype': [u'1'], u'remarks': [u'1'], 
> u'csrfmiddlewaretoken': [u'1Vhl04H1HgelkDdnS6IsCw61dtSyitkX'], u'rdatefrom': 
> [u'1/2/2012'], u'id': [u'22065'], u'own_id': [u'148']}> to Decimal
>
> Can anyone fix this? I can sense where the prob is but I have no idea how to 
> solve this.
>
>
>
>
>
> --
> MP
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



"Cannot convert <QueryDict:" after limiting foreign key

2012-07-11 Thread Marilena Papageorgiou
I have a django modelForm that it was being submitted successfully until I
added this code in my forms.py:
def __init__(self, own_id=None, **kwargs):
super(WebrequestsForm, self).__init__(**kwargs)
if own_id:

self.fields['veh_id1'].queryset =
Vehicles.objects.filter(own_id1=own_id)
self.fields['veh_id2'].queryset =
Vehicles.objects.filter(own_id2=own_id)

in order to limit the entries of the above foreign keys. After that only
the related choices appeared in the form, as expected but the form couldn't
be submitted.
I get the following error:

Cannot convert 
to Decimal

Can anyone fix this? I can sense where the prob is but I have no idea
how to solve this.





-- 
MP

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



Recommended middleware /tools.tips for profiling a django server

2012-07-11 Thread Gelonida N

Hi,
I'm having a nginx / uwsgi / django server and wanted to get some 
profiling data to identify bottle necks learn more about where time is 
consumed
(80% dynamic difficult to cache contents, so don't worry too much about 
serving static contents)



In this question I'm mostly interested in django / python specific 
profiling.

I posted another question in the uwsgi group for uwsgi specific profiling.


What would be recommended strategies to create decent reports, that can 
help to pinpoint potentially critical code.



I could add specific profiling features to the server even if they would 
slow down the system. I'd just enable them for a few days, gather the 
data and would disable them afterwards.



What statistics do you normally use to identify such issues and how 
could you get them?


Some measures I can think of:


report of django requests and their execution time
-
Is there already any simple middleware measuring request times.
It might be useful for profiling on test servers.
On the real servers I'd probably use directly the uwsgi logs, which 
report if I recall correctly already the request time.



individually profile each Django request
--

In django snippets I found a profiling middleware
http://djangosnippets.org/snippets/727/ which seems to print the stats 
just plainly into the log file. Not sure how one is supposed to create a 
decent report afterwards.


Alternatively I found a suggestion of using hotshot and save the reports.
https://code.djangoproject.com/wiki/ProfilingDjango
http://packages.python.org/django-extensions/runprofileserver.html

or another profiling middleware reporting for each request at the end of 
the response. 
http://www.no-ack.org/2010/12/yet-another-profiling-middleware-for.html


ANy experience with any of above.


number of SQL queries
---
I know how to visualize the number of sql queries for a page request 
with django debug toolbar.


I wondered about a good middleware to report this on a view by view 
basis or on a client by client basis




analyzing these reports.
--

Any good tools to analyze profiling reports for a django uwsig setup.

At the moment I itnend to view whatever reports manually or with self 
written scripts, but would be interested inwhat others use.



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



Re: map in django

2012-07-11 Thread Satvir Toor
On Wed, Jul 4, 2012 at 9:23 PM, yak-man  wrote:
> You might try browsing these:
> The code from Zain's US PyCon2012 tutorial on making interaxtive maps is also 
> in his github repositories - you might find that interesting.
What is link for that???


-- 
Satvir Kaur
satveerkaur.blogspot.in

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

2012-07-11 Thread Matt Schinckel
Michael,

I've been able to reproduce it: I'm not quite sure of the best way to deal 
with it.

One solution is to set either null=True, or blank=True on the field, or set 
a default.

The trick is, an empty string isn't valid JSON. I guess I've always been 
using a default (usually of {} or [], depending upon context).

Happy for you to suggest improvements, though.

I believe it's actually related 
to 
https://bitbucket.org/schinckel/django-jsonfield/issue/13/integrityerrors-when-using-empty-string

Matt.

-- 
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/-/tymGeL-UuCgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Release considerations

2012-07-11 Thread Jon Black
Thanks Reinout, that's a great checklist - much more than I thought of.
-- 
Jon Black
www.jonblack.org


On Tue, Jul 10, 2012, at 22:15, Reinout van Rees wrote:
> On 10-07-12 08:24, Jon Black wrote:
> > I've been working on a task management project and am at a point where
> > I'm happy to make my first release. The idea is that people can install
> > the project on their own server (at home, at work, wherever) and use it
> > to manage their tasks.
> >
> > What should I consider doing before making the code available to both
> > make life easier for the users/keep private information out of the
> > repository?
> 
> First you have to get the basics right like a proper setup.py, a README, 
> a changelog, that sort of stuff.
> 
> If you're looking at how-to-package-a-django-site examples, I'd look at 
> sentry. I liked the way they packaged it. Install it in a virtualenv and 
> it'll set up a django site for you. A custom settings file is installed 
> in some ~/.sentry directory, with defaults imported from a sentry 
> default settings file. Works fine. Pretty clear.
> 
> Make sure you've got example configurations on how to integrate it with 
> a webserver (apache/nginx).
> 
> 
> Reinout
> 
> -- 
> Reinout van Reeshttp://reinout.vanrees.org/
> rein...@vanrees.org http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: JSONField: which app to choose ?

2012-07-11 Thread Matt Schinckel
Hi Michael.

It should 'just work' in the admin: I'm using it fairly extensively, and 
most of our access is through the admin (or a JSON api).

If we can get a minimal failing test, then I'll make sure it gets fixed.

(And thanks, Reinout, for the referral/comment)

Matt.


On Wednesday, July 11, 2012 7:21:45 AM UTC+9:30, Michael Palumbo wrote:
>
> Can you get it work in the admin ?
> I don't understand why I get a ValidationError  "[u"'' is not a valid JSON 
> string."] as soon as I try to reach the Add admin page of my Model...
>
> import jsonfield
> class Mapping(models.Model):
> data_map4 = jsonfield.JSONField()
> -
> class MappingAdmin(admin.ModelAdmin):
> fields = ['data_map4']
> list_display = ('data_map4',)
>
> Thanks.
>
> Le mardi 10 juillet 2012 22:08:50 UTC+2, Reinout van Rees a écrit :
>>
>> On 09-07-12 20:52, Michael Palumbo wrote: 
>> > Hi, 
>> > 
>> > I have found several implementations of a Django JSON Field. 
>> > Have you ever tried one ? Which one do you recommend ? 
>>
>> I'm using the 'django-jsonfield' on pypi: 
>> http://pypi.python.org/pypi/django-jsonfield/  
>>
>> It is https://bitbucket.org/schinckel/django-jsonfield/  on bitbucket. 
>> I looked at it with a colleague and it seemed to have a bit more 
>> validation than some others. Little things. 
>>
>>
>> Reinout 
>>
>> -- 
>> Reinout van Reeshttp://reinout.vanrees.org/  
>> rein...@vanrees.org http://www.nelen-schuurmans.nl/  
>> "If you're not sure what to do, make something. -- Paul Graham" 
>>
>>
>>
>>

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