Re: Unable to establish odbc connection to MS SQL Server

2020-04-27 Thread Darren Williams
Lets

On Apr 27, 2020 10:31 PM, "Gurmeet Kaur" 
wrote:

Hi There,

I have also implemented this in my project. The code in my settings.py is
below. You could also try the same.

DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'MyDbName',

'USER': 'user',
'PASSWORD': 'password',
'HOST': 'DbHost',
'OPTIONS': {
'driver': 'ODBC Driver 13 for SQL Server',
'unicode_results': True,

},
}
}

On Mon, Apr 27, 2020 at 10:22 PM Kirk Brown 
wrote:

> I'm getting an error when I try to runserver. Here is my code in manage.py:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'sql_server.pyodbc',
> 'NAME': 'database',
> 'HOST': 'localhost',
> 'USER': 'user',
> 'PASSWORD': 'password',
>
> 'OPTIONS': {'ODBC Driver 17 for SQL Server',
> }
> }
> }
>
>
> And here is the error:
>
> (venv) C:\Users\Kirk\PycharmProjects\PyShop>manage.py runserver
> Unhandled exception in thread started by  check_errors..wrapper at 0x01770CD61438>
> Traceback (most recent call last):
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\utils\autoreload.py",
> line 225, in wrapper
> fn(*args, **kwargs)
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\core\management\commands\runserver.py",
> line 109, in inner_run
> autoreload.raise_last_exception()
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\utils\autoreload.py",
> line 248, in raise_last_exception
> raise _exception[1]
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\core\management\__init__.py",
> line 337, in execute
> autoreload.check_errors(django.setup)()
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\utils\autoreload.py",
> line 225, in wrapper
> fn(*args, **kwargs)
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\__init__.py",
> line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\apps\registry.py",
> line 112, in populate
> app_config.import_models()
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\apps\config.py",
> line 198, in import_models
> self.models_module = import_module(models_module_name)
>   File
> "C:\Users\Kirk\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py",
> line 127, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 967, in
> _find_and_load_unlocked
>   File "", line 677, in _load_unlocked
>   File "", line 728, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\contrib\auth\models.py",
> line 2, in 
> from django.contrib.auth.base_user import AbstractBaseUser,
> BaseUserManager
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\contrib\auth\base_user.py",
> line 47, in 
> class AbstractBaseUser(models.Model):
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\db\models\base.py",
> line 101, in __new__
> new_class.add_to_class('_meta', Options(meta, app_label))
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\db\models\base.py",
> line 305, in add_to_class
> value.contribute_to_class(cls, name)
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\db\models\options.py",
> line 203, in contribute_to_class
> self.db_table = truncate_name(self.db_table,
> connection.ops.max_name_length())
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\db\__init__.py",
> line 33, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\django\db\utils.py",
> line 203, in __getitem__
> conn = backend.DatabaseWrapper(db, alias)
>   File
> "C:\Users\Kirk\PycharmProjects\PyShop\venv\lib\site-packages\sql_server\pyodbc\base.py",
> line 193, in __init__
> self.driver_charset = opts.get('driver_charset', None)
> AttributeError: 'set' object has no attribute 'get'
>
>
> Any help is much appreciated. Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7f003a10-2c5e-472f-9bdc-eca8a2e277c1%40googlegroups.com
> 

Re: Pass post data to UpdateView

2020-04-26 Thread Darren Williams
Talk to me


On Sun, Apr 26, 2020, 18:18 Darren Williams  wrote:

> Ain't really sure learning myself but I look into it for you
>
> On Apr 26, 2020 8:02 AM, "'MH' via Django users" <
> django-users@googlegroups.com> wrote:
>
> Hi
>
> I do not know how to access request.POST, when I call UpdateView. Just to
> avoid a misunderstanding: I do not want to process the data after updating
> a model, but I want to pass a parameter to the UpdateView, which is not
> model related when the page opens.
>
> But I get a NameError that request is not defined. How can I make the POST
> data accessible?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0e13ecd0-93f9-4847-a93b-2439efe277ee%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0e13ecd0-93f9-4847-a93b-2439efe277ee%40googlegroups.com?utm_medium=email_source=footer>
> .
>
>
>

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


Re: Pass post data to UpdateView

2020-04-26 Thread Darren Williams
Ain't really sure learning myself but I look into it for you

On Apr 26, 2020 8:02 AM, "'MH' via Django users" <
django-users@googlegroups.com> wrote:

Hi

I do not know how to access request.POST, when I call UpdateView. Just to
avoid a misunderstanding: I do not want to process the data after updating
a model, but I want to pass a parameter to the UpdateView, which is not
model related when the page opens.

But I get a NameError that request is not defined. How can I make the POST
data accessible?

Thanks!

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

.

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


numjobs returned from glassdoor API is not equal to it showed on the website

2016-11-25 Thread Darren Li


I am trying to get some company information from glassdoor by itsAPI, but i 
found the number of jobs returned from API is not equal to it showed on 
website for most companies. 

I am providing my api url and result as followed. I have two questions:

1. for 'Merkle', why numjobs on the website is 196, but 499 returned from 
API, supposedly, i searched all is for US.

2. on the page returned when searching 'Merkle', we also can see numjobs 
for 'Presence Health', it shows 17 for numjobs, but it is 2.9k on its 
webpages, and when i search  'Presence Health' by API, return 745121.


Anyone encountered this before or check some issues out here, can you 
please help me? really thanks!


http://api.glassdoor.com/api/api.htm?t.p=xxx=xxx=0.0.0.0==json=1=jobs-stats=us=true=merkle











-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fa9866eb-cfcd-44c5-9e83-a367866c8716%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django image upload not saving

2014-06-26 Thread Darren Spruell
On Thu, Jun 26, 2014 at 10:58 AM, Bobby Gulshan <bamaba...@gmail.com> wrote:
> No errors when hitting upload. But the image doesn't appear where I have
> indicated it ought to. Put an absolute path in MEDIA_ROOT and referenced the
> same in (upload_to) param ImageField. Not sure what I am missing.
>
> Model:
>
> class FileUploadHandler(models.Model):
> title = models.CharField(max_length=100)
> file =
> models.ImageField(upload_to='/Python27/Lib/site-packages/django/bin/mideastinfo/wiki/static/')

Your upload_to path looks like an absolute directory, which means that
Django will attempt to store the file in that subdirectory of the path
you've configured for MEDIA_ROOT.

https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.storage

You want to do like Mario suggested and set 'upload_to' to a relative
path from the MEDIA_ROOT where you want images for that model stored.

-- 
Darren Spruell
phatbuck...@gmail.com




> View:
>
> from models import Article, Edit
> from forms import ArticleForm, EditForm
> from forms import *
> from PIL import Image
> from models import FileUploadHandler
>
> def image_upload(request):
> if request.method == 'POST':
> form = UploadImageForm(request.POST, request.FILES)
> if form.is_valid():
> FileUploadHandler(request.FILES['image'])
> return render_to_response('wiki/gallery.html')
> else:
> form = UploadImageForm()
> return render_to_response('wiki/gallery.html',
> RequestContext(request, {'form': form}))
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/29eff052-3181-4e0d-80fc-84fffe6ba029%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Combining use of template tag + filter in same expression

2014-06-26 Thread Darren Spruell
I have a template in which I'm trying to achieve the use of the
'firstof' tag to display whichever of two variables is present, and
the resulting variable filtered through 'truncatewords'. Is there a
way this can be accomplished?

Have tried the following:

{% first of result.meta.summary|truncatewords:12
result.description|truncatewords:12 %}

It doesn't work as I thought it might, instead rendering 'None' in the template.

This construct seems to work as expected if only the last variable is
applied the filter:

{% firstof result.meta.summary result.description|truncatewords:2 %}

Can this be made to work? Or is the combination of firstof and a
filter on more than the last variable unsupported?

Python 2.7.7
Django 1.6.5

-- 
Darren Spruell
phatbuck...@gmail.com

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


Re: Have browsers broken post-redirect-get? best practice now?

2013-10-04 Thread Darren Spruell
On Thu, Oct 3, 2013 at 6:15 AM, graeme <graeme.piete...@gmail.com> wrote:
> I disagree that breaking the back button is always bad. For example suppose
> you have a series of forms (i.e. a "wizard"):
>
> Page 1) fill in form. On POST creates a new Model() and saves it to the
> database
> 2) do stuff to the object (e.g. add inlines, whatever).
> 3) whatever comes next
>
> At stop two, user clicks back. They then post the form again, and get
> another object. On the other hand the page in step 2 can provide a back
> button on the page that takes the user back to edit what they entered on
> page 1. Which is more useful? I would say the latter - and users may not
> then understand that the browser back button and page back button do
> different things.

Django supports this form wizard behavior in a sane way through Form Wizards:

https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/

In the case of form wizards, each step through the series of forms in
the wizard occurs from the same URL, and the API provides users a way
to traverse individual forms (steps) in the wizard in a controlled
way. If the client uses the browser back button, it drops them back
from the URL the form wizard is served from, not to a previous step in
the form.

DS




> On Tuesday, October 1, 2013 8:33:41 PM UTC+5:30, antialiasis wrote:
>>
>> You should still be able to use the back button; it just shouldn't try to
>> post the data again if you do so. Are you getting a prompt about resending
>> post data, or are you just talking about being able to use the back button
>> at all? If the latter, that's exactly what should happen. Breaking the
>> user's back button is bad.
>>
>> On Tuesday, October 1, 2013 12:41:20 PM UTC, graeme wrote:
>>>
>>> The Django  docs (and a lot else) recommend redirecting after
>>> successfully processing a post request (if it changes data). i.e. post, the
>>> save stuff to the database, then redirect.
>>>
>>> Current browsers seem to allow this. I have tried Chromium 28 and 24 on
>>> Linux, I user return redirect(...) after the post, and I can still use the
>>> back button.
>>>
>>> Is it my configuration, or is it usual? What is the best practice if this
>>> is broken?
>>>
>>> In some cases I think tracking where the user is (in the session, or
>>> using the state of a particular object such as an order model), and
>>> redirecting any request for an earlier page in a sequence may be the way to
>>> go. Or is this a solved problem that I am too far behind the curve to know
>>> about?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cf0dd1f1-b004-4595-800f-1190ca9f4171%40googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Darren Spruell
phatbuck...@gmail.com

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


Re: Dealing with redundant JS inclusions at template levels

2013-09-30 Thread Darren Spruell
On Mon, Sep 30, 2013 at 6:11 AM, Rafael E. Ferrero
<rafael.ferr...@gmail.com> wrote:
> I Dont know your design, usually i include the js library on base template
> and my apps templates extend from that... or just put another base template
> for every app...
>
> If you have some example code or tell us why you do that then we be more
> helpfull

My setup looks like this:

Django 1.5

Project/app structure:

mysite/ # Project root
 mysite/
  settings.py   # INSTALLED_APPS includes 'foo', a reusable app
 templates/
  base.html # Project base template, includes jQuery &
# Bootstrap JS for project
 static/# Static assets for project
  js/
   jquery.js
   bootstrap.min.js


foo/# Reusable app
 templates/
  foo/
   index.html   # app template, extends 'base.html'. Requires
# and includes jQuery and Bootstrap JS for app
 static/# Static assets for 'foo' app
  foo/
   js/
jquery.js
bootstrap.min.js
app.js

So when 'index.html' from the foo app is rendered, the JS imports look
like this:


  
  

  
  
  
 
  


...because both the project and the reusable app are using jQuery and
Bootstrap JS, loading them twice on the same page results in screwed
up JS behavior.


Also,

On Mon, Sep 30, 2013 at 6:18 AM, Dariel Dato-on <oddration...@gmail.com> wrote:
> You can consider using Django Sekizai to manage your Javascript and CSS
> imports:
>
> https://django-sekizai.readthedocs.org/en/latest/

Seems interesting, I'll look into it more. To be honest, I think I'm
looking for a best practice rather than a solution; how are others
managing redundant JS includes when combining their own projects and
reusable apps? I imagine there's no app required to do this
intelligently.

DS



> 2013/9/30 Darren Spruell <phatbuck...@gmail.com>
>>
>> Spent a bit of time debugging some faulty JavaScript library
>> functionality before I realized that I had included the library at
>> multiple levels in the project - first site-wide in the base template,
>> and then within a app. I think I ran into this:
>>
>>
>> http://stackoverflow.com/questions/4891278/what-is-the-danger-in-including-the-same-javascript-library-twice
>>
>> Is there a good design pattern to this situation, bearing in mind a
>> need to include JS libraries at project level and a desire to use apps
>> that include the same libraries in an attempt to be reusable?
>>
>> Looking at jQuery and Bootstrap for this.
>>
>> --
>> Darren Spruell
>> phatbuck...@gmail.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAKVSOJVxQ8XF9wojenv6FW53CTHw28xMsD7LCoYas5%2BRchxtBA%40mail.gmail.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> Rafael E. Ferrero
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJJc_8XTE884Y9oCCK1StrtRGxt0Jvd%3DcJiOfboNOdarK%3DC05A%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Darren Spruell
phatbuck...@gmail.com

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


Dealing with redundant JS inclusions at template levels

2013-09-30 Thread Darren Spruell
Spent a bit of time debugging some faulty JavaScript library
functionality before I realized that I had included the library at
multiple levels in the project - first site-wide in the base template,
and then within a app. I think I ran into this:

http://stackoverflow.com/questions/4891278/what-is-the-danger-in-including-the-same-javascript-library-twice

Is there a good design pattern to this situation, bearing in mind a
need to include JS libraries at project level and a desire to use apps
that include the same libraries in an attempt to be reusable?

Looking at jQuery and Bootstrap for this.

-- 
Darren Spruell
phatbuck...@gmail.com

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


Re: Executing validation on entry to class-based views

2013-09-30 Thread Darren Spruell
Hm, yes! Thanks, had forgotten about dispatch().

On Thu, Sep 26, 2013 at 1:24 AM, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Thursday, 26 September 2013 07:29:38 UTC+1, dspruell wrote:
>>
>> Greetings,
>>
>> I have an app with a CBV for the main functionality that I'd like to
>> do some validation on config settings (in settings.py) before carrying
>> out the view.
>>
>> My particular view in this case is a FormWizard, but I'd like to know
>> general to any CBV; what is the correct pattern for doing this? Is
>> there a standard way to execute validation code upon entering a view
>> that allows one to access the request object (e.g. for setting
>> messages) and redirecting clients?
>>
>> My initial thought was to override __init__() and perform it there but
>> IIANM it lacks self.request at that point.
>>
>> What I'd like to implement:
>>
>> if not settings.SOMEAPP_SETTINGS.get('sender_address'):
>> messages.error(self.request, "Configuration error:
>> submission sender address not found. Configure SOMEAPP_SETTINGS in
>> your project settings file.")
>> return redirect('index')
>>
>> --
>> Darren Spruell
>> phatb...@gmail.com
>
>
>
> One way would be to override `dispatch()`.  You have access to the request
> there and can choose whether to call the super method to do the actual
> dispatching, or redirect instead.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Darren Spruell
phatbuck...@gmail.com

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


Executing validation on entry to class-based views

2013-09-26 Thread Darren Spruell
Greetings,

I have an app with a CBV for the main functionality that I'd like to
do some validation on config settings (in settings.py) before carrying
out the view.

My particular view in this case is a FormWizard, but I'd like to know
general to any CBV; what is the correct pattern for doing this? Is
there a standard way to execute validation code upon entering a view
that allows one to access the request object (e.g. for setting
messages) and redirecting clients?

My initial thought was to override __init__() and perform it there but
IIANM it lacks self.request at that point.

What I'd like to implement:

if not settings.SOMEAPP_SETTINGS.get('sender_address'):
messages.error(self.request, "Configuration error:
submission sender address not found. Configure SOMEAPP_SETTINGS in
your project settings file.")
return redirect('index')

-- 
Darren Spruell
phatbuck...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Handling temporary file storage with WizardView

2013-09-13 Thread Darren Spruell
I'm working on a WizardView (django.contrib.formtools) and have a step
that handles a file upload, so I'm setting the file_storage attribute
as required. I'd like the file storage to be a securely created
temporary directory under /tmp so I'm trying to set it to an instance
of tempfile.mkdtemp as below, but I'm stumping myself:


class FileSubmissionWizardView(SessionWizardView):
"Form wizard implementation to handle uploaded samples"

# XXX required. Also, need to take care of removing dir/file in the end.
file_storage = FileSystemStorage(location=mkdtemp(prefix='avsubmit_'))

def done(self, form_list, **kwargs):
# do_something_with_the_form_data(form_list)

# Remove temp upload directory. Eh?
shutil.rmtree(self.file_storage.location)

# Set a message, do a log
return redirect('avsubmit_index')

def process_step_files(self, form):
# do something like set storage extra data
return self.get_form_step_files(form)


My fu is weak, so I'm not certain the right approach here.
file_storage is a class attribute (right?), so I'm not sure this meets
my envisioned goal of having a new temporary directory created for
each uploaded file which I can then delete when finished. Would like
this workflow:

1. User uploads file
2. View invoked to process form, creates _new_ temporary directory for
FileSystemStorage and writes uploaded file to dir. Variable is
populated containing path from mkdtemp() to delete later
3. View processes form
4. View calls shutil.rmtree to delete temporary directory and file
5. View complete

How far off of target am I? Is there a good way to do the above file
resource management using WizardView?

-- 
Darren Spruell
phatbuck...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Warning about old install when upgrading via pip

2013-09-02 Thread Darren Spruell
Running Django in a virtualenv, have another instance of Django
installed system-wide on the system

When upgrading the virtualenv Django using 'pip install -U', I see
that the old version is uninstalled and the new version installed. At
the end of the upgrade, the package reports having been installed over
the top of a previous installation. The path to the previous
installation shows up as the installation of the system-wide Django.

[...]
Installing collected packages: Django
  Found existing installation: Django 1.4.5
Uninstalling Django:
  Successfully uninstalled Django
  Running setup.py install for Django
changing mode of build/scripts-2.7/django-admin.py from 644 to 755

warning: no previously-included files matching '__pycache__' found
under directory '*'
warning: no previously-included files matching '*.py[co]' found
under directory '*'
changing mode of
/home/dspruell/venv.d/django-home/bin/django-admin.py to 755



WARNING!


You have just installed Django over top of an existing
installation, without removing it first. Because of this,
your install may now include extraneous files from a
previous version that have since been removed from
Django. This is known to cause a variety of problems. You
should manually remove the

/usr/local/lib/python2.7/site-packages/django

directory and re-install Django.

Successfully installed Django
Cleaning up...


Is this an expected warning when upgrading Django via pip? And any
reason I'd be seeing references to the system-wide install (outside of
virtualenv) when I'm doing this upgrade within an active virtualenv?

-- 
Darren Spruell
phatbuck...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form Validation Error: 'No' value must be either True or False.

2013-05-03 Thread Darren Mansell
Solved.

To anyone who may come across this very obscure issue for themselves, it's
entirely an error specific to my setup.

I had rsync'd the code onto the live server from /home/django/rfc/ into
/home/django/rfc/rfc. As it's inside the pythonpath, the code is still
valid and will be executed, especially when you have various stuff in the
same dir names as your app etc.

I grep'd through the django code and found that only BooleanField gave my
specific error and I only didn't have BooleanField anymore. So I did a grep
of my code on live and found my old models.py file buried underneath
everything, which did have the fields as BooleanField.

Wow. 2 whole days to find that.


On 3 May 2013 13:49, Darren Mansell <darren.mans...@gmail.com> wrote:

>
>
>
> On 3 May 2013 13:06, Tom Evans <tevans...@googlemail.com> wrote:
>
>> On Fri, May 3, 2013 at 12:38 PM, Darren Mansell
>> <darren.mans...@gmail.com> wrote:
>> >
>> > Another bit of info, just in case anyone is currently looking at this..
>> >
>> > The error is coming from
>> >
>> /usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py
>> >
>> > …
>> >
>> > So it's failing validation because it's seeing the field as a
>> > BooleanField, when I quite obviously have set it as a CharField.
>> >
>> > I'm absolutely stuck.
>>
>> In your second mail, you say that the only failing case is "live
>> server with Apache 2.2.22-1ubuntu1.3 / mod-wsgi 3.3-4build1". Are you
>> sure you have fully updated and restarted this server to pick up your
>> changes?
>>
>> Cheers
>>
>> Tom
>>
>> Hey Tom, thanks for the reply.
>
> Yeah the live server is Ubuntu 12.04 and the dev server is actually my
> laptop running Ubuntu 13.10 which accounts for the version differences.
>
> I'm rsyncing files from one to the other and have checked the code gets
> copied which it does.
>
> I'm now thinking that because I've got another copy of this project
> running on the server, but with older code, it's failing with that.
>
> I'll clone the VM and run it fully separate.
>
> Thanks.
>

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




Re: Form Validation Error: 'No' value must be either True or False.

2013-05-03 Thread Darren Mansell
On 3 May 2013 13:06, Tom Evans <tevans...@googlemail.com> wrote:

> On Fri, May 3, 2013 at 12:38 PM, Darren Mansell
> <darren.mans...@gmail.com> wrote:
> >
> > Another bit of info, just in case anyone is currently looking at this..
> >
> > The error is coming from
> >
> /usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py
> >
> > …
> >
> > So it's failing validation because it's seeing the field as a
> > BooleanField, when I quite obviously have set it as a CharField.
> >
> > I'm absolutely stuck.
>
> In your second mail, you say that the only failing case is "live
> server with Apache 2.2.22-1ubuntu1.3 / mod-wsgi 3.3-4build1". Are you
> sure you have fully updated and restarted this server to pick up your
> changes?
>
> Cheers
>
> Tom
>
> Hey Tom, thanks for the reply.

Yeah the live server is Ubuntu 12.04 and the dev server is actually my
laptop running Ubuntu 13.10 which accounts for the version differences.

I'm rsyncing files from one to the other and have checked the code gets
copied which it does.

I'm now thinking that because I've got another copy of this project running
on the server, but with older code, it's failing with that.

I'll clone the VM and run it fully separate.

Thanks.

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




Re: Form Validation Error: 'No' value must be either True or False.

2013-05-03 Thread Darren Mansell
Another bit of info, just in case anyone is currently looking at this..

The error is coming from
/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py

class BooleanField(Field):
empty_strings_allowed = False
default_error_messages = {
*'invalid': _("'%s' value must be either True or False."),*
}
description = _("Boolean (Either True or False)")

def __init__(self, *args, **kwargs):
kwargs['blank'] = True
if 'default' not in kwargs and not kwargs.get('null'):
kwargs['default'] = False
Field.__init__(self, *args, **kwargs)

def get_internal_type(self):
return "BooleanField"

def to_python(self, value):
if value in (True, False):
# if value is 1 or 0 than it's equal to True or False, but we
want
# to return a true bool for semantic reasons.
return bool(value)
if value in ('t', 'True', '1'):
return True
if value in ('f', 'False', '0'):
return False
*msg = self.error_messages['invalid'] % value*
raise exceptions.ValidationError(msg)


So it's failing validation because it's seeing the field as a BooleanField,
when I quite obviously have set it as a CharField.

I'm absolutely stuck.

On 3 May 2013 11:13, Darren Mansell <darren.mans...@gmail.com> wrote:

> Bit more info (all pointing to the same database / db server):
>
> test server with Django dev server : works
> test server with Apache 2.2.22-6ubuntu5 / mod-wsgi 3.4-0ubuntu3 : works
>
> live server with Django dev server : works
> live server with Apache 2.2.22-1ubuntu1.3 / mod-wsgi 3.3-4build1 : doesn't
> work
>
>
>
>
> On 3 May 2013 10:35, Darren Mansell <darren.mans...@gmail.com> wrote:
>
>> Hi all. Really really confused by this one. Can someone show me where I'm
>> being stupid please?
>>
>> Standard Django 1.5.1 app with MySQL. Trying to save to a VARCHAR(3)
>> column with a forms.CharField form field and a models.CharField model field.
>>
>> When I try to save the form I get this validation error:
>>
>> [image: Inline images 1]
>>
>>
>> This is the MySQL column definition:
>>
>> `customers_impacted` varchar(3) DEFAULT NULL,
>>
>>
>> This is from forms.py (it's a ModelForm):
>>
>> YES_NO = (
>> ('No', 'No'),
>> ('Yes', 'Yes'),
>> )
>> customers_impacted =
>> forms.CharField(widget=forms.Select(choices=YES_NO),max_length=3)
>>
>>
>> This is from models.py:
>>
>> customers_impacted = models.CharField(max_length=3)
>>
>>
>> The field was originally a BooleanField but I changed it to CharField and
>> I can't see anywhere it could still be getting the Boolean / True / False
>> info from.
>>
>> Strangely, it works fine using the development server, but this error
>> happens when using Apache + mod_wsgi. I've rebooted the server, restarted
>> everything, tried changing collation etc.
>>
>> Could anyone suggest anything? Any extra logging etc I can turn on
>> somewhere to show where the validation is failing?
>>
>> Thanks.
>> Darren (confused)
>>
>
>

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


<>

Re: Form Validation Error: 'No' value must be either True or False.

2013-05-03 Thread Darren Mansell
Bit more info (all pointing to the same database / db server):

test server with Django dev server : works
test server with Apache 2.2.22-6ubuntu5 / mod-wsgi 3.4-0ubuntu3 : works

live server with Django dev server : works
live server with Apache 2.2.22-1ubuntu1.3 / mod-wsgi 3.3-4build1 : doesn't
work



On 3 May 2013 10:35, Darren Mansell <darren.mans...@gmail.com> wrote:

> Hi all. Really really confused by this one. Can someone show me where I'm
> being stupid please?
>
> Standard Django 1.5.1 app with MySQL. Trying to save to a VARCHAR(3)
> column with a forms.CharField form field and a models.CharField model field.
>
> When I try to save the form I get this validation error:
>
> [image: Inline images 1]
>
>
> This is the MySQL column definition:
>
> `customers_impacted` varchar(3) DEFAULT NULL,
>
>
> This is from forms.py (it's a ModelForm):
>
> YES_NO = (
> ('No', 'No'),
> ('Yes', 'Yes'),
> )
> customers_impacted =
> forms.CharField(widget=forms.Select(choices=YES_NO),max_length=3)
>
>
> This is from models.py:
>
> customers_impacted = models.CharField(max_length=3)
>
>
> The field was originally a BooleanField but I changed it to CharField and
> I can't see anywhere it could still be getting the Boolean / True / False
> info from.
>
> Strangely, it works fine using the development server, but this error
> happens when using Apache + mod_wsgi. I've rebooted the server, restarted
> everything, tried changing collation etc.
>
> Could anyone suggest anything? Any extra logging etc I can turn on
> somewhere to show where the validation is failing?
>
> Thanks.
> Darren (confused)
>

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


<>

Form Validation Error: 'No' value must be either True or False.

2013-05-03 Thread Darren Mansell
Hi all. Really really confused by this one. Can someone show me where I'm
being stupid please?

Standard Django 1.5.1 app with MySQL. Trying to save to a VARCHAR(3) column
with a forms.CharField form field and a models.CharField model field.

When I try to save the form I get this validation error:

[image: Inline images 1]


This is the MySQL column definition:

`customers_impacted` varchar(3) DEFAULT NULL,


This is from forms.py (it's a ModelForm):

YES_NO = (
('No', 'No'),
('Yes', 'Yes'),
)
customers_impacted =
forms.CharField(widget=forms.Select(choices=YES_NO),max_length=3)


This is from models.py:

customers_impacted = models.CharField(max_length=3)


The field was originally a BooleanField but I changed it to CharField and I
can't see anywhere it could still be getting the Boolean / True / False
info from.

Strangely, it works fine using the development server, but this error
happens when using Apache + mod_wsgi. I've rebooted the server, restarted
everything, tried changing collation etc.

Could anyone suggest anything? Any extra logging etc I can turn on
somewhere to show where the validation is failing?

Thanks.
Darren (confused)

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


<>

Seeking pattern for building URLs with all query parameters intact

2012-11-25 Thread Darren Spruell
I've got a handful of applications that feature paginated object lists
as well as a search dialog allowing users to search for simple object
attributes.

What is the common pattern to use in Django apps to build URI query
strings in view code that can preserve parameters for rendering links
in templates? In my case I'd like to handle the following:

1. User searches for string, passed as GET parameter and application
returns paginated object list the spans multiple pages
2. First page contains links for subsequent pages ('page' parameter in
URI query string) and preserves search string (additional 'search'
parameter in URI query string)

So far I've taken key/value pairs out of request.GET and added them to
the context as more_query_params and passed them in to templates. This
seems a little raw and klugey although it works for the simple cases.
There must be a better way. Currently (from a view that returns
paginated object list:

# Determine other parameters from request, provide to template to craft
# smarter URLs that handle concurrent search + pagination (etc.).
if request.method == 'GET':
more_query_params = ''
for key, value in request.GET.items():
if key != 'page':
more_query_params += '&%s=%s' % (key, value)
return render_to_response('submissionlog_pages.html', {
'submissionlogs': submissionlogs,
'search_form': search_form,
'more_query_params': more_query_params,
}, context_instance=RequestContext(request))

What are better ways to handle this?

-- 
Darren Spruell
phatbuck...@gmail.com

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



Options for migrating from django.contrib.markup for rST

2012-11-24 Thread Darren Spruell
Greetings,

Currently using django.contrib.markup for the restructuredtext filter.
1.5 deprecates the module, and I'd like to start work on replacing it.
What libraries are contenders in this space? Aware of this:

http://code.google.com/p/django-rstify/
https://github.com/bartTC/django-markup
http://packages.python.org/django-markup/

...although this project seems a bit dated.

-- 
Darren Spruell
phatbuck...@gmail.com

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



Using subclass of RegexValidator for form field

2012-06-27 Thread Darren Spruell
Django 1.3.1
Python 2.7.1

I'm attempting to subclass RegexValidator in my app's validators.py to
supply specific 'regex' and 'message' attributes and finding that the
field validation I'm attempting does not work. I figure I don't quite
understand how to subclass this validator correctly, or else how to
implement it as a callable for the 'validators' parameter:


# app_name/validators.py
from django.core.validators import RegexValidator

class PayloadValidator(RegexValidator):
regex = 'x'
message = u'Valid payload strings contain the letter "x"'


# app_name/models.py
from app_name import validators

class Configuration(models.Model):
payload = models.CharField(max_length=64, help_text="Text string
to match in health check signature",
validators=[validators.PayloadValidator])
...


But when I submit the form, the Configuration instance validates and
saves if I enter 'abc' as a value.

The following use of URLValidator in my models appears to work
correctly, and I had figured I used these validators in the same
manner:

reference_url = models.URLField(verbose_name="reference URL",
blank=True, help_text="(Optional) Reference URL",
validators=[URLValidator])


Here, entering "foo" into the field for reference_url outputs a
validation error on the form if I enter "foo".

What am I missing? Thanks.

-- 
Darren Spruell
phatbuck...@gmail.com

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



Handling multiple parameters on URI via GET

2012-01-27 Thread Darren Spruell
I've puzzled my way into a corner. Figuring this will be a
palm-to-forehead moment.

I have a page on my site which is Paginator-ed for the object list.
I'm sticking to the vanilla setup from the docs so when it is in
effect I've got a URI query string of '?page=%d' processed via GET.
I've added a search form to the page and am passing the form data via
GET as well so when a search is in effect I have '?search=%s' on the
URI query. I'm incredibly creative (not) so most of this is done very
closely modeling the approach at
http://www.djangobook.com/en/1.0/chapter07/. I can do either of them
individually  just fine, but I can't figure a clean way to have both
pagination and search parameters operate properly across requests as
the user selects next/previous, etc. in the page navigation. It works
if I manually append the missing query parameter to the URI.

How is this typically best handled in Django? I thought about trying
to determine uri query in template and dynamically build the nav links
to include parameters for search and pagination but I didn't figure a
way that wasn't a complete mess.


## view

def list_submissions(request):
"""
Present list of submission logs, paginated.

"""
search_form = SubmissionLogSearchForm()
query = request.GET.get('search', '')
if query:
qset = (
Q(file_name__icontains=query) |
Q(file_md5=query) |
Q(file_sha1=query) |
Q(submitter__username=query)
)
submissionlog_list = SubmissionLog.objects.filter(qset)
else:
submissionlog_list = SubmissionLog.objects.all()

paginator = Paginator(submissionlog_list, 15)  # show N logs per page

# Make sure page request is an int. If not, deliver first page.
try:
page = int(request.GET.get('page', '1'))
except ValueError:
page = 1

# If page request () is out of range, deliver last page of results.
try:
submissionlogs = paginator.page(page)
except (EmptyPage, InvalidPage):
submissionlogs = paginator.page(paginator.num_pages)

return render_to_response('avsubmit/submissionlog_pages.html', {
'submissionlogs': submissionlogs,
'search_form': search_form,
}, context_instance=RequestContext(request))


## template

Showing {{ submissionlogs.object_list.count }} submission{{
submissionlogs.object_list.count|pluralize }} of {{
submissionlogs.paginator.count }} total

{% if submissionlogs %}

{{ search_form.as_p }}




  
File MD5File
NameSubmitterSubmission Date
  
  {% for log in submissionlogs.object_list %}
  {% cycle 'row1' 'row2' as rowcolors silent %}
  
{{ log.file_md5 }}
{{ log.file_name }}
{{ log.submitter }}
{{ log.date_submitted|date:"m/d/Y h:i A" }}
  
  {% endfor %}

{% endif %}



{% if submissionlogs.has_previous %}

{% endif %}


Page {{ submissionlogs.number }} of {{
submissionlogs.paginator.num_pages }}


{% if submissionlogs.has_next %}
    
    {% endif %}



Thx,

-- 
Darren Spruell
phatbuck...@gmail.com

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



Re: How to use ManyToMany model relations to track user membership?

2011-09-09 Thread Darren
It sounds like you want to specify a custom many-to-many relationship
table using the manytomany.through option.  Check out
https://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany
for an example.

On Sep 9, 12:10 am, jollyroger  wrote:
> Hi.
>
> Can someone please tell, what kind of relations is required to store
> user's membership in multiple groups to be able to recover:
>
>    1. history of user participation in some groups (date joined, date
> quit)
>    2. list of current user groups (in join order) to determine his
> current status
>    3. list of users, who were participating in that group at a given
> period of time
>
> I guess it is ManyToMany (or an ugly kind of OneToMany), but can't
> decide how to implement it; need a minimal example in Django.
>
> And what kind of database consistency problems should be expected at
> deleting some group/user?

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

2011-03-19 Thread Darren
Oops! Thankyou :)

(tedious name for it though, although I do concede it's Python's
invention.)


On Mar 18, 9:29 pm, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> On Fri, 2011-03-18 at 17:57 -0700, Darren wrote:
> > I want to store costs (prices) in my DB. The obvious field type is
> > Integer, storing the cost in cents (strings prevent arithmetic
> > operations, floats are entirely inappropriate).
>
> I thought that is what the DecimalField is for
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

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



Cost model field

2011-03-18 Thread Darren
Hello,

I want to store costs (prices) in my DB. The obvious field type is
Integer, storing the cost in cents (strings prevent arithmetic
operations, floats are entirely inappropriate).

For input via a form, I have a nice CostField defined as follows:

class CostField(forms.CharField):
def validate(self, value):
super(CostField, self).validate(value)
if not re.match(r'^\d+(\.\d\d)?$', value):
raise forms.ValidationError("Enter a price in the form 
1.50")

def clean(self, value):
value = super(CostField, self).clean(value)
return float(value) * 100

So it starts as a CharField, gets validated appropriately and then
converted to the cents-only equivalent.

But for output in templates, I have not found an elegant solution.
Currently I am using this:

def h_price(price):
dollars = price / 100
cents = str(price % 100)
if len(cents) == 1:
cents = '0%s' % cents
return '%s.%s' % (dollars, cents)

class Whatever(models.Model):
price = models.IntegerField()
@property
def h_price(self):
return h_price(self.price)

But the problem is that I need obviously to repeat the property
definition for every usage of money in the schema.

I tried creating a custom field as follows:

class CostField(models.IntegerField):
def h(self):
return 'hello'

and using this in a template like this: {{ item.price.h }}

But this doesn't work, it doesn't even call my h() function.

Can anyone point me in the right direction?

Thankyou :-)

Darren

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

2010-09-12 Thread darren
Thanks.

I will keep this in mind.

On Sun, Sep 12, 2010 at 12:51 PM, Justin Myers <masterb...@gmail.com> wrote:

> Another idea would be to connect to User's post-save signal. You can
> set it up to check whether the User instance being saved is just being
> created, and if so, you can create its UserProfile instance at the
> same time. That'd make it so all future users have profiles as soon as
> they're created; once you create UserProfile instances for each of
> your existing users, you could probably avoid the check altogether.
>
> Example:
> from django.db.models.signals import post_save
> from django.contrib.auth.models import User
>
> def create_profile(sender, **kwargs):
>if 'created' in kwargs and 'instance' in kwargs:
>if kwargs['created']:
>profile = UserProfile(user=kwargs['instance'])
>profile.save()
> post_save.connect(create_profile, sender=User)
>
> HTH,
> Justin
>
> On Sep 11, 8:45 pm, darren <backdoc...@gmail.com> wrote:
> > I think that my main problem was that I was expecting the save to the
> model
> > form to actually create the profile.
> >
> > Here's what I ended up with in my view.
> >
> >  86 @login_required
> >  87 def createProfile(request):
> >  88 UserProfile.objects.get_or_create(user=request.user)[0]
> >  89 if request.method == 'POST':
> >  90 form = UserProfileForm(request.POST,
> > instance=request.user.get_profile())
> >  91 if form.is_valid():
> >  92 form.save()
> >  93 return HttpResponseRedirect("/")
> >  94 else:
> >  95 return render_to_response('fav/createProfile.tpl', {
> 'form'
> > : form  }, RequestContext(request) )
> >  96 else:
> >  97 form = UserProfileForm(instance=request.user.get_profile())
> >  98 return render_to_response('fav/createProfile.tpl', { 'form' :
> form}, RequestContext(request))
> >
> >  99
> >
> > On Sat, Sep 11, 2010 at 12:37 AM, Shawn Milochik <sh...@milochik.com>
> wrote:
> > > I think you just may be missing a call to get_profile() in this view.
> > > You can just do that and do a try block with an except block for
> > > DoesNotExist. That will let you know the situation you're in, whether
> > > the profile already existed or not.
> >
> > > Also, unless I'm misreading something you're trying to pass a User
> > > instance as the instance for a user profile, which will not work. If
> > > anything, you should be doing a .get() on the user profile where user
> > > = request.user, but that doesn't matter anyway because get_profile()
> > > does the same thing and is the correct way to do this.
> >
> > > Shawn
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Integrating User Profile with Auth

2010-09-11 Thread darren
I think that my main problem was that I was expecting the save to the model
form to actually create the profile.

Here's what I ended up with in my view.

 86 @login_required
 87 def createProfile(request):
 88 UserProfile.objects.get_or_create(user=request.user)[0]
 89 if request.method == 'POST':
 90 form = UserProfileForm(request.POST,
instance=request.user.get_profile())
 91 if form.is_valid():
 92 form.save()
 93 return HttpResponseRedirect("/")
 94 else:
 95 return render_to_response('fav/createProfile.tpl', { 'form'
: form  }, RequestContext(request) )
 96 else:
 97 form = UserProfileForm(instance=request.user.get_profile())
 98 return render_to_response('fav/createProfile.tpl', { 'form' : form
}, RequestContext(request))
 99


On Sat, Sep 11, 2010 at 12:37 AM, Shawn Milochik  wrote:

> I think you just may be missing a call to get_profile() in this view.
> You can just do that and do a try block with an except block for
> DoesNotExist. That will let you know the situation you're in, whether
> the profile already existed or not.
>
> Also, unless I'm misreading something you're trying to pass a User
> instance as the instance for a user profile, which will not work. If
> anything, you should be doing a .get() on the user profile where user
> = request.user, but that doesn't matter anyway because get_profile()
> does the same thing and is the correct way to do this.
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Integrating User Profile with Auth

2010-09-11 Thread darren
Thanks.

That helped me figure it out.  I'll post my solution back later
today/tonight.


On Sat, Sep 11, 2010 at 12:37 AM, Shawn Milochik  wrote:

> I think you just may be missing a call to get_profile() in this view.
> You can just do that and do a try block with an except block for
> DoesNotExist. That will let you know the situation you're in, whether
> the profile already existed or not.
>
> Also, unless I'm misreading something you're trying to pass a User
> instance as the instance for a user profile, which will not work. If
> anything, you should be doing a .get() on the user profile where user
> = request.user, but that doesn't matter anyway because get_profile()
> does the same thing and is the correct way to do this.
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Integrating User Profile with Auth

2010-09-10 Thread darren
I am following the information in the docs to add fields to maintain, in
addition to the ones Auth already maintains.  I'm starting with the docs
here:


So far, I have a model form I've created based on the additional fields.
 And, I'm displaying my form in my template.  But, I can't seem to get the
form to work.  My plan is to use the exception encountered when
get_profile() is called in another view, but the profile doesn't yet exist.
I want to catch the error and send the user to a form to fill out the extra
field I want to maintain and pre-populate another.

Mostly I think my problem arises when I try to save my form.  But, it could
be when I create it.  The form is displaying a drop down list box of all of
the users.  So, something odd is going on there.  Also, every time I submit
the form, the submit method is GET, even though the method is set to POST in
the form's attributes.

I believe I may be stumbling over this part of the docs:

"The method 
get_profile()
 does not create the profile, if it does not exist. You need to register a
handler for the
signaldjango.db.models.signals.post_save
 on the User model, and, in the handler, if created=True, create the
associated user profile"

A suggestion is made here
to create the
profile.

*User.profile = property(lambda u:
UserProfile.objects.get_or_create(user=u)[0])*

But, if I automatically create the profile, I can't catch the exception for
a missing profile.

Here's some code:

In my template, I have this code (line 93 seems to be instrumental in my
problem).  I can get a post if I use line 92 instead of line 93.  But, I
still have 2 problems.  First, it's letting me choose the user (I was hoping
the code on line 90 would eliminate that).  And, second, the form simply
won't save.:

 86 @login_required
 87 def createProfile(request):
 88 err_msg = [request.method] # I have this so I can see the method
 89 messages = []
 90 a = User.objects.get(username=request.user.username)
 91 # err_msg = [request.method, a]
 92 # form = UserProfileForm(instance=a)
 93 form = UserProfileForm(request.POST, instance=a)
 94 if request.method == 'POST':
 95 if form.is_valid():
 96 form.save()
 97 return HttpResponseRedirect("/")
 98 else:
 99 err_msg.append("Error Processing File")
100 return render_to_response('fav/createProfile.tpl', {
'ERROR_MSG' : err_msg, 'messages' : messages, 'form' : form  },
RequestContext(request) )
101 return render_to_response('fav/createProfile.tpl', { 'ERROR_MSG' :
err_msg, 'form' : form }, RequestContext(request))

My Model:

  1 from django.db import models
  2 from django.forms import ModelForm
  3 from django.contrib.auth.models import User
  4
  5 class UserProfile(models.Model):
  6 user = models.ForeignKey(User, unique=True)
  7 screenname = models.CharField('Screen Name', max_length=25,
unique=True)
  8 credits = models.PositiveSmallIntegerField('Credits', default=3)
  9
 10 class UserProfileForm(ModelForm):
 11 class Meta:
 12 model = UserProfile
 13 #fields = ['screenname'] # I've tried uncommenting this.
~

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



Re: Admin site not formatted

2010-07-11 Thread Darren
I have had that happen a long time ago. I think my problem was that apache 
didn't gave permission to the CSS. I know that's not much to go on. But, maybe 
it will help. 

Darren

On Jul 10, 2010, at 12:50 PM, octopusgrabbus <old_road_f...@verizon.net> wrote:

> Using Apache and not the built-in Django web server, I can reach the
> admin site, but it's not formatted well, as it is with the built-in
> web server.
> 
> Any ideas on what to do?
> 
> Here's the location directive in apache
> 
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE chapter4.settings
> PythonOption django.root /home/amr/web/django/chapter4
> PythonPath "['/home/amr/web/django/'] + ['/home/amr/web/django/
> favorites/'] + sys.path
> "
> PythonDebug On
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Tutorial problems

2010-06-27 Thread Darren
If you are using apache on Debian Linux, /etc/init.d/apache restart. Other 
Linux distros and Mac look for apachectrl. 

Darren

On Jun 27, 2010, at 9:49 AM, zippzom <zipp...@gmail.com> wrote:

> How does one go about restarting the server?
> 
> Thanks in advance!
> 
> On Jun 25, 10:37 pm, Michael Schade <mich...@mschade.me> wrote:
>> As Gabriel mentioned, make sure you reran the server after making the
>> changes (though if using runserver, it should handle that for you). Also
>> make sure you did not miss this bit in the tutorial:
>> 
>> "Wait a minute.  is, utterly, an unhelpful representation
>> of this object. Let's fix that by editing the polls model (in the
>> polls/models.py file) and adding a
>> __unicode__()<http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db>
>> method
>> to both Poll and Choice:"
>> 
>> class Poll(models.Model):
>> # ...
>> def __unicode__(self):
>> return self.question
>> 
>> Sincerely,
>> Michael Schade
>> Spearhead Development LLC
>> 
>> On Fri, Jun 25, 2010 at 5:54 PM, Gabriel Gayan <gabrielga...@gmail.com>wrote:
>> 
>>> Have you tried re-running the server after saving the changes?
>>> the tutorial worked perfectly for me.
>> 
>>> On Fri, Jun 25, 2010 at 1:16 PM, zippzom <zipp...@gmail.com> wrote:
>> 
>>>> So, i'm working through the tutorial, but i'm having a problem with
>>>> the unicode method in the part 1 writing your own apps. I've copied
>>>> the code to the letter, but it still only returns 
>>>> instead . Any ideas why this could be happening?
>> 
>>>> Sorry if this is the wrong place to post this.
>> 
>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "Django users" group.
>>>> To post to this group, send email to django-us...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>>>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/django-users?hl=en.
>> 
>>> --
>>> Gabriel Gayan
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



ordering fields in admin form

2010-06-12 Thread darren
I'm sure the answer is probably documented clearly somewhere.  But, I
can't find it.

I would like to change the ordering of a field in a form on the admin
site based on the model below.  The "game" column is several records
long.  I would like to order desc.  I've tried adding a META class to
my model and tinkering with the admin.py.  But, I haven't been able to
figure this out.

Could someone point me to the documentation?  I've been reading this:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#ref-contrib-admin,
but I don't see what I'm looking for there.

Thanks

104 class AtBat(models.Model):
105 atbat_id = models.AutoField(primary_key=True)
106 player = models.ForeignKey(Person, to_field='f_name',
verbose_name='Player', limit_choices_to={'relationship' : 'Player'})
107 game = models.ForeignKey(Score, to_field='scores_id',
verbose_name='Game')
108 result = models.CharField('Result', choices=(('H', 'Hit'),
('BB', 'Walk'), ('K', 'Strike Out'), ('ROE', 'Reached On Error'),
('HBP', 'Hit By Pitch'), ('FO', 'Ground or Fly Out'), ('FC', 'Fielders
Choice'), ('Sacrifice', 'Sacrafice')), max_length=10)
109 rbi = models.PositiveSmallIntegerField("RBI", default=0)
110
111 def __unicode__(self):
112 return unicode('%s %s %s %s' % (self.atbat_id,
self.player, self.game, self.result))

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



Re: Unable to import libxml2mod from the python script

2010-06-03 Thread Darren
Go to  /usr/local/bin and do ls -l and see if python is a sym link. If  
so, see where it points and verify it points to python25. Your modules  
are here:

/usr/local/lib/python2.5/site-packages


Verify that the python executable matches.

Darren

On Jun 2, 2010, at 9:38 PM, Superman <ramseydsi...@gmail.com> wrote:


Thanks for your reply. How do you check env path variables diff
between shell and code
execution?

To my wsgi file, I have this line "#!/usr/local/bin/python" which
tells which interpreter to use. And yes, libxml2.py and libxml2mod.so
files are there in "/usr/local/lib/python2.5/site-packages/" folder.
Also running ldd on libxml2mod.so outputs:

libxml2.so.2 => /usr/local/lib/libxml2.so.2 (0x2b5368ebe000)

Also my python path looks correct. The django shell manages to find
and import the respective modules.

I have a feeling that the solution is quite easy after which I will
hit myself in the head hard! I have been pulling hair over this
problem since days now. Anyone, with any suggestions/info on how they
got their libxml2 module to work, please don't hesitate to reply.

Thanks


On Jun 2, 2:14 pm, Jeliuc Alexandr <jeliucalexa...@gmail.com> wrote:

You should check env path variables diff  between shell and code
execution. Another way check this error path is there libxml2 or not.
it may be in usr/lib/python2.5. or something like that.

On Jun 2, 4:57 pm, Superman <ramseydsi...@gmail.com> wrote:


I have a django site that is integrated with scrapy, but when the
scrapy code is called from the view, I get this error:



File "/usr/local/lib/python2.5/site-packages/libxml2.py", line 1, in

  import libxml2mod



ImportError: /usr/local/lib/python2.5/site-packages/
libxml2mod.so:
undefined symbol:xmlTextReaderSetup



But using the same python executable file on shell, I can import
libxml2 and libxml2mod fine!



import libxml2mod
import libxml2



Does anyone have an idea why my program is not working from .py file
as import is working perfect from python prompt.


--
You received this message because you are subscribed to the Google  
Groups "Django users" group.

To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com 
.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en 
.




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



Re: Unable to import libxml2mod from the python script

2010-06-02 Thread Darren
Just grasping at straws here, but could it have anything to do with  
permissions or the python path?  I don't fully understand how imports  
work.  But, those are things I'd explore first.


Darren

On Jun 2, 2010, at 8:57 AM, Superman <ramseydsi...@gmail.com> wrote:


I have a django site that is integrated with scrapy, but when the
scrapy code is called from the view, I get this error:

File "/usr/local/lib/python2.5/site-packages/libxml2.py", line 1, in

 import libxml2mod

   ImportError: /usr/local/lib/python2.5/site-packages/
libxml2mod.so:
   undefined symbol:xmlTextReaderSetup

But using the same python executable file on shell, I can import
libxml2 and libxml2mod fine!


import libxml2mod
import libxml2



Does anyone have an idea why my program is not working from .py file
as import is working perfect from python prompt.

--
You received this message because you are subscribed to the Google  
Groups "Django users" group.

To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com 
.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en 
.




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



Re: best approach to solve statistical problem

2010-05-27 Thread darren
Needing to get this done, I went with SQL.  The sql seems rather
inefficient.  But, my data set will be rather small.  I posted what I
went with on Pastebin:  http://pastebin.com/VmiYNXan (good for 24
hrs).

I don't have much data loaded (just one tournament).  But, you can see
the resulting table of data here: rankintornadoes.com.

I would still like to know if this would be the recommended Django
way.  Any advice would be welcome.

Darren

On Thu, May 27, 2010 at 2:19 PM, darren <backdoc...@gmail.com> wrote:
> I'm looking for ideas on the best way to approach this problem.
> Should I write raw SQL, stay with the ORM or even mix Javascript with
> either ORM or SQL?
>
> I want to keep up with player stats for a baseball team.  I've been
> reading up on aggregates and annotations.  And, I'm getting somewhere
> with it.  But, not quite all the way yet.  I  also wrote some SQL that
> accomplishes most everything I need all at once.  I think I could run
> with it, too.
>
> To calculate things like "on base percentage" or "batting average", I
> need to mix math both vertically and horizontally in the table.  One
> way I thought about handling this is to build an HTML table of data
> using a queryset based on this example in the Django documentation:
>
> Book.objects.aggregate(Avg('price'), Max('price'), Min('price'))
>
> except, I would need something that summed 3 or 4 different columns.
>
> At that point, I could use javascript to Sum() the total of each and
> calculate averages.  So, a table would be built like:
>
>          A            B              C                D            E
>                                 F
>             G                                     H
> Player Name |  Hits  |  Strike Outs  |  Walks  |  Fouled Out |
> Javascript Calcuated Total at Bats |  Javascript Calc. Batting AVG  |
> Javasctipt On Base %
> Player 1             3              2                5             2
>                         A+B+C+D+E
>  B/F                              (B+D)/F
> Player 2             4              2                5             1
>                         A+B+C+D+E
>  B/F                              (B+D)/F
>
>
> My models contain 3 tables that join people, tournaments and an "at
> bat".  The "AtBat" class is where the statistical data will be
> recorded. The model looks like this.  So, I'm saving one result per
> record:
>
> 101  class AtBat(models.Model):
> 102     atbat_id = models.AutoField(primary_key=True)
> 103     player = models.ForeignKey(Person, to_field='f_name',
> verbose_name='Player', limit_choices_to={'relationship' : 'Player' })
> 104     game = models.ForeignKey(Score, to_field='scores_id',
> verbose_name='Game')
> 105     result = models.CharField('Result', choices=(('H', 'Hit'),
> ('BB', 'Walk'), ('K', 'Strike Out'), ('FO', 'Ground or Fly Out'),
> ('Sacrifice', 'Sacrafice')), max_length=10)
>
> One of my goals would be to allow users to select certain players,
> date ranges or games to filter the results. I'm not sure how that
> might impact the solution.
>
> Any suggestions?
>

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



db problems after upgrading

2010-05-27 Thread darren
I upgraded django version from (not exactly sure) about 1.0 to 1.2.
After doing so, if I run manage.py syncdb, I get messages saying I
need to add unique constraints.  I added "unique=True" to the columns
in the model that were indicated.  However, I continue to get the
messages.  That didn't turn out to be what I wanted anyway because I
couldn't add additional records due to those constraints.

For example:
Error: One or more models did not validate:
links.extra_link: Field 'tourn_name' under model 'Tournament' must
have a unique=True constraint.

How do I need to handle this?

TIA,
Darren

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



Re: best approach to solve statistical problem

2010-05-27 Thread darren
Drats!  It looks like my HTML table came out jumbled.  I'll try to
post it somewhere where it is more legible.  But, it will be a few
hours.

One idea that came to mind after I submitted my question was to break
out the results column into individual booleans.  So, my model would
look more like:

Class AtBat(model.models):
  .
  hit = BooleanField()
  strikeOut = BooleanField()
  walk = BooleanField()
  .

That would allow me to sum those columns like:
select sum('hit'), sum('strikeOut'), sum('walk') from AtBat

But, I'm not sure I like this because some columns are mutually
exclusive.  You can't have a walk and a strike out at the same 'at
bat'.

On Thu, May 27, 2010 at 2:19 PM, darren <backdoc...@gmail.com> wrote:
> I'm looking for ideas on the best way to approach this problem.
> Should I write raw SQL, stay with the ORM or even mix Javascript with
> either ORM or SQL?
>
> I want to keep up with player stats for a baseball team.  I've been
> reading up on aggregates and annotations.  And, I'm getting somewhere
> with it.  But, not quite all the way yet.  I  also wrote some SQL that
> accomplishes most everything I need all at once.  I think I could run
> with it, too.
>
> To calculate things like "on base percentage" or "batting average", I
> need to mix math both vertically and horizontally in the table.  One
> way I thought about handling this is to build an HTML table of data
> using a queryset based on this example in the Django documentation:
>
> Book.objects.aggregate(Avg('price'), Max('price'), Min('price'))
>
> except, I would need something that summed 3 or 4 different columns.
>
> At that point, I could use javascript to Sum() the total of each and
> calculate averages.  So, a table would be built like:
>
>          A            B              C                D            E
>                                 F
>             G                                     H
> Player Name |  Hits  |  Strike Outs  |  Walks  |  Fouled Out |
> Javascript Calcuated Total at Bats |  Javascript Calc. Batting AVG  |
> Javasctipt On Base %
> Player 1             3              2                5             2
>                         A+B+C+D+E
>  B/F                              (B+D)/F
> Player 2             4              2                5             1
>                         A+B+C+D+E
>  B/F                              (B+D)/F
>
>
> My models contain 3 tables that join people, tournaments and an "at
> bat".  The "AtBat" class is where the statistical data will be
> recorded. The model looks like this.  So, I'm saving one result per
> record:
>
> 101  class AtBat(models.Model):
> 102     atbat_id = models.AutoField(primary_key=True)
> 103     player = models.ForeignKey(Person, to_field='f_name',
> verbose_name='Player', limit_choices_to={'relationship' : 'Player' })
> 104     game = models.ForeignKey(Score, to_field='scores_id',
> verbose_name='Game')
> 105     result = models.CharField('Result', choices=(('H', 'Hit'),
> ('BB', 'Walk'), ('K', 'Strike Out'), ('FO', 'Ground or Fly Out'),
> ('Sacrifice', 'Sacrafice')), max_length=10)
>
> One of my goals would be to allow users to select certain players,
> date ranges or games to filter the results. I'm not sure how that
> might impact the solution.
>
> Any suggestions?
>

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



best approach to solve statistical problem

2010-05-27 Thread darren
I'm looking for ideas on the best way to approach this problem.
Should I write raw SQL, stay with the ORM or even mix Javascript with
either ORM or SQL?

I want to keep up with player stats for a baseball team.  I've been
reading up on aggregates and annotations.  And, I'm getting somewhere
with it.  But, not quite all the way yet.  I  also wrote some SQL that
accomplishes most everything I need all at once.  I think I could run
with it, too.

To calculate things like "on base percentage" or "batting average", I
need to mix math both vertically and horizontally in the table.  One
way I thought about handling this is to build an HTML table of data
using a queryset based on this example in the Django documentation:

Book.objects.aggregate(Avg('price'), Max('price'), Min('price'))

except, I would need something that summed 3 or 4 different columns.

At that point, I could use javascript to Sum() the total of each and
calculate averages.  So, a table would be built like:

  AB  CDE
 F
 G H
Player Name |  Hits  |  Strike Outs  |  Walks  |  Fouled Out |
Javascript Calcuated Total at Bats |  Javascript Calc. Batting AVG  |
Javasctipt On Base %
Player 1             3              2                5             2
 A+B+C+D+E
  B/F  (B+D)/F
Player 2             4              2                5             1
 A+B+C+D+E
  B/F  (B+D)/F


My models contain 3 tables that join people, tournaments and an "at
bat".  The "AtBat" class is where the statistical data will be
recorded. The model looks like this.  So, I'm saving one result per
record:

101  class AtBat(models.Model):
102     atbat_id = models.AutoField(primary_key=True)
103     player = models.ForeignKey(Person, to_field='f_name',
verbose_name='Player', limit_choices_to={'relationship' : 'Player' })
104     game = models.ForeignKey(Score, to_field='scores_id',
verbose_name='Game')
105     result = models.CharField('Result', choices=(('H', 'Hit'),
('BB', 'Walk'), ('K', 'Strike Out'), ('FO', 'Ground or Fly Out'),
('Sacrifice', 'Sacrafice')), max_length=10)

One of my goals would be to allow users to select certain players,
date ranges or games to filter the results. I'm not sure how that
might impact the solution.

Any suggestions?

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



Re: Make MPs answer to us

2010-05-06 Thread Darren Mansell
On 6 May 2010 07:41, Darren Mansell <darren.mans...@gmail.com> wrote:

>
>
> On 6 May 2010 00:35, Russell Keith-Magee <freakboy3...@gmail.com> wrote:
>
>> On Thu, May 6, 2010 at 3:04 AM, Darren Mansell <darren.mans...@gmail.com>
>> wrote:
>> >
>> > It's election day tomorrow. This is a great web site for lots of info
>> about what's really going on:
>> > [http://www.38degrees.org.uk]
>>
>> This is a forum about using Django. The site you reference is in no
>> way relevant to that topic (as far as I can make out, it's written in
>> PHP).
>>
>> Furthermore, this a forum where the vast majority of readers are not
>> eligible to vote in the UK elections.
>>
>> While I heartily endorse the message that you should vote when
>> appropriate in your particular jurisdiction, and be well informed when
>> doing so, django-users isn't the right place to start promoting your
>> political viewpoints. Please don't do this again.
>>
>> Yours,
>> Russ Magee %-)
>>
>>
>>
> Sorry Keith and everyone, accidentally loaded this mail address from my
> contacts. Oops.
>

And of course by Keith I meant Russ. Oh dear I should just give up.

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



Re: Make MPs answer to us

2010-05-06 Thread Darren Mansell
On 6 May 2010 00:35, Russell Keith-Magee <freakboy3...@gmail.com> wrote:

> On Thu, May 6, 2010 at 3:04 AM, Darren Mansell <darren.mans...@gmail.com>
> wrote:
> >
> > It's election day tomorrow. This is a great web site for lots of info
> about what's really going on:
> > [http://www.38degrees.org.uk]
>
> This is a forum about using Django. The site you reference is in no
> way relevant to that topic (as far as I can make out, it's written in
> PHP).
>
> Furthermore, this a forum where the vast majority of readers are not
> eligible to vote in the UK elections.
>
> While I heartily endorse the message that you should vote when
> appropriate in your particular jurisdiction, and be well informed when
> doing so, django-users isn't the right place to start promoting your
> political viewpoints. Please don't do this again.
>
> Yours,
> Russ Magee %-)
>
>
>
Sorry Keith and everyone, accidentally loaded this mail address from my
contacts. Oops.

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



Make MPs answer to us

2010-05-05 Thread Darren Mansell
It's election day tomorrow. This is a great web site for lots of info about 
what's really going on:
[http://www.38degrees.org.uk]
Darren

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



heads up

2010-05-04 Thread darren
I thought I would pass this along in case it helps anyone.

A recent update on my Mac broke my python symlink.  I have my
/usr/bin/python pointing to /usr/local/bin/python2.6 via a symlink.  My
modules are located in /usr/local/lib/python2.6.  If you are experiencing a
problem with importing modules after a mac update, check you python path.
You will know if you are having that problem if you see this in your apache
error log:

TemplateSyntaxError: Caught ImportError while rendering: No module named



HTH

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



modelForm ordering

2010-04-20 Thread darren
I am not able to figure out how to order the records that fill the
drop down list in a model form.  On line 112 below, I have attempted
to order the Rotation model by player.  But, the drop down list that
is created for me is not ordered that way.  I also tried relocating
line 112 to within the Meta class definition.  But, that didn't work
either.  I see field ordering in the docs.  But, I don't see this
mentioned.

Any suggestions would be more than appreciated.

101 class Rotation(models.Model):
102 player = models.ForeignKey(Person, to_field='f_name',
verbose_name='Player', limit_choices_to={'relationship' : 'Player'})
103 date = models.DateField('Date', default=datetime.date.today)
104 game_type = models.CharField("Game Type",
choices=(('Scrimmage', 'Scrimmage'), ('Tournament', 'Tournament')),
max_length=10)
105 inning_count = models.IntegerField("Innings Out", default=1)
106 def __unicode__(self):
107 return '%s || %s %s || %s || %s' % (self.date,
self.player.f_name, self.player.l_name, self.game_type,
str(self.inning_count))
108 class Meta:
109 ordering = ['date']
110
111 class RotationForm(forms.ModelForm):
112 Rotation.objects.order_by('player')
113 class Meta:
114 model = Rotation
115 exclude = ['date', 'inning_count']

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



Re: conditional join with foreign key [SOLVED]

2010-04-15 Thread darren
I found exactly what I was looking for in the docs,
http://www.djangoproject.com/documentation/0.96/model-api/#many-to-one-relationships.


Using limit_choices_to={column_in_related_table_as_string : value_as_string}
did exactly what I was looking for.

Hope this helps someone else.

Darren

On Wed, Apr 14, 2010 at 10:29 PM, darren <backdoc...@gmail.com> wrote:

> I have two model classes that are related via a foreign key.  However,
> that's not limiting my results enough.  I'm getting too many choices in the
> drop down list of choices in the admin interface.  I'm trying to figure out
> where I should filter this.  If I was writing my own sql, I'd limit my
> results in the WHERE.  And, my query would look like this:
>
>   SELECT * FROM person a, stat b
>   WHERE
> a.name = b.name and
> a.type = 'Player'
>
> My model classes are like:
>
>   Class Person(models.Model):
> name=charField(.)
> type = choiceField(choices=(('Player', 'Player'), ('Sibling',
> 'Sibling'),('Coach', 'Coach')))
>
>   Class Stat(models.Model):
> name = foreignKey(Person, to_field=name)
> stats = charField()
>
> The key here is that I want to limit my drop down list to only 'Players".
>  Since this is not a view that I've written, I'm not sure how to approach
> this.  I was figuring that if I wrote the view, I would do something like
> this (warning, I may not have that syntax quite right):
>
> players = Stat.objects.filter(Person__type='Player')
>
> TIA,
> Darren
>
>
>
>
>

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



conditional join with foreign key

2010-04-14 Thread darren
I have two model classes that are related via a foreign key.  However,
that's not limiting my results enough.  I'm getting too many choices in the
drop down list of choices in the admin interface.  I'm trying to figure out
where I should filter this.  If I was writing my own sql, I'd limit my
results in the WHERE.  And, my query would look like this:

  SELECT * FROM person a, stat b
  WHERE
a.name = b.name and
a.type = 'Player'

My model classes are like:

  Class Person(models.Model):
name=charField(.)
type = choiceField(choices=(('Player', 'Player'), ('Sibling',
'Sibling'),('Coach', 'Coach')))

  Class Stat(models.Model):
name = foreignKey(Person, to_field=name)
stats = charField()

The key here is that I want to limit my drop down list to only 'Players".
 Since this is not a view that I've written, I'm not sure how to approach
this.  I was figuring that if I wrote the view, I would do something like
this (warning, I may not have that syntax quite right):

players = Stat.objects.filter(Person__type='Player')

TIA,
Darren

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



EuroPython 2010 registration and talk submissions now open!

2010-03-19 Thread Darren
Greetings djangonauts!

EuroPython 2010 - 17th to 24th July 2010

EuroPython is a conference for the Python programming language
community, including the Django, Zope and Plone communities. It is
aimed at everyone in the Python community, of all skill levels, both
users and programmers.

Last year's conference was the largest open source conference in the
UK and one of the largest community organised software conferences in
Europe.

This year EuroPython will be held from the 17th to 24th July in
Birmingham, UK. It will include over 100 talks, tutorials, sprints and
social events.

Registration

Registration is open now at: http://www.europython.eu/registration/

For the best registration rates, book as soon as you can! Extra Early
Bird closes soon, after which normal Early Bird rate will apply until
10th May

Talks, Activities and Events

Do you have something you wish to present at EuroPython? You want to
give a talk, run a tutorial or sprint?
Go to http://www.europython.eu/talks/cfp/ for information and advice!
Go to http://wiki.europython.eu/Sprints to plan a sprint!

Help Us Out
---
EuroPython is run by volunteers, like you! We could use a hand, and
any contribution is welcome.
Go to http://wiki.europython.eu/Helping to join us!
Go to http://www.europython.eu/contact/ to contact us directly!

Sponsors

Sponsoring EuroPython is a unique opportunity to affiliate with this
prestigious conference and to reach a large number of Python users
from computing professionals to academics, from entrepreneurs to
motivated and well-educated job seekers.
http://www.europython.eu/sponsors/

Spread the Word
---
We are a community-run not-for-profit conference. Please help to
spread the word by distributing this announcement to colleagues,
project mailing lists, friends, your blog, Web site, and through your
social networking connections. Take a look at our publicity resources:
http://wiki.europython.eu/Publicity

General Information
---
For more information about the conference, please visit the official
site: http://www.europython.eu/

Looking forward to see you!
The EuroPython Team

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



Re: Adding Fields To Querysets

2010-03-12 Thread Darren
the simplest method should work, perhaps you made a mistake early on
which set you off on the wrong path?

class Person(models.Model):
name = models.CharField(max_length=100)

def view_func(request):
people = Person.objects.all()
for person in people:
person.calcs = [ 1, 2, 3 ]
return render_to_response('people.html', { 'people':people })

{% for person in people %}
{{ person.name }}
{% for c in person.calcs %}
{{ c }}
{% endfor %}

{% endfor %}

- is this what you're after?

Darren

On Mar 11, 5:10 pm, wubble u <danmouseonm...@googlemail.com> wrote:
> Hi All,
>
> I've been passing querysets to templates for looping through rows to
> create tables / lists on the page... nice and easy... but I need to
> perform calculations on these rows and pass them with the queryset so
> I can loop through and display them along with the data from each row.
>
> I can't seem to find a way to add fields to the queryset, so I've
> tried creating a list of lists/dictionaries manually, and adding the
> data this way and then passing the list, but not having much luck here
> either.
>
> Then I tried tackling it at the model level using managers and model
> methods, but can't seem to access the data from the template.
>
> I'm from a .NET background so I'm used to populating datatables and
> adding columns and moving them around nice and easily, so I guess I'm
> probably just going about it the wrong way...
>
> Anyone got any ideas as to the pythonic way of accomplishing this?
>
> Cheers,
> wubble u

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



Database connection handling problem

2009-08-20 Thread Darren Platt

I am new to django - have used established installations before but am
setting it up for the first time now.  I am using vista 64 bit,  the
current SVN tree, python 2.5.2  and sqlite and pretty much following
the tutorial.  Everything went fine until I tried to access the admin
page (I can sync the databases etc, have added content and models).
I get a trackback (see below) when loading the admin page.  It looks
superficially like a db access problem but I have done the path
correctly (fwd slashes), checked permission, monitored file access at
the OS level (django opens and closes the sqlite file ok) and then in
sheer frustrating added print statements to track django's access to
sqlite. It does successfully open and close the database several
times, creating the session entries for example using these queries
(and I've verified it puts things into the sqlite db)

'SELECT "django_session"."session_key", "django_session"."ses
sion_data", "django_session"."expire_date" FROM "django_session" WHERE
("django_
session"."session_key" = %s  AND "django_session"."expire_date" >
%s )'

'SELECT (1) AS "a" FROM "django_session" WHERE "django_sessio
n"."session_key" = %s '

It then closes the database and *after* closing, tries the call stack
below which seems to blow up because the database isn't open.  It's
driving me nuts and has left me feeling less than enthusiastic about
django having wasted a good day so far troubleshooting.  Any help
greatly appreciated

Darren


Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 279, in run
self.result = application(self.environ, self.start_response)

  File "/usr/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 651, in __call__
return self.application(environ, start_response)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 245, in __call__
response = middleware_method(request, response)

  File "/usr/lib/python2.5/site-packages/django/contrib/sessions/
middleware.py", line 36, in process_response
request.session.save()

  File "/usr/lib/python2.5/site-packages/django/contrib/sessions/
backends/db.py", line 58, in save
obj.save(force_insert=must_create)

  File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 410, in save
self.save_base(force_insert=force_insert,
force_update=force_update)

  File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 474, in save_base
rows = manager.filter(pk=pk_val)._update(values)

  File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 444, in _update
return query.execute_sql(None)

  File "/usr/lib/python2.5/site-packages/django/db/models/sql/
subqueries.py", line 120, in execute_sql
cursor = super(UpdateQuery, self).execute_sql(result_type)

  File "/usr/lib/python2.5/site-packages/django/db/models/sql/
query.py", line 2369, in execute_sql
cursor.execute(sql, params)

  File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)

  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
base.py", line 206, in execute
ret =  Database.Cursor.execute(self, query, params)

OperationalError: unable to open database file

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Exception in transaction block hidden by "InternalError: transaction aborted ..." exception

2009-08-18 Thread Darren

any thoughts on this?

thanks,
darren

On Aug 17, 2:57 pm, Darren <accounts.dar...@gmail.com> wrote:
> Hi
>
> My app saves data in a method with "@transaction.commit_manually".
>
> My code had a bug - a field in a model was the wrong datatype for what
> was passed in, so I got a DataError exception back.
>
> However, the only exception that was displayed to me was
> "psycopg2.InternalError: current transaction is aborted, commands
> ignored until end of transaction block".
>
> I had to comment out "@transaction.commit_manually" in order to get
> the real DataError exception to show.
>
> My code looks like this:
>
>     @transaction.commit_manually
>     def save(self):
>         try:
>             # save data here
>         except BaseException as e:
>             traceback.print_exc()       # prints
> psycopg2.InternalError traceback
>             transaction.rollback()
>         else:
>             transaction.commit()
>
> I'm sure there's a way to get the original, DataError, exception...
> can anyone help?
>
> Thanks,
> Darren
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Exception in transaction block hidden by "InternalError: transaction aborted ..." exception

2009-08-17 Thread Darren

Hi

My app saves data in a method with "@transaction.commit_manually".

My code had a bug - a field in a model was the wrong datatype for what
was passed in, so I got a DataError exception back.

However, the only exception that was displayed to me was
"psycopg2.InternalError: current transaction is aborted, commands
ignored until end of transaction block".

I had to comment out "@transaction.commit_manually" in order to get
the real DataError exception to show.

My code looks like this:

@transaction.commit_manually
def save(self):
try:
# save data here
except BaseException as e:
traceback.print_exc()   # prints
psycopg2.InternalError traceback
transaction.rollback()
else:
transaction.commit()

I'm sure there's a way to get the original, DataError, exception...
can anyone help?

Thanks,
Darren

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



Dynamic App Creation

2009-07-07 Thread Darren Mansell
Hello. I'm looking into making a Django app that allows you to create Django
models.

The idea is that you should be able to add fields and user workflows using a
web page that then creates a model, view, template and syncs the DB. Users
can then access these newly created apps separately.

An example:

An accounts department of a company wants to replace their Excel files that
they currently use for expenses, claims etc. with a web-based system. The
web based system will have a page where you can create fields such as a
field for name, field for dept, field for expense, tax etc. The page then
creates a Django app with a model, view and template from this for employees
to fill in to submit expenses.
The employees DB will have info about who is who's manager and will then
allow the page creator to include workflows - e.g. employees enters details
and submits, their manager gets a mail to request authorisation, they
authorise and their director then has to authorise etc.

I think if something like this were to exist it would allow lots of
businesses to replace static documents for workflow with web based systems.

Does anyone know of anything out there that already does this kind of thing?

Darren

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



Overriding block tags in included templates?

2009-07-07 Thread Darren

Hi guys,

Chasing my tail a bit here, hoping you can help me.

say I have a base.html:

-

{% include 'header.html' %}

--

header.html:
-
{% block title %}Default title{% endblock title %}
-

And a child detail.html
---
{% extends 'base.html %}
{% block title %}Different title{% endblock title %}
---

When rendering detail.html, should the title block in header.html be
overridden? I'm guessing my understanding of how the template
including/inheritance understanding is wrong, so please correct me :)

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



User Authentication Redirect Loop

2009-07-06 Thread Darren Mansell
Hello.

I'm trying to log a user in using the @login_required decorator. I've
followed the examples on
http://docs.djangoproject.com/en/dev/topics/auth/#topics-auth but I can't
get it to stop spiraling into a redirect loop. I've tried everything I can
think of but I'm out of ideas. Please help.

My settings.py has:

LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'

My urls.py is:

from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root),
(r'^$', 'logviewer.viewer.views.index'),
(r'^(?P\D+)/(?P\S+)/$',
'logviewer.viewer.views.logview'),
(r'^(?P\D+)/$', 'logviewer.viewer.views.detail'),
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', 'django.contrib.auth.views.logout'),
)

And this is part of the views:

@login_required(redirect_field_name='redirect_to')
def index(request):
listOfSites = os.listdir('/root/Releases/WebSites')
ignoreList = ['ScriptTest', 'Supportal']
realList = []
for site in listOfSites:
if site not in ignoreList:
realList.append(site)
return render_to_response('logviewer/index.htm', {'realList' :
realList})


Firefox redirects like so:

http://logviewer/login/?redirect_to=/login/%3Fredirect_to%3D/login/%253Fredirect_to%253D/login/%25253Fredirect_to%25253D/login/%2525253Fredirect_to%2525253D/login/%252525253Fredirect_to%252525253D/login/%25252525253Fredirect_to%25252525253D/login/%2525252525253Fredirect_to%2525252525253D/login/%252525252525253Fredirect_to%252525252525253D/login/%25252525252525253Fredirect_to%25252525252525253D/login/%2525252525252525253Fredirect_to%2525252525252525253D/login/%252525252525252525253Fredirect_to%252525252525252525253D/login/%25252525252525252525253Fredirect_to%25252525252525252525253D/login/%2525252525252525252525253Fredirect_to%2525252525252525252525253D/login/%252525252525252525252525253Fredirect_to%252525252525252525252525253D/login/%25252525252525252525252525253Fredirect_to%25252525252525252525252525253D/login/%2525252525252525252525252525253Fredirect_to%2525252525252525252525252525253D/login/%252525252525252525252525252525253Fredirect_to%252525252525252525252525252525253D/login/%25252525252525252525252525252525253Fredirect_to%25252525252525252525252525252525253D/login/%2525252525252525252525252525252525253Fredirect_to%2525252525252525252525252525252525253D/

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this
address in a way that will never complete.

*   This problem can sometimes be caused by disabling or refusing to
accept
  cookies

Darren

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



Re: How to group_by..

2009-06-08 Thread Darren

Nice, thanks for the update, Russell and Alex !

-d

On Jun 5, 10:10 pm, Russell Keith-Magee <freakboy3...@gmail.com>
wrote:
> On Sat, Jun 6, 2009 at 7:55 AM, Alex Gaynor<alex.gay...@gmail.com> wrote:
>
> > On Fri, Jun 5, 2009 at 12:03 PM, Darren <blogposts.dar...@gmail.com> wrote:
>
> >> That's cool. You don't happen to have an updated estimate of the 1.1
> >> release date by any chance?
>
> > At this point 1.1 will be released as soon as the last 30 or so bugs have
> > been fixed.
>
> To clarifiy - of the 30 or so bugs, there are really only 10 that are
> actually bugs that need fixing. The remaining 20 are mostly
> translations and documentation. Based on current progress, I'd hazard
> a wild guess that we're O(weeks) away from a release.
>
> 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: How to group_by..

2009-06-05 Thread Darren

That's cool. You don't happen to have an updated estimate of the 1.1
release date by any chance?

Thanks,
Darren

On Jun 5, 12:35 pm, Russell Keith-Magee <freakboy3...@gmail.com>
wrote:
> On Sat, Jun 6, 2009 at 12:20 AM, Darren<blogposts.dar...@gmail.com> wrote:
>
> > Fantastic, thanks!
>
> > This is 1.1 only though correct?
>
> Apologies, I should have mentioned this. Yes, the syntax I gave will
> only work with Django trunk (soon to be v1.1)
>
> 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: How to group_by..

2009-06-05 Thread Darren

Fantastic, thanks!

This is 1.1 only though correct?

Cheers :)
Darren


On Jun 5, 11:39 am, Russell Keith-Magee <freakboy3...@gmail.com>
wrote:
> On Fri, Jun 5, 2009 at 11:24 PM, Darren<blogposts.dar...@gmail.com> wrote:
>
> > Hey,
>
> > Would anyone be able to to help me convert this SQL to Django code?
>
> > SELECT A.a, COUNT(B.b)
> > FROM A, B
> > WHERE A.id = B.a_id
> > GROUP BY A.id
> > ORDER BY A.id;
>
> It's impossible to give you a canonical answer without a complete
> Django model, but the query you have written would be rendered using
> something like:
> A.objects.values('a').annotate(Count(b__b)).order_by('id')
>
> As a point of clarification - if you actually only want a count of B
> objects, not a count of unique values of B.b, then you could use:
>
> A.objects.values('a').annotate(Count(b)).order_by('id')
>
> The values() clause is also potentially optional. The purpose of that
> clause is to reduce the output set so that it contains only the field
> 'a' and the count. If you are happy with returning full A instances,
> annotated with the count, you would use:
>
> A.objects.annotate(Count(b)).order_by('id')
>
> 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
-~--~~~~--~~--~--~---



How to group_by..

2009-06-05 Thread Darren

Hey,

Would anyone be able to to help me convert this SQL to Django code?

SELECT A.a, COUNT(B.b)
FROM A, B
WHERE A.id = B.a_id
GROUP BY A.id
ORDER BY A.id;

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



forms with ajax - how to use ModelForm?

2009-06-04 Thread Darren

Hi

I am trying to make sense of Django's form capabilities, having only
done ajax posts before..

Before ajaxification:


{{ form.as_p }}



def add_person(request):
form = PersonForm(request.POST)
if form.is_valid():
Person.objects.create(name=form.cleaned_data['name'])
return HttpResponseRedirect('/people/')

After ajaxification:

Name:

submit

p = Person.objects.create(name=request.POST['name'])
data = json.dumps({ 'name': p.name })
return HttpResponse(data, mimetype="application/javascript")

So my question is, is it worth using all the Django gubbins when the
alternative appears very simple?

Thanks!
Darren

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: forms with ajax - how to use ModelForm?

2009-06-04 Thread Blogposts Darren
(obviously, the second example omits the clean_data() call by accident!
question still applies..)

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



manage.py syncdb Ignoring Models

2009-03-25 Thread Darren Mansell
I'm just trying to do a bit of home development on Ubuntu 9.04 which has
Python 2.6.

When trying to populate the database from the models it's randomly ignoring
model definitions. I have no idea what's going on but the deprecation
warning of sets may be to do with it?

Output of ./manage.py syncdb:

darr...@lenny:/home/darth/darth$ ./manage.py syncdb
/var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
DeprecationWarning: the sets module is deprecated
  from sets import ImmutableSet
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table bmi_servertype
Creating table bmi_tomcatstyle
Creating table bmi_server
Creating table bmi_site
Creating table bmi_buildtype
Creating table bmi_build
Creating table bmi_generalsettings
Creating table django_admin_log

bmi/models.py:

from django.db import models
import datetime

class ServerType(models.Model):
server_type = models.CharField('Server Use', max_length=100)
def __unicode__(self):
return self.server_type

class TomcatStyle(models.Model):
tomcat_style = models.CharField('Description', max_length=100)
filesystem_location = models.CharField('Tomcat Filesystem Location
(before the site name)', max_length=100)
suffix = models.CharField('Site Suffix (to be appended to the site
name)', max_length=100, blank=True)
def __unicode__(self):
return self.tomcat_style

class Server(models.Model):
server_name = models.CharField(max_length=50)
created_date = models.DateTimeField('Date Created')
server_type = models.ForeignKey(ServerType)
admin_user = models.CharField(max_length=20)
admin_password = models.CharField(max_length=20)
ip_address = models.IPAddressField()
tomcat_style = models.ForeignKey(TomcatStyle, blank=True, null=True)
def __unicode__(self):
return self.server_name

class Site(models.Model):
broker_name = models.CharField('Broker Name', max_length=50)
site_name = models.CharField('Site Name', max_length=50)
created_date = models.DateTimeField('Date Created')
st_tomcat_server = models.ForeignKey(Server, related_name='st_tomcat')
uat_tomcat_server = models.ForeignKey(Server, related_name='uat_tomcat')
live_tomcat_server = models.ForeignKey(Server,
related_name='live_tomcat')
st_sql_server = models.ForeignKey(Server, related_name='st_sql')
uat_sql_server = models.ForeignKey(Server, related_name='uat_sql')
live_sql_server = models.ForeignKey(Server, related_name='live_sql')
def __unicode__(self):
return self.broker_name

class BuildType(models.Model):
build_type = models.CharField('Type of build', max_length=100)
def __unicode__(self):
return self.build_type

class BuildStage(models.Model):
build_stage_name = models.CharField(max_length=20)
def __unicode__(self):
return self.build_stage_name

class Build(models.Model):
site = models.ForeignKey(Site)
current_stage = models.ForeignKey(BuildStage)
created_date = models.DateTimeField('Date Created')
build_release = models.CharField('Release', max_length=7, unique=True)
notes = models.TextField('Build Notes')
sys_test_workflow = models.BooleanField('Include System Test Workflow')
proj_coord_workflow = models.BooleanField('Include Project
Co-ordination')
build_path = models.CharField(max_length=200, blank=True, null=True)
def __unicode__(self):
return self.build_release

class DeployTo(models.Model):
build_release = models.ForeignKey(Build)
build_stage = models.ForeignKey(BuildStage)
planned_date = models.DateTimeField('Planned Date')
scheduled_date = models.DateTimeField('Scheduled Deployment')

class GeneralSettings(models.Model):
releases_dir = models.CharField('Local Path to Releases Directory',
max_length=100, unique=True)
class Meta:
verbose_name_plural = 'General Settings'
def __unicode__(self):
return "General Darth settings"

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



Re: What's the most scalable Django deployment out there currently?

2009-03-25 Thread Darren Mansell
On Wed, Mar 25, 2009 at 5:09 AM, Alex Gaynor  wrote:

>
>
> On Wed, Mar 25, 2009 at 1:06 AM, Graham Dumpleton <
> graham.dumple...@gmail.com> wrote:
>
>>
>>
>>
>> On Mar 25, 3:45 pm, Alex Gaynor  wrote:
>> > On Wed, Mar 25, 2009 at 12:43 AM, Adam V.  wrote:
>> >
>> > > Curse (http://www.curse.com/) manages to stay up on WoW patch day, so
>> > > that's a pretty good sign.
>> >
>> > Curse is no longer running on Django(it's ASP.net now I think), no idea
>> if
>> > that was a technical decision or not.
>>
>> If it using ASP.net, maybe that is why none of their addresses respond
>> to me from where I am. :-)
>>
>> Curse was using mod_python:
>>
>>  http://www.davidcramer.net/curse/44/what-powers-curse.html
>>
>> David Cramer though has since switched to mod_wsgi and has expressed
>> the opinion that mod_wsgi works a lot better.
>>
>> Important think though is not so much the hosting mechanism but how
>> well you optimise the performance of your application and database.
>>
>> Graham
>>
>>
>>
>>
>>
> David also did a good talk on scaling Django(based on his experiences at
> curse) at DjangoCon, the video is on youtube.
>
> Alex
>
>
As far as DBs go we are scaling MySQL quite hard. If you ensure you have the
tools to support it you can use circular replication with Linux-HA to
provide a single IP address that the app connects to. You can also scale out
Apache with Linux-HA in this way. We've found that it's very hard to scale
asp.Net/SQL platforms out but using Linux with HA it's very cheap and easy.

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

2009-03-24 Thread Darren Mansell
That was a great help thanks. I also used the copy() method on the
request.POST dict and I could redirect to the same view. Cheers.

On Mar 24, 2009 3:43 PM, "Thomas Guettler"  wrote:


Hi,

my guess: You need to redirect after POST.

if you give request.POST to the Form, it will overwrite the values
from the model with the values from request.POST. If you do a redirect
after POST, the value from the model will be displayed, since POST
is empty after the redirect.

BTW, I often do it like this:

def view(request):
   if request.POST:
   data=request.POST
   else:
   data=None
   form=MyForm(data)

Why do you access 'build_release' in POST? It would be better
the create a Field for it and access form.cleaned_data['build_release']

 HTH,
  Thomas

DarrenM schrieb:
> ...

> elif request.POST['build_release']: > f = BuildForm(request.POST) > ...
--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


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



File Browser and Editor with Django,any help?

2008-07-04 Thread Darren Lee

Hi,all
   I am new to this community. these days My leader give me a
mission ,describe as below:
the httpd server was installed under a linux server ,and the it  use
Django tech. I should add the web server with a funtion like Windows
Explorer  and Editor in the WebBrowser like firefox.

any one can help ?
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i'm tired

2008-02-09 Thread Darren Redmond


try placing the word python in front of the line:

python django-admin.py startproject mysite

newbiedoobiedoo wrote:
> I did exactly what you said here.
> The very first instruction on the tutorial failed:
> django-admin.py startproject mysite
>
> The error was
> "bash: django-admin.py: command not found"
>
> Any suggestion?
>
> On Feb 9, 1:54 pm, Wilson MacGyver <[EMAIL PROTECTED]> wrote:
>   
>> I think you made it more complex than it really has to be,
>> especially for learning.
>>
>> For a straight OSX install when I first started messing around
>> with django. here is what I did.
>>
>> Step 1: download and install macpython from the python.org
>> url ishttp://www.python.org/ftp/python/2.5.1/python-2.5.1-macosx.dmg
>>
>> this ensures you have python 2.5.1
>>
>> Step 2: download the stable version 
>> fromhttp://www.djangoproject.com/download/0.96.1/tarball/
>>
>> Step 3: On OSX, I untar it and install from my home dir.
>> by doing this.
>>
>> Assuming I'm at my home directory.
>> tar xzvf Django-0.96.1.tar.gz
>> cd Django-0.96.1
>> sudo python setup.py install
>>
>> that's it. you are done. No need to mess with apache, no
>> need to mess with mod_python. Worry about that when you
>> are doing deployment, not when you want to get started and
>> learn django.
>>
>> After these 3 steps above, you are ready to follow along
>> the tutorial for 0.96
>>
>> http://www.djangoproject.com/documentation/0.96/tutorial01/
>>
>> newbiedoobiedoo wrote:
>> 
>>> i was totally stoked about python.  it seemed like the best language
>>> i'd seen
>>> in a while.
>>>   
>>> but i must confess i've just looked at the script for installing the
>>> development
>>> environement
>>> http://code.djangoproject.com/wiki/SimpleBashScriptToSetupDevelopment...
>>>   
>>> this is after installing svn, trying to get mod_python installed,
>>> etc.
>>>   
>>> i'm a health care person, who does a little programming.
>>>   
>>> i'm beat.   i'm done.   python is only for turbo charged hackers.
>>> i might be able to program in it.  but i sure as h*** can't install
>>> it.
>>>   
> >
>
>   


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



Re: fundamental issues with configuring Apache and mod_python

2007-01-31 Thread darren
Thanks  I took your configuration and was able to configure mine
accordingly.  I still don't completely understand it, but at least I can get
to the admin page and the poll page.  And, now I can finish the tutorial.  I
don't think that I have some permissions correct though because my pages
don't have any style.  So, I think I must need to open access to the Apache
user to wherever the style sheets are stored.

Here's the configuration that worked for me:


ServerName www.myDomain.com
ServerAlias myDomain.com *.myDomain.com
DocumentRoot /usr/local/www/myDomain.com/docroot
# # for django

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE linkshare.settings
PythonDebug On
PythonPath "['/usr/local/www/myDomain.com/'] + sys.path"



For anyone searching the archives for this topic, the keys to my problem
were the following:

I moved the separate  directive into my  directory.
So, now the are combined.  This next part is a complete assumption.  But,
this is how it looks like to me.
The value for the  directive is appended to the DocumentRoot
directive to construct the path on the file system that you want Python to
handle.  So, I set mine to "/".
The "SetEnv DJANGO_SETTINGS_MODULE linkshare.settings" line is either
apparently relative to the path you add to the  directive, which
is appended to the the DocumentRoot, or it is appended to the PythonPath.

Thanks Alex


On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Hi!
>
> On Jan 31, 6:47 pm, "backdoc" <[EMAIL PROTECTED]> wrote:
> > I am trying to experiment with django.  And, I'm at a loss.  My
> > problem is that I just don't conceptually understand how to match up
> > where everything is supposed to go on the filesystem and how to
> > configure Apache and mod_python to be aware of it.
>
> Its not clear for me where the problem is (since you see /polls).
> Just for reference here is config of my site:
>
> 
>   ServerName alex.koval.kharkov.ua
>   ServerAdmin [EMAIL PROTECTED]
>   CustomLog /var/log/apache2/alex.koval.kharkov.ua-access_log combined
>   DocumentRoot /var/www/alex.koval.kharkov.ua/PersonalWebSite/htdocs
>   
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> PythonPath "sys.path+['/var/www/alex.koval.kharkov.ua/
> PersonalWebSite/','
> /var/www/alex.koval.kharkov.ua/']"
> SetEnv DJANGO_SETTINGS_MODULE PersonalWebSite.settings
> SetEnv LANG en_EN
> SetEnv LC_ALL C
> PythonDebug Off
>   
>   
> SetHandler None
>   
>   Alias /static "/var/www/alex.koval.kharkov.ua/PersonalWebSite/
> htdocs/"
>   
> SetHandler None
>   
> 
>
> Source code of my site can be seen here:
> http://code.koval.kharkov.ua/browser/PersonalWebSite/trunk
>
>
>
> >
>

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



Re: confused about licensing

2006-05-30 Thread Darren Redmond


Nicola,

Thanks for the prompt response.

Let's hope the explanation keeps our legal team happy, otherwise I need 
another database.

cheers
Darren

tekNico wrote:
>> I have been using django with postgres on windows while builiding my
>> application for the last month or so.
>> I have just spend the day putting the app onto a linux box. It has just
>> been pointed out to me by one of my colleagues,
>> while building psycopg on the linux box, that it is a Gnu Public License.
>>
>> Now my understanding of GPL is that if a product uses it, it can't claim
>> to be BSD. So given that django imports psycopg dynamically,
>> how does Django maintain its BSD status?
>>
>> Also has anyone else noticed this and how have other people got around
>> this issue when using a postgres backend?
>> 
>
> Disclaimer: this is not legal advice, read the fine print and decide
> for yourself.
>
>
> This is a FAQ (unfortunately not included in the PsycoPg FAQ).
>
> Summary: usage of PsycoPg with OpenSSL and PostgreSQL libpq does not
> extend the GPL license to the whole program.
>
> Details follow.
>
>
> >From http://initd.org/svn/psycopg/psycopg1/trunk/README:
>
> Licence
> ---
>
> psycopg is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version. See file COPYING for details.
>
> As a special exception, specific permission is granted for the GPLed
> code in this distribition to be linked to OpenSSL and PostgreSQL libpq
> without invoking GPL clause 2(b).
>
>
> >From http://initd.org/svn/psycopg/psycopg2/trunk/LICENSE:
>
> psycopg and the GPL
> ===
>
> psycopg is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version. See file COPYING for details.
>
> As a special exception, specific permission is granted for the GPLed
> code in this distribition to be linked to OpenSSL and PostgreSQL libpq
> without invoking GPL clause 2(b).
>
> Note that the GPL was chosen to avoid proprietary adapters based on
> psycopg code. Using psycopg in a proprietary product (even bundling
> psycopg with the proprietary product) is fine as long as:
>
>  1. psycopg is called from Python only using only the provided API
> (i.e., no linking with C code and no C modules based on it); and
>
>  2. all the other points of the GPL are respected (you offer a copy
> of psycopg's source code, and so on.)
>
>
> --
> Nicola Larosa - http://www.tekNico.net/
>
> Baby, I can tell you there's no easy way out
> Lost inside of dreams that guide you on
> Baby, I can tell you there's no easy way out
> Soon the guiding moonlight will be gone
>  -- David Sylvian, Silver Moon, Gone to Earth, 1986
>
>
> >
>
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



confused about licensing

2006-05-30 Thread Darren Redmond


hi all,

I have been using django with postgres on windows while builiding my 
application for the last month or so.
I have just spend the day putting the app onto a linux box. It has just 
been pointed out to me by one of my colleagues,
while building psycopg on the linux box, that it is a Gnu Public License.

Now my understanding of GPL is that if a product uses it, it can't claim 
to be BSD. So given that django imports psycopg dynamically,
how does Django maintain its BSD status?

Also has anyone else noticed this and how have other people got around 
this issue when using a postgres backend?

worried ;)
Darren


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: 'str' object has no attribute 'write' Exception

2006-05-25 Thread Darren Redmond


Mary,

In your code you have assigned output to be a string.
So output as a string would cease to have the operation write on it.

so change the last two lines of your code to be

tempOutput = ', '.join([m.menu_text for m in latest_menu_list])
output.write(tempOutput)

I hope that this helps

cheers
Darren


Mary Adel wrote:
> dear all 
>
> i have this error:Request Method: 
>
> GET Request URL: http://127.0.0.1:8000/xmlmenu/ 
> Exception Type: AttributeError Exception Value: 'str' object has no
> attribute 'write' Exception 
> Location: /var/www/xml-python/xmleditor/../xmleditor/menues/views.py in
> index, line 14
>
> when i wrote this view:
>
> def index(request):
> output=open( '/var/www/xml-python/xmleditor/test.xml','w')
> output.write('')
> output.write('')
> latest_menu_list = Menu.objects.all().order_by('-id')
> output = ', '.join([m.menu_text for m in latest_menu_list])
> output.write(output)
>
>
>
>
>
> >
>
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---