How to send custom value to the SelectMultiple Widget

2009-01-21 Thread Lee

Hi, everyone.

I have some trouble in SelectMultiple Widget. The detailed information
is that:

In the form.py, I have defined a TestForm which contain a
SelectMultiple Widget called selection

#form.py
class TestForm(forms.Form):
  selection = forms.CharField( widget=forms.SelectMultiple() )

Howvever, if I want to assign values to that widget, how to do that in
the views.py?


thank you very much

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 changing the ordering of a queryset stored in session

2009-01-21 Thread Brandon Taylor

Hi everyone,

I need to do some table sorting and paging. To reduce trips to the DB,
I'm storing my initial queryset in a session using the file system
backend for local development.

I was thinking I might be able to use the dictsort filter and just
pass in the column as a variable to do the column sorting, but I can't
seem to convert a queryset into a dictionary to use with the dictsort
filter. Calling dict(queryset) returns an error.

Can anyone offer some pointers?

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



Re: Model.save() vs. ManyToMany

2009-01-21 Thread David Gordon

Hi Malcom,

> Please post a small example fragment demonstrating what you're trying to
> do.

Here's the problem code:

class Xeme(models.Model):
"""Grapheme, phoneme, morpheme, etc - any linguistic entity
representable by a string."""

text = models.CharField(max_length=150, db_index=True)
type = models.PositiveSmallIntegerField(choices=XEME_TYPES)
language = models.ForeignKey(Language, db_index=True)
components   = models.ManyToManyField('self',
  symmetrical  = False,
  blank= True,
  related_name = 'component_of')

class Meta:
unique_together = ('text', 'type', 'language')

def tokenize(self):
"""Break the text field into fragments which might match the 
text
fields of
other Xemes. Returns an iterator."""

return TokenizerFactory.create(self.language.name)(self.text)

def update_components(self):
"""Find any xemes contained by this one (according to tokenize) 
and
add
references to them in the components field."""

q_objects = [models.Q(text=text) for text in self.tokenize()]

if q_objects:
components = Xeme.objects.filter(reduce(lambda x, y: x 
| y,
q_objects))
self.components.add(*components)


I've tried running the update_components method in Xeme.save (both
before and after calling Model.save), using the post_save signal and
using the Xeme's ModelAdmin.save_model() method, to no avail.

I tried printing the contents of db.connection.queries within
Xeme.save and saw the expected INSERT calls for update_components, but
without the expected result appearing in the database. I also noticed
that if I entered values for components myself in the admin interface,
they would appear, but I couldn't see any reference to them in the SQL
printed from Xeme.save(). That's how I got the idea it may be
happening elsewhere.

thanks for your help,

David

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



Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger

OK. I figured it out and it was VERY STRANGE. Maybe some one reading
this can tell me WWWHHHYYY my solution works. For now, it's voodoo to
me...

Turns out that some of my code (in the view where I was having
trouble) called some code that looked sort of like this:

field_list = model._meta.fields
field_list.extend(model._meta.many_to_many)
for field in field_list:
related_model_name = None
related_model_app_name = None
if (not field.name[-4:] == '_ptr') and (not field.__class__ ==
AutoField):

if issubclass(field.__class__, related.RelatedField):
if not field.__class__ == related.ForeignKey:
related_model_app_name = field.rel.to.__module__.split
('.')[0]
# We'll ignore all django-specific models (such as
User, etc).
if not related_model_app_name == 'django':
related_model_name = field.rel.to.__name__
full_related_model_name = '.'.join
([field.rel.to.__module__, related_model_name])
relation_tuple_list.append((full_model_name
+'%relation'+field.name+'%' + full_related_model_name, \
'Mapping: ' +
model.__name__ + '-' + \
related_model_name))
else:
continue

It is just pulling together a list of relationships between two
models. I'm not using these models to actually DO anything. Just what
you see.

I could go to the command line and do the following:
>>> from batchimport.forms import ImportOptionsForm
>>> from sbase.models import Student
>>> mydict = {'city': u'Columbus', 'first_name': u'Jimmy', 'last_name': 
>>> u'Jones', 'zip': 43215.0, 'title': u'Mr.', 'dob': '1956-12-29', 
>>> 'phone_primary': u'614-468-5940', 'state': u'OH', 'address': u'142, Quilly 
>>> Lane', 'type': u'Student', 'email': u'miles.l.ye...@spambob.com'}
>>> mystudent = Student(**mydict)

The import of ImportOptionsForms, it turns out, called the above code.

OK. The above series of commands would fail every time with the
following error.
'Student' instance needs to have a primary key value before a many-to-
many relationship can be used.

I was close. I could repeat my strange in-app problem on the command
line. Yea.

So after a LONG time of messing with it, it turns out that django
didn't like how I was handling the many-to-many fields
(model._meta.many_to_many).

But I was able to fix my problem by just doing this:

for field_list in [model._meta.fields, model._meta.many_to_many]:
for field in field_list:
related_model_name = None
related_model_app_name = None
if (not field.name[-4:] == '_ptr') and (not
field.__class__ == AutoField):

if issubclass(field.__class__, related.RelatedField):
if not field.__class__ == related.ForeignKey:
related_model_app_name =
field.rel.to.__module__.split('.')[0]
# We'll ignore all django-specific models
(such as User, etc).
if not related_model_app_name == 'django':
related_model_name = field.rel.to.__name__
full_related_model_name = '.'.join
([field.rel.to.__module__, related_model_name])
relation_tuple_list.append((full_model_name
+'%relation'+field.name+'%' + full_related_model_name, \
'Mapping: ' +
model.__name__ + '-' + \
 
related_model_name))
else:
continue

YEAH! That's all I changed. Instead of extending my list of fields
with the many_to_many fields, I just iterated over one (to get the
ForeignKey relationships etc, and then I subsequently iterated over my
many-to-many fields.

Why (the HELL) does the first version trigger this error:
'Student' instance needs to have a primary key value before a many-to-
many relationship can be used.

But the second version doesn't?

If I'm an idiot, PLEASE tell me how so, because I'd really like to
avoid this kind of quagmire if I can

Thank you VERY MUCH Martin and Malcolm. I appreciate your respective
looks at this problem very much. Your taking time to help with this
kind of thorny issue is what makes this community rock and, frankly,
inspires me to help out more.

Keyton

On Jan 21, 3:59 pm, Keyton Weissinger  wrote:
> Hmm. Thanks Martin. I will try with the SVN HEAD revision. I have
> already tried the Student(**mydict) approach and get the exact same
> issue. I will test tonight and respond. Thanks very much for taking
> time...
>
> Keyton
>
> On Jan 21, 3:24 pm, Martin Conte Mac Donell  wrote:
>
> > Again, i can't reproduce your problem.
>
> > It's working using SVN HEAD with your model and this 
> > view:http://dpaste.com/111590/. Could you try to use that dict and
> > Student(**mydict) instead of
> > 

Re: RESTful PUT request

2009-01-21 Thread junker37

Thanks!  The trailing slash was indeed my problem.

For those that come upon this later, if you're sending json data, use
django.utils.simplejson.loads(request.raw_post_data) to convert the
data into a python dict.

On Jan 21, 7:25 pm, Malcolm Tredinnick 
wrote:
> On Wed, 2009-01-21 at 16:47 -0800, junker37 wrote:
> > Thanks, I see the request.raw_post_datanow in my middleware class,
> > however, that request never gets to my view, but instead is sent back
> > as a 301 redirect and then the request_post_data is gone.
>
> A 301 redirect is effected as a GET request. So that's not unexpected
> behaviour.
>
>
>
> >   I'm
> > guessing one of the other middleware classes is causing that, but I
> > couldn't figure out which one from looking at the code.
>
> > Here are my middleware classes:
> > MIDDLEWARE_CLASSES = (
> >     'django.middleware.common.CommonMiddleware',
> >     'django.contrib.sessions.middleware.SessionMiddleware',
> >     'django.contrib.auth.middleware.AuthenticationMiddleware',
> >     'django_openid.consumer.SessionConsumer',
> >     'account.middleware.LocaleMiddleware',
> >     'django.middleware.doc.XViewMiddleware',
> >     'djangologging.middleware.LoggingMiddleware',
> >     'pagination.middleware.PaginationMiddleware',
> >     'misc.middleware.SortOrderMiddleware',
> >     'djangodblog.middleware.DBLogMiddleware',
> >     'django.middleware.transaction.TransactionMiddleware',
> > )
>
> Then try to work out a simpler case. Start removing middleware,
> particularly those that don't come in the default MIDDLEWARE_CLASSES
> list, until you isolate the problem. Debugging is done by changing
> things, one at at a time, and seeing which change affects the result.
>
> Check for the usual causes of redirection, such as not being logged in
> when authentication is required, not having a trailing slash on URLs
> when the common middleware would normally add on. Things like that.
>
> Also, if you're using the development server (or even if you're not),
> look at where the redirection is going to. It's very unlikely that
> you're being redirected back to exactly the same URL. That should give
> you some clue. Check for things like "/foo" being redirected to
> "/foo/" (which would indicate the common middleware is redirecting to
> the canonical URL form).
>
> > Do I need some sort of decorator for my view to allow PUT requests?
>
> No. Django, in general, doesn't care about the method. It will put the
> method name in request.method and give you the data via
> request.raw_post_data.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Auth section not showing in admin interface

2009-01-21 Thread Greg Taylor

Does anyone have any idea why the "Auth" section wouldn't show up in
the admin display? Here's my APPS:

INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.flatpages',
'django.contrib.comments',
'django.contrib.humanize'
)

manage.py validate returns no errors.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: RESTful PUT request

2009-01-21 Thread Malcolm Tredinnick

On Wed, 2009-01-21 at 16:47 -0800, junker37 wrote:
> Thanks, I see the request.raw_post_data now in my middleware class,
> however, that request never gets to my view, but instead is sent back
> as a 301 redirect and then the request_post_data is gone.

A 301 redirect is effected as a GET request. So that's not unexpected
behaviour.

>   I'm
> guessing one of the other middleware classes is causing that, but I
> couldn't figure out which one from looking at the code.
> 
> Here are my middleware classes:
> MIDDLEWARE_CLASSES = (
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django_openid.consumer.SessionConsumer',
> 'account.middleware.LocaleMiddleware',
> 'django.middleware.doc.XViewMiddleware',
> 'djangologging.middleware.LoggingMiddleware',
> 'pagination.middleware.PaginationMiddleware',
> 'misc.middleware.SortOrderMiddleware',
> 'djangodblog.middleware.DBLogMiddleware',
> 'django.middleware.transaction.TransactionMiddleware',
> )

Then try to work out a simpler case. Start removing middleware,
particularly those that don't come in the default MIDDLEWARE_CLASSES
list, until you isolate the problem. Debugging is done by changing
things, one at at a time, and seeing which change affects the result.

Check for the usual causes of redirection, such as not being logged in
when authentication is required, not having a trailing slash on URLs
when the common middleware would normally add on. Things like that.

Also, if you're using the development server (or even if you're not),
look at where the redirection is going to. It's very unlikely that
you're being redirected back to exactly the same URL. That should give
you some clue. Check for things like "/foo" being redirected to
"/foo/" (which would indicate the common middleware is redirecting to
the canonical URL form).


> Do I need some sort of decorator for my view to allow PUT requests?

No. Django, in general, doesn't care about the method. It will put the
method name in request.method and give you the data via
request.raw_post_data.

Regards,
Malcolm


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



Context and Variable.resolve

2009-01-21 Thread Andrew Ingram

Hi all,

I'm writing the render method of a template tag, and I want to make the 
format of the tokens quite flexible.

I have a dict of args, some in the format 'string', some just numbers 
like 50 and others references to context variables. I am wondering if 
there's an elegant way of resolving all the values.

ie, my dict is:

args = {
'foo': '50',
'bar': '\'string\'',
'foobar': 'object.blah',
}

If they were all context variables I know I could just use 
Variable('object.blah').resolve(context), but I'm not so sure about how 
to tackle the strings and numbers. I guess some regexps could be used to 
do some basic branching.

Any thoughts would be appreciated.

Regards,
Andrew Ingram

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

2009-01-21 Thread junker37

Thanks, I see the request.raw_post_data now in my middleware class,
however, that request never gets to my view, but instead is sent back
as a 301 redirect and then the request_post_data is gone.  I'm
guessing one of the other middleware classes is causing that, but I
couldn't figure out which one from looking at the code.

Here are my middleware classes:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_openid.consumer.SessionConsumer',
'account.middleware.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
'djangologging.middleware.LoggingMiddleware',
'pagination.middleware.PaginationMiddleware',
'misc.middleware.SortOrderMiddleware',
'djangodblog.middleware.DBLogMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)

Do I need some sort of decorator for my view to allow PUT requests?

On Jan 21, 4:17 pm, Malcolm Tredinnick 
wrote:
> On Wed, 2009-01-21 at 07:01 -0800, junker37 wrote:
> > I can't seem to get django to handle a PUT request.
>
> > I've googled quited a bit and there seems to be some RESTful
> > interfaces available for django, however, I can't seem to get any of
> > them to work because the PUT request gets a 301 direct to a GET
> > request.
>
> > I created my own middleware where I can see it getting the PUT
> > request, however, I can not find where in the request I can get at the
> > PUT data.
>
> request.raw_post_data contains the submitted data.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Writing your first Django app, part 2 error in using http://127.0.0.1:8000/admin/

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 2:55 PM, bconnors  wrote:

>
> in followingWwriting your first Django app, part 2
>
> when I typed in: http://127.0.0.1:8000/admin/
>
> I got:
>
> [snip]

File "C:\Python26\Lib\site-packages\django\views\defaults.py", line
> 23, in server_error
>t = loader.get_template(template_name) # You need to create a
> 500.html template.
>
>  File "C:\Python26\Lib\site-packages\django\template\loader.py", line
> 80, in get_template
>source, origin = find_template_source(template_name)
>
>  File "C:\Python26\Lib\site-packages\django\template\loader.py", line
> 73, in find_template_source
>raise TemplateDoesNotExist, name
>
> TemplateDoesNotExist: 500.html
>
>
>
> any ideas?


You have two problems.  First, a server error (uncaught exception) happened
when trying to generate a page in response to the url you entered.  When
that happens, and debug is off, the server responds with a generic "server
error" page.  For this it needs a 500.html template, but you apparently
haven't created one, so that's your second problem. You will need a 500.html
template eventually, but as you are just getting started it would be easier
at this point if you just set DEBUG to True in settings.py.  Then, when a
server error happens, the server won't even try to use a 500.html to
generate a generic "server error" page but rather will generate an
informative debug page that will help in figuring out what is causing the
first error.

Karen

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



Re: Model.save() vs. ManyToMany

2009-01-21 Thread Malcolm Tredinnick

On Wed, 2009-01-21 at 14:01 -0800, David Gordon wrote:
> Hi Folks,
> 
> I'm aware that foreign key fields such as manytomany don't update
> during the save() method of Model, and that there are some issues
> surrounding relations to 'self'. I have a model which has a couple of
> utility functions to update two such relations, and I've found that
> they don't do anything if I call them during Model.save() - perhaps
> because the SQL is executed out of order, 

This isn't correct. Unless you have some different idea of what order
you might be expecting.

> or some nuance of the sql
> cursor behavior?
> 
> I've also tried using signals and the save_model call of AdminModel,
> none of them have any effect. self-relations only seem to update in a
> separate request.
> 
> Also note that all the relevant primary keys exist already.
> 
> My setup is almost a clean install of the latest django. I haven't
> changed the transaction stuff. It's the latest mysql, Python 2.5 on OS
> X 10.5.
> 
> I am wondering if perhaps there is some asynchronous db stuff going
> on? Perhaps I could force it to flush before I run my update methods?

None of these sound particularly likely. However, based on the complete
lack of sample code you've posted, it's impossible to know what you're
doing.

Please post a small example fragment demonstrating what you're trying to
do.

Regards,
Malcolm


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

2009-01-21 Thread Malcolm Tredinnick

On Mon, 2008-12-22 at 19:03 -0800, DragonSlayre wrote:
> I've created my own form:
> 
> 
>   Login:
>   Username: 
>   
>   Password:
>   
>   
> 
> 
> I am mappying /accounts/login/ to a view of mine, which is then
> calling:
> 
> if request.method == 'POST':
> username = request.POST['login_username']
> 
> I have no idea why I'm getting the error - "Key 'login_username' not
> found in ".
> 
> What am I doing wrong?

There is no form field element in your HTML called login_username, just
as the error message suggests. You have a label element with an id of
login_username, but that isn't a form field.

Malcolm



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

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 2:21 PM, NoviceSortOf  wrote:

>
>
> Karen:
>
> Thanks again, you are right I had the userprofile installed instead of
> django-profiles
> installed.
>
> I went to the bitbucket django-registration link you mentioned before
> and downloaded the django-profiles linked there and installed it.
> I made a small modification to mysite.myproject.models to reconcile
> the data definitions.
>
> Registration is sort of working
> _email notifications get sent
> _user tables get appended to
>
> but
>
> _the program still chokes returning the following errors in the
> browser.
>
>
> 
> ImportError at /accounts/register/   No module named urls
> Request URL:http://.../accounts/register/
> Exception Type: ImportError
> Exception Location: /usr/lib/python2.3/site-packages/django/core/
> urlresolvers.py in _get_urlconf_module, line 197
>
> 
> Detail http://dpaste.com/111548/
>
> Now my question is twofold and proactive.
>
> 1. Import error says No module named urls
>   _how do i determine exactly which set of urls it's trying to call,
>i can see its line 197 in _get_urlconf_module but can't seem to
>get a grip on exactly what line of code with exactly what
> paramters
>are calling this.
>
> 2. any other insights in how to correct this appreciated.
>

The django-registration code is trying to do a reverse url resolution.  This
requires that ALL your  utlpatterns be valid.  Unfortunately it can be a
little tricky to track down exactly which one is causing the problem since
the debug information doesn't include as much information as might be nice
to see when the failure is encountered.  Take a look at your urls.py and see
if you have anything left over from the earlier package you were using that
shouldn't be there anymore.  If so, remove it.  If not, remove (comment out)
everything except the ones you know you need to run this particular scenario
and verify that that fixes the problem.  Then start adding things back until
it breaks -- when it breaks, the one that you last added back is the cause
of the problem.

Karen

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

2009-01-21 Thread Malcolm Tredinnick

On Wed, 2009-01-21 at 07:05 -0800, Evgeniy Ivanov (powerfox) wrote:
> Hi,
> 
> I've returned to the problem and noticed, that recipe described in the
> docs is a kind of wrong: intermediary model is just a kind of M2M (I
> mean multiselection) since you have select widgets for inline model
> and to make real m2m editing have to add more inlines.
> 
> Custom model can help, but this hack is ugly too:
> 
> ==
> class Groups(ModelForm):
> users = forms.ModelMultipleChoiceField(queryset=Users.objects.all
> (),required=False)
>  
> widget=admin.widgets.FilteredSelectMultiple(_("Users"), False))
> class Meta:
> model = Groups
> ==
> 
> Now you have to add custom saving! It's wrong IMHO.

How is it wrong that when you want a custom form you have to actually
write some code? Django cannot read your mind. It cannot possibly
accommodate every single use-case of every person on the planet out of
the box. It's designed to be extensible for precisely that reason.

"I have to write some code" is not a bad thing. Django is a library for
programmers.

> I think it would be much better to specify both M2M fields with the
> same table name.

Well, have lots of fun implementing your own field type to do this, if
it's what you want.

Django's ManyToManyField is, and always will be, specified on exactly on
model. That describes the data and the programmatic API. Trying to hack
that to modify the presentation of a form is still attacking the wrong
end of the problem.

Malcolm


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

2009-01-21 Thread Malcolm Tredinnick

On Wed, 2009-01-21 at 07:01 -0800, junker37 wrote:
> I can't seem to get django to handle a PUT request.
> 
> I've googled quited a bit and there seems to be some RESTful
> interfaces available for django, however, I can't seem to get any of
> them to work because the PUT request gets a 301 direct to a GET
> request.
> 
> I created my own middleware where I can see it getting the PUT
> request, however, I can not find where in the request I can get at the
> PUT data.

request.raw_post_data contains the submitted data.

Regards,
Malcolm



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

2009-01-21 Thread Malcolm Tredinnick

On Wed, 2009-01-21 at 05:23 -0800, Iqbal Abdullah wrote:
> Hi Malcolm,
> 
> Thank you for the tip!
> I see now that in my particular code example above, the idea of using
> session id and manually setting it through the request can only work
> if the session id itself doesn't change after i've set it into the
> response. From your explaination, there is no guarantee of this
> happening, so in the code above I've to make sure that the timing of
> setting it into the response must be the last action before passing it
> to render_to_response()
> 
> Please point out if my logic is mistaken.

I must admit that I don't really understand what you're trying to do
here. However, I would strongly suggest simply following the same logic
as the existing session middleware, which seems to involve setting
things at the last minute.

Personally, though, if I had to work on a system that didn't allow
cookies, I'd try to avoid using Django's session framework. You don't
need sessions very much in many situations (the usual amount is to
record that somebody is logged in and an encrypted form variable of URL
parameter could do that), so you might be trying to solve a small
problem with a large and awkward hammer.

In any case, good luck.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: TypeError: Related Field has invalid lookup: icontains

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 3:04 PM, Alessandro Ronchi <
alessandro.ron...@soasi.com> wrote:

>
> 2009/1/21 Karen Tracey :
> > On Wed, Jan 21, 2009 at 10:21 AM, Alessandro Ronchi
> >  wrote:
> >>
> >> When one tries to make a search in admin with a model table he gets this
> >> error:
> >>
> >> TypeError: Related Field has invalid lookup: icontains
> >>
> >> is there anyway to solve it and make it returns nothings instead of 500
> >> error?
> >
> > Some details of the model and admin defs in use here would help someone
> help
> > you.
> >
> > Karen
>
> A part of my models.py:
> http://dpaste.com/111580/
>
> and my admin:
> http://dpaste.com/111581/
>
> Thanks in advance!
>

Egads, they're huge.  Any way you could cut that down to a small failing
example?  Or at least mention which model you are trying the search on?
Also a traceback instead of just the last error message would probably help,
as it might give some clue where to start looking.

Karen

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



Model.save() vs. ManyToMany

2009-01-21 Thread David Gordon

Hi Folks,

I'm aware that foreign key fields such as manytomany don't update
during the save() method of Model, and that there are some issues
surrounding relations to 'self'. I have a model which has a couple of
utility functions to update two such relations, and I've found that
they don't do anything if I call them during Model.save() - perhaps
because the SQL is executed out of order, or some nuance of the sql
cursor behavior?

I've also tried using signals and the save_model call of AdminModel,
none of them have any effect. self-relations only seem to update in a
separate request.

Also note that all the relevant primary keys exist already.

My setup is almost a clean install of the latest django. I haven't
changed the transaction stuff. It's the latest mysql, Python 2.5 on OS
X 10.5.

I am wondering if perhaps there is some asynchronous db stuff going
on? Perhaps I could force it to flush before I run my update methods?

thanks,

David

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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] can i use both a ModelAdmin and an Inline for the same model class? How?

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 4:37 PM, TeenSpirit83
wrote:

>
> I'm developing a little webapp starting from the contrib.admin
> at the moment i manage a class in the model with a modeladmin class
> but i need to edit the entries as a tabular inline of another class.
> if i write both the inline and the modeladmin classes in admin.py and
> try to register them both, django raises an error on the second
> registrarion instruction sayoing the mode class is already registered.
> is there a solution?
> thanks


Your post is a little short on details, so I am not sure what you are doing
wrong.  You should not register the inline model admin class.  To do what
you are asking you need a TabularInine that you specify (but not register)
in the ModelAdmin where you want the inlines to appear, and a ModelAdmin,
independent of the tabular inline class, that you register.

Karen

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



[admin] can i use both a ModelAdmin and an Inline for the same model class? How?

2009-01-21 Thread TeenSpirit83

I'm developing a little webapp starting from the contrib.admin
at the moment i manage a class in the model with a modeladmin class
but i need to edit the entries as a tabular inline of another class.
if i write both the inline and the modeladmin classes in admin.py and
try to register them both, django raises an error on the second
registrarion instruction sayoing the mode class is already registered.
is there a solution?
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: MultiValueDictKeyError when accessing POST items

2009-01-21 Thread esatterwh...@wi.rr.com

I've run into a similar problem, but am trying to submit the form with
a text link and java script.

The  submit element is on the page, but hidden. and I get the same
error:

 HTML
--

  
http://media.muskegohitmen.com images/
siteLogo_sm.png"/>
  Username: 
  Password: 
  LoginForgot Password ?!
  
  

--   EXTERNAL JS FUNCTION
---

// There is some mootools code in there, I thought that might be the
problem, so I stuck the document line in there to see if that would
fix it.
function hitmenFormSubmit(form_id)
{
  form = form_id.get('id');
  this.alert("form submit " +" "+form);
 document.login_form.submit();
 //$(form).submit();
}

my views function is looking for request.POST['login'] == Login

Any ideas?

If i press input button, it works fine, if i press the javascript
button I get the error
On Dec 22 2008, 9:23 pm, Malcolm Tredinnick 
wrote:
> On Mon, 2008-12-22 at 19:03 -0800, DragonSlayre wrote:
> > I've created my own form:
>
> > 
> >   Login:
> >   Username: 
> >   
> >   Password:
> >   
> >   
> > 
>
> > I am mappying /accounts/login/ to a view of mine, which is then
> > calling:
>
> > if request.method == 'POST':
> >         username = request.POST['login_username']
>
> > I have no idea why I'm getting the error - "Key 'login_username' not
> > found in ".
>
> > What am I doing wrong?
>
> login_username is the value of the id attribute on the label, not on the
> form input element. Basically, your HTML isn't correct for the type of
> form you're after. You need to identify the form input elements, rather
> than the label elements. Compare the output from a Django form to what
> you have an you should see the difference fairly quickly.
>
> Regards,
> Malcolm

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

2009-01-21 Thread esatterwh...@wi.rr.com

 HTML

  
http://media.muskegohitmen.com/images/
siteLogo_sm.png"/>
Username: 
Password: 
LoginForgot
Password ?!
  


# JS - there is a little mootools in there, but though that might be
the problem so I used the document. to see if that would do it
function hitmenFormSubmit(form_id)
{
 form = form_id.get('id');
 this.alert("form submit " +" "+form);
 document.login_form.submit();
 //$(form).submit();
}

The HTML button is on the page for debugging. The HTML button works
just fine. but the javascript button results in this error.

Views function is looking for request.POST ['login'] == Login

Why would a javascript submit not post the same data?

On Dec 22 2008, 9:23 pm, Malcolm Tredinnick 
wrote:
> On Mon, 2008-12-22 at 19:03 -0800, DragonSlayre wrote:
> > I've created my own form:
>
> > 
> >   Login:
> >   Username: 
> >   
> >   Password:
> >   
> >   
> > 
>
> > I am mappying /accounts/login/ to a view of mine, which is then
> > calling:
>
> > if request.method == 'POST':
> >         username = request.POST['login_username']
>
> > I have no idea why I'm getting the error - "Key 'login_username' not
> > found in ".
>
> > What am I doing wrong?
>
> login_username is the value of the id attribute on the label, not on the
> form input element. Basically, your HTML isn't correct for the type of
> form you're after. You need to identify the form input elements, rather
> than the label elements. Compare the output from a Django form to what
> you have an you should see the difference fairly quickly.
>
> Regards,
> Malcolm

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



Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger

Hmm. Thanks Martin. I will try with the SVN HEAD revision. I have
already tried the Student(**mydict) approach and get the exact same
issue. I will test tonight and respond. Thanks very much for taking
time...

Keyton

On Jan 21, 3:24 pm, Martin Conte Mac Donell  wrote:
> Again, i can't reproduce your problem.
>
> It's working using SVN HEAD with your model and this 
> view:http://dpaste.com/111590/. Could you try to use that dict and
> Student(**mydict) instead of
> "model_import_info.model_for_import.objects.create" ?
>
> Regards,
> M
>
> On Wed, Jan 21, 2009 at 3:06 PM, Keyton Weissinger  wrote:
>
> > I'm on django 1.0.1 (NOT 1.0.2). Do you think that has any impact on
> > this problem? I will try upgrading tonight.
>
> > Any other ideas?
>
> > K
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Enforce requirement for a UserProfile in admin

2009-01-21 Thread Delta20

Anybody have any ideas?

The validators approach I mentioned can't work because UserProfile is
not a field of UserChangeForm. Is there a way I can add a validation
requirement to UserAdmin (i.e. the ModelAdmin)?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 doesn't like serving a view to Apache

2009-01-21 Thread joshuajonah

I am running this script through shell while ssh'd into the server so
its coming from the same source


On Jan 21, 3:44 pm, joshuajonah  wrote:
> The library is for pulling data from MLS.
>
> I tried running it under the apache user, works fine there. I guess
> I'll have to dig a little.
>
> On Jan 21, 3:39 pm, Colin Bean  wrote:
>
> > On Wed, Jan 21, 2009 at 12:18 PM, joshuajonah  wrote:
>
> > > Why wouldn't it at least except?
>
> > > On Jan 21, 3:17 pm, joshuajonah  wrote:
> > >> It doesn't even get to start the session:http://dpaste.com/111586/
>
> > >> On Jan 21, 3:14 pm, joshuajonah  wrote:
>
> > >> > It works and outputs what it should:http://dpaste.com/111584/
>
> > >> > I'll try commenting out some lines and seeing how far it gets.
>
> > >> > On Jan 21, 3:10 pm, Colin Bean  wrote:
>
> > >> > > On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah  
> > >> > > wrote:
>
> > >> > > > I'm having an issue getting Apache to serve a view. It appears to 
> > >> > > > work
> > >> > > > fine through shell (http://dpaste.com/111549/), however when viewed
> > >> > > > through a web browser, it loads indefinitely.
>
> > >> > > > Here is the view:http://dpaste.com/111551/
>
> > >> > > > Any ideas guys?
>
> > >> > > What's the contents of the response in the shell?  Perhaps the shell
> > >> > > version encounters an exception and returns, while the server version
> > >> > > gets hung up on something further along (looks like you're accessing 
> > >> > > a
> > >> > > remote session, which might take a while).  Either way, I'd put some
> > >> > > debugging statements in your view and see how far it gets...
>
> > >> > > Colin
>
> > How long were you waiting for the view to return?  I'm not familiar
> > with the library you're using, but if it's timing out on the network
> > access it might take a while before it generates an exception.
>
> > It does look like accessing your remote session under apache is
> > causing the problem (your shell test was done from the same box as the
> > apache server, correct?).  If you're using mod_python, your code is
> > stuck running under the 'apache' user... could that be a problem?  You
> > could start a shell with sudo -u apache and run your view test again
> > to check.
>
> > Beyond that, all I can recommend is doing something to examine your
> > network traffic and see if there's anything that points to a problem.
> > Might be worth checking the apache error log too, if you haven't
> > already.
>
> > Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 doesn't like serving a view to Apache

2009-01-21 Thread joshuajonah

The library is for pulling data from MLS.

I tried running it under the apache user, works fine there. I guess
I'll have to dig a little.

On Jan 21, 3:39 pm, Colin Bean  wrote:
> On Wed, Jan 21, 2009 at 12:18 PM, joshuajonah  wrote:
>
> > Why wouldn't it at least except?
>
> > On Jan 21, 3:17 pm, joshuajonah  wrote:
> >> It doesn't even get to start the session:http://dpaste.com/111586/
>
> >> On Jan 21, 3:14 pm, joshuajonah  wrote:
>
> >> > It works and outputs what it should:http://dpaste.com/111584/
>
> >> > I'll try commenting out some lines and seeing how far it gets.
>
> >> > On Jan 21, 3:10 pm, Colin Bean  wrote:
>
> >> > > On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah  
> >> > > wrote:
>
> >> > > > I'm having an issue getting Apache to serve a view. It appears to 
> >> > > > work
> >> > > > fine through shell (http://dpaste.com/111549/), however when viewed
> >> > > > through a web browser, it loads indefinitely.
>
> >> > > > Here is the view:http://dpaste.com/111551/
>
> >> > > > Any ideas guys?
>
> >> > > What's the contents of the response in the shell?  Perhaps the shell
> >> > > version encounters an exception and returns, while the server version
> >> > > gets hung up on something further along (looks like you're accessing a
> >> > > remote session, which might take a while).  Either way, I'd put some
> >> > > debugging statements in your view and see how far it gets...
>
> >> > > Colin
>
> How long were you waiting for the view to return?  I'm not familiar
> with the library you're using, but if it's timing out on the network
> access it might take a while before it generates an exception.
>
> It does look like accessing your remote session under apache is
> causing the problem (your shell test was done from the same box as the
> apache server, correct?).  If you're using mod_python, your code is
> stuck running under the 'apache' user... could that be a problem?  You
> could start a shell with sudo -u apache and run your view test again
> to check.
>
> Beyond that, all I can recommend is doing something to examine your
> network traffic and see if there's anything that points to a problem.
> Might be worth checking the apache error log too, if you haven't
> already.
>
> Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 doesn't like serving a view to Apache

2009-01-21 Thread Colin Bean

On Wed, Jan 21, 2009 at 12:18 PM, joshuajonah  wrote:
>
> Why wouldn't it at least except?
>
> On Jan 21, 3:17 pm, joshuajonah  wrote:
>> It doesn't even get to start the session:http://dpaste.com/111586/
>>
>> On Jan 21, 3:14 pm, joshuajonah  wrote:
>>
>> > It works and outputs what it should:http://dpaste.com/111584/
>>
>> > I'll try commenting out some lines and seeing how far it gets.
>>
>> > On Jan 21, 3:10 pm, Colin Bean  wrote:
>>
>> > > On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah  
>> > > wrote:
>>
>> > > > I'm having an issue getting Apache to serve a view. It appears to work
>> > > > fine through shell (http://dpaste.com/111549/), however when viewed
>> > > > through a web browser, it loads indefinitely.
>>
>> > > > Here is the view:http://dpaste.com/111551/
>>
>> > > > Any ideas guys?
>>
>> > > What's the contents of the response in the shell?  Perhaps the shell
>> > > version encounters an exception and returns, while the server version
>> > > gets hung up on something further along (looks like you're accessing a
>> > > remote session, which might take a while).  Either way, I'd put some
>> > > debugging statements in your view and see how far it gets...
>>
>> > > Colin
> >
>

How long were you waiting for the view to return?  I'm not familiar
with the library you're using, but if it's timing out on the network
access it might take a while before it generates an exception.

It does look like accessing your remote session under apache is
causing the problem (your shell test was done from the same box as the
apache server, correct?).  If you're using mod_python, your code is
stuck running under the 'apache' user... could that be a problem?  You
could start a shell with sudo -u apache and run your view test again
to check.

Beyond that, all I can recommend is doing something to examine your
network traffic and see if there's anything that points to a problem.
Might be worth checking the apache error log too, if you haven't
already.

Colin

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



Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Martin Conte Mac Donell

Again, i can't reproduce your problem.

It's working using SVN HEAD with your model and this view:
http://dpaste.com/111590/. Could you try to use that dict and
Student(**mydict) instead of
"model_import_info.model_for_import.objects.create" ?

Regards,
M

On Wed, Jan 21, 2009 at 3:06 PM, Keyton Weissinger  wrote:
>
> I'm on django 1.0.1 (NOT 1.0.2). Do you think that has any impact on
> this problem? I will try upgrading tonight.
>
> Any other ideas?
>
> K

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 doesn't like serving a view to Apache

2009-01-21 Thread joshuajonah

Why wouldn't it at least except?

On Jan 21, 3:17 pm, joshuajonah  wrote:
> It doesn't even get to start the session:http://dpaste.com/111586/
>
> On Jan 21, 3:14 pm, joshuajonah  wrote:
>
> > It works and outputs what it should:http://dpaste.com/111584/
>
> > I'll try commenting out some lines and seeing how far it gets.
>
> > On Jan 21, 3:10 pm, Colin Bean  wrote:
>
> > > On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah  
> > > wrote:
>
> > > > I'm having an issue getting Apache to serve a view. It appears to work
> > > > fine through shell (http://dpaste.com/111549/), however when viewed
> > > > through a web browser, it loads indefinitely.
>
> > > > Here is the view:http://dpaste.com/111551/
>
> > > > Any ideas guys?
>
> > > What's the contents of the response in the shell?  Perhaps the shell
> > > version encounters an exception and returns, while the server version
> > > gets hung up on something further along (looks like you're accessing a
> > > remote session, which might take a while).  Either way, I'd put some
> > > debugging statements in your view and see how far it gets...
>
> > > Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 doesn't like serving a view to Apache

2009-01-21 Thread joshuajonah

It doesn't even get to start the session: http://dpaste.com/111586/

On Jan 21, 3:14 pm, joshuajonah  wrote:
> It works and outputs what it should:http://dpaste.com/111584/
>
> I'll try commenting out some lines and seeing how far it gets.
>
> On Jan 21, 3:10 pm, Colin Bean  wrote:
>
> > On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah  wrote:
>
> > > I'm having an issue getting Apache to serve a view. It appears to work
> > > fine through shell (http://dpaste.com/111549/), however when viewed
> > > through a web browser, it loads indefinitely.
>
> > > Here is the view:http://dpaste.com/111551/
>
> > > Any ideas guys?
>
> > What's the contents of the response in the shell?  Perhaps the shell
> > version encounters an exception and returns, while the server version
> > gets hung up on something further along (looks like you're accessing a
> > remote session, which might take a while).  Either way, I'd put some
> > debugging statements in your view and see how far it gets...
>
> > Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 doesn't like serving a view to Apache

2009-01-21 Thread joshuajonah

It works and outputs what it should: http://dpaste.com/111584/

I'll try commenting out some lines and seeing how far it gets.

On Jan 21, 3:10 pm, Colin Bean  wrote:
> On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah  wrote:
>
> > I'm having an issue getting Apache to serve a view. It appears to work
> > fine through shell (http://dpaste.com/111549/), however when viewed
> > through a web browser, it loads indefinitely.
>
> > Here is the view:http://dpaste.com/111551/
>
> > Any ideas guys?
>
> What's the contents of the response in the shell?  Perhaps the shell
> version encounters an exception and returns, while the server version
> gets hung up on something further along (looks like you're accessing a
> remote session, which might take a while).  Either way, I'd put some
> debugging statements in your view and see how far it gets...
>
> Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 doesn't like serving a view to Apache

2009-01-21 Thread Colin Bean

On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah  wrote:
>
> I'm having an issue getting Apache to serve a view. It appears to work
> fine through shell (http://dpaste.com/111549/), however when viewed
> through a web browser, it loads indefinitely.
>
> Here is the view: http://dpaste.com/111551/
>
> Any ideas guys?
> >
>


What's the contents of the response in the shell?  Perhaps the shell
version encounters an exception and returns, while the server version
gets hung up on something further along (looks like you're accessing a
remote session, which might take a while).  Either way, I'd put some
debugging statements in your view and see how far it gets...

Colin

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

2009-01-21 Thread Alistair Marshall

On Jan 21, 7:54 pm, joshuajonah  wrote:
> A normal manage.py dump to fixture doesn't work?
>

I had missed that one, didn't know it was an option.

my bad

Thanks
Alistair
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: TypeError: Related Field has invalid lookup: icontains

2009-01-21 Thread Alessandro Ronchi

2009/1/21 Karen Tracey :
> On Wed, Jan 21, 2009 at 10:21 AM, Alessandro Ronchi
>  wrote:
>>
>> When one tries to make a search in admin with a model table he gets this
>> error:
>>
>> TypeError: Related Field has invalid lookup: icontains
>>
>> is there anyway to solve it and make it returns nothings instead of 500
>> error?
>
> Some details of the model and admin defs in use here would help someone help
> you.
>
> Karen

A part of my models.py:
http://dpaste.com/111580/

and my admin:
http://dpaste.com/111581/

Thanks in advance!


-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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

2009-01-21 Thread saved...@gmail.com

Hello Malcolm,

This is what I get...

Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python25\Lib\site-packages\Django-1.0\django\languagen\..
\languagen\questions\views.py" in answer
  10. a = q.answers.get(question=q, pk=request.POST['answer'])
File "C:\Python25\Lib\site-packages\django\utils\datastructures.py" in
__getitem__
  203. raise MultiValueDictKeyError, "Key %r not found in
%r" % (key, self)

Exception Type: MultiValueDictKeyError at /questions/1/answer/
Exception Value: "Key 'answer' not found in "

Any advice?

On Jan 21, 2:24 pm, "saved...@gmail.com"  wrote:
> Let me learn how to crawl before I can walk...
> Thanks for your time..
> Ken
>
> On Jan 21, 10:48 am, "saved...@gmail.com"  wrote:
>
> > Hello Malcolm,
> > Thanks for your response.  I have thought very carefully before
> > responding to your email.  In no way was I ignoring your previous
> > posts, I was trying to take the easy way, rather than the correct
> > way.  Furthermore, I really don't know how.
> > I have spent hours trying to look it up, but to no avail.
> > Would I place the print statements after each line of the view?
> > Regards,
> > Ken
>
> > On Jan 20, 10:13 pm, Malcolm Tredinnick 
> > wrote:
>
> > > On Tue, 2009-01-20 at 17:51 -0800, saved...@gmail.com wrote:
> > > > Hello Malcolm,
>
> > > > Thanks for you reply.  Unfortunately, there is no 404 error message.
> > > > For some reason (beyond the scope of my django knowledge), the view
> > > > just won't redirect. The scope of my django knowledge.  Here are my
> > > > simple urls, if that is of any assistance.
>
> > > > urlpatterns = patterns('django.views.generic.list_detail',
> > > >     (r'^$', 'object_list', info_dict),
> > > >     (r'^(?P\d+)/answer/$', 'object_detail', info_dict),
> > > > )
> > > > urlpatterns += patterns('',
> > > >     (r'^(?P\d+)/answer/$',
> > > > 'languagen.questions.views.answer'),
> > > > )
>
> > > > I'm not sure on how I should
>
> > > Stop trying to debug this through the browser and be prepared to debug
> > > the Python code. I've suggested twice now (this is the third time) that
> > > you put some print statements in your code to show the values of various
> > > variables.
>
> > > If you're running with Django's runserver, they will print to the
> > > console. If you're serving your pages through something like Apache,
> > > print to sys.stderr and the output will go the http error log.
>
> > > Attempting to debug this in the browser is like trying to bake a cake
> > > whilst being at the other end of the house from the kitchen. You have to
> > > get closer to the problem. Use the browser to trigger the problem (i.e.
> > > request the page), but it's your Python code that is behaving
> > > erratically, so debug that, not the browser output.
>
> > > Put in a print statement to work out which branch of the "if" test is
> > > being taken. Print out the value of q.next.get_absolute_url(). Print out
> > > anything else that might help you decide which lines of code are being
> > > executed. This is very normal debugging technique.
>
> > > Regards,
> > > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: httpresponseredirect

2009-01-21 Thread saved...@gmail.com

Hello Malcolm,

This is what I get...

Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python25\Lib\site-packages\Django-1.0\django\languagen\..
\languagen\questions\views.py" in answer
  10. a = q.answers.get(question=q, pk=request.POST['answer'])
File "C:\Python25\Lib\site-packages\django\utils\datastructures.py" in
__getitem__
  203. raise MultiValueDictKeyError, "Key %r not found in
%r" % (key, self)

Exception Type: MultiValueDictKeyError at /questions/1/answer/
Exception Value: "Key 'answer' not found in "

Any advice?

On Jan 21, 2:24 pm, "saved...@gmail.com"  wrote:
> Let me learn how to crawl before I can walk...
> Thanks for your time..
> Ken
>
> On Jan 21, 10:48 am, "saved...@gmail.com"  wrote:
>
> > Hello Malcolm,
> > Thanks for your response.  I have thought very carefully before
> > responding to your email.  In no way was I ignoring your previous
> > posts, I was trying to take the easy way, rather than the correct
> > way.  Furthermore, I really don't know how.
> > I have spent hours trying to look it up, but to no avail.
> > Would I place the print statements after each line of the view?
> > Regards,
> > Ken
>
> > On Jan 20, 10:13 pm, Malcolm Tredinnick 
> > wrote:
>
> > > On Tue, 2009-01-20 at 17:51 -0800, saved...@gmail.com wrote:
> > > > Hello Malcolm,
>
> > > > Thanks for you reply.  Unfortunately, there is no 404 error message.
> > > > For some reason (beyond the scope of my django knowledge), the view
> > > > just won't redirect. The scope of my django knowledge.  Here are my
> > > > simple urls, if that is of any assistance.
>
> > > > urlpatterns = patterns('django.views.generic.list_detail',
> > > >     (r'^$', 'object_list', info_dict),
> > > >     (r'^(?P\d+)/answer/$', 'object_detail', info_dict),
> > > > )
> > > > urlpatterns += patterns('',
> > > >     (r'^(?P\d+)/answer/$',
> > > > 'languagen.questions.views.answer'),
> > > > )
>
> > > > I'm not sure on how I should
>
> > > Stop trying to debug this through the browser and be prepared to debug
> > > the Python code. I've suggested twice now (this is the third time) that
> > > you put some print statements in your code to show the values of various
> > > variables.
>
> > > If you're running with Django's runserver, they will print to the
> > > console. If you're serving your pages through something like Apache,
> > > print to sys.stderr and the output will go the http error log.
>
> > > Attempting to debug this in the browser is like trying to bake a cake
> > > whilst being at the other end of the house from the kitchen. You have to
> > > get closer to the problem. Use the browser to trigger the problem (i.e.
> > > request the page), but it's your Python code that is behaving
> > > erratically, so debug that, not the browser output.
>
> > > Put in a print statement to work out which branch of the "if" test is
> > > being taken. Print out the value of q.next.get_absolute_url(). Print out
> > > anything else that might help you decide which lines of code are being
> > > executed. This is very normal debugging technique.
>
> > > Regards,
> > > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Writing your first Django app, part 2 error in using http://127.0.0.1:8000/admin/

2009-01-21 Thread bconnors

in followingWwriting your first Django app, part 2

when I typed in: http://127.0.0.1:8000/admin/

I got:

Traceback (most recent call last):

  File "C:\Python26\Lib\site-packages\django\core\servers
\basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)

  File "C:\Python26\Lib\site-packages\django\core\servers
\basehttp.py", line 635, in __call__
return self.application(environ, start_response)

  File "C:\Python26\Lib\site-packages\django\core\handlers\wsgi.py",
line 239, in __call__
response = self.get_response(request)

  File "C:\Python26\Lib\site-packages\django\core\handlers\base.py",
line 116, in get_response
return self.handle_uncaught_exception(request, resolver,
sys.exc_info())

  File "C:\Python26\Lib\site-packages\django\core\handlers\base.py",
line 160, in handle_uncaught_exception
return callback(request, **param_dict)

  File "C:\Python26\Lib\site-packages\django\views\defaults.py", line
23, in server_error
t = loader.get_template(template_name) # You need to create a
500.html template.

  File "C:\Python26\Lib\site-packages\django\template\loader.py", line
80, in get_template
source, origin = find_template_source(template_name)

  File "C:\Python26\Lib\site-packages\django\template\loader.py", line
73, in find_template_source
raise TemplateDoesNotExist, name

TemplateDoesNotExist: 500.html



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



Re: move/change database type

2009-01-21 Thread joshuajonah

A normal manage.py dump to fixture doesn't work?


On Jan 21, 2:44 pm, Alistair Marshall 
wrote:
> Hi folks,
>
> I have been developing a project on my desktop using sqlite, I have
> just attempted to move it onto a 'proper' server and was hoping to use
> mysql.
>
> The thing is I have some data in the database from some beta users and
> was hoping to take the data over with the move.
>
> I had planned on using db_dump.py which has worked in the past but
> this time it wont work, I _think_ the problem is to do with the fact
> that this time I am using multi-table model inheritance.
>
> I was wondering what other tools where out there (I surely cant be the
> only one trying to do this)
>
> Thanks
> Alistair
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 doesn't like serving a view to Apache

2009-01-21 Thread joshuajonah

Also, this instance of django serves other views fine.

On Jan 21, 2:34 pm, joshuajonah  wrote:
> I'm having an issue getting Apache to serve a view. It appears to work
> fine through shell (http://dpaste.com/111549/), however when viewed
> through a web browser, it loads indefinitely.
>
> Here is the view:http://dpaste.com/111551/
>
> Any ideas guys?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



move/change database type

2009-01-21 Thread Alistair Marshall

Hi folks,

I have been developing a project on my desktop using sqlite, I have
just attempted to move it onto a 'proper' server and was hoping to use
mysql.

The thing is I have some data in the database from some beta users and
was hoping to take the data over with the move.

I had planned on using db_dump.py which has worked in the past but
this time it wont work, I _think_ the problem is to do with the fact
that this time I am using multi-table model inheritance.

I was wondering what other tools where out there (I surely cant be the
only one trying to do this)

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

2009-01-21 Thread Adi Sieker

Hi,

check this out.

http://code.djangoproject.com/ticket/6932

adi

On 21.01.2009, at 16:53, Gordon wrote:

>
> Hi
> I've just started to use Django and have been using the flatpages
> plugin for serving static pages. Does anyone know how or a plugin that
> will generate a content's tree from the URLs?
> e.g.
> /staff/
> /staff/management/
> /staff/clerical/
> /staff/technical/
> /projects/
> /projects/ace/
> /projects/django/
> /projects/ruby/
>
> what I'm looking for is someway of automatically traversing the URLS
> for all the flatpages on my site so that I can generate a table of
> contents relative to where I am on the site.
>
> Regards
> Gordon
>
> 
--
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   skype:  adijsieker
SAP-Consultantweb:http://www.sieker.info/profile
   openbc: https://www.openbc.com/hp/ 
AdiJoerg_Sieker/

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



Django doesn't like serving a view to Apache

2009-01-21 Thread joshuajonah

I'm having an issue getting Apache to serve a view. It appears to work
fine through shell (http://dpaste.com/111549/), however when viewed
through a web browser, it loads indefinitely.

Here is the view: http://dpaste.com/111551/

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



Re: I don't even know where to begin writing this template-tags

2009-01-21 Thread Doug B

I went the hideous route, but tried to make it general enough I could
reuse.  I'm still on .96, but it shouldn't be too much trouble to make
it work with 1.0.

In [2]: template.Template("{% load kwtag %}{% do_kwtagtest foo foo=bar
%}").render(template.Context())
Out[2]: "['foo']{'foo': 'bar'}"

In [6]: template.Template("{% load kwtag %}{% do_kwtagtest foo foo=bar
%}").render(template.Context({'foo':'blue'}))
Out[6]: "['blue']{'foo': 'bar'}"

In [7]: template.Template("{% load kwtag %}{% do_kwtagtest foo foo=bar
%}").render(template.Context({'foo':'blue','bar':'brown'}))
Out[7]: "['blue']{'foo': 'brown'}"

The parsing is not perfect, but it's usable for most simple stuff I
needed to do with it.  Might be of some use.

http://dpaste.com/111554/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Multiple managers for reverse-links between subclasses

2009-01-21 Thread Mackenzie Kearl

On Jan 21, 11:14 am, Aneurin Price  wrote:
> (Apologies for the vague subject; I couldn't think how to summarise this :P)
>
> Hello all,
>
> I have an application where some models are inherited from others, like so:
>    Foo
>   /   \
> Bar  Baz
> Each object has (or may have) a parent object, which is a Foo (it might be a 
> Bar
> or a Baz, or some other subclass, but it's definitely a Foo). I'd like to be
> able to find the children of an object, both overall and by subclass, using
> 'foo_object.children.all()', or 'foo_object.bars.all()' and so on.
>
> Originally I set up parent links in Foo, as something like
> "parent=models.ForeignKey('self', related_name='children')", but when I 
> realised
> that I mostly want to get the children in groups, I changed the way I was 
> doing
> this. Now I have per-class links like "parent=models.ForeignKey('Foo',
> related_name='bars')", etc. This allows me to have the parent/child hierarchy
> that I want, and access the children in the appropriate groups, but it feels
> rathr ugly, and I'd still like an aggregate 'children' set so that I don't 
> have
> to use each set individually (and update every use if I ever add new
> subclasses).
>
> Additionally, I don't know if I'll need this, but I'm interested in how I 
> might
> get a link to 'children_of_same_type', so in Foo it would be an alias to
> 'children', but in Bar it would be an alias to 'bars', etc. I can't just do
> 'children_of_same_type = bars' because 'bars' is autogenerated so hasn't been
> defined yet.
>
> I hope that makes sense, but if not I can come up with a few more examples to
> try to clarify it.
>
> Does anybody have any suggestions as to how I should structure this? Would I 
> be
> best to leave the parent links as they are and define custom Managers for
> 'children' and 'children_of_same_type'? If so, pointers on how to go about 
> this
> would be appreciated.
>
> Thanks,
> Nye

Why don't you instead of subclass Foo just create a foreignkey to Foo
or a OneToOne with foo.

'foo_object.children.all()'
I don't think that this is possible because it contains different
models in the query.

The other option that you could try is a generic relation something
like the way django-tagging works.

I hope this is a help



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



Re: httpresponseredirect

2009-01-21 Thread saved...@gmail.com

Let me learn how to crawl before I can walk...
Thanks for your time..
Ken

On Jan 21, 10:48 am, "saved...@gmail.com"  wrote:
> Hello Malcolm,
> Thanks for your response.  I have thought very carefully before
> responding to your email.  In no way was I ignoring your previous
> posts, I was trying to take the easy way, rather than the correct
> way.  Furthermore, I really don't know how.
> I have spent hours trying to look it up, but to no avail.
> Would I place the print statements after each line of the view?
> Regards,
> Ken
>
> On Jan 20, 10:13 pm, Malcolm Tredinnick 
> wrote:
>
> > On Tue, 2009-01-20 at 17:51 -0800, saved...@gmail.com wrote:
> > > Hello Malcolm,
>
> > > Thanks for you reply.  Unfortunately, there is no 404 error message.
> > > For some reason (beyond the scope of my django knowledge), the view
> > > just won't redirect. The scope of my django knowledge.  Here are my
> > > simple urls, if that is of any assistance.
>
> > > urlpatterns = patterns('django.views.generic.list_detail',
> > >     (r'^$', 'object_list', info_dict),
> > >     (r'^(?P\d+)/answer/$', 'object_detail', info_dict),
> > > )
> > > urlpatterns += patterns('',
> > >     (r'^(?P\d+)/answer/$',
> > > 'languagen.questions.views.answer'),
> > > )
>
> > > I'm not sure on how I should
>
> > Stop trying to debug this through the browser and be prepared to debug
> > the Python code. I've suggested twice now (this is the third time) that
> > you put some print statements in your code to show the values of various
> > variables.
>
> > If you're running with Django's runserver, they will print to the
> > console. If you're serving your pages through something like Apache,
> > print to sys.stderr and the output will go the http error log.
>
> > Attempting to debug this in the browser is like trying to bake a cake
> > whilst being at the other end of the house from the kitchen. You have to
> > get closer to the problem. Use the browser to trigger the problem (i.e.
> > request the page), but it's your Python code that is behaving
> > erratically, so debug that, not the browser output.
>
> > Put in a print statement to work out which branch of the "if" test is
> > being taken. Print out the value of q.next.get_absolute_url(). Print out
> > anything else that might help you decide which lines of code are being
> > executed. This is very normal debugging technique.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Ongoing problems with django-registration installation.

2009-01-21 Thread NoviceSortOf


Karen:

Thanks again, you are right I had the userprofile installed instead of
django-profiles
installed.

I went to the bitbucket django-registration link you mentioned before
and downloaded the django-profiles linked there and installed it.
I made a small modification to mysite.myproject.models to reconcile
the data definitions.

Registration is sort of working
_email notifications get sent
_user tables get appended to

but

_the program still chokes returning the following errors in the
browser.


ImportError at /accounts/register/   No module named urls
Request URL:http://.../accounts/register/
Exception Type: ImportError
Exception Location: /usr/lib/python2.3/site-packages/django/core/
urlresolvers.py in _get_urlconf_module, line 197

Detail http://dpaste.com/111548/

Now my question is twofold and proactive.

1. Import error says No module named urls
   _how do i determine exactly which set of urls it's trying to call,
i can see its line 197 in _get_urlconf_module but can't seem to
get a grip on exactly what line of code with exactly what
paramters
are calling this.

2. any other insights in how to correct this appreciated.





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



Re: problem on django book tutorial

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 1:36 PM, xankya  wrote:

>
> class Admin didnt show "book" on admin interface. instead admin.py in
> the books folder show up "book" on admin interface.
>
> Can anyone conform "class Amin: pass" works ??
>

'class Admin' worked for the level of Django that was current when the book
was written.  For Django 1.0 and later, it's best to use the online docs to
learn about how to specify admin stuff, since that is up-to-date whereas
most books I have heard of have not yet been updated to match the Django 1.0
level.

Karen

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



problem on django book tutorial

2009-01-21 Thread xankya

class Admin didnt show "book" on admin interface. instead admin.py in
the books folder show up "book" on admin interface.

Can anyone conform "class Amin: pass" works ??

class Book(models.Model):
title = models.CharField(maxlength=100)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)
publication_date = models.DateField()
num_pages = models.IntegerField(blank=True, null=True)

def __str__(self):
return self.title

class Admin:
pass

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

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 12:22 PM, NoviceSortOf  wrote:

>
> > 0.7 is where full Django 1.0 compatibility was included.  I'm assuming
> you
> > are using Django 1.0 or higher?  The error related to 'alnum_re' you
> mention
> > later looks to be the result of django-registration using a core
> validator
> > thingy -- these were all removed prior to Django 1.0, so if you got an
> error
> > on that then it sounds like you are running a later version of Django
> than
> > is supported by the version of django-registration you installed.  Rather
> > than trying to patch the registration code you have (which is what has
> led
> > to the syntax error you report), upgrade to a django-registration version
> > (0.7 or current code) that supports the level of Django you are running.
>
> Karen:
>
> I'm running django version 1.0 final SVN
> I upgraded to Django registration 0.7 just now.
> Thanks, that certainly sorts out the  'alnum_re' problem
>
> Now the remaining problem is after filling the form I get is
>
>
> 
> SyntaxError at /accounts/register/
> invalid syntax (views.py, line 87)
> Request Method: POST
> Request URL:http://www.rareasianbooks.com/accounts/register/
> Exception Type: SyntaxError
> invalid syntax (views.py, line 87)
> Exception Location: /usr/lib/python2.3/site-packages/userprofile/urls/
> en.py in ?, line 3
>
> *
> verbose paste of debug results can be seen here  http://dpaste.com/111499/
>
> I looked at ...registration.views.py but line 87 there is a commented
> area so it
> must be talking about another view.py file.
>
> Where should I look next?
>
>
I thought you were using the companion app to django-registration, which is
django-profiles:

http://bitbucket.org/ubernostrum/django-profiles/wiki/Home

However the traceback you posted at dpaste includes:

module = __import__("userprofile.urls.en", {}, {}, "urlpatterns")

from:

"/usr/lib/python2.3/site-packages/userprofile/urls/__init__.py"

which doesn't match up to anything I can see has ever been in
django-profiles. Google search on that line of code makes it appear you may
instead by running this app:

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

Then I can find in its v0.3 level (which is fairly old, from April of 2008)
the match for this last part of the traceback:

File "/usr/lib/python2.3/site-packages/userprofile/urls/en.py" in ?
3. from userprofile.views import *

If I then look at its views.py around line 87:

http://code.google.com/p/django-profile/source/browse/tags/0.3/userprofile/views.py?r=279#86

I can see a problem -- it is using decorator syntax, which was added in
Python 2.4, but based on your tracebacks you are running Python 2.3.

That app just isn't going to work with the level of Python you are running.
I wouldn't be surprised if it also had other problems due to the level you
have of it being from well before Django 1.0.  But I don't think it's really
the app you want to be running, since I thought you wanted django-profiles,
the one that goes along with django-registration.  Switching to
django-profiles should help, assuming it supports Python 2.3 (I'd guess it
does but don't know that for sure as I've never used it myself and don't
have time right now to research it).

Karen

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

2009-01-21 Thread Costin Stroie

On Jan 21, 9:27 am, urukay  wrote:
> Hi
>
> i would use raw SQL to retrieve models, that would be the fastest way i
> quess:http://docs.djangoproject.com/en/dev/topics/db/sql/
>
> from django.db import connection
>
> cursor = connection.cursor()
> cursor.execute(...Sqlquery...)
> ...
> ...
>
> Other way could look like this:
>
> result = []
> all_models=MyModel.objects.all()
> for x in all_models:
>if x.width>x.maxwidth:
>result.append(x)
> ...
> ...
>
> Hope it helps.

Thank you, but... it won't. Your example works, but it is not what I
need.
I need a queryset method, much like .filter(), to return a queryset,
applying that condition.


--
Costin Stroie

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: I don't even know where to begin writing this template-tags

2009-01-21 Thread Preston Holmes

It may not be as pretty as a parseable param array, but what about
just having all your args in a single JSON string. Are your template
authors savvy enough?

-Preston


On Jan 20, 3:32 pm, Andrew Ingram  wrote:
> I'm building a simple banner/promotion system for a site. Aside from a
> few date-related fields, a banner consists of:
> - an image
> - a target url
> - the image dimensions
> - some tags (using django-tagging)
>
> I'm trying to figure out how to build a template-tag to allow me to
> display a number of banners based on their properties.
>
> i.e
>
> {% get-banners max-width='450' max-height='100' min-height='50'
> match-any='foo, bar' match-all='homepage' limit='2' as banners %}
>
> {% for banner in banners %}
>   
> {% endfor %}
>
> The only way I can see to do this is to write a hideous parser function,
> made worse by the fact that almost all of the arguments are optional.
> This would take about 5 minutes in Rails (and I don't like Rails), it
> would take about 10 minutes in Tapestry (a Java framework which I
> despise). So I'm hoping there's a nice elegant way of doing this in
> Django because the only approach I can think of is very unappealing.
>
> Regards,
> Andrew Ingram
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to Model Formset

2009-01-21 Thread Mackenzie Kearl

The only way to describe  what I am trying to accomplish is through an
example. Here are my models

class B(models.Model):
credits = models.FloatField(,null=True)

class A(models.Model):
b = models.OneToOneField(B)
description = models.TextField()


I want to get a formset of A forms for each item in B.objects.all().
One  requirement is that I only want it to save if they fill in a
description.
The other requirement is that in the form I don't want the user to be
able to change the value of b.

This is the reverse of an inline formset.



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

2009-01-21 Thread NoviceSortOf

> 0.7 is where full Django 1.0 compatibility was included.  I'm assuming you
> are using Django 1.0 or higher?  The error related to 'alnum_re' you mention
> later looks to be the result of django-registration using a core validator
> thingy -- these were all removed prior to Django 1.0, so if you got an error
> on that then it sounds like you are running a later version of Django than
> is supported by the version of django-registration you installed.  Rather
> than trying to patch the registration code you have (which is what has led
> to the syntax error you report), upgrade to a django-registration version
> (0.7 or current code) that supports the level of Django you are running.

Karen:

I'm running django version 1.0 final SVN
I upgraded to Django registration 0.7 just now.
Thanks, that certainly sorts out the  'alnum_re' problem

Now the remaining problem is after filling the form I get is


SyntaxError at /accounts/register/
invalid syntax (views.py, line 87)
Request Method: POST
Request URL:http://www.rareasianbooks.com/accounts/register/
Exception Type: SyntaxError
invalid syntax (views.py, line 87)
Exception Location: /usr/lib/python2.3/site-packages/userprofile/urls/
en.py in ?, line 3
*
verbose paste of debug results can be seen here  http://dpaste.com/111499/

I looked at ...registration.views.py but line 87 there is a commented
area so it
must be talking about another view.py file.

Where should I look next?


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



Multiple managers for reverse-links between subclasses

2009-01-21 Thread Aneurin Price

(Apologies for the vague subject; I couldn't think how to summarise this :P)

Hello all,

I have an application where some models are inherited from others, like so:
   Foo
  /   \
Bar  Baz
Each object has (or may have) a parent object, which is a Foo (it might be a Bar
or a Baz, or some other subclass, but it's definitely a Foo). I'd like to be
able to find the children of an object, both overall and by subclass, using
'foo_object.children.all()', or 'foo_object.bars.all()' and so on.

Originally I set up parent links in Foo, as something like
"parent=models.ForeignKey('self', related_name='children')", but when I realised
that I mostly want to get the children in groups, I changed the way I was doing
this. Now I have per-class links like "parent=models.ForeignKey('Foo',
related_name='bars')", etc. This allows me to have the parent/child hierarchy
that I want, and access the children in the appropriate groups, but it feels
rathr ugly, and I'd still like an aggregate 'children' set so that I don't have
to use each set individually (and update every use if I ever add new
subclasses).

Additionally, I don't know if I'll need this, but I'm interested in how I might
get a link to 'children_of_same_type', so in Foo it would be an alias to
'children', but in Bar it would be an alias to 'bars', etc. I can't just do
'children_of_same_type = bars' because 'bars' is autogenerated so hasn't been
defined yet.

I hope that makes sense, but if not I can come up with a few more examples to
try to clarify it.

Does anybody have any suggestions as to how I should structure this? Would I be
best to leave the parent links as they are and define custom Managers for
'children' and 'children_of_same_type'? If so, pointers on how to go about this
would be appreciated.

Thanks,
Nye

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



Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger

I'm on django 1.0.1 (NOT 1.0.2). Do you think that has any impact on
this problem? I will try upgrading tonight.

Any other ideas?

K

On Jan 21, 8:33 am, Keyton Weissinger  wrote:
> More information...
>
> I stuck the following into my code at the same place the other code is
> bombing. I did this just to make sure that I wasn't getting anything
> weird in the dictionary here that I wasn't getting in the command
> line.
>
> mydict = {'city': u'Columbus', 'first_name': u'Miles', 'last_name':
> u'Yeung', 'school': import_object_dict['school'], 'zip': 43215.0,
> 'title': u'Mr.', 'dob': '1956-12-29', 'phone_primary':
> u'614-468-5940', 'state': u'OH', 'address': u'142, Quilly Lane',
> 'type': u'Student', 'email': u'miles.l.ye...@spambob.com'}
>
> new_object = Student(**mydict)
>
> Same exact error as before. It's almost as if the Student object is
> behaving differently within the context that it does within manage.py
> shell.
>
> Just in case it was the school that was causing the issue above
> (doubtful but good to rule it out) I tried the above WITHOUT the
> school entry in the dictionary with the same results.
>
> Still stuck.
>
> Keyton
>
> On Jan 21, 8:13 am, Keyton Weissinger  wrote:> Oh, and I 
> have printed the import_object_dict, it has exactly what I
> > think it should... Argh!
>
> > ;-)
>
> > K
>
> > On Jan 21, 12:12 am, Martin Conte Mac Donell 
> > wrote:
>
> > > On Wed, Jan 21, 2009 at 2:35 AM, Keyton Weissinger  
> > > wrote:
>
> > > > Oh and just to re-state, this exact same code works like a champ on
> > > > import of School or Parent data (neither of which have a ManyToMany
> > > > field).
>
> > > > Keyton
>
> > > I can't reproduce this exception. Try to print import_object_dict just
> > > before "new_object =
> > > model_import_info.model_for_import.objects.create(**import_object_dict)".
>
> > > > Note that I am NOT yet trying to SAVE the Student object, just 
> > > > instantiate it.
>
> > > Actually Model.objects.create() do try to save() object. If you don't
> > > want it, call Model(**import_object_dict)
>
> > > M.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Problems with InlineModelAdmin: Date hierarchy?

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 11:36 AM, Benjamin Buch  wrote:

> I simplified the models a bit for better demonstration.
>

Thanks.  That makes it easier to spot the problem.


> Here's the model:
>
> from django.db import models
>
> class a(models.Model):
> title = models.CharField(max_length=50)
> other_model = models.ManyToManyField('b')
>
> def __unicode__(self):
> return self.title
>
> class b(models.Model):
> title = models.CharField(max_length=50)
>
> def __unicode__(self):
> return self.title
>
> Here's admin.py:
>
> from myproject.myapp.models import a, b
> from django.contrib import admin
>
> class bInline(admin.TabularInline):
> model = b
>
> class aAdmin(admin.ModelAdmin):
> inlines = [bInline]
>
> admin.site.register(b, bInline)
>

This is the problem.  You don't need to register inlines.  You register the
model ModelAdmin that includes them in  'inlines', namely:


> admin.site.register(a, aAdmin)
>

is all you need to register.  If you want an admin page for model b
independent of the inlines edited with model a, then you need to create a
regular ModelAdmin for b and register that.

Karen

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

2009-01-21 Thread Benjamin Buch
All right, I think I've got it:

1: I tried to use InlineModelAdmin with a ManyToMany-Field.
You can do this, but you've got to do it as described here I guess:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-many-to-many-intermediary-models
 
.

2: I confused the model which has the foreign key  with the other one.
If class a has a foreign key to class b, it's class a which inherits  
from TabularInline, not the other way around like I did.

3: You don't have to register Inline classes, as Karen said in her  
mail (which I got while I'm writing this one...Thanks Karen!)

Here's the working example:

from django.db import models

class a(models.Model):
 title = models.CharField(max_length=50)

 def __unicode__(self):
 return self.title

class b(models.Model):
 title = models.CharField(max_length=50)
 other_model = models.ForeignKey('a')

 def __unicode__(self):
 return self.title

admin.py:

from myproject.myapp.models import a, b
from django.contrib import admin

class bInline(admin.TabularInline):
 model = b

class aAdmin(admin.ModelAdmin):
 inlines = [bInline]

admin.site.register(a, aAdmin)

Thanks!
Benjamin


Am 21.01.2009 um 17:36 schrieb Benjamin Buch:

> I simplified the models a bit for better demonstration.
> Here's the model:
>
> from django.db import models
>
> class a(models.Model):
> title = models.CharField(max_length=50)
> other_model = models.ManyToManyField('b')
>
> def __unicode__(self):
> return self.title
>
> class b(models.Model):
> title = models.CharField(max_length=50)
>
> def __unicode__(self):
> return self.title
>
> Here's admin.py:
>
> from myproject.myapp.models import a, b
> from django.contrib import admin
>
> class bInline(admin.TabularInline):
> model = b
>
> class aAdmin(admin.ModelAdmin):
> inlines = [bInline]
>
> admin.site.register(b, bInline)
> admin.site.register(a, aAdmin)
>
> Now, when I'm trying to acess the admin in the browser, I get this  
> error thrown (Traceback):
>
> Traceback:
> File "/Library/Python/2.5/site-packages/django/core/handlers/ 
> base.py" in get_response
>   77. request.path_info)
> File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py"  
> in resolve
>   181. for pattern in self.url_patterns:
> File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py"  
> in _get_url_patterns
>   205. patterns = getattr(self.urlconf_module,  
> "urlpatterns", self.urlconf_module)
> File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py"  
> in _get_urlconf_module
>   200. self._urlconf_module =  
> __import__(self.urlconf_name, {}, {}, [''])
> File "/Users/benjamin/Code/django/myproject/../myproject/urls.py" in  
> 
>   6. admin.autodiscover()
> File "/Library/Python/2.5/site-packages/django/contrib/admin/ 
> __init__.py" in autodiscover
>   54. __import__("%s.admin" % app)
> File "/Users/benjamin/Code/django/myproject/../myproject/myapp/ 
> admin.py" in 
>   10. admin.site.register(b, bInline)
> File "/Library/Python/2.5/site-packages/django/contrib/admin/ 
> sites.py" in register
>   76. validate(admin_class, model)
> File "/Library/Python/2.5/site-packages/django/contrib/admin/ 
> validation.py" in validate
>   72. if cls.date_hierarchy:
>
> Exception Type: AttributeError at /admin/
> Exception Value: type object 'bInline' has no attribute  
> 'date_hierarchy'
>
> Thanks,
> Benjamin
>
> Am 21.01.2009 um 17:19 schrieb Karen Tracey:
>
>> On Wed, Jan 21, 2009 at 10:53 AM, Benjamin Buch   
>> wrote:
>>
>> Hi,
>>
>> I'm trying to use InlineModelAdmins, but get a strange error  
>> thrown...
>>
>> You get this error raised when you do what, exactly?  Also the full  
>> traceback might provide a clue of what is going on.
>>
>> Karen
>
> >


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

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 10:06 AM, NoviceSortOf  wrote:

>
>
> Initially my problem was getting django-registration to add/update new
> users to my
> custom designed mysite.UserProfile table.
>
> Other than that django-registration worked o.k. sent notifications and
> so on,
> but without it giving me control of our custom user profile it was
> impossible to
> move forward.
>
> I'm my discussions here though in this discussion group, it appears
> that the my questions might be better answered if I used the profiles
> component that registration was built to work with, so the questions
> and answers would have more of a standard context.
>
> * Today I updated django-registration to .06 and also installed its
> userprofiles .06 cousin.
>

You mean 0.6?  Why 0.6?  If I look here:

http://bitbucket.org/ubernostrum/django-registration/src/bc149ae50db3/CHANGELOG.txt

0.7 is where full Django 1.0 compatibility was included.  I'm assuming you
are using Django 1.0 or higher?  The error related to 'alnum_re' you mention
later looks to be the result of django-registration using a core validator
thingy -- these were all removed prior to Django 1.0, so if you got an error
on that then it sounds like you are running a later version of Django than
is supported by the version of django-registration you installed.  Rather
than trying to patch the registration code you have (which is what has led
to the syntax error you report), upgrade to a django-registration version
(0.7 or current code) that supports the level of Django you are running.

Karen

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

2009-01-21 Thread Benjamin Buch
I simplified the models a bit for better demonstration.
Here's the model:

from django.db import models

class a(models.Model):
 title = models.CharField(max_length=50)
 other_model = models.ManyToManyField('b')

 def __unicode__(self):
 return self.title

class b(models.Model):
 title = models.CharField(max_length=50)

 def __unicode__(self):
 return self.title

Here's admin.py:

from myproject.myapp.models import a, b
from django.contrib import admin

class bInline(admin.TabularInline):
 model = b

class aAdmin(admin.ModelAdmin):
 inlines = [bInline]

admin.site.register(b, bInline)
admin.site.register(a, aAdmin)

Now, when I'm trying to acess the admin in the browser, I get this  
error thrown (Traceback):

Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"  
in get_response
   77. request.path_info)
File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py"  
in resolve
   181. for pattern in self.url_patterns:
File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py"  
in _get_url_patterns
   205. patterns = getattr(self.urlconf_module, "urlpatterns",  
self.urlconf_module)
File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py"  
in _get_urlconf_module
   200. self._urlconf_module =  
__import__(self.urlconf_name, {}, {}, [''])
File "/Users/benjamin/Code/django/myproject/../myproject/urls.py" in  

   6. admin.autodiscover()
File "/Library/Python/2.5/site-packages/django/contrib/admin/ 
__init__.py" in autodiscover
   54. __import__("%s.admin" % app)
File "/Users/benjamin/Code/django/myproject/../myproject/myapp/ 
admin.py" in 
   10. admin.site.register(b, bInline)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py"  
in register
   76. validate(admin_class, model)
File "/Library/Python/2.5/site-packages/django/contrib/admin/ 
validation.py" in validate
   72. if cls.date_hierarchy:

Exception Type: AttributeError at /admin/
Exception Value: type object 'bInline' has no attribute 'date_hierarchy'

Thanks,
Benjamin

Am 21.01.2009 um 17:19 schrieb Karen Tracey:

> On Wed, Jan 21, 2009 at 10:53 AM, Benjamin Buch   
> wrote:
>
> Hi,
>
> I'm trying to use InlineModelAdmins, but get a strange error thrown...
>
> You get this error raised when you do what, exactly?  Also the full  
> traceback might provide a clue of what is going on.
>
> Karen

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

2009-01-21 Thread NoviceSortOf


update to the above -  running manage.py syncdb DID
create the mysite.myproject.userprofile
with all the userprofile.models base fields included.

on completion of the registration form though i still get The
following error

* Request URL:  http://www.rareasianbooks.com/accounts/register/
  invalid syntax (views.py, line 87)
  Exception Location:   /usr/lib/python2.3/site-packages/userprofile/
urls/en.py in ?, line 3


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

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 10:53 AM, Benjamin Buch  wrote:

>
> Hi,
>
> I'm trying to use InlineModelAdmins, but get a strange error thrown...
>

You get this error raised when you do what, exactly?  Also the full
traceback might provide a clue of what is going on.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: TypeError: Related Field has invalid lookup: icontains

2009-01-21 Thread Karen Tracey
On Wed, Jan 21, 2009 at 10:21 AM, Alessandro Ronchi <
alessandro.ron...@soasi.com> wrote:

>
> When one tries to make a search in admin with a model table he gets this
> error:
>
> TypeError: Related Field has invalid lookup: icontains
>
> is there anyway to solve it and make it returns nothings instead of 500
> error?
>

Some details of the model and admin defs in use here would help someone help
you.

Karen

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



Flatpages

2009-01-21 Thread Gordon

Hi
I've just started to use Django and have been using the flatpages
plugin for serving static pages. Does anyone know how or a plugin that
will generate a content's tree from the URLs?
e.g.
/staff/
/staff/management/
/staff/clerical/
/staff/technical/
/projects/
/projects/ace/
/projects/django/
/projects/ruby/

what I'm looking for is someway of automatically traversing the URLS
for all the flatpages on my site so that I can generate a table of
contents relative to where I am on the site.

Regards
Gordon

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



Problems with InlineModelAdmin: Date hierarchy?

2009-01-21 Thread Benjamin Buch

Hi,

I'm trying to use InlineModelAdmins, but get a strange error thrown...

Here's admin.py:

from mysite.showroom.models import Project, ProjectImage, Client,  
Service
from django.contrib import admin
from filebrowser import fb_settings

class ProjectImageInline(admin.TabularInline):
 model = ProjectImage
 class Media:
 js = [fb_settings.URL_FILEBROWSER_MEDIA + '/js/ 
AddFileBrowser.js']

class ProjectAdmin(admin.ModelAdmin):
 inlines = [ProjectImageInline,]
 prepopulated_fields = {'slug': ('title',)}
 class Media:
 js = [fb_settings.URL_FILEBROWSER_MEDIA + '/js/ 
AddFileBrowser.js']

class ClientAdmin(admin.ModelAdmin):
 prepopulated_fields = {'slug': ('name',)}
 class Media:
 js = [fb_settings.URL_FILEBROWSER_MEDIA + '/js/ 
AddFileBrowser.js']

class ServiceAdmin(admin.ModelAdmin):
 pass

admin.site.register(ProjectImage, ProjectImageInline)
admin.site.register(Project, ProjectAdmin)
admin.site.register(Client, ClientAdmin)
admin.site.register(Service, ServiceAdmin)

The error says

type object 'ProjectImageInline' has no attribute 'date_hierarchy'

What is this about a 'date hirarchy'?

The model ProjectImage has not date:

class ProjectImage(models.Model):
 """One or more images for the project model"""
 title = models.CharField(max_length=100, help_text='The title is  
also used as the alt tag of the image.')
 image = FileBrowseField(max_length=250,
 initial_directory='/showroom/projects/',
 extensions_allowed=['.jpg', '.jpeg',  
'.gif', '.png', '.tif', '.tiff'])

 def __unicode__(self):
 return self.title

What could be wrong here?


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



Re: httpresponseredirect

2009-01-21 Thread saved...@gmail.com

Hello Malcolm,
Thanks for your response.  I have thought very carefully before
responding to your email.  In no way was I ignoring your previous
posts, I was trying to take the easy way, rather than the correct
way.  Furthermore, I really don't know how.
I have spent hours trying to look it up, but to no avail.
Would I place the print statements after each line of the view?
Regards,
Ken

On Jan 20, 10:13 pm, Malcolm Tredinnick 
wrote:
> On Tue, 2009-01-20 at 17:51 -0800, saved...@gmail.com wrote:
> > Hello Malcolm,
>
> > Thanks for you reply.  Unfortunately, there is no 404 error message.
> > For some reason (beyond the scope of my django knowledge), the view
> > just won't redirect. The scope of my django knowledge.  Here are my
> > simple urls, if that is of any assistance.
>
> > urlpatterns = patterns('django.views.generic.list_detail',
> >     (r'^$', 'object_list', info_dict),
> >     (r'^(?P\d+)/answer/$', 'object_detail', info_dict),
> > )
> > urlpatterns += patterns('',
> >     (r'^(?P\d+)/answer/$',
> > 'languagen.questions.views.answer'),
> > )
>
> > I'm not sure on how I should
>
> Stop trying to debug this through the browser and be prepared to debug
> the Python code. I've suggested twice now (this is the third time) that
> you put some print statements in your code to show the values of various
> variables.
>
> If you're running with Django's runserver, they will print to the
> console. If you're serving your pages through something like Apache,
> print to sys.stderr and the output will go the http error log.
>
> Attempting to debug this in the browser is like trying to bake a cake
> whilst being at the other end of the house from the kitchen. You have to
> get closer to the problem. Use the browser to trigger the problem (i.e.
> request the page), but it's your Python code that is behaving
> erratically, so debug that, not the browser output.
>
> Put in a print statement to work out which branch of the "if" test is
> being taken. Print out the value of q.next.get_absolute_url(). Print out
> anything else that might help you decide which lines of code are being
> executed. This is very normal debugging technique.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Best Practices for debugging URL problems

2009-01-21 Thread Adam Nelson

I recently had what is a common issue for many Django developers:

"No module named urls"

What turned out to be the issue is that I had deleted one of the
urls.py files accidentally because I deleted an app that I thought I
was no longer being used but was in fact being called by the top level
urls.py.

Is there any good way to diagnose this class of problems?  There is
nowhere either through the interactive debugger or the debugging page
that would have shown this issue because the url error is thrown with
the first call to {{ url }}.  In the end I had to revert to previous
revisions and just find out which one caused the problem by trial and
error.

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



TypeError: Related Field has invalid lookup: icontains

2009-01-21 Thread Alessandro Ronchi

When one tries to make a search in admin with a model table he gets this error:

TypeError: Related Field has invalid lookup: icontains

is there anyway to solve it and make it returns nothings instead of 500 error?

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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

2009-01-21 Thread Erik S.

On Jan 21, 3:52 am, Gath  wrote:
> Guys,
>
> Its seems the best way to do templates in Django is via plain html and
> css, but am having a problem in understanding css easily, can someone
> recommend some nice material/site on css i can read, i mean step by
> step till complex stuff.
>
> Paul

As said before, alistapart.com is excellent. One of their recent
articles on web education mentioned another set of tutorials at
http://www.opera.com/company/education/curriculum/

They look like a good starting point.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Pickling a dictionary into a PostgreSQL database?

2009-01-21 Thread Torsten Bronger

Hallöchen!

teth writes:

> Using str(pickle.dumps()) and the pickle.loads(str()) works
> perfectly.

Unfortunately, I had to realise that it is not so simple due to
.  Now it use the following
functions:

def ascii_pickle(python_object):
u"""Converts an arbitrary Python object to an ASCII-only string to be
written to the database.  Unfortunately, even protocol 0 of Python's
``pickle`` module may emit non-ASCII characters, see
.  However, this is dangerous since the
database expects Unicode strings and can't decode such octet strings.
Therefore, this routine does another encoding step using base64.  This
makes debugging slightly more difficult, but there we go.

:Parameters:
  - `python_object`: the object instance to be pickled

:type python_object: object

:Return:
  the ASCII-only string representing the object instance

:rtype: str
"""
# FixMe: Maybe instead of base64 another encoder should be used that keeps
# the string largely readable.
return base64.b64encode(pickle.dumps(python_object, protocol=2))


def ascii_unpickle(string):
u"""This is the inverse function of `ascii_pickle`.

:Parameters:
  - `string`: the ASCII-only database string to be unpickled

:type string: str

:Return:
  the original Python object instance that was represented by the string

:rtype: object
"""
return pickle.loads(base64.b64decode(string))

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de


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



Ongoing problems with django-registration installation.

2009-01-21 Thread NoviceSortOf


Initially my problem was getting django-registration to add/update new
users to my
custom designed mysite.UserProfile table.

Other than that django-registration worked o.k. sent notifications and
so on,
but without it giving me control of our custom user profile it was
impossible to
move forward.

I'm my discussions here though in this discussion group, it appears
that the my questions might be better answered if I used the profiles
component that registration was built to work with, so the questions
and answers would have more of a standard context.

* Today I updated django-registration to .06 and also installed its
userprofiles .06 cousin.

* Modifications to mysite.myproject.models.py and mysite.settings were
made
  closer to online examples to make my installation more standard for
the sake
  of discussion.


*** I though have the following problems.

* after running manage.py the new table that should be created from
  from the userprofile.models imported from BaseProfile does not
  appear in my phpPgAdmin (postgreSQL) browser even after
  refresh and reboot of the server.

* when attempting a registration i get the following error
  global name 'alnum_re' is not defined

  so i go to registration.views.py and
  rem out that...
  #from django.core.validators import alnum_re

  and add:

  import
  alnum_re = re.compile(r'^\w+$') # regexp. from jamesodo in #django

* now when I attempt registration i get
  Request URL:  http://www.rareasianbooks.com/accounts/register/
  invalid syntax (views.py, line 87)
  Exception Location:   /usr/lib/python2.3/site-packages/userprofile/
urls/en.py in ?, line 3


Any suggestions would be appreciated.

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



Re: ManyToManyField in both models

2009-01-21 Thread Evgeniy Ivanov (powerfox)

Hi,

I've returned to the problem and noticed, that recipe described in the
docs is a kind of wrong: intermediary model is just a kind of M2M (I
mean multiselection) since you have select widgets for inline model
and to make real m2m editing have to add more inlines.

Custom model can help, but this hack is ugly too:

==
class Groups(ModelForm):
users = forms.ModelMultipleChoiceField(queryset=Users.objects.all
(),required=False)
 
widget=admin.widgets.FilteredSelectMultiple(_("Users"), False))
class Meta:
model = Groups
==

Now you have to add custom saving! It's wrong IMHO.
I think it would be much better to specify both M2M fields with the
same table name.

On Jan 16, 7:26 pm, "Evgeniy Ivanov (powerfox)"
 wrote:
> On Jan 16, 12:47 pm, Malcolm Tredinnick 
> wrote:
>
>
>
> > On Fri, 2009-01-16 at 01:33 -0800, Evgeniy Ivanov (powerfox) wrote:
>
> > > On Jan 16, 5:16 am, Malcolm Tredinnick 
> > > wrote:
>
> > [...]
>
> > > > You need to go back and look at your original problem. You wantedforms
> > > > with multiselect fields forbothforms. So the real question is "how do
> > > > you do that". I suspect the answer is that you have to manually
> > > > construct one of theforms(which you can write a helper function to do
> > > > if you need this in a lot of projects, or, if this only happens for one
> > > > model, just write a single form class).
>
> > > Thanks, will try. Current sollution (create table manually and specify
> > > name/columns) is neither right or cute.
>
> > I think part of the conceptual problem here is that you're trying to
> > solve your problem by working on the model definition. But the problem
> > is a form issue. It's about presentation, not data storage. So approach
> > it from that end.
>
> Malcolm, thanks for your help.
> Today I was reading docs for some another things (filtering, etc) and
> found clear explanation of the thing we 
> discuss:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RESTful PUT request

2009-01-21 Thread junker37

I can't seem to get django to handle a PUT request.

I've googled quited a bit and there seems to be some RESTful
interfaces available for django, however, I can't seem to get any of
them to work because the PUT request gets a 301 direct to a GET
request.

I created my own middleware where I can see it getting the PUT
request, however, I can not find where in the request I can get at the
PUT data.

Please let me know what I am doing wrong.  Currently I am running with
the built-in web server in django.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Convert iso-8859-1 queryset to utf-8

2009-01-21 Thread bruno desthuilliers

On 21 jan, 12:55, Anders  wrote:
> My django site uses iso-8859-1 as default output of all the web pages
> (due to ssi intergration with other iso-8859-1 pages).
>
> So I have set:
> DEFAULT_CHARSET = 'iso-8859-1'
> FILE_CHARSET = 'iso-8859-1'
>
> and this works fine for alle the pages I serve.
>
> But now I have to serve an xml output for use with actionscript in a
> Flash. This xml should be UTF-8 encoded.
>
> Is there som way I can convert the queryset to utf-8


Admin list exclusions

2009-01-21 Thread django_fo...@codechimp.net

I have a class called Entry that has a one-to-many relationship with
itself like:

class Entry(models.Model):
title = models.CharField(max_length=255)
body = models.TextField()
author = models.ForeignKey(User)
date_published = models.DateTimeField()
parent = models.ForeignKey('self',null=True,blank=True)

When I go to the Admin page, I would like to exclude Entries that have
a parent set, I.E. Entries that have parents should not show up in the
list.  I have read through the Admin pages and the Meta pages several
times, and nothing has jumped out at me on how to do this.  Its
probably there, it just didn't register.

Can someone please lend me a hand and point me in the correct location?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: AUTH_PROFILE_MODULE confusion

2009-01-21 Thread NoviceSortOf


creecode:

we cross posted yesterday. i tried your suggestion about using signal
but
could not get it to add records to the designated user profile.

for now i've reinstalled registration upgrading to .06 as well as the
matching
userprofile profiles .06

Still am encountering hours of problems getting it to work but will
post
those issues in another topic, for now. I 'm hoping by standardizing
on django-registration and django-profiles can perhaps get this to
work.



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



Re: I don't even know where to begin writing this template-tags

2009-01-21 Thread bruno desthuilliers

On 21 jan, 14:17, Puneet Madaan  wrote:
> try this... its complete tutorial which include template tags too.. will
> help you to understand

Thanks but as far as I'm concerned, I've written far enough template
tags to not have a use for an introductory tutorial to Django's
templates !-)

And FWIW, I don't think the OP's problem is with template tags by
themselves, but with the parser function for lot of optional keyword
arguments.

(snip)

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



Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger

More information...

I stuck the following into my code at the same place the other code is
bombing. I did this just to make sure that I wasn't getting anything
weird in the dictionary here that I wasn't getting in the command
line.

mydict = {'city': u'Columbus', 'first_name': u'Miles', 'last_name':
u'Yeung', 'school': import_object_dict['school'], 'zip': 43215.0,
'title': u'Mr.', 'dob': '1956-12-29', 'phone_primary':
u'614-468-5940', 'state': u'OH', 'address': u'142, Quilly Lane',
'type': u'Student', 'email': u'miles.l.ye...@spambob.com'}

new_object = Student(**mydict)

Same exact error as before. It's almost as if the Student object is
behaving differently within the context that it does within manage.py
shell.

Just in case it was the school that was causing the issue above
(doubtful but good to rule it out) I tried the above WITHOUT the
school entry in the dictionary with the same results.

Still stuck.

Keyton


On Jan 21, 8:13 am, Keyton Weissinger  wrote:
> Oh, and I have printed the import_object_dict, it has exactly what I
> think it should... Argh!
>
> ;-)
>
> K
>
> On Jan 21, 12:12 am, Martin Conte Mac Donell 
> wrote:
>
> > On Wed, Jan 21, 2009 at 2:35 AM, Keyton Weissinger  wrote:
>
> > > Oh and just to re-state, this exact same code works like a champ on
> > > import of School or Parent data (neither of which have a ManyToMany
> > > field).
>
> > > Keyton
>
> > I can't reproduce this exception. Try to print import_object_dict just
> > before "new_object =
> > model_import_info.model_for_import.objects.create(**import_object_dict)".
>
> > > Note that I am NOT yet trying to SAVE the Student object, just 
> > > instantiate it.
>
> > Actually Model.objects.create() do try to save() object. If you don't
> > want it, call Model(**import_object_dict)
>
> > M.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



install django on a shared host, with fastcgi

2009-01-21 Thread codediscuss.com

Hello,

I'm new to python, apache and django. I'm trying to install django on
my shared host (hostmonster). I searched for some tutorials and
followed them but no luck.

Here is the page I get when I try to visit my site:

Not Found

The requested URL /home/pri*/public_html/django.fcgi/visual**/
was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request


pri is my account name.
django.fcgi is created by me following some tutorials
Visual* is my web site name, which is a sub folder on the shared
host.

I need help to step into the world of django and python!

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



Convert iso-8859-1 queryset to utf-8

2009-01-21 Thread Anders

My django site uses iso-8859-1 as default output of all the web pages
(due to ssi intergration with other iso-8859-1 pages).

So I have set:
DEFAULT_CHARSET = 'iso-8859-1'
FILE_CHARSET = 'iso-8859-1'

and this works fine for alle the pages I serve.

But now I have to serve an xml output for use with actionscript in a
Flash. This xml should be UTF-8 encoded.

Is there som way I can convert the queryset to utf-8 so that this will
work? Or can I convert each string as I output it in the template
(yeah, I use the template to create xml - not good, I know).

In addition the render_to_response uses the default charset, is is
possible to override this default and use UTF-8?

Thnx
Anders

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: I don't even know where to begin writing this template-tags

2009-01-21 Thread Puneet Madaan
try this... its complete tutorial which include template tags too.. will
help you to understand

http://www.webmonkey.com/tutorial/Use_Templates_in_Django

greetings,
Puneet

On Wed, Jan 21, 2009 at 2:13 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
> On 21 jan, 00:32, Andrew Ingram  wrote:
> > I'm building a simple banner/promotion system for a site. Aside from a
> > few date-related fields, a banner consists of:
> > - an image
> > - a target url
> > - the image dimensions
> > - some tags (using django-tagging)
> >
> > I'm trying to figure out how to build a template-tag to allow me to
> > display a number of banners based on their properties.
> >
> > i.e
> >
> > {% get-banners max-width='450' max-height='100' min-height='50'
> > match-any='foo, bar' match-all='homepage' limit='2' as banners %}
> >
> > {% for banner in banners %}
> >   
> > {% endfor %}
> >
> > The only way I can see to do this is to write a hideous parser function,
> > made worse by the fact that almost all of the arguments are optional.
>
> This may help:
> http://www.djangosnippets.org/snippets/1293/
>
>
> >
>


-- 
If you spin an oriental man, does he become disoriented?
(-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu

is der net süß » ε(●̮̮̃•̃)з
-PM

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

2009-01-21 Thread Iqbal Abdullah

Hi Malcolm,

Thank you for the tip!
I see now that in my particular code example above, the idea of using
session id and manually setting it through the request can only work
if the session id itself doesn't change after i've set it into the
response. From your explaination, there is no guarantee of this
happening, so in the code above I've to make sure that the timing of
setting it into the response must be the last action before passing it
to render_to_response()

Please point out if my logic is mistaken.

- i

On Jan 21, 9:42 pm, Malcolm Tredinnick 
wrote:
> On Wed, 2009-01-21 at 04:11 -0800, Iqbal Abdullah wrote:
> > Hi guys,
>
> > I need to support some browsers which doesn't handle cookies, so I
> > have followed the snippet here to manually get session ids from the
> > request:
> >http://www.djangosnippets.org/snippets/460/
>
> > and positioned the new middleware before the SessionMiddleware in the
> > settings.py file.
>
> > I did an experiment with a view, which is something like this:
>
> > 16 def test(request):
> > 17
> > 20     ses_key_1 = request.session.session_key
> > 24
> > 25     response_dict = {'test_01': "TEST01",
> > 27                      'test_03': request.session.session_key,
> > 28                      'sid': request.session.session_key,
> > 29                      'sid_key': settings.SESSION_COOKIE_NAME ,
> > 30                      }
> > 31     request.session['test'] = "test"
> > 32     ses_key_2 = request.session.session_key
> > 35
> > 36     return render_to_response('test.html', RequestContext(request,
> > dict=response_dict))
>
> > and found out, that ses_key_1 and ses_key_2 are different session ids
> > when the browser (which doesn't handle cookies) accesses it. Can
> > anyone explain to me why a new session id was made when there is
> > already one for the request?
>
> One situation where this will happen is when a user logs in. The session
> id is changed (although the session contents are retained). This is to
> prevent one class of security attacks wherein somebody grabs a session
> ID from an anonymous user and it remains valid after that user has
> logged in (at which point their whole interaction may have switched to
> HTTPS, so snooping the session id is harder for the attacker). Since it
> doesn't hurt to change the session id, we do it for everybody when a
> login occurs.
>
> Similarly, if a user ever logs out, their entire session is flushed and
> a new session id will be created.
>
> Other code *may* call the cycle_key() method in the session backends,
> but those are the only situations out-of-the-box that will do so.
>
> The point is, you have to be able to handle the session id changing. It
> does not identify the session to Django itself (on the server side). The
> session object does that and changing the id within the Python object is
> valid. The session id is used by the client side to identify the
> particular session object for the next request it makes (and that won't
> change outside of a particular user's request).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Login during registration

2009-01-21 Thread Alastair Campbell

Thanks Bruno,

Looks like out emails crossed in the ether!

The error message didn't really help, it was failing at the auth
stage, which doesn't help debugging. My colleague had to add debug
code to Django auth to figure out the issue.

I was just surprised that @login_required didn't check for is_active.

Thanks for the offer,

-Alastair

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



Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger

Oh, and I have printed the import_object_dict, it has exactly what I
think it should... Argh!

;-)

K

On Jan 21, 12:12 am, Martin Conte Mac Donell 
wrote:
> On Wed, Jan 21, 2009 at 2:35 AM, Keyton Weissinger  wrote:
>
> > Oh and just to re-state, this exact same code works like a champ on
> > import of School or Parent data (neither of which have a ManyToMany
> > field).
>
> > Keyton
>
> I can't reproduce this exception. Try to print import_object_dict just
> before "new_object =
> model_import_info.model_for_import.objects.create(**import_object_dict)".
>
> > Note that I am NOT yet trying to SAVE the Student object, just instantiate 
> > it.
>
> Actually Model.objects.create() do try to save() object. If you don't
> want it, call Model(**import_object_dict)
>
> M.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: I don't even know where to begin writing this template-tags

2009-01-21 Thread bruno desthuilliers

On 21 jan, 00:32, Andrew Ingram  wrote:
> I'm building a simple banner/promotion system for a site. Aside from a
> few date-related fields, a banner consists of:
> - an image
> - a target url
> - the image dimensions
> - some tags (using django-tagging)
>
> I'm trying to figure out how to build a template-tag to allow me to
> display a number of banners based on their properties.
>
> i.e
>
> {% get-banners max-width='450' max-height='100' min-height='50'
> match-any='foo, bar' match-all='homepage' limit='2' as banners %}
>
> {% for banner in banners %}
>   
> {% endfor %}
>
> The only way I can see to do this is to write a hideous parser function,
> made worse by the fact that almost all of the arguments are optional.

This may help:
http://www.djangosnippets.org/snippets/1293/


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



Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger

Hi Martin,

Thanks for the suggestion. I've tried it both ways to no avail.

All,

Here's the code from django.db.models.base.py (in the Model.__init__)
where the trouble seems to start (around line 224):

# Now we're left with the unprocessed fields that *must* come
from
# keywords, or default.
print kwargs
for field in fields_iter:
print field.name
rel_obj = None
if kwargs:
if isinstance(field.rel, ManyToOneRel):
try:
# Assume object instance was passed in.
rel_obj = kwargs.pop(field.name)
except KeyError:
try:
# Object instance wasn't passed in -- must
be an ID.
val = kwargs.pop(field.attname)
except KeyError:
val = field.get_default()
else:
# Object instance was passed in. Special case:
You can
# pass in "None" for related objects if it's
allowed.
if rel_obj is None and field.null:
val = None
else:
val = kwargs.pop(field.attname, field.get_default
())
else:
val = field.get_default()
print field.name + ' default value ' + `val`
# If we got passed a related instance, set it using the
field.name
# instead of field.attname (e.g. "user" instead of
"user_id") so
# that the object gets properly cached (and type checked)
by the
# RelatedObjectDescriptor.
if rel_obj:
setattr(self, field.name, rel_obj)
else:
setattr(self, field.attname, val)

If I send in kwargs (and I've confirmed that it's getting what I think
it's getting) it goes merrily along until it gets to my ManyToMany
field at which time, it tries (using the last line above) to call
setattr(self, field.attname, val) with None (the default value for the
field). This triggers a call to the __set__ in related.py which in
turn tries to call the __get__ to find my related object (diligently)
and whammo.

The thing's doing exactly what it's coded to do.

My question is this:

If I'm in the init for this model and the field's default value is
None, why is the code ever trying to go get the related object? The
code should know it's not there. Shouldn't there be a check somewhere
in the stack to prevent the call to related.py in this case (in
__init__ when I don't actually have a related object)?

And why (the HECK) does this work just fine on the command line? That
points to my code, but all my code is doing is generating the kwargs
and feeding it into this process.

Very frustrating...

Thanks for whatever time anyone has on all of this...

Keyton


On Jan 21, 12:12 am, Martin Conte Mac Donell 
wrote:
> On Wed, Jan 21, 2009 at 2:35 AM, Keyton Weissinger  wrote:
>
> > Oh and just to re-state, this exact same code works like a champ on
> > import of School or Parent data (neither of which have a ManyToMany
> > field).
>
> > Keyton
>
> I can't reproduce this exception. Try to print import_object_dict just
> before "new_object =
> model_import_info.model_for_import.objects.create(**import_object_dict)".
>
> > Note that I am NOT yet trying to SAVE the Student object, just instantiate 
> > it.
>
> Actually Model.objects.create() do try to save() object. If you don't
> want it, call Model(**import_object_dict)
>
> M.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Q about cache backend for sessions and clustering

2009-01-21 Thread shi shaozhong
Dear Andrew Ingram,

What you are doing is very interesting.   I am looking into JSON at client
side and Python at server side.

I am particularly interested in how to access session objects in JSON and
Python, so that both sides know the same sessions to handle.

I am using Windows IIS.

Is there a straightforward way to programmatically access session, session
id?  Is there is a concise and straightforward instruction on this and
working demo scripts in JSON and Python?

Regards.

David

2009/1/19 Andrew Ingram 

>
> The new cache backend for sessions in 1.1 looks very promising, I just
> have a quick question.
>
> When running in a cluster, we need to make sure that if a user hops from
> one server to another that the session data remains in sync between the
> requests. I know that with the db backend the response for the first
> request won't be returned until the session data has been written
> successfully - which means there are no sync issues. Is the same true of
> the memcached-based backend? i.e is the response delayed until there is
> some confirmation that the cache has been written to?
>
> Regards,
> Andrew Ingram
>
> >
>

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

2009-01-21 Thread bruno desthuilliers

On 21 jan, 00:27, AlastairC  wrote:
> Hi everyone,
>
> I'm trying to create a registration process that includes membership
> details and a paypal bit (for a non-profit org), and use the
> registration app as the first step.
>
> However, I'd like to log people in when they 'activate' (click the
> link in the email and return to the site). I've gotten stuck, although
> I can log people in by sub-classing the form, that's *before* they've
> activated. (Sidenote: it seems wrong that I can log someone in
> manually even though they aren't active?)
>
> I'm currently getting a "NotImplementedError", with this 
> code:http://dpaste.com/111247/

Please post the whole traceback (or copy/paste it to dpaste.com). We
don't necessarily want to setup a whole django project just to test
your code !-)



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

2009-01-21 Thread Alastair Campbell

To answer my own question... I got some help at work, and established
that the login was failing because it is using the hashed password,
not the raw one.

That means that there is no way for me to use the activation stage to
log the person in (apart from asking them for their details again). I
can understand that from a security point of view, but that means my
best bet for logging them in is to do so before they are activated.

Therefore I'll log them in immediately and use activation just to make
them active.

The impact is that I can't use @login_required for many of my views,
I'll have to use the passes test check:
http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.decorators.user_passes_test

Hopefully if someone finds themselves in the same position, this will
help... this is probably a better solution longer term, as I'll be
using group permissions as well.

-Alastair

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

2009-01-21 Thread shi shaozhong
Hello, Guyon Moree,

What you are doing is very interesting.   I am also looking into JSON at
client side and Python at server side.

I am particularly interested in how to access session objects in JSON and
Python, so that both sides know the same sessions to handle.

I am using Windows IIS.

Is there a straightforward way to programmatically access session, session
id?  Is there is a concise and straightforward instruction on this and
working demo scripts in JSON and Python?

Regards.

David

2009/1/21 Guyon Morée 

>
> Hi,
>
> I've built a bunch of 'normal' views rendering templates and
> processing POST's.
>
> Now, I'd like to build a API for my site, based on JSON. When building
> this API I noticed most of the views are 99% the same, except for
> outputting JSON instead of HTML templates.
>
> Any ideas how I could reduce duplication of code in these cases?
>
>
> --
> Guyon Moree
> http://gumuz.nl/
> >
>

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

2009-01-21 Thread bruno desthuilliers

On 20 jan, 23:26, bfrederi  wrote:
> I have a general question about creating a response in Django.
>
> If I am creating a response using the return
> django.shortcuts.render_to_response function:
>
> return render_to_response(
>     'template_name.html',
>     {'huge_dictionary_of_data': huge_dictionary_of_data,},
>     RequestContext(request, {}),
> )
>
> And the data that I am using to render the template with is 2Mb in
> size or more, is it more taxing on Django (Apache-mod_python) than
> just taking the parts that I need from that giant 2Mb dictionary of
> data and rendering it that way?
>
> I just wanted to know if it would be a significant difference if I
> passed the whole dictionary versus just the parts I need to
> render_to_response?

If it's a normal Python dict, then it doesn't make any difference (at
least wrt/ resource usage), since Python doesn't copy objects passed
as arguments to functions (FWIW, Python never copy anything unless
explicitely asked for).

But I stronly suggest you find a way to avoid loading 2mb dataset if
you only need a subpart of it...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sessions being written twice?

2009-01-21 Thread shi shaozhong
Hello.

I am using Windows IIS and Python.  I am very much interested in how to
access session objects, session ids, so that I probably can use session ids
to create temporary folders for users.   Any concise instructions on this
and any demo scripts available for me to understand how to programmatically
use session objects in Python?

Regards.

David

2009/1/21 Malcolm Tredinnick 

>
> On Wed, 2009-01-21 at 04:11 -0800, Iqbal Abdullah wrote:
> > Hi guys,
> >
> > I need to support some browsers which doesn't handle cookies, so I
> > have followed the snippet here to manually get session ids from the
> > request:
> > http://www.djangosnippets.org/snippets/460/
> >
> > and positioned the new middleware before the SessionMiddleware in the
> > settings.py file.
> >
> > I did an experiment with a view, which is something like this:
> >
> > 16 def test(request):
> > 17
> > 20 ses_key_1 = request.session.session_key
> > 24
> > 25 response_dict = {'test_01': "TEST01",
> > 27  'test_03': request.session.session_key,
> > 28  'sid': request.session.session_key,
> > 29  'sid_key': settings.SESSION_COOKIE_NAME ,
> > 30  }
> > 31 request.session['test'] = "test"
> > 32 ses_key_2 = request.session.session_key
> > 35
> > 36 return render_to_response('test.html', RequestContext(request,
> > dict=response_dict))
> >
> > and found out, that ses_key_1 and ses_key_2 are different session ids
> > when the browser (which doesn't handle cookies) accesses it. Can
> > anyone explain to me why a new session id was made when there is
> > already one for the request?
>
> One situation where this will happen is when a user logs in. The session
> id is changed (although the session contents are retained). This is to
> prevent one class of security attacks wherein somebody grabs a session
> ID from an anonymous user and it remains valid after that user has
> logged in (at which point their whole interaction may have switched to
> HTTPS, so snooping the session id is harder for the attacker). Since it
> doesn't hurt to change the session id, we do it for everybody when a
> login occurs.
>
> Similarly, if a user ever logs out, their entire session is flushed and
> a new session id will be created.
>
> Other code *may* call the cycle_key() method in the session backends,
> but those are the only situations out-of-the-box that will do so.
>
> The point is, you have to be able to handle the session id changing. It
> does not identify the session to Django itself (on the server side). The
> session object does that and changing the id within the Python object is
> valid. The session id is used by the client side to identify the
> particular session object for the next request it makes (and that won't
> change outside of a particular user's request).
>
> Regards,
> Malcolm
>
>
>
> >
>

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

2009-01-21 Thread Malcolm Tredinnick

On Wed, 2009-01-21 at 04:11 -0800, Iqbal Abdullah wrote:
> Hi guys,
> 
> I need to support some browsers which doesn't handle cookies, so I
> have followed the snippet here to manually get session ids from the
> request:
> http://www.djangosnippets.org/snippets/460/
> 
> and positioned the new middleware before the SessionMiddleware in the
> settings.py file.
> 
> I did an experiment with a view, which is something like this:
> 
> 16 def test(request):
> 17
> 20 ses_key_1 = request.session.session_key
> 24
> 25 response_dict = {'test_01': "TEST01",
> 27  'test_03': request.session.session_key,
> 28  'sid': request.session.session_key,
> 29  'sid_key': settings.SESSION_COOKIE_NAME ,
> 30  }
> 31 request.session['test'] = "test"
> 32 ses_key_2 = request.session.session_key
> 35
> 36 return render_to_response('test.html', RequestContext(request,
> dict=response_dict))
> 
> and found out, that ses_key_1 and ses_key_2 are different session ids
> when the browser (which doesn't handle cookies) accesses it. Can
> anyone explain to me why a new session id was made when there is
> already one for the request?

One situation where this will happen is when a user logs in. The session
id is changed (although the session contents are retained). This is to
prevent one class of security attacks wherein somebody grabs a session
ID from an anonymous user and it remains valid after that user has
logged in (at which point their whole interaction may have switched to
HTTPS, so snooping the session id is harder for the attacker). Since it
doesn't hurt to change the session id, we do it for everybody when a
login occurs.

Similarly, if a user ever logs out, their entire session is flushed and
a new session id will be created.

Other code *may* call the cycle_key() method in the session backends,
but those are the only situations out-of-the-box that will do so.

The point is, you have to be able to handle the session id changing. It
does not identify the session to Django itself (on the server side). The
session object does that and changing the id within the Python object is
valid. The session id is used by the client side to identify the
particular session object for the next request it makes (and that won't
change outside of a particular user's request).

Regards,
Malcolm



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

2009-01-21 Thread Kenneth Gonsalves

On Wednesday 21 Jan 2009 3:24:22 pm bruno desthuilliers wrote:
> The references are on the w3c site - but they are, well, references. A
> good starting point for actually learning how to use css is A List
> Apart:
>
> http://alistapart.com/

that is not a starting point - that is nirvana

-- 
regards
KG
http://lawgon.livejournal.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
-~--~~~~--~~--~--~---



Sessions being written twice?

2009-01-21 Thread Iqbal Abdullah

Hi guys,

I need to support some browsers which doesn't handle cookies, so I
have followed the snippet here to manually get session ids from the
request:
http://www.djangosnippets.org/snippets/460/

and positioned the new middleware before the SessionMiddleware in the
settings.py file.

I did an experiment with a view, which is something like this:

16 def test(request):
17
20 ses_key_1 = request.session.session_key
24
25 response_dict = {'test_01': "TEST01",
27  'test_03': request.session.session_key,
28  'sid': request.session.session_key,
29  'sid_key': settings.SESSION_COOKIE_NAME ,
30  }
31 request.session['test'] = "test"
32 ses_key_2 = request.session.session_key
35
36 return render_to_response('test.html', RequestContext(request,
dict=response_dict))

and found out, that ses_key_1 and ses_key_2 are different session ids
when the browser (which doesn't handle cookies) accesses it. Can
anyone explain to me why a new session id was made when there is
already one for the request?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 may i write Recursion for this

2009-01-21 Thread Praveen

Hi Malcolm

Thanks for reply.

whatever you said i do agree.

I do not have huge dataset. whatevere i have given the records in table
(See earlier message of this discussion) that is fixed not going to be
expand.
as you said i wrote Level3 inside Level2

def latest_listing(request):
listing_result = Listing_channels.objects.all().filter
(list_channel='Sight Seeing')
for n in listing_result:
   print "N1.id : ", n.id
   if n.list_channel:
   qset=(
   Q(list_parent_id = n.id)
   )
level2 = Listing_channels.objects.filter(qset).distinct()
for n in level2:
   print "N2.id : ", n.id
   if n.list_channel:
   qset=(
   Q(list_parent_id = n.id)
   )
   print "QSET : ", qset
   level3 = Listing_channels.objects.filter(qset).distinct
()
   for n in level3:
print "N3.id : ", n.id
if n.list_channel:
qset=(Q(list_parent_id = n.id))

level4 = Listing_channels.objects.filter(qset).distinct()
#sight_result = Listing_channels.objects.all().filter
(list_parent_id=6)
print "Listing Result : ", listing_result
print "Level2 : ", level2
print "Level3 : ", level3
print "Level4 : ", level4
#print "Sight Result : ", sight_result
#return render_to_response('sight_seeing.html',
{'listing_result':listing_result,'level2':level2,'level3':level3})
return render_to_response('sight_seeing.html',
{'listing_result':listing_result})

But even though my 'level3' list is empty.

here is my output

N1.id :  2
N2.id :  6
QSET :  (AND: ('list_parent_id', 6L))
N3.id :  12
N3.id :  13
N3.id :  14
N2.id :  7
QSET :  (AND: ('list_parent_id', 7L))
N2.id :  8
QSET :  (AND: ('list_parent_id', 8L))
N2.id :  9
QSET :  (AND: ('list_parent_id', 9L))
N2.id :  10
QSET :  (AND: ('list_parent_id', 10L))
N2.id :  11
QSET :  (AND: ('list_parent_id', 11L))
Listing Result :  []
Level2 :  [, , , , , ]
Level3 :  []
Level4 :  []


I tried in other way too

def latest_listing(request):
channels = Listing_channels.objects.all().filter(parent_id=0)
res={}
print channels
for channel in channels:
subchannels = getsubchannels(channel.id)
if subchannels:
for subchannel in subchannels:
#res[subchannel.list_channel]=[]
categorys = getsubcategory(subchannel.id)
if categorys:
result=[]
for category in categorys:
result.append(category.list_channel)
res[subchannel.list_channel]=result
print res
return render_to_response("Restaurants.html",
{'channels':channels,'result':result,'res':res})

def getsubchannels(channel):
channels = Listing_channels.objects.all()
for n in channels:
if n.list_channel:
qset = (
  Q(parent_id = channel)
)
subchannels = Listing_channels.objects.filter(qset).distinct()
return subchannels

def getsubcategory(channel):
channels = Listing_channels.objects.all()
for n in channels:
if n.list_channel:
qset = (
  Q(parent_id = channel)
)
subchannels = Listing_channels.objects.filter(qset).distinct()
return subchannels



On Jan 21, 2:26 pm, Malcolm Tredinnick 
wrote:
> On Wed, 2009-01-21 at 00:43 -0800, Praveen wrote:
> > class Listing_channels(models.Model):
> >   list_parent_id = models.IntegerField(blank = True)
> >   list_channel = models.CharField(max_length = 20)
> >   visibility = models.BooleanField()
> >   index = djangosearch.ModelIndex(text=['list_channel'], additional=
> > [])
>
> >   def __unicode__(self):
> >     return self.list_channel
>
> >   def get_absolute_url(self):
> >     return u'%s' % self.list_channel
>
> > these are the records of list_channel
>
> > id   list_parent_id   list_channel
> > 1       0     Top Menu
> > 2       1     Sight Seeing
> > 3       1     Real Estate
> > 4       1     Shopping
> > 5       1     Restaurants
> > 6       2     Activities
> > 7       2     Amusement park 1
> > 8       2     Art Galleries
> > 9       2     Museums
> > 10       2     Parks
> > 11       2     Tour operators
> > 12       6     Bowling
> > 13       6     Dinner Cruises
> > 14       6     Diving
> > 15       3     Developers
> > 16       3     Orientation
> > 17       3     Real Estate Agents
> > 18       3     Relocation
>
> > I wanted to print like this for Sight Seeing see here
> >http://explocity.in/Dubai/sightseeing/activites/diving-sightseeing.html
>
> > i wrote in views.py
>
> > def 

Re: Invalid block tag: "get_comment_count"

2009-01-21 Thread Florian Lindner


Am 20.01.2009 um 21:40 schrieb Florian Lindner:

>
>
> Am 19.01.2009 um 22:58 schrieb Briel:
>
>>
>> You should try playing around with the tags, trying to load comments
>> different places trying some of the other comment tags to see what
>> happens ect.
>> Also are you using the block tags? what block tags do you have where
>> have you placed them in relation to your code?
>
> Hi!
> I've stripped down my code to merely these two lines:
>
> {% load comments % }
> {% get_comment_count for object as comment_count %}

Well, I got it now. It was one whitespace too much: {% load comments  
%} vs. {% load comments % }.



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

2009-01-21 Thread Malcolm Tredinnick

On Wed, 2009-01-21 at 01:32 -0800, Guyon Morée wrote:
> Hi,
> 
> I've built a bunch of 'normal' views rendering templates and
> processing POST's.
> 
> Now, I'd like to build a API for my site, based on JSON. When building
> this API I noticed most of the views are 99% the same,

Excellent. :-)

That's the ideal situation.

>  except for
> outputting JSON instead of HTML templates.
> 
> Any ideas how I could reduce duplication of code in these cases?

A rough "general" pattern here is that most of your view is constructing
a dictionary of values -- and it could be some other data structure, but
we'll assume a dictionary here -- that will be used to generate the
output. For templates, this dictionary is usually just passed to a
Context class to create the template context. But there might be some
other transformation you have to do to it first.

In any case, that's where the split happens. One function is responsible
for collecting the output data and putting it into a neutral data
structure -- again, let's say, a dictionary. That output data will be
the same, no matter what the format of the response.

Then you decide, based on the request, whether to process that data into
a json response, or an Atom response, or an HTML templated response.
Each of those "convert the dictionary into an output response" could be
another function. Those functions might have to do some further munging
of the dictionary for their own circumstances -- for example, the
template version might drop in some extra variables for "the current
page" or something related to tab ids -- but, by and large, they'll all
be handing off the data to a different renderer. Either
simplejson.dumps, or render_to_string (or render_to_response) or
whatever.

In pseudo-code:

def my_view(request, ):
result_data = gather_the_data(...)

if response_type == "html":
return render_to_html(request, result_data)
if response_type == "json":
return HttpResponse(render_to_json(request,
result_data))

def render_to_html(request, result_data):
template_name =
get_template_name(result_data["target_name"])
return render_to_response(template_name, result_data)

def render_to_json(request, result_data):
return simplejson.dumps(result_data)

This is very simplistic, but it hopefully gets the idea across.
"result_data" is the neutral form, gather_the_data() does all the heavy
lifting and the various presentation functions do the final bit. 

Depending on how your code works out, it's probably going to be easy to
make this all more regular, too. A function to work out the response
type, which is then used as a key to look up a dictionary of
presentation functions to call (render_to_html, render_to_json, etc).

Daniel Lindsley has a blog post about a version of this that uses
templates for all the output formats -- see [1]. I tend to go for the
"presentation functions" approach, since templates don't feel like the
right solution for json or Atom. But the principle is the same and
Daniel's post (and a follow-up one James Bennett did at [2]) should give
you some more ideas.

[1] http://toastdriven.com/fresh/multiresponse/
[2] http://www.b-list.org/weblog/2008/nov/29/multiresponse/

Regards,
Malcolm


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

2009-01-21 Thread Guyon Morée

Malcolm, thank you for the elaborate response, much appreciated!



On Jan 21, 10:51 am, Malcolm Tredinnick 
wrote:
> On Wed, 2009-01-21 at 01:32 -0800, Guyon Morée wrote:
> > Hi,
>
> > I've built a bunch of 'normal' views rendering templates and
> > processing POST's.
>
> > Now, I'd like to build a API for my site, based on JSON. When building
> > this API I noticed most of the views are 99% the same,
>
> Excellent. :-)
>
> That's the ideal situation.
>
> >  except for
> > outputting JSON instead of HTML templates.
>
> > Any ideas how I could reduce duplication of code in these cases?
>
> A rough "general" pattern here is that most of your view is constructing
> a dictionary of values -- and it could be some other data structure, but
> we'll assume a dictionary here -- that will be used to generate the
> output. For templates, this dictionary is usually just passed to a
> Context class to create the template context. But there might be some
> other transformation you have to do to it first.
>
> In any case, that's where the split happens. One function is responsible
> for collecting the output data and putting it into a neutral data
> structure -- again, let's say, a dictionary. That output data will be
> the same, no matter what the format of the response.
>
> Then you decide, based on the request, whether to process that data into
> a json response, or an Atom response, or an HTML templated response.
> Each of those "convert the dictionary into an output response" could be
> another function. Those functions might have to do some further munging
> of the dictionary for their own circumstances -- for example, the
> template version might drop in some extra variables for "the current
> page" or something related to tab ids -- but, by and large, they'll all
> be handing off the data to a different renderer. Either
> simplejson.dumps, or render_to_string (or render_to_response) or
> whatever.
>
> In pseudo-code:
>
>         def my_view(request, ):
>             result_data = gather_the_data(...)
>
>             if response_type == "html":
>                 return render_to_html(request, result_data)
>             if response_type == "json":
>                 return HttpResponse(render_to_json(request,
>         result_data))
>
>         def render_to_html(request, result_data):
>             template_name =
>         get_template_name(result_data["target_name"])
>             return render_to_response(template_name, result_data)
>
>         def render_to_json(request, result_data):
>             return simplejson.dumps(result_data)
>
> This is very simplistic, but it hopefully gets the idea across.
> "result_data" is the neutral form, gather_the_data() does all the heavy
> lifting and the various presentation functions do the final bit.
>
> Depending on how your code works out, it's probably going to be easy to
> make this all more regular, too. A function to work out the response
> type, which is then used as a key to look up a dictionary of
> presentation functions to call (render_to_html, render_to_json, etc).
>
> Daniel Lindsley has a blog post about a version of this that uses
> templates for all the output formats -- see [1]. I tend to go for the
> "presentation functions" approach, since templates don't feel like the
> right solution for json or Atom. But the principle is the same and
> Daniel's post (and a follow-up one James Bennett did at [2]) should give
> you some more ideas.
>
> [1]http://toastdriven.com/fresh/multiresponse/
> [2]http://www.b-list.org/weblog/2008/nov/29/multiresponse/
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Recommendation on understanding CSS

2009-01-21 Thread bruno desthuilliers

On 21 jan, 09:52, Gath  wrote:
> Guys,
>
> Its seems the best way to do templates in Django is via plain html and
> css, but am having a problem in understanding css easily, can someone
> recommend some nice material/site on css i can read, i mean step by
> step till complex stuff.


The references are on the w3c site - but they are, well, references. A
good starting point for actually learning how to use css is A List
Apart:

http://alistapart.com/

You'll find lot of concrete examples, tips and tricks, and links to
other related material.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Shortcut for combining "with...as" and "include" template tags?

2009-01-21 Thread Flo Ledermann


On Jan 21, 10:11 am, Malcolm Tredinnick 
wrote:
> > Coming back from the generalization to my usecase, i cannot see how
>
> > {% with a as b %}
> > {% with x as y %}
> > {% include "foo.html" %}
> > {% endwith %}
> > {% endwith %}
>
> > is syntactically or semantically superior to
>
> > {% include "foo.html" with a as b, x as y %}
>
> Because, no code will ever be that short. People don't use one-letter
> variable names for a start (those that do should stop).

OK I admit I was cheating a bit ;)

> We're not discouraging modular coding. Far from it. We're simply saying
> that there aren't template-level namespaces (which is all that variable
> aliasing is in programming languages). If you're going to substitute
> things into template foo.html, use the same names all the time. Use
> common, descriptive names in foo.html and the views that include that
> data won't be unclear. There are enough descriptive words in the English
> language (or language of choice) that avoiding name collision just isn't
> that hard.

Well in the case of components you will want to use the same component
on the same page in different contexts. Since the number of such
components is always limited and they should have well-defined
semantics anyway I will go with a non-generic template inclusion tag
for each of these components now, I guess.

for future readers:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags

Maybe the documentation of the include tag should contain a not like
"If you want to use more sophisticated include patterns like passing
parameters to included templates, take a look at creating inclusion
tags (link)" - I think this is really something that people coming
from other frameworks have to be pointed to.

Thanks for the insightful discussion, as always!

Flo

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



  1   2   >