blank and null with Oracle

2013-02-27 Thread Skylar Saveland
Some odd behavior with Oracle involving blank and null.

blank is True on this field:
my_auto = models.AutoField(blank=False, null=False, primary_key=True)

null is True on this field:
uncles = models.ManyToManyField(Uncle, blank=False, null=False) 

null is True on this field:
photo = models.ImageField(upload_to="uploads/") 

And, then, as documented null=True on CharFields.

The most disturbing thing is that blank/null on the first two examples are 
the opposite of what is explicitly declared.

Should I post this on django-developers. Is this behavior documented? Are 
this problems/quirks known?

-Skylar

-- 
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: charField null=false not enforced for table creation in oracle

2013-02-22 Thread Skylar Saveland
This is still a good question :)

On Thursday, March 11, 2010 5:57:13 AM UTC-8, Wayne wrote:
>
> Hi Karen,
>
> Many thanks for your reply.
> Now our business requirements do not allow either empty string or null
> value for this particular charField column (name =
> models.CharField(max_length=512, null=False, blank=False)). How do you
> suggest we should configure this field so that we can enforce not null
> condition in the oracle database by using syncdb? Currently, after
> creating those tables we need to manually modify the column properties
> in Oracle to make them not null. Or Django Oracle backend deliberately
> ignores null=false for charField creation?
>
> Wayne
>
> On Feb 26, 8:47 pm, Karen Tracey  wrote:
> > On Fri, Feb 26, 2010 at 5:35 PM, Wayne  wrote:
> > > Hi,
> > > I try to create tables using Django models in our test oracle
> > > database. I define a model with one column like this: name =
> > > models.CharField(max_length=512, null=False, blank=False). After
> > > running python manage.py syncdb, I found that column 'name' in the
> > > generated table still allows null value in the column definition. I
> > > understand that null = false is the default option. And I verified
> > > that for other types of Django fields, null = false or no such option
> > > at all would generate columns that do not allow null values in the
> > > database. Is there particular reason why null = false is not enforced
> > > for charField?
> >
> > Yes. Oracle does not distinguish between null and an empty string. So
> > null=False applied at the database level would mean that you also could 
> not
> > store the empty string in that field, which would be quite different from
> > what you would see running the same code on most other databases, where 
> the
> > empty string is a valid value for a NOT NULL character field.
> >
> > The behavior is documented, see the note here:
> http://docs.djangoproject.com/en/dev/ref/models/fields/#null. The note is
> > perhaps not as clear as it could be about when the empty string is 
> allowed
> > for a field. That's a property of the field type (for example, empty 
> strings
> > are allowed for CharField but not a DateField), and is not in any way 
> tied
> > to the value of the field's blank option. The blank option, as noted in 
> its
> > description, is used for validation and is not applied at the database
> > level.
> >
> > Karen
>
>

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




Possible Bug with GenericRelation and values_list

2012-12-10 Thread Skylar Saveland
I may have found a bug. I made a test case here:

https://github.com/skyl/django/commit/556df1c46146c2fc9c4022d838fa23f652f0ea8d

The final assertion fails. Is this a bug or do I misunderstand how this 
should work?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/FcwARKk-EswJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Class based views and form processing

2011-01-12 Thread Skylar Saveland
what's wrong with just defining form_valid sth like:


  form_valid(self, form):
self.object = form.save(commit=False)
#ponies
self.object.save()
return HttpResponseRedirect(self.get_success_url())

does that not work?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Class based views and form processing

2011-01-12 Thread Skylar Saveland
instead of calling super, you could just call FormMixin.form_valid directly, 
yes?

-- 
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: User.get_profile() not working

2010-09-28 Thread Skylar Saveland
Using *args and **kwargs might work

then maybe

self.website = kwargs.get('website', 'default.com')

On Sep 28, 1:45 pm, adj7388  wrote:
> Django newbie issue. Just trying to understand. I'm setting up a
> simple UserProfile class to link to User (as described in several
> places in documentation). Here's what I have --- a simple example of
> storing the user's website in a profile
>
> #In myapp/models.py
> class UserProfile(models.Model):
>     def __init__(self, website='http://www.default.com'):
>         super(UserProfile, self).__init__()
>         self.website = website
>     user = models.ForeignKey(User, unique=True,
> related_name="user_profile") <-- note related_name...see below
>     website = models.URLField()
>
> #In myproject/settings.py
> AUTH_PROFILE_MODULE = "myapp.UserProfile"
>
> Now I create a empty db
> run: python2.6 manage.py syncdb
> All tables look good in postgres.
>
> Now in the python shell:
>
> Python 2.6.5 (r265:79063, May 12 2010, 10:28:19)
>
> >>> from django.contrib.auth.models import User
> >>> from myapp.models import UserProfile
> >>> u = User(username='testuser', password='s')
> >>> u.save()
> >>> up = UserProfile(website='www.overridethesite.com')
> >>> up.user=u
> >>> up.save()
>
> So far so good
> Over in Postgres, everything looks fine:
> mydb=> select au.id as id, au.username, up.id as upid, up.user_id as
> fk_userid, up.website from auth_user au join myapp_userprofile up on
> (au.id=up.user_id);
>    id | username | upid | fk_userid |         website
> --+--+--+---+-
>     2 | testuser |    1 |         2 |www.overridethesite.com
> (1 row)
>
> Now back in the python shell, trying to use the profile from the user
> obj:
>
> >>> u.user_profile.values()  <--- works fine using the related_name I set in 
> >>> the UserProfile class
>
> [{'website': u'www.overridethesite.com', 'user_id': 2, 'id': 1}]
>
> ### But get_profile() fails:
>
> >>> myprofile = u.get_profile()
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/home/myusername/webapps/django_boosters/lib/python2.6/django/
> contrib/auth/models.py", line 370, in get_profile
>     self._profile_cache =
> model._default_manager.using(self._state.db).get(user__id__exact=self.id)
>   File "/home/myusername/webapps/django_boosters/lib/python2.6/django/
> db/models/query.py", line 336, in get
>     num = len(clone)
>   File "/home/myusername/webapps/django_boosters/lib/python2.6/django/
> db/models/query.py", line 81, in __len__
>     self._result_cache = list(self.iterator())
>   File "/home/myusername/webapps/django_boosters/lib/python2.6/django/
> db/models/query.py", line 282, in iterator
>     obj = self.model(*row[index_start:aggregate_start])
> TypeError: __init__() takes at most 2 arguments (4 given)
>
> Can anyone tell me what's going on, or what I'm doing wrong? Thanks in
> advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: User.get_profile() not working

2010-09-28 Thread Skylar Saveland
Overriding __init__ might be a little shady, but you probably can get
away with it if you use *args and **kwargs

On Sep 28, 1:45 pm, adj7388  wrote:
> Django newbie issue. Just trying to understand. I'm setting up a
> simple UserProfile class to link to User (as described in several
> places in documentation). Here's what I have --- a simple example of
> storing the user's website in a profile
>
> #In myapp/models.py
> class UserProfile(models.Model):
>     def __init__(self, website='http://www.default.com'):
>         super(UserProfile, self).__init__()
>         self.website = website
>     user = models.ForeignKey(User, unique=True,
> related_name="user_profile") <-- note related_name...see below
>     website = models.URLField()
>
> #In myproject/settings.py
> AUTH_PROFILE_MODULE = "myapp.UserProfile"
>
> Now I create a empty db
> run: python2.6 manage.py syncdb
> All tables look good in postgres.
>
> Now in the python shell:
>
> Python 2.6.5 (r265:79063, May 12 2010, 10:28:19)
>
> >>> from django.contrib.auth.models import User
> >>> from myapp.models import UserProfile
> >>> u = User(username='testuser', password='s')
> >>> u.save()
> >>> up = UserProfile(website='www.overridethesite.com')
> >>> up.user=u
> >>> up.save()
>
> So far so good
> Over in Postgres, everything looks fine:
> mydb=> select au.id as id, au.username, up.id as upid, up.user_id as
> fk_userid, up.website from auth_user au join myapp_userprofile up on
> (au.id=up.user_id);
>    id | username | upid | fk_userid |         website
> --+--+--+---+-
>     2 | testuser |    1 |         2 |www.overridethesite.com
> (1 row)
>
> Now back in the python shell, trying to use the profile from the user
> obj:
>
> >>> u.user_profile.values()  <--- works fine using the related_name I set in 
> >>> the UserProfile class
>
> [{'website': u'www.overridethesite.com', 'user_id': 2, 'id': 1}]
>
> ### But get_profile() fails:
>
> >>> myprofile = u.get_profile()
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/home/myusername/webapps/django_boosters/lib/python2.6/django/
> contrib/auth/models.py", line 370, in get_profile
>     self._profile_cache =
> model._default_manager.using(self._state.db).get(user__id__exact=self.id)
>   File "/home/myusername/webapps/django_boosters/lib/python2.6/django/
> db/models/query.py", line 336, in get
>     num = len(clone)
>   File "/home/myusername/webapps/django_boosters/lib/python2.6/django/
> db/models/query.py", line 81, in __len__
>     self._result_cache = list(self.iterator())
>   File "/home/myusername/webapps/django_boosters/lib/python2.6/django/
> db/models/query.py", line 282, in iterator
>     obj = self.model(*row[index_start:aggregate_start])
> TypeError: __init__() takes at most 2 arguments (4 given)
>
> Can anyone tell me what's going on, or what I'm doing wrong? Thanks in
> advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: iPhone talking to Django server (matching session)

2010-09-28 Thread Skylar Saveland
User.objects.get(pk=Session.objects.get(pk=session_id).get_decoded()
['_auth_user_id']) via @SmileyChris

On Sep 28, 9:36 pm, Danny Bos  wrote:
> Heya,
>
> I've got a Django application talking to an iPhone sending photos and
> User data back and forth. I figured the best way to approach this
> (tell me otherwise) was to log the user in on the server and pass the
> iPhone back the 'session ID' in a JSON array.
>
> Then when the iPhone sends me back some info, they send me that same
> 'session ID' and I match that to the associated user content in order
> to get the User details. Does this make sense? Is it the way to go in
> order to pass User details back and forth to an iPhone.
>
> If so.
>
> How do I find the User when the iPhone passes me back the 'session
> ID'?
>
> Thanks in advance,
> Hope all is well your side of town ...
>
> d.

-- 
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: form validation for empty checkboxes that are not required (and they are the only fields present)

2010-09-28 Thread Skylar Saveland
class Asset(models.Model):
languages = models.ManyToManyField('account.Language', null=True,
blank=True)


class AssetLanguageForm(forms.ModelForm):
languages = forms.ModelMultipleChoiceField(
queryset=Language.objects.all(),
required=False,
widget=forms.CheckboxSelectMultiple
)

class Meta:
model = Asset
fields = ('languages',)


Adding a hidden garbage field works.  Seems like it's just a little
edge-case bug/gotcha.



On Sep 28, 8:49 am, Brian Neal <bgn...@gmail.com> wrote:
> On Sep 27, 11:35 am, Skylar Saveland <skylar.savel...@gmail.com>
> wrote:> I have some modelforms within a .  Each form has one
> > checkboxselectmultiple that is not required.  If I post nothing (all
> > checkboxes are empty) then all of the forms are invalid.  If I post
> > anything then all of the forms are valid.  This anything could be that
> > one of the forms has a box checked, or that I add  > name='omg' value='wtf'> to the form.
>
> Can you please post your model and form code? Perhaps in a pastebin?
>
> BN

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



form validation for empty checkboxes that are not required (and they are the only fields present)

2010-09-27 Thread Skylar Saveland
I have some modelforms within a .  Each form has one
checkboxselectmultiple that is not required.  If I post nothing (all
checkboxes are empty) then all of the forms are invalid.  If I post
anything then all of the forms are valid.  This anything could be that
one of the forms has a box checked, or that I add  to the form.


This constitutes a bug?  Is there already an issue?  Is there
something standard I can do to make it work without the hidden field
or is the hidden field a good way to go?


POSTing with no data:

Th[4320923648] 2010-09-27 12:13:48,689 cms.views [DEBUG   ] POSTing to
edit_assets with 
Th[4320923648] 2010-09-27 12:13:48,695 cms.forms [DEBUG   ] the
formset data is 
Th[4320923648] 2010-09-27 12:13:48,695 cms.forms [DEBUG   ] forms are:
[,
]
Th[4320923648] 2010-09-27 12:13:48,695 cms.forms [DEBUG   ] asset
metadata formset validation: [False, False]  (.is_valid() on the
forms)
Th[4320923648] 2010-09-27 12:13:48,695 cms.forms [DEBUG   ] errors?
[{}, {}]
[27/Sep/2010 12:13:48] "POST /portal/edit-assets/?collection=foobar
HTTP/1.1" 200 2434


if anything is in the POST, the forms are valid.

-- 
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: Unexpected query behavior

2010-07-09 Thread Skylar Saveland
http://docs.djangoproject.com/en/1.2/topics/db/queries/#spanning-multi-valued-relationships

On Jul 10, 12:33 am, Skylar Saveland <skylar.savel...@gmail.com>
wrote:
> If I chain my .filter()s
>
> Collection.objects.filter(collection_revisions__articles=article).filter(co 
> llection_revisions__char_fi="p")
>
> collection_revisions is related_name, FK to Collection.
> articles relname, m2m with collection_revision (with a through table).
>
> I get ~20 results with this query::
>
> SELECT "catalog_collection"."id",
>         ...
>
>        "catalog_collection"."collection_type_id"
> FROM "catalog_collection"
> INNER JOIN "catalog_collection_revision" ON ("catalog_collection"."id"
> = "catalog_collection_revision"."collection_id")
> INNER JOIN "catalog_collection_revision_item" ON
> ("catalog_collection_revision"."id" =
> "catalog_collection_revision_item"."collection_revision_id")
> INNER JOIN "catalog_collection_revision" T5 ON
> ("catalog_collection"."id" = T5."collection_id")
> WHERE ("catalog_collection"."is_archived" = False
>        AND "catalog_collection_revision_item"."article_id" = 3
>        AND T5."revision_tag" = p)
>
> When I put the two queries within the same call to filter, I thought
> it would be the same.  But, there is not the 3rd INNER JOIN and it
> only returns 1 object::
>
> Collection.objects.filter(collection_revisions__articles=article,
> filter(collection_revisions__revision_tag="p")
>
> SELECT "catalog_collection"."id",
>         ...
>
>        "catalog_collection"."collection_type_id"
> FROM "catalog_collection"
> INNER JOIN "catalog_collection_revision" ON ("catalog_collection"."id"
> = "catalog_collection_revision"."collection_id")
> INNER JOIN "catalog_collection_revision_item" ON
> ("catalog_collection_revision"."id" =
> "catalog_collection_revision_item"."collection_revision_id")
> WHERE ("catalog_collection"."is_archived" = False
>        AND "catalog_collection_revision_item"."article_id" = 3
>        AND "catalog_collection_revision"."revision_tag" = p)
>
> Is this the expected behavior?  Can someone explain what's going 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.



Re: Unexpected query behavior

2010-07-09 Thread Skylar Saveland
the second query should read:

Collection.objects.filter(collection_revisions__articles=article,
collection_revisions__revision_tag="p")

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



Unexpected query behavior

2010-07-09 Thread Skylar Saveland
If I chain my .filter()s

Collection.objects.filter(collection_revisions__articles=article).filter(collection_revisions__char_fi="p")

collection_revisions is related_name, FK to Collection.
articles relname, m2m with collection_revision (with a through table).

I get ~20 results with this query::


SELECT "catalog_collection"."id",
...

   "catalog_collection"."collection_type_id"
FROM "catalog_collection"
INNER JOIN "catalog_collection_revision" ON ("catalog_collection"."id"
= "catalog_collection_revision"."collection_id")
INNER JOIN "catalog_collection_revision_item" ON
("catalog_collection_revision"."id" =
"catalog_collection_revision_item"."collection_revision_id")
INNER JOIN "catalog_collection_revision" T5 ON
("catalog_collection"."id" = T5."collection_id")
WHERE ("catalog_collection"."is_archived" = False
   AND "catalog_collection_revision_item"."article_id" = 3
   AND T5."revision_tag" = p)



When I put the two queries within the same call to filter, I thought
it would be the same.  But, there is not the 3rd INNER JOIN and it
only returns 1 object::

Collection.objects.filter(collection_revisions__articles=article,
filter(collection_revisions__revision_tag="p")

SELECT "catalog_collection"."id",
...

   "catalog_collection"."collection_type_id"
FROM "catalog_collection"
INNER JOIN "catalog_collection_revision" ON ("catalog_collection"."id"
= "catalog_collection_revision"."collection_id")
INNER JOIN "catalog_collection_revision_item" ON
("catalog_collection_revision"."id" =
"catalog_collection_revision_item"."collection_revision_id")
WHERE ("catalog_collection"."is_archived" = False
   AND "catalog_collection_revision_item"."article_id" = 3
   AND "catalog_collection_revision"."revision_tag" = p)


Is this the expected behavior?  Can someone explain what's going 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.



Re: Serving django admin files using mod_python

2010-06-24 Thread Skylar Saveland
mod_python is dead.

you can just serve your static files .. statically.  usually you might
point at a cdn or put nginx in front although you could set /media or /
ash/media to serve statically with apache.

On Jun 24, 5:47 pm, commonzenpython  wrote:
> i have been playing with django using mod_python, so i activated the
> admin for my application and instead of the pretty looking page, i
> get :
>
> Django administration
>
> Welcome, ashtanga. Change password / Log out
> Site administration
>
> Auth
> Groups  Add     Change
> Users   Add     Change
> Sites
> Sites   Add     Change
> Recent Actions
>
> My Actions
>
> None available
>
> i know this has something to do with the static files, and iv read
> several posts on it, but i cant find a solution for mod_python, this
> is my httpd.conf for mod_python:
>
> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE ash.settings
>     SetEnv PYTHON_EGG_CACHE /tmp
>     PythonOption django.root /ash
>     PythonDebug On
>    PythonPath "['/home/ashtanga/public_html/', '/home/ashtanga/
> public_html/ash'] + sys.path"
> 
>
> my project path is /home/ashtanga/public_html/ash

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



pointer 1to1, '_ptr', what are the rules?

2010-06-24 Thread Skylar Saveland
I have:


class Foo(models.Model):

...


class Bar(Foo):

  class Meta:
proxy=True


class Baz(Foo):

  ...

my baz instances have a `foo_ptr` attr on them and my bar instances do
not.  The only reason I can think of that this is is b/c Bar is a
proxy.  Is this correct?  Is there some documentation or other
readings that I can do to understand what is happening under the
covers?  I suppose that I could grep the source code...

Right, so I'm right.  I guess I'll just leave this for the next
hapless googler who is not greping the source.

django.db.models.base.ModelBase

...

-- 
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: djapian not working with apach2

2010-06-21 Thread Skylar Saveland
I would guess that you are trying to access /index with the webserver
user but that is owned by another user and the user that owns the web
process has not the sufficient permissions to do the attempted
operation.  Set the permissions on the directory accordingly, perhaps
ownership as well.  You could just nuke the permissions with a chmod
777 /index (or so) if security is not crucial.  Otherwise you need to
give permissions to the dir to your webserver user in a less nukular
way.

You could also run the wsgi process(es) as the user of your choice
using perhaps 
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess
hope that helps.

On Jun 21, 10:03 am, watad  wrote:
> hi all,
>
> im using djapian for my search , it seems to work fine when i run it
> in django development server
> but when i configure my sites to use apach2 im always getting this
> error when i try to search :
>
> "Caught OSError while rendering: [Errno 13] Permission denied: '/
> index'"
> i am sure it is not a folder permission issue because when i run my
> sites using ./manage.py runserver   i get the results of my search.
>
> im using mod_wsgi
>
> my locasites.conf :
>
> # ---
>
> 
>     ServerName mysite.name
>     ServerAlias mysitealias
>
>     WSGIScriptAlias / "/path/to/my/apache/file.wsgi"
>     
>         Allow from all
>     
>
>     Alias /site_media/ "/path/to/mysite/media/"
>     
>         Order allow,deny
>         Options Indexes FollowSymLinks
>         Allow from all
>         IndexOptions FancyIndexing
>     
>
>     Alias /media/ "/usr/local/lib/python2.6/dist-packages/django/
> contrib/admin/media/"
>      admin/media/">
>         Order allow,deny
>         Options Indexes FollowSymLinks
>         Allow from all
>         IndexOptions FancyIndexing
>     
>
> 
>
>  this is repeated for all the sites.
>
> can anyone help with issue
> regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 with ManyToManyField on the other side

2010-06-21 Thread Skylar Saveland
class Material(models.Model):

products = ManyToManyField('Product', related_name='materials')

class Products(models.Model):

...

class ProductForm(forms.ModelForm):

class Meta:
model = Product
fields = ('materials', )

I want to do this.

I saw this discussion:

http://groups.google.com/group/django-users/browse_thread/thread/49213bf57a6a3033/cceb6912ad43fca0?show_docid=cceb6912ad43fca0=1

And, I tried this snippet:
http://djangosnippets.org/snippets/1295/

The related names of this snippet make no sense.  If they are made to
make sense, then there would be an accessor clash.  Without the class,
the accessors are redundant at best...

Has any progress been made on this convenience or is the recommended
course just to create a non-Model form and make a save method?

-- 
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: Localization and date format

2010-04-24 Thread Skylar Saveland
I presume that you mean date formatting in the templates:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date

you can use the strftime format bits iirc:

http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior

you can set the default with a setting

http://docs.djangoproject.com/en/dev/ref/settings/#date-format

The language code shouldn't mess with the l10n date formatting that
I'm aware of, not sure. ... I think that UK locale is  ... hrm ..

you should be able to take care of your dates with the above info
though .. hrm ..

On Apr 24, 9:41 am, pjmorse  wrote:
> Is there any way to force a particular localization on date
> formatting?
>
> Our site (Django 1.0.2, Python 2.5) was set up with "UK" as the
> language code for the U.K. This apparently didn't cause any problems
> for years, but now that the person who made that decision is out of
> arm's reach, it's been discovered that dates in the UK localization
> are being displayed in... wait for it... Ukranian.
>
> Swapping the language code to "en" (which would be correct) breaks
> most of the rest of the site for reasons I don't fully understand yet.
>
> Is there any way to either override the localization on date
> formatting, or provide a parameter with the correct language code?
>
> Thanks,
>
> pjm
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: SCORM(Sharable Content Object Reference Model) Compliant for Django?

2010-04-23 Thread Skylar Saveland
I was about to need to do something along these lines, so I used
inspectdb to look at Moodle.  I was going to connect django and moodle
to the same DB since moodle was going to be a certainty in the
position that I didn't end up taking:

http://github.com/skyl/django-moodle

This is a really basic, early, no momentum, old project.

http://bitbucket.org/nautilebleu/django-scorm-rest-rte/src might be
more interesting.

On Apr 22, 5:05 am, Zeal  wrote:
> Hi, All,
>
> Does anyone has the experience on SCORM(Sharable Content Object
> Reference Model) support with Django? I want to let my django
> application having SCORM support for learning management app.
> However, after researching on internet, there is no any post for such
> topic. I know that 'moodle' is a greate LMS project with SCORM
> support, however it is developed by PHP, not python. Your professional
> advice would be highly appreciated!
>
> Zeal
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Performing an action on model.save() but not on update

2010-04-23 Thread Skylar Saveland
Yeah, and I think my suggestion fails for a user-defined rather than
auto-incrementing pk.

On Apr 23, 4:21 pm, Nick Serra <nickse...@gmail.com> wrote:
> A post save signal seems better suited for this. The post save signal
> has an attribute 'created' that will be true or false depending on if
> the object is being created or updated. Check out the post_save
> documentation:http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.si...
>
> On Apr 23, 3:32 pm, Skylar Saveland <skylar.savel...@gmail.com> wrote:
>
>
>
>
>
> > On Apr 23, 3:27 pm, Jim N <jim.nach...@gmail.com> wrote:
>
> > > Hi,
>
> > > I have overridden the default save() on a model so that I can update
> > > some counts every time a save occurs.  Unfortunately, I don't want to
> > > perform these actions every time the model is updated, which seems to
> > > happen.
>
> > > Is there another approach I can take that distinguishes between save
> > > and update?
>
> > > class Answer(models.Model):
> > >     answer = models.TextField()
> > >     user = models.ForeignKey(User, null=True)
> > >     submit_date = models.DateTimeField('Date Submitted',
> > > default=datetime.datetime.now)
> > >     question = models.ForeignKey(Question)
> > >     permalink = models.CharField(max_length=300, blank=True)
>
> > >     def save(self, *args, **kwargs):
> > >         super(Answer, self).save(*args, **kwargs) # Call the "real"
> > > save() method.
> > >         if(self.user):
> > >             quser = self.user.get_profile()
> > >             quser.increment_answers()   # <-- I don't want to do this
> > > on an update.
> > >             self.question.increment_responses() # <-- I don't want to
> > > do this either.
>
> > > Or in more readable form:http://dpaste.de/I2IR/
>
> > Before you call super you can see if bool(self.pk) is True or False.
> > It will be False before the first save.
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Oracle cursor.execute problem

2010-04-23 Thread Skylar Saveland
Ah, I guess it's only %s and strings for execute?  At anyrate, the
third argument to connection.execute(self, query, parms=None), params,
is a list of strings, each member of the list should have a '%s'
placeholder in the query.  The string-formatting link is a not really
germane ..

On Apr 23, 4:32 pm, Skylar Saveland <skylar.savel...@gmail.com> wrote:
> Looking at the source for execute on django-trunk in
> django.db.backends.oracle
>
> If you have a param, you will have an arg for the query (type:
> string).
>
> http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-...
>
> ... your params should be a list of things to interpolate into the
> query string, yes?
>
> http://docs.python.org/library/stdtypes.html#string-formatting
>
> On Apr 23, 3:59 pm, Tim Sawyer <list.dja...@calidris.co.uk> wrote:
>
>
>
>
>
> > Hello.
>
> > This code works fine:
>
> >  >>> import cx_Oracle
> >  >>> lDsn = cx_Oracle.makedsn(lDatabaseHost, int(lDatabasePort),
> > lDatabaseName)
> >  >>> lConnectString = "%s/%...@%s" % (lDatabaseUsername,
> > lDatabasePassword, lDsn)
> >  >>> lConnection = cx_Oracle.connect(lConnectString)
> >  >>> cursor = lConnection.cursor()
> >  >>> lOutput = cursor.var(cx_Oracle.STRING)
> >  >>> cursor.execute("BEGIN :out := 'N'; END;", {'out' : lOutput})
> >  >>> print lOutput
> > 
> >  >>> print lOutput.getvalue()
> > N
>
> > However, if I change this to get the connection from Django, it all
> > falls in a big heap:
>
> >  >>> from django.db import connection
> >  >>> cursor = connection.cursor()
> >  >>> import cx_Oracle
> >  >>> lOutput = cursor.var(cx_Oracle.STRIN
> >  >>> cursor.execute("BEGIN :out := 'N'; END;", {'out' : lOutput})
> > Traceback (most recent call last):
> >    File "", line 1, in 
> >    File "/dev/HEAD/INTERNAL/websites/Wam3\django\db\backends\util.py",
> > line 19, in execute
> >      return self.cursor.execute(sql, params)
> >    File "/web/djangocourse\django\db\backends\oracle\base.py", line 435,
> > in execute
> >      query = convert_unicode(query % tuple(args), self.charset)
> > TypeError: not all arguments converted during string formatting
>
> > Can anyone point me in the direction of how I can fix this?
>
> > Cheers,
>
> > Tim.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Oracle cursor.execute problem

2010-04-23 Thread Skylar Saveland
Looking at the source for execute on django-trunk in
django.db.backends.oracle

If you have a param, you will have an arg for the query (type:
string).

http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly

... your params should be a list of things to interpolate into the
query string, yes?

http://docs.python.org/library/stdtypes.html#string-formatting

On Apr 23, 3:59 pm, Tim Sawyer  wrote:
> Hello.
>
> This code works fine:
>
>  >>> import cx_Oracle
>  >>> lDsn = cx_Oracle.makedsn(lDatabaseHost, int(lDatabasePort),
> lDatabaseName)
>  >>> lConnectString = "%s/%...@%s" % (lDatabaseUsername,
> lDatabasePassword, lDsn)
>  >>> lConnection = cx_Oracle.connect(lConnectString)
>  >>> cursor = lConnection.cursor()
>  >>> lOutput = cursor.var(cx_Oracle.STRING)
>  >>> cursor.execute("BEGIN :out := 'N'; END;", {'out' : lOutput})
>  >>> print lOutput
> 
>  >>> print lOutput.getvalue()
> N
>
> However, if I change this to get the connection from Django, it all
> falls in a big heap:
>
>  >>> from django.db import connection
>  >>> cursor = connection.cursor()
>  >>> import cx_Oracle
>  >>> lOutput = cursor.var(cx_Oracle.STRIN
>  >>> cursor.execute("BEGIN :out := 'N'; END;", {'out' : lOutput})
> Traceback (most recent call last):
>    File "", line 1, in 
>    File "/dev/HEAD/INTERNAL/websites/Wam3\django\db\backends\util.py",
> line 19, in execute
>      return self.cursor.execute(sql, params)
>    File "/web/djangocourse\django\db\backends\oracle\base.py", line 435,
> in execute
>      query = convert_unicode(query % tuple(args), self.charset)
> TypeError: not all arguments converted during string formatting
>
> Can anyone point me in the direction of how I can fix this?
>
> Cheers,
>
> Tim.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: auto generate "dummy" content (e.g. Lorem ipsum generator for Django)

2010-04-23 Thread Skylar Saveland
http://docs.djangoproject.com/en/dev/ref/contrib/webdesign/#ref-contrib-webdesign

On Apr 23, 3:41 pm, Brad Buran  wrote:
> Is there any easy way of generating dummy content for models in Django?  As
> I'm learning how to use Django, I often find myself deleting the sqlite
> database and running syncdb each time (rather than dealing with the issues
> of manual schema migration each time I make a change to my models).  As part
> of this, I'd like to regenerate some dummy content so I can test the various
> views and templates quickly.  It seems pretty straightforward: the
> model.*Fields can give the necessary clues as to the content that can be
> generated.  Before I start writing this, I thought I'd check to see if
> anyone has done something similar.  I tried searching for a similar app, but
> couldn't find anything.
>
> Brad
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Autocomplete with two tables

2010-04-23 Thread Skylar Saveland
http://docs.djangoproject.com/en/dev/topics/db/queries/


On Apr 23, 11:11 am, Pep  wrote:
> Hi everybody !
>
> I have two tables on my database : one for the products (named
> Product) and one for my clients (name Client).
> In Client, there is a row named 'products' where I put all the client
> products with a list and a dictionnary.
> For exemple :  list = ["prod1": {"name"="product1", "price"=2},
> "prod2":{"name"="product2", "price"=3}]
>
> I want to autocomplete a field with Jquery with the table Product.
> So I wrote (ok ! copy :p) this function :
>
> def lookup_product(request, name):
>     # Default return list
>     results = []
>     if request.method == "GET":
>         if request.GET.has_key(u'query'):
>             value = request.GET[u'query']
>             # Ignore queries shorter than length 3
>             if len(value) > 2:
>                 model_results =
> Product.objects.filter(name__icontains=value)
>                 results = [ x.name for x in model_results ]
>     json = simplejson.dumps(results)
>     return HttpResponse(json, mimetype='application/json')
>
> However, I want to filter the table Product with all the client
> products.
>
> Does anybody have an idea to do it ?
> I thought on something like that : add in filter "name is present on
> list" where list is the client products list. What's your opinion ?
>
> Thanks
>
> PEP
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Filtering for an object that is modified in memory loses those modifications?

2010-04-23 Thread Skylar Saveland
Yes.  The filter method returns a queryset which is a lazy database
object that will query the database to get the queryset.  You would
have to save the object for the queryset to return it.  You could
however get all of the objects which are not your select objects

 
MyModel.objects.exclude(pk__in=iterable_of_in_memory_pks_not_to_be_returned)

On Apr 23, 3:15 pm, Margie Roginski  wrote:
> I have a situation where I have a handle to a db object and I've
> modified a field in it.  Then I later end up executing a filter that
> finds that same object (among others) and saves all of the objects it
> finds.  In this situation the modified fields do not get saved out.
> It's like the filter is getting the object directly from the database,
> as opposed to getting the object that is in memory and modified (but
> not yet saved).
>
> Is this the expected behavior?
>
> Margie
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Performing an action on model.save() but not on update

2010-04-23 Thread Skylar Saveland


On Apr 23, 3:27 pm, Jim N  wrote:
> Hi,
>
> I have overridden the default save() on a model so that I can update
> some counts every time a save occurs.  Unfortunately, I don't want to
> perform these actions every time the model is updated, which seems to
> happen.
>
> Is there another approach I can take that distinguishes between save
> and update?
>
> class Answer(models.Model):
>     answer = models.TextField()
>     user = models.ForeignKey(User, null=True)
>     submit_date = models.DateTimeField('Date Submitted',
> default=datetime.datetime.now)
>     question = models.ForeignKey(Question)
>     permalink = models.CharField(max_length=300, blank=True)
>
>     def save(self, *args, **kwargs):
>         super(Answer, self).save(*args, **kwargs) # Call the "real"
> save() method.
>         if(self.user):
>             quser = self.user.get_profile()
>             quser.increment_answers()   # <-- I don't want to do this
> on an update.
>             self.question.increment_responses() # <-- I don't want to
> do this either.
>
> Or in more readable form:http://dpaste.de/I2IR/
>

Before you call super you can see if bool(self.pk) is True or False.
It will be False before the first save.

-- 
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: Django IDE

2010-02-14 Thread Skylar Saveland
This might be the wrong way to help you if you want something super-
gui-fabulous.  But, I have a dusty old project that is not gaining any
traction to make a nice IDE out of vim.  If you don't know/like vim
and have no desire to learn then I might just be wasting your time.

http://github.com/skyl/vim-config-python-ide

I use something pretty close to the supertab branch myself.  vim
config is kind of a personal thing though.  So is an IDE.  There  are
lots of answers on stack overflow that will tell you eclipse with
pydev.  Many people use textmate, emacs and even some prominent people
are using gedit?

To go farther than just an editor, I just use the gnu-linux command
line with git/hg and ipython for debugging and bpython as the shell.
I like small tools that do one thing well.

On Feb 14, 11:59 pm, dj_vishal <2009vis...@gmail.com> wrote:
> Hello
>
>    Hi to all am new to the Django Framework.am learning django
>    Which IDE is suitable for Django ..plz help me in right way
>
>    Thanks in Advance
>    vishal
>    2009vis...@gmail.com
> --
> View this message in 
> context:http://old.nabble.com/Django-IDE-tp27589650p27589650.html
> Sent from the django-users mailing list archive at Nabble.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-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: looping over dictionaries

2010-02-14 Thread Skylar Saveland
{% for k, v in d.items %}
{{k}} {{v}}
{% endfor %}

On Feb 14, 1:58 pm, Madis  wrote:
> Why will this not work or how should i write it to work:
>
> I have the following dictionary:
> projects = {u'NetMinutes': {'chains': [u'Arendus', u'Uuslahendus']},
> u'Veel': {'chains': []}}
>
> Now in a template I want to iterate over them as follows:
> {% for project in projects %}
> {{ project }}
>   {% for chain in project.chains %}
>   -- {{ chain }}
>   {% endfor %}
> {% endfor %}
>
> It iterates over the projects and prints out the project names but
> will not iterate over the project.chains.
> Maybe someone can give me some clues?
>
> Regards,
> Madis

-- 
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: Need help testing views with csrf in 1.1.1

2010-01-08 Thread Skylar Saveland
In case anyone else runs across this, the answer appears to be:
disable csrf protection while testing.

On Jan 8, 7:04 pm, Skylar Saveland <skylar.savel...@gmail.com> wrote:
> I wondering what I'm doing wrong here.  These views work as expected
> with a browser.  I was looking to improve my test coverage.
>
> >>> c = Client()
> >>> get_response = c.get( reverse('create', kwargs={'typ':'residential'}) )
> >>> get_response.status_code
> 200
> >>> post_response = c.post( reverse('create', kwargs={'typ':'residential'}), {
>
> ...             'username':'@14.com', 'username2':'@14.com',
> 'password1':'1',
> ...             'password2':'1', 'last':'Saveland', 'first':'Skylar',
> ...             'evening_phone': '706-338-4901', 'day_phone':
> '706-338-4901',
> ...             'secret_question': '1', 'answer': '1',
> 'receive_email': '2',
> ...             'x': '0', 'y': '0','tos': 'on',})>>> 
> post_response.status_code                          # this post works fine, 
> redirects, all intended side-effects are there.
> 302
> >>> response = c.get( reverse('select_type', kwargs={'typ':'residential'}) )
> >>> response.status_code
> 200
> >>> c.cookies
>
> >>> response = 
> c.post( reverse('select_type', kwargs={'typ':'residential'}), 
> {'residential_type':'1r'})
> >>> response.content
>
> 'http://www.w3.org/1999/xhtml;
> xml:lang="en">403 ForbiddenCross Site Request
> Forgery detected. Request aborted
> .'
>
>
>
> Any ideas why this second POST would fail?  The Client instance does
> get logged in with the first post and the db is hit and everything.
> The first post seems to be doing everything right.  The second post, I
> can only get 403 no matter what I try, it seems.  On the other hand, I
> get good responses and a redirect with a good post from web browsers
> on this 'select_type' view.
-- 
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.




Need help testing views with csrf in 1.1.1

2010-01-08 Thread Skylar Saveland
I wondering what I'm doing wrong here.  These views work as expected
with a browser.  I was looking to improve my test coverage.

>>> c = Client()
>>> get_response = c.get( reverse('create', kwargs={'typ':'residential'}) )
>>> get_response.status_code
200
>>> post_response = c.post( reverse('create', kwargs={'typ':'residential'}), {
... 'username':'1...@14.com', 'username2':'1...@14.com',
'password1':'1',
... 'password2':'1', 'last':'Saveland', 'first':'Skylar',
... 'evening_phone': '706-338-4901', 'day_phone':
'706-338-4901',
... 'secret_question': '1', 'answer': '1',
'receive_email': '2',
... 'x': '0', 'y': '0','tos': 'on',})
>>> post_response.status_code  # this post works fine, 
>>> redirects, all intended side-effects are there.
302
>>> response = c.get( reverse('select_type', kwargs={'typ':'residential'}) )
>>> response.status_code
200
>>> c.cookies

>>> response = c.post( reverse('select_type', kwargs={'typ':'residential'}), 
>>> {'residential_type':'1r'})
>>> response.content
'http://www.w3.org/1999/xhtml;
xml:lang="en">403 ForbiddenCross Site Request
Forgery detected. Request aborted
.'
>>>


Any ideas why this second POST would fail?  The Client instance does
get logged in with the first post and the db is hit and everything.
The first post seems to be doing everything right.  The second post, I
can only get 403 no matter what I try, it seems.  On the other hand, I
get good responses and a redirect with a good post from web browsers
on this 'select_type' view.
-- 
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: django-registration terms of service link

2009-12-04 Thread Skylar Saveland
help_text is safe by default?  Might be of some use.

aa56280 wrote:
> The "safe" filter works on a string, not the entire form. So you'll
> have to apply it to the label of the field:
>
> {{ form.tos.label|safe }}
>
> Hope that helps.
>
>
>
> On Dec 4, 11:55 am, Viktor  wrote:
> > ahoj,
> >
> > I wrote a simple backend that extends RegistrationFormTermsOfService
> > of django-restration as I would like to add links into the text
> > stating that the user accepts the terms of service.
> >
> > But when I pass it to the template, the link's text is always escaped.
> > I've tried to add a template filter, but it didn't help.
> >
> > here is the code
> >
> > class RegistrationFormTermsOfService(RegistrationForm):
> >     tos = forms.BooleanField(widget=forms.CheckboxInput
> > (attrs=attrs_dict),
> >                              label=_(u'I have read and agree to the  > href="%s">Terms of Service') % settings.TERMS_OF_SERVICE_URL,
> >                              error_messages={ 'required': _("You must
> > agree to the terms to register") })
> >
> > and I've tried to write this out with:
> > {{ form|safe }}
> >
> > but I still ended up with:
> > I have read and agree to the Terms of Service:
> >
> > could someone give me an idea how to solve this problem?
> >
> > thx, Viktor

--

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: ModelForm save() cleans data first?

2009-12-01 Thread Skylar Saveland
Wait, this is a better question than I thought on first glance.  Not
entirely sure, sorry for the terse first response.

Skylar Saveland wrote:
> Former
>
> Continuation wrote:
> > When a ModelForm object calls save(), does it first clean the form
> > data using form.cleaned_data? Or do I need to call form.cleaned_data
> > explicitly?

--

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: ModelForm save() cleans data first?

2009-12-01 Thread Skylar Saveland
Former

Continuation wrote:
> When a ModelForm object calls save(), does it first clean the form
> data using form.cleaned_data? Or do I need to call form.cleaned_data
> explicitly?

--

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: cannot import name settings - accessing Django environment from external script

2009-12-01 Thread Skylar Saveland
I thought that it was best practice to not put python code in /var/www
and to own the code with an unprivileged user.  Doesn't seem like it
is necessarily germane to the present topic but perhaps something to
think about.

Am I wrong? Are there exceptions?  I think I have seen some high
profile websites running application code under /var/www



Stodge wrote:
> This:
>
>   sys.path.append("/var/www/sites/indigo/")
>   os.environ['DJANGO_SETTINGS_MODULE'] = 'indigo.settings'
>   from django.core.management import setup_environ
>   import settings
>   project_directory = setup_environ(settings)
>   from indigo.project.ticket.models import Ticket
>
> Gives me "ImportError: No module named project.ticket.models". Hmmm.
> So it can import the settings before calling setup_environ but the
> environment isn't unusable afterwards.
>
>
> On Dec 1, 12:51 pm, Stodge  wrote:
> > Argh! Taking this a step further - I'm now trying to access my Django
> > environment from within a Trac (http://trac.edgewall.org) plugin, but
> > I'm getting a similar issue.
> >
> > This works:
> >
> >                 sys.path.append("/var/www/sites/indigo/")
> >                 os.environ['DJANGO_SETTINGS_MODULE'] = 'indigo.settings'
> >                 from django.core.management import setup_environ
> >                 import settings
> >                 project_directory = setup_environ(settings)
> >
> > But this:
> >
> >                 sys.path.append("/var/www/sites/indigo/")
> >                 os.environ['DJANGO_SETTINGS_MODULE'] = 'indigo.settings'
> >                 from django.core.management import setup_environ
> >                 import settings
> >                 project_directory = setup_environ(settings)
> >                 from django.contrib.auth.models import User
> >
> > Gives "ImportError: Could not import settings 'indigo.settings' (Is it
> > on sys.path? Does it have syntax errors?): No module named settings"
> >
> > It's the exact same code that works in my Mercurial plugin. Any ideas?
> > 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-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: django not finding modules on pythonpath

2009-12-01 Thread Skylar Saveland
Are you using python-path arg to WDP?  Also, you might do some
sys.path hacking in the .wsgi script.

neridaj wrote:
> Hello,
>
> I'm trying to deploy my project to my server and I don't understand
> why django isn't finding modules I've added to my pythonpath. When I
> try to access my site I get 500 errors and after looking at the server
> log I see a traceback with this:
>
> [error] [client 174.xxx.xxx.xxx] ImportError: No module named blog
>
> However, when I run python I am able to import the modules. I'm using
> nginx as a proxy to apache2/mod_wsgi on Ubuntu 9.04.
>
> Thanks,
>
> J

--

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: django url and reverse

2009-11-29 Thread Skylar Saveland
You simply can't call request.user.get_profile() on an anonymous user.

caliman wrote:
> Hi!
>
> In my project most of my views requires the user to be logged in but
> in some i don't for example the login view wich only displays a login
> form. When I'm going to the login form as a non logged in user I get
> an error:
> "Error was: 'AnonymousUser' object has no attribute 'get_profile'" The
> error is thrown when I use django reverse or url (from template). It
> seems as when it checks for urls in my urls.py it parses not only that
> file to get the url it also tries to execute all views. Thats why I
> got the error when it executes a view that requires login and therefor
> uses my user.get_profile().
>
> Anyone know how to solve this? I do wnat to use url and reverse even
> for pages that doesn't require the user to be logged in.
>
> Stefan

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Error when generating PDF

2009-11-26 Thread Skylar Saveland
>    Paragraph(rack.nick, normalstyle, bulletText=None),

Yep, rack.nick is None here it would seem.  Like Karen said, don't
have nullable CharField if you can help it;  blank=True is good and
then and empty will be "".  I have a dirty hack for you that should
'work'.

Paragraph(  rack.nick if rack.nick else "", normalstyle,
bulletText=None )

but avoid using null, 
http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.null
for a CharField if that's what led to 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: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-26 Thread Skylar Saveland

>
> I'm reading a string value that is stored in my database. This string
> the main content of my webpage and it contains contents like
> javascript, css styling, and django template tags/filters.
>
> After I load string value by {{ stringValue|safe }} filter, everything
> is added to the page just as text; Javascript, css styling, template
> tags/filters all show up on the page.
>
> Can anyone tell me how I can load the content and execute/render the
> javascript, css styling, template tags/filters?

+1 for this sounding pretty weird.  But you might do the rendering and
manipulation in the view before rendering it to the template and get
what you want.

http://docs.djangoproject.com/en/dev/ref/templates/api/#compiling-a-string

Also, the little autoescape filter might help you prevent Django from
preventing you from blasting your foot off ;).
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#autoescape

bon voyage!

--

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: Show field labels instead of names in form error lists

2009-11-26 Thread Skylar Saveland

On Nov 27, 1:27 am, Yang Zhang  wrote:
> What's the easiest way to have error lists describe fields using their
> labels instead of their names? Thanks in advance.

I don't think that I understand your question.  Is there something to
it that isn't covered in 
http://docs.djangoproject.com/en/dev/topics/forms/#customizing-the-form-template
?

--

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 for "regular" users - still a bad idea?

2009-11-26 Thread Skylar Saveland
> each user has their own table in the
> db for transactions, and they can do whatever they want to their own
> data. i wouldn't want them to be able to touch anyone else's tables,
> but it seems like django has a permissions system to restrict that.

ha, reading lists on mobile ... I didn't even see that you said that
each user has their own table (still hard to see exactly how this is
efficient/possible/done though).  I think it's still a bad idea.
Don't let untrusted users log into the admin is a general rule that
I've seen tossed around.

--

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 for "regular" users - still a bad idea?

2009-11-26 Thread Skylar Saveland
> I don't
> believe you can do inline formsets with generic views, which is
> unfortunate, but it's not hard with a simple custom view.

well, perhaps not automagically, but you can just send extra_context
and then do a little bit of custom work ``if request.method == POST``.

--

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 for "regular" users - still a bad idea?

2009-11-26 Thread Skylar Saveland
Yep, still a bad idea.  Permissions are by table not by row.  Use
generic views for basic CRUD.

Count László de Almásy wrote:
> i've seen notes in some django documentation that implies that using /
> admin/ for non-trusted users is not a good idea. which is unfortunate
> since it seems like the admin interface is about 95% of what i want
> for my users to be able to view and manipulate their sales
> transactions data over the web. each user has their own table in the
> db for transactions, and they can do whatever they want to their own
> data. i wouldn't want them to be able to touch anyone else's tables,
> but it seems like django has a permissions system to restrict that.
>
> with the latest django, is it still considered a bad idea to do this?
> if so, what is the alternative, writing custom views to mimic what the
> admin interface does?

--

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: How can I change the values of select options created by a ModelForm?

2009-11-26 Thread Skylar Saveland
You're primary question is a little tough, ther are a couple of ways
to go.  I just wanted to mention that your slug might not be unique
the way you have it and you could get IntegrityError.  Also, your
get_absolute_url would be better served with permalink.  Your primary
question, well, I'm just arriving at thanksgiving dinner 


jul wrote:
> hi,
>
> I'm generating, using ModelForm, a form from a Restaurant model, which
> has a Country field.
> Country has a 'code' and a 'name' fields.
> When the form is created in my template, the values of the select
> options are the Country ids. How can I replace them by the Country
> 'code' values. Is it possible to choose which field is used as the
> value by overriding the Country field in the ModelForm?
>
> thanks
>
>
> I have that:
>
> Country:  id="id_country">
> -
> Andorra
> United Arab Emirates
> Afghanistan
>
> and I want that:
>
> Country:  id="id_country">
> -
> Andorra
> United Arab Emirates
> Afghanistan
>
>
> Models and ModelForm:
>
> class Country(models.Model):
> code = models.CharField(max_length=5, unique=True)
> name = models.CharField(max_length=100, unique=True)
>
> class Meta:
> verbose_name_plural = 'Countries'
>
> def __unicode__(self):
> return self.name
>
>
>
> class Restaurant(models.Model):
>
> name = models.CharField(max_length=100)
> country=models.ForeignKey(Country)
> city=models.ForeignKey(City)
> street=models.CharField(max_length=100)
> street_number=models.PositiveSmallIntegerField()
> phone_number=models.CharField(max_length=16, blank=True,
> null=True)
> price_range=models.PositiveSmallIntegerField(blank=True,
> null=True)
> category=models.ManyToManyField(Category, blank=True,
> null=True)
> tag=models.ManyToManyField(Tag, blank=True, null=True)
> slug = models.SlugField(unique=True)
>
> def get_absolute_url(self):
> return "/restaurant/%s/" % self.slug
>
> def __unicode__(self):
> return self.name
>
> def save(self):
> self.slug = slugify(self.name)
> super(Restaurant, self).save()
>
>
> class AddRestaurantForm(ModelForm):
>
> class Meta:
> model = Restaurant
> exclude = ('slug')

--

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: Chart tool

2009-11-26 Thread Skylar Saveland
You might also check out pycha?


S.Selvam wrote:
> On Thu, Nov 26, 2009 at 2:01 AM, Javier Guerra  wrote:
>
> > On Wed, Nov 25, 2009 at 3:07 PM, S.Selvam  wrote:
> > > I need to show some data as a chart.
> > >
> > > I would like to achieve a high quality rendering.
> > >
> > > Is reportlab or matplotlib enough ?
> >
> > reportlab allows you to generate PDFs, which can be as high quality as
> > you want; but if you want to display them on a webpage it's far from
> > the best.
> >
> > matplotlib is nice, being python.  the biggest drawback is that being
> > a server-side task, so you have to deal with the processing time
> > and/or storage/deletion of (old) images.
> >
> > for in-page charts, you can use flot (http://code.google.com/p/flot/),
> > or Google Charts (http://code.google.com/apis/chart/).  the first one
> > is a jQuery plugin, the other is an API that basically lets you
> > construct an URL for a PNG that's rendered on Google servers.  in both
> > cases, you simply put (some of) your data on the page and let either
> > the client (if using flot) or somebody else (if using Google charts)
> > deal with the heavy tasks.
> >
>
>
> Thanks Javier,
>It helped me a lot.
>
>   I have been trying with matplotlib by drawing the resultant chart to
> canvas and attaching it with response.(Hence i dont save the image as a temp
> file ).
>
>
>
> >
> > --
> > Javier
> >
> > --
> >
> > 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.
> >
> >
> >
>
>
> --
> Yours,
> S.Selvam

--

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: Addree Book Contact Importer in django/python

2009-11-18 Thread Skylar Saveland

>   I need to import contacts of given email id/pwd from gmail,yahoo,hotmail
> for django app. Please suggest?

yaho:
http://developer.yahoo.com/auth/
http://www.amaltas.org/show/using-yahoo-bbauth-with-django.html

goog:
http://code.google.com/p/gdata-python-client/

Not sure about hotmail.

--

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




Re: Redirect problems

2009-11-18 Thread Skylar Saveland
What are the details of the error?

On Nov 18, 7:06 am, Zeynel  wrote:
> I've been trying to redirect
>
> /admin/ to /admin/wkw1/lawyer
>
> The suggestions from my previous 
> posthttp://groups.google.com/group/django-users/msg/67c4594a4083bd45
> did not work.
>
> I read the redirect section in the documents as suggested
>
> http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-...
>
> and tried this urls.py
>
> from django.conf.urls.defaults import *
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>     (r'^wkw1/$', 'sw1.wkw1.views.index'),
> #    (r'^admin/', include(admin.site.urls)),
> )
>
> urlpatterns += patterns('django.views.generic.simple',
>    ('^admin/$', 'redirect_to', {'url': '/admin/wkw1/lawyer/'}),
>    )
>
> but this too results in a server error.
>
> Any suggestions?
>
> 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-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=.




Re: ModelForm and fieldsets

2009-11-18 Thread Skylar Saveland
> that was my mistake - had an error in the template - it wors no.
> But according to this, I've another problem - fields which are foreign
> keys don't get rendered.

Typos?  Wrong names?  Maybe try to define the fields explicitly with
the widgets and choices that you want (but then the save method may be
wrong if you are not appropriately matching the model fields but
rather adding fields ...).

--

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




Re: bulk product import to satchmo

2009-11-18 Thread Skylar Saveland
My buddy did a talk on generically importing data from excel for
pyatl.

http://www.mefeedia.com/watch/25167971

You can check out some code here:

http://code.google.com/p/django-batchimport/

Not sure how it will do with this satchmo business.

> there is no script for parsing.  I'm importing CSV files right into
> the database through the import function in myphpadmin.  I've
> populated the following tables:

E :P

Well, I don't know anything about php but perhaps this method does not
create the autoincrementing PK? - do these rows have ids?

Sounds like trouble generally

> > I've posted this on the satchmo group but i'm not getting any love so
> > I wanted to post it here to see if anyone has done what i'm trying to
> > do.  My client has about 3500 products in an excel spreadsheet and i'm
> > trying to at least import as much product data as possible so that he
> > doesn't have to hand type all of this stuff again.  I've got the
> > product_product table populated but there are no products listed on
> > the product listing page in the admin so he can edit the items.  This
> > leads me to believe that there are other tables which need to be
> > populated in order for the items to show up on the listing page.  Has

mrrr, i think that if a change-list is dependent on another table you
would at least get a traceback.

> > anyone ever done bulk importing from csv successfully?  

Yes :)

--

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




Re: ModelForm and fieldsets

2009-11-18 Thread Skylar Saveland
If you haven't already, you could instantiate one in the shell and
render/inspec it there.  You will at least be able to see what might
be a problem with your class/python-code vs what might be wrong at the
template level.

On Nov 18, 9:27 am, Benjamin Wolf  wrote:
> Hi there,
>
> I'm using a ModelForm and had the wish to use fieldsets.
> After a short search I've found 
> this:http://pypi.python.org/pypi/django-form-utils/0.1.5
> Seems to be what I want. So I've installed it and changed my form from
> ModelForm to BetterModelForm.
>
> It works so far, but when I try to create a fieldset, it gets ignored /
> not rendered.
> Here's my form definition:
>
> class ContactForm(BetterModelForm):
>     class Meta:
>         model = Disposal
>         fieldsets = ('main', {'fields': ('customer_name',), 'legend':
> 'Customer Data'}),
>
> Thanks for your help,
> greets ben

--

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




Re: How to handle this race condition?

2009-11-10 Thread Skylar Saveland

Why store it in the database?  You might be able to avoid this
directly if you use a model method for this attribute.


Continuation wrote:
> I'm working on an auction app.
>
> In an Auction object I store the current_high_bid for that auction.
>
> When a new_bid comes in, I:
> 1) retrieve the current_high_bid field of the Auction object
> 2) compare it with the new_bid
> 3) if the new bid is higher than current_high_bid, I update
> current_high_bid to the value of the new_bid.
>
> but there's a (slight) chance that between steps (1) and (3) a
> different user could've submitted an even higher bid which then become
> the current_high_bid. In that case step 3 should not proceed. What can
> I do to make sure such a situation does not arise?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Interview Questions

2009-11-02 Thread Skylar Saveland

Doesn't work on my mobile browser.

Dimitri Gnidash wrote:
> Hey guys,
>
> For all those of you interviewing or being interviewed, I created a
> quick list of sample interview questions.
> While not comprehensive, it is a good start to review these before the
> interview, if anything, to gain a perspective on how other people
> might be using Django.
>
>
> http://blog.lightsonsoftware.com/django-interview-questions-0
>
>
> Dimitri Gnidash
> www.lightsonsoftware.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: Migrating a Wordpress website to Django

2009-11-02 Thread Skylar Saveland

inspectdb might be of some interest

John K wrote:
> Hello all,
>
> We are auditing several web frameworks and will ultimately choose one
> that will replace Wordpress (Wordpress hosted on our servers). So far,
> Django fits the bill.
>
> Has anyone had any experience migrating a Wordpress site to a Django
> solution? If so, it would be great to hear how your experience went,
> and any tips that may help the migration go smoothly.
>
> Our 2 big tickets are content migration and user migration.
>
> • We currently have tens of thousands of articles and thousands of
> user accounts. Are there any automated tools for importing Wordpress
> data into Django? What content migration strategy did you use?
>
> • Any issues with porting pre-existing URLs into Django? How did you
> handle URL routing? (old Wordpress URLs into Django)?
>
> • Were there any problems or pitfalls during your migration that were
> not immediately apparent in the beginning of the migration process?
>
> Thanks in advance
> John
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: syncdb for INSTALLED_APPS throws errors

2009-10-29 Thread Skylar Saveland

If you are not in a virtualenv with -no-site-packages then you should
be able to just:

sudo aptitude install python-mysqldb



sridharpandu wrote:
> Thanks. That was quick. I use Ubuntu 9.04 (jaunty). I am unable to
> figure out the location of MySQLdb. A "WHEREIS MySQLdb" at the command
> prompt returned MySQLdb:
>
> Is there a way to figure out
>
> Best regards
>
> Sridhar
>
> On Oct 29, 12:07 pm, Kenneth Gonsalves  wrote:
> > On Thursday 29 Oct 2009 12:17:56 pm sridharpandu wrote:
> >
> > >  raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> > > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> > > module: No module named MySQLdb
> >
> > you need MysSQLdb to connect to the database, either it is not installed or 
> > it
> > is not on the path.
> > --
> > regards
> > Kenneth Gonsalves
> > Senior Project Officer
> > NRC-FOSShttp://nrcfosshelpline.in/web/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: mptt get_ancestor method breaks based on data?

2009-09-18 Thread Skylar Saveland

Well, after further review it looks like changing the data and running
syncdb with initial_data is probably the culprit.. makes sense?

On Sep 18, 1:28 pm, Skylar Saveland <skylar.savel...@gmail.com> wrote:
> I have a model on which django-mptt works with the simple test data.
> However, when I load the production data (where I have seen that
> get_ancestor is not working) to my dev machine, get_ancestor returns
> [].
>
> In [5]: for p in Page.objects.filter(parent__isnull=False):
>    ...:     print p, p.get_ancestors()
>    ...:
>    ...:
> ...
> |__categories []
> ..
> |__preparation-tips []
> ...
>
> These models have a parent but get_ancestors() returns []
>
> Does anyone have a clue why the data would break this method?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mptt get_ancestor method breaks based on data?

2009-09-18 Thread Skylar Saveland

I have a model on which django-mptt works with the simple test data.
However, when I load the production data (where I have seen that
get_ancestor is not working) to my dev machine, get_ancestor returns
[].

In [5]: for p in Page.objects.filter(parent__isnull=False):
   ...: print p, p.get_ancestors()
   ...:
   ...:
...
|__categories []
..
|__preparation-tips []
...

These models have a parent but get_ancestors() returns []

Does anyone have a clue why the data would break this method?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: serving a static file via nginx requiring authentication from django

2009-07-01 Thread Skylar Saveland

You could document this experience once you get it running; sounds
useful.

On Jun 30, 1:00 am, John Hensley  wrote:
> On 6/28/09 10:20 PM, Annie wrote:
>
> > I'm trying to this to work: users can download their files from their
> > account page from a url like 
> > this:http://example.com/account/download/a1234565789asedga-2/
> > for which django processes the authentication and then passes along
> > the info to nginx to serve the file.
>
> [...]
>
>
>
> > Here are the relevant bits of code:
>
> > # part of the views.py
>
> > def download_file(request, dlkey=None, ftype=None):
> >      if request.user.is_authenticated():
> >          try:
> >              k = Ebook.objects.select_related().filter
> > (ftype__exact=ftype).filter
> > (book__orderdetail__dlkey__exact=dlkey).filter
> > (book__orderdetail__medium__exact='E')[:1]
> >              for e in k:
> >                  ebook = e.ebook
> >                  filename = os.path.join(PROTECTED_DIR, os.path.basename
> > (ebook))
> >                  response = HttpResponse()
> >                  response['X-Accel-Redirect'] = ebook
> >                  response['Content-Disposition'] =
> > "attachment;filename=" + ebook
> >                  return response
> >          except Exception:
> >              raise Http404
>
> > # part of the nginx configuration for the domain:
>
> >                  location ^~ /account/download/ {
> >                          include         /etc/nginx/
> > fastcgi_params_django;
> >                          fastcgi_pass    127.0.0.1:1024;
> >                          alias           /home/me/web/example.com/
> > public/media/books/;
> >                  }
>
> >                  location ^~ /media/books/ {
> >                          root            /home/me/web/example.com/
> > public;
> >                          internal;
> >                  }
>
> [...]
>
> > [1]http://wiki.nginx.org/NginxXSendfile
>
> I think the answer's in that document, actually. The value of
> X-Accel-Redirect should be your internal location's URL
> ('/media/books/') plus your filename (os.path.basename(ebook), in your
> view). Nginx will deliver
> /home/me/web/example.com/public/media/books/ebook-basename.pdf.
>
> John
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



orbited tutorial .. wsgi instead of mod_python shouldn't matter?

2009-06-29 Thread Skylar Saveland

http://darkporter.com/?p=7
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Need help

2009-05-31 Thread Skylar Saveland

sky...@abc255:/$ sudo updatedb
[sudo] password for skylar:
sky...@abc255:/$ locate pg_hba.conf
/etc/postgresql/8.3/main/pg_hba.conf
sky...@abc255:/$ sudo vim /etc/postgresql/8.3/main/pg_hba.conf

There should be some lines something like this (for local access):
local   all postgres  ident sameuser
local   all skylarident sameuser
local   geoDjango   geoUser   md5
local   geoPinaxgeoUser   md5
local   yourDB  yourUser  md5

I rather like these instructions:
http://www.punteney.com/writes/setting-django-slicehost-ubuntu-hardy-postgres-apa/

On May 31, 4:47 am, mizan rahman  wrote:
> No, i've checked that i've created a user named "djangouser" and the
> problem still exist what will i do? Plz help me
>
> Regards,
> Mizan
>
> On 5/29/09, Tim Chase  wrote:
>
>
>
> >>   File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
> >> postgresql_psycopg2/base.py", line 84, in _cursor
> >>     self.connection = Database.connect(conn_string, **self.options)
> >> psycopg2.OperationalError: FATAL:  Ident authentication failed for
> >> user "djangouser"
>
> > Sounds like your postgres database doesn't have a user named
> > "djangouser", or if so, you put the wrong password in the
> > settings.py file
>
> > -tkc
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 wrong with this code?

2009-05-31 Thread Skylar Saveland

It looks pretty good to me.  Are you trying this in a shell?  If not
that might help you debug.  You are missing a ')' at the end of

>>>reader = csv.reader(open("mysite\restaurants.csv")

that is probably actually your problem ;-).  I was experiencing some
strange behavior as I was playing with the csv module just now though
but it worked for me with a little test file I made:

>>> reader = csv.reader(open("rest.csv"))

In [32]: for r in reader:
   : for i in range(7):
   : string += r[i]
   :
   :

In [33]: string
Out[33]:
'nameaddressphonetypedistancedeliveryalcoholname1123bronx123-1234goodfaryesnoname2123jimmy321-4321friedclosenoyes'

On May 31, 4:56 am, andrew_dunn  wrote:
> I'm trying to run a script to import data to my model. All the field
> names are correct. What I'm getting is an error message that says my
> syntax is incorrect on the line that says "for row in reader:" It says
> the error is on the colon. If I remove the colon, it gives a syntax
> error on the last "e" on "restaurant_name = row[0]" Here's the code:
>
> import sys
> from django.core.management import setup_environ
> sys.path.append('C:\django')
> from mysite import settings
> setup_environ(settings)
>
> from mysite.mealfinder.models import Restaurant
>
> import csv
> reader = csv.reader(open("mysite\restaurants.csv")
>
> for row in reader:
>    restaurant_name = row[0]
>    address_name = row[1]
>    phone_number = row[2]
>    cuisine_type = row[3]
>    walking_distance = row[4]
>    delivery_avail = row[5]
>    alcohol_avail = row[6]
>
>    Restaurant.objects.get_or_create(Name=restaurant_name,
> Address=address_name, Phone = phone_number, Cuisine = cuisine_type,
> Walking = walking_distance, Delivery = delivery_avail, Alcohol =
> alcohol_avail)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Revisit Django trunk and Python 2.6

2009-05-24 Thread Skylar Saveland

On May 24, 3:21 am, Kegan  wrote:
> I am always using Django trunk and Python 2.5.4. And having no
> problem.
>
> I am thinking of switching to Python 2.6 (just to use latest python
> version). Anyone is already doing this in development? production? Any
> problem?
>
> Thanks.

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



Re: 2 seperate projects, or 2 seperate apps?

2009-05-23 Thread Skylar Saveland

> each be on their own domain when finished, and they will both have
> their own auth models (to use both sites, you need an account on each
> site).

Sounds like two different settings files to me but I would be
interested to hear what others have to input.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Python noob tuples question

2009-05-22 Thread Skylar Saveland


> if I start a tuple with ( ('john","adams"))

Also, this is the same as ('john', 'adams')... it is just a tuple and
not a tuple within a tuple
( ('john', 'adams'), )  (note the comma .. something of an idiom ..
parenthesis do not create the tuple but rather the comma) would be a
tuple containing exactly 1 2-tuple.  Tuples being immutable means that
they can not be sorted or modified, appended and members cannot be
deleted.  They are more suited toward holding some static data b/c
they can not be modified in any way.

Your += actually creates a new tuple.

PEOPLE += (('john','doe'),) does "work" however.  But, I think that
when you get the hang of lists you will find that they are really
powerful.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: password_change - specify minimum password length

2009-05-22 Thread Skylar Saveland

> I'm using the built-in password_change view. Is there an easy way to
> specify a minimum password length for the new password? (Other than
> using javascript in the template)

Well, you probably want your server-side to match whatever validation
on the client-side and you want it to work without js.  I don't know
if this is the *best way to do it but you could modify some of the
clean methods in django/contrib/auth/forms.py and return an error if
it is not above the certain length.  I was also told that a regex
might work.

def clean_password2(self):
password1 = self.cleaned_data.get("password1", "")
password2 = self.cleaned_data["password2"]
if password1 != password2:
raise forms.ValidationError(_("The two password fields
didn't match."))
if len(password1) < YourMinValueAsInt:
raise form.ValidationError(_("Password not long enough"))
return password2

If you don't want to change it for all apps using this django install
you could move auth into your project dir and have "auth" in your
installed apps instead of django.contrib.auth.  Maybe someone has a
better solution but there doesn't appear to be a simple setting for
this.


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



Re: Installing django

2009-05-22 Thread Skylar Saveland

> why follow their steps? just follow the steps in the django tutorial.

+1, I say use VPS and learn unix.  However, if we are talking
webfaction you will have to go the web dashboard and click things.
(yuck)

and then you will have some sort of virtual environment that is unlike
a VPS or your home machine and doesn't really jive with the django
docs that are geared towards having control of your machine.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Installing django

2009-05-22 Thread Skylar Saveland

> I meant for webfaction - I use webfaction, but do not use their django set up
> method. I set it up like I would set up django on my own box - using the
> latest svn trunk and configuring apache. It certainly doesn't take 21 minutes.

I seem to always jump in the middle of a thread and say something
stupid ;)  I'll try to be more patient in the future.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 interface is slow

2009-05-20 Thread Skylar Saveland

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



Re: Django Training

2008-12-09 Thread Skylar Saveland
+1, Perhaps building a fully-working site using all parts of Django,
implementing interesting and useful features.  Also setting-up with reverse
proxy/static server with lean, fast networking.  Depends on how long the
class is I suppose.

On Tue, Dec 9, 2008 at 3:32 PM, Jane <[EMAIL PROTECTED]> wrote:

>
> I think it would be good to ask students how they plan to use django.
> For myself, we'd like to deploy databases on a web page, and I'm
> interested to learn how much of that can be done in python and django,
> then what do you add to make the database look pretty for outside
> users.
>
> On Dec 8, 11:06 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> > I am looking at expanding our training offerings for the coming year,
> > and a short course in Django looks like it might be popular. There
> > don't seem to be many Django classes at the moment, and several of the
> > students from our introductory Python classes expressed interest in
> > Django.
> >
> > Without wanting anyone on the list to do my work for me, it would be
> > useful to see some opinions about what to include. The tutorial gives
> > people a good start: should we assume that anyone who wants to take
> > the class has already run through that, or would it be better to start
> > from scratch?
> >
> > Django is such a rich platform it would be possible to write several
> > classes: what material do readers regard as the "essentials of
> > Django", and what should be relegated to more advanced classes? What
> > can I do to put a compelling introductory class together?
> >
> > regards
> >  Steve
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---