Re: New to unit testing, need advice

2009-07-15 Thread Javier Guerra

Joshua Russo wrote:
> This thought struck me most when I was going through the testing
> documentation, in the section regarding the testing of models. It
> seems to me that very little logic generally goes into the model
> classes. At least for me, I have far more logic in admin.py and
> views.py.

besides the testing issues (which are certainly a heated debate!), i have to 
say that my Django projects became far better organized and a lot more flexible 
when i learned to put most of the code on the models, and not on the views.

IOW, it has become a lot more productive for me not to think in terms of the 
webapp, but in terms of the data objects.  first invest a good portion of time 
(and several diagrams) getting the right structures to represent your data, add 
several methods to do any needed manipulation right in terms of the data, not 
in terms of the user's actions.  sometimes it's necessary to add manager 
objects to make model objects more 'high-level' and not as tied to the RDBMS 
tables used to store them.

with that structures in place, the view functions become very thin, just to get 
the needed objects for the templates, and interpret the user's actions to call 
any mutating operation on the relevant models.

when you do that, it becomes clear that a lot of the tests can be right in the 
models.py file, to exercise said functionality.  the tests.py is (mostly) 
reserved for testing the user interface, calling the URLs and verifying the 
response and effects.

hope that helps,

-- 
Javier

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: usernames for auth.User are too restrictive for my company's clients

2009-07-15 Thread Rama Vadakattu

1.Simply extend the User model by using UserProfile Technique
   More details :
   http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/

2.You can also customize your authentication needs
  More details :
 
http://groups.google.com/group/django-users/browse_thread/thread/c943ede66e6807c/2fbf2afeade397eb?q=#2fbf2afeade397eb

--rama





On Jul 16, 12:50 am, "Andrew D. Ball"  wrote:
> Good afternoon.
>
> Here's the username field from the latest Django trunk's 
> django.contrib.auth.models module:
>
> username = models.CharField(_('username'), max_length=30, unique=True, 
> help_text=_("Required. 30 characters or fewer.     Alphanumeric characters 
> only (letters, digits and underscores)."))
>
> Why is the format of the username so restrictive?  The company I work for
> has clients with usernames that contain spaces, email addresses, possibly even
> non-ASCII characters.  I would love to use the standard User model, but I 
> can't
> dictacte the format of the usernames of our clients' own systems.
>
> Is there any way to work around this?  We have already implemented our own
> user model, but I would like to use the standard Django one to make 
> integration
> with apps like Satchmo more feasible.
>
> Peace,
> Andrew
> --
> ===
> Andrew D. Ball
> ab...@americanri.com
> Software Engineer
> American Research Institute, Inc.http://www.americanri.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: syncdb doesn't updated database after adding null=True to an IntegerField

2009-07-15 Thread Dj Gilcrease

On Wed, Jul 15, 2009 at 8:33 PM, Ben wrote:
> Is syncdb supposed to fully sync the database to the model
> definitions? If so I would call this a bug.

You would need to delete the tables and run syncdb again to get it to
add any model level changes

OR

look up http://code.google.com/p/django-evolution/ which will evolve
you model changes into your existing DB

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



syncdb doesn't updated database after adding null=True to an IntegerField

2009-07-15 Thread Ben

I'm using the admin site. I noticed that I couldn't leave an
IntegerField empty even when I had "year = models.IntegerField
(blank=True)". I googled and found out I should set null=True as well.
I did this, ran syncdb, and it didn't fix the issue.

I am using sqlite3 with a temporary database. I restarted my machine,
so that the database was deleted, ran syncdb, and the issue was fixed.
I tested again and it looks like once the database and tables are
created, adding null=True to an IntegerField and running syncdb won't
actually update the database.

Is syncdb supposed to fully sync the database to the model
definitions? If so I would call this a bug.

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: Saving Data To Your DB. Simple?

2009-07-15 Thread The Danny Bos


Hopefully my last question on this,
How do I get back to the page with the form, perhaps with a "Thank
You" message, without having the POST still available if you hit
refresh.
I figured I'd use 'reverse' but not quite sure why it isn't
working ...

Here's where I am now:

#views.py
def record_detail(request, slug):
record = Record.objects.get(slug=slug)
if request.method == 'POST':
form = RatingForm(request.POST)
if form.is_valid():
record_rating = Rating()
record_rating.item_id = record.id
record_rating.writer_id = request.user.id
record_rating.rating = form.cleaned_data['rating']
record_rating.save()

return render_to_response(reverse('record_detail', 
args=[slug]))
else:
form = RatingForm()
return render_to_response('records/detail.html', {'record_detail':
record, 'form': form}, context_instance=RequestContext(request))

I get the below error.

NoReverseMatch at /records/temp-record-name/
Reverse for 'record_detail' with arguments '(u'temp-record-name',)'
and keyword arguments '{}' not found.


And even if it does get passed back to the original page, how would I
have a "Thank You" message?

Thanks again,


d



On Jul 16, 10:49 am, Russell Keith-Magee 
wrote:
> On Thu, Jul 16, 2009 at 8:36 AM, The Danny Bos wrote:
>
> > Any ideas on this one guys?
>
> > I gave up on it last night.
> > I feel way off ...
>
> Ok - some back tracking.
>
> Your first approach (no forms) should have worked. The reason you
> didn't get any errors is that your code is explicitly ignoring _all
> errors_. You are catching all exceptions, passing, and moving on. That
> means that if an error - ANY minor error - is thrown in your 'form
> processing' code, then it will be silently ignored.
>
> Step 1 - Make it be not silent. Instead of using:
>
> except:
>     pass
>
> try using
>
> except Exception, e:
>     print 'ERROR!!', e
>
> And see what it says. You will probably find that it's something
> really simple, like a typo in a variable name somewhere. Fix those
> issues, and you should find things start to work- the general approach
> you describe should be fine.
>
> Your second attempt, using forms, can be made to work in a number of ways.
>
> 1) Save the values back from the form.
>
> record_rating.rating = form.cleaned_data['rating']
> record_rating.record_id = form.cleaned_data['record']
> record_rating.writer_id = form.cleaned_data['writer']
>
> I would also note that your form probably won't have values for record
> and writer - because they are hidden inputs and you're not providing
> initial values. Look into the `initial` argument to fields, or to the
> form as a whole.
>
> 2) Don't put the values on the form in the first place. After all -
> they're hidden inputs.
>
> class RatingForm(forms.Form):
>        rating = forms.ChoiceField(choices=RATING_CHOICES)
> ...
> record_rating.rating = form.cleaned_data['rating']
> record_rating.record = Record.objects.get()
> record_rating.writer = Writer.objects.get()
>
> 3) Look at using a ModelForm. This will handle the saving of the
> entire Rating object; however, given that you seem to want to use
> hidden inputs, you will need to jump through some extra hoops to
> override the default widgets. Overriding widgets is covered in the
> docs.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: code of models from oracle to mysql

2009-07-15 Thread Vincent

thank you lan.

i solve the problem with your idea.

On Jul 15, 11:44 pm, Ian Kelly  wrote:
> On Jul 15, 7:07 am, Karen Tracey  wrote:
>
> > On Wed, Jul 15, 2009 at 4:18 AM, pho...@gmail.com  wrote:
>
> > > the code of models:
> > >    mgsyxs = models.DecimalField(decimal_places=-127, null=True,
> > > max_digits=126, db_column='MGSYXS', blank=True) # Field name made
> > > lowercase.
>
> > > i appreciate for your suggestion.
>
> > decimal_places=-127 doesn't look right, I don't think that value should be
> > lower than 0.  What is this field defined as in your original (Oracle?) db?
> > It's possible that inspectdb is not working properly for whatever it you
> > have in your original DB.
>
> DecimalField(decimal_places=-127, max_digits=126) is what the Oracle
> introspection returns for float columns, since that's how the database
> describes them.  If you change them to FloatField you should be okay.
>
> Ian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: New to unit testing, need advice

2009-07-15 Thread Shawn Milochik

Basically, you want to test anything that might break if another part  
of the code is changed that interacts with it,  might break if the  
application takes an alternative flow (maybe finally hits the 'else'  
of that if/else statement), or could possibly receive invalid input.

Unfortunately, that is theoretically everything.

I don't know what the correct answer is, and I suspect that the  
correct answer is (as is so often the case) "it depends." All  
applications are unique.

In any case, if you care enough to be doing it at all, and are  
concerned about doing it the right way, then you'll probably be fine.



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

2009-07-15 Thread The Danny Bos


Russ, this makes a lot of sense, thanks so much.
I'll give it a go now ...


d



On Jul 16, 10:49 am, Russell Keith-Magee 
wrote:
> On Thu, Jul 16, 2009 at 8:36 AM, The Danny Bos wrote:
>
> > Any ideas on this one guys?
>
> > I gave up on it last night.
> > I feel way off ...
>
> Ok - some back tracking.
>
> Your first approach (no forms) should have worked. The reason you
> didn't get any errors is that your code is explicitly ignoring _all
> errors_. You are catching all exceptions, passing, and moving on. That
> means that if an error - ANY minor error - is thrown in your 'form
> processing' code, then it will be silently ignored.
>
> Step 1 - Make it be not silent. Instead of using:
>
> except:
>     pass
>
> try using
>
> except Exception, e:
>     print 'ERROR!!', e
>
> And see what it says. You will probably find that it's something
> really simple, like a typo in a variable name somewhere. Fix those
> issues, and you should find things start to work- the general approach
> you describe should be fine.
>
> Your second attempt, using forms, can be made to work in a number of ways.
>
> 1) Save the values back from the form.
>
> record_rating.rating = form.cleaned_data['rating']
> record_rating.record_id = form.cleaned_data['record']
> record_rating.writer_id = form.cleaned_data['writer']
>
> I would also note that your form probably won't have values for record
> and writer - because they are hidden inputs and you're not providing
> initial values. Look into the `initial` argument to fields, or to the
> form as a whole.
>
> 2) Don't put the values on the form in the first place. After all -
> they're hidden inputs.
>
> class RatingForm(forms.Form):
>        rating = forms.ChoiceField(choices=RATING_CHOICES)
> ...
> record_rating.rating = form.cleaned_data['rating']
> record_rating.record = Record.objects.get()
> record_rating.writer = Writer.objects.get()
>
> 3) Look at using a ModelForm. This will handle the saving of the
> entire Rating object; however, given that you seem to want to use
> hidden inputs, you will need to jump through some extra hoops to
> override the default widgets. Overriding widgets is covered in the
> docs.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Saving Data To Your DB. Simple?

2009-07-15 Thread Russell Keith-Magee

On Thu, Jul 16, 2009 at 8:36 AM, The Danny Bos wrote:
>
> Any ideas on this one guys?
>
> I gave up on it last night.
> I feel way off ...

Ok - some back tracking.

Your first approach (no forms) should have worked. The reason you
didn't get any errors is that your code is explicitly ignoring _all
errors_. You are catching all exceptions, passing, and moving on. That
means that if an error - ANY minor error - is thrown in your 'form
processing' code, then it will be silently ignored.

Step 1 - Make it be not silent. Instead of using:

except:
pass

try using

except Exception, e:
print 'ERROR!!', e

And see what it says. You will probably find that it's something
really simple, like a typo in a variable name somewhere. Fix those
issues, and you should find things start to work- the general approach
you describe should be fine.

Your second attempt, using forms, can be made to work in a number of ways.

1) Save the values back from the form.

record_rating.rating = form.cleaned_data['rating']
record_rating.record_id = form.cleaned_data['record']
record_rating.writer_id = form.cleaned_data['writer']

I would also note that your form probably won't have values for record
and writer - because they are hidden inputs and you're not providing
initial values. Look into the `initial` argument to fields, or to the
form as a whole.

2) Don't put the values on the form in the first place. After all -
they're hidden inputs.

class RatingForm(forms.Form):
   rating = forms.ChoiceField(choices=RATING_CHOICES)
...
record_rating.rating = form.cleaned_data['rating']
record_rating.record = Record.objects.get()
record_rating.writer = Writer.objects.get()

3) Look at using a ModelForm. This will handle the saving of the
entire Rating object; however, given that you seem to want to use
hidden inputs, you will need to jump through some extra hoops to
override the default widgets. Overriding widgets is covered in the
docs.

Yours,
Russ Magee %-)

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



Re: Saving Data To Your DB. Simple?

2009-07-15 Thread The Danny Bos

Any ideas on this one guys?

I gave up on it last night.
I feel way off ...


d



On Jul 15, 11:33 pm, The Danny Bos  wrote:
> Agreed, I should get used to using Forms.
> So I gave it a go, the new problem I have is out of my three fields,
> two need to be hidden and have values automatically assigned from the
> page they're on. This is freaking me out.
>
> Now I have:
>
> # forms.py
> class RatingForm(forms.Form):
>         record = forms.CharField(widget=forms.HiddenInput)
>         critic = forms.CharField(widget=forms.HiddenInput)
>         rating = forms.ChoiceField(choices=RATING_CHOICES)
>
> #views.py
> def record_detail(request):
>         if request.method == 'POST':
>                 form = RatingForm(request.POST)
>                 if form.is_valid():
>                         record_rating = Rating()
>
>                         record_rating.rating = form.cleaned_data['rating']
>                         record_rating.record = 
>                         record_rating.writer = 
>                         record_rating.save()
>
>                         return HttpResponseRedirect('/')
>         else:
>                 ...
>
> How do I get the User.ID (as you'll need to be logged in), into that
> hidden field or the DB. And also the Record.ID from the page I was
> just on.
>
> Know what I mean. Am I way off?
> I'm new to this, so any detailed help is very welcome.
>
> Thanks again,
>
> d
>
> On Jul 15, 2:37 am, Lakshman Prasad  wrote:
>
>
>
> > > It runs OK (no errors) but doesn't save a single thing
>
> >      It has to run without errors because you have enclosed the whole thing
> > in try.
>
> >      You have to coerce the record_id and user_id into int before assigning
> > to the model fields, for it to save.
>
> > On Tue, Jul 14, 2009 at 9:45 PM, The Danny Bos  wrote:
>
> > > Heya, am trying to simply save 3 values to a database, without using
> > > Forms.
>
> > > In the Template:
>
> > > 
> > >        
> > >        
> > >        Rate This: {% for n in numbers %} > > value="{{ n }}">{{ n }}{% endfor %}
> > >        
> > > 
>
> > > In the View:
>
> > > from mysite.rating.models import Rating
> > > def critics_rating(request):
> > >        try:
> > >                record_id = request.POST['record_id']
> > >                user_id = request.POST['user_id']
> > >                rating_val = request.POST['rating']
>
> > >                rating = Rating()
> > >                rating.rating = rating_val
> > >                rating.item = record_id
> > >                rating.writer = user_id
> > >                rating.save()
>
> > >                return HttpResponseRedirect('/')
> > >        except:
> > >                pass
> > >        obj = Record.objects.get(id=record)
> > >        return render_to_response('record/detail.html', {'object_detail':
> > > obj}, context_instance=RequestContext(request))
>
> > > It runs OK (no errors) but doesn't save a single thing, also it goes
> > > back to the 'detail.html' page fine, but when you hit reload, it sends
> > > the data again. Again, not saving.
>
> > > Any ideas what's wrong with this?
> > > I've done a lot of searching but all people seem to use the Forms
> > > widget, I was thinking as this is only three fields I'd skip that.
> > > Silly?
>
> > --
> > Regards,
> > Lakshman
> > becomingguru.com
> > lakshmanprasad.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New to unit testing, need advice

2009-07-15 Thread Wayne Koorts

> I'm in the process of implementing testing (both doc tests and unit
> tests) though I'm having some conceptual difficulty. I'm not sure how
> far to take the testing. I'm curious what people concider an
> appropriate level of testing.

Uh oh, be ready for a huge thread.  This is one of those unending debates.

Basically:

- More thorough test coverage == more confidence as you know there is
less chance that when you break something it will go unnoticed.
- Creating complete test coverage and keeping it up to date takes a
lot of time, and sometimes the decision is made to use that time for
other things.

As with anything, there's a balance.  It's very dependant on the
project and team involved.

Regards,
Wayne Koorts
http://www.wkoorts.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
-~--~~~~--~~--~--~---



New to unit testing, need advice

2009-07-15 Thread Joshua Russo

I'm in the process of implementing testing (both doc tests and unit
tests) though I'm having some conceptual difficulty. I'm not sure how
far to take the testing. I'm curious what people concider an
appropriate level of testing.

This thought struck me most when I was going through the testing
documentation, in the section regarding the testing of models. It
seems to me that very little logic generally goes into the model
classes. At least for me, I have far more logic in admin.py and
views.py.

What are peoples thoughts on testing models? What exactly are you
testing for there? How do you gauge code that should be tested versus
code that doesn't really need it?

Thanks for your help
Josh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Done? Database -> Python objects -> JSON -> JavaScript 'class instances'

2009-07-15 Thread Russell Keith-Magee

On Thu, Jul 16, 2009 at 3:12 AM, jfine wrote:
>
> Hi
>
> Django can, of course, serialize database objects into JSON:
>    http://docs.djangoproject.com/en/dev/topics/serialization/
>
> I'd like to turn that JSON into JavaScript objects.  I'd like, of
> course, a Formula object to be turned into an 'instance of the Formula
> class'. (The quotes are because JavaScript doesn't really have classes
> and instances.)
>
> Django can also, of course, serialize a whole database into JSON.  A
> more ambitious task is to turn that JSON into a linked collection of
> database objects.
>
> Does this sound interesting? Has something like this been done
> already?

Sure, this _could_ be done. You can write and install custom
serializer - you just need to work out exactly how a random database
object is realized as a JavaScript object. The existing serializers
should give you a reasonable idea of how to do this.

Has it been done already? Not to my knowledge, but I won't claim to
have omniscient knowledge of the Django community. Google is your
friend.

Should it be done? I have a minor hesitation based around attack
vectors - when sending JSON, you're sending raw data, so the potential
for attacks is limited. However, if you're serializing objects with
the expectation that they will be executable as received, you've
opened up a door through which exploits could enter. Of course,
whether this is actually a problem depends very much on how you handle
the received objects. Caveat Emptor.

Also - keep in mind that from a Django perspective, a serializer is
only half the job. There is also the deserializer, for converting a
JavaScript object back into a database object. Of course, you may not
need this for your own bespoke purposes.

Yours,
Russ Magee %-)

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



Re: Dynamic var passing in queryset for date_based.archive_index

2009-07-15 Thread Sonal Breed

Ya I was :-O
That article was immensely helpful.
Thanks for your help Almir.

Sincerely,
Sonal

On Jul 15, 2:54 pm, Almir Karic  wrote:
> IMHO you are vastly over complicating things 
> :),http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-gen...
> this should help you
>
> python/django hacker & sys 
> adminhttp://almirkaric.com://twitter.com/redduck666
>
> On Wed, Jul 15, 2009 at 1:42 PM, Sonal Breed wrote:
>
> > Hello Almir,
> > Thanks for your comment. I added following in my wrapper view:
>
> > @login_required()
> > def story_index(request, username, d={}):
> >   Stroy Index"""
> >  d['this_user'] = user = get_model(User, username=username)
> >  if not user: return find_user(username)
>
> >  d["story_index"] = Story.objects.filter(user=user)
> >  d['latest'] = archive_index(request, CareStory.objects.filter
> > (user=user), 'date_created')
>
> >  #return render(request, 'care_story_index.html', d)
> >  return render(request, 'social/carestory_archive.html', d)
>
> > Now, the page is redirected to carestory_archive.html, which is simply
> > {% for story in latest %}
> > {{ story.title }}
> > Published on {{ story.date_created|date:"F j, Y" }}
> > {% endfor %}
>
> > But it does not parse the html elements, namely  html tags like 
> > and 
> > are displayed simply like text.
>
> > Any inputs on this?
>
> > Thanks a lot,
> > Sonal.
>
> > On Jul 15, 12:11 pm, Almir Karic  wrote:
> >> I would make an wrapper view that sets up the queryset and calls the
> >> generic view.
>
> >> python/django hacker & sys 
> >> adminhttp://almirkaric.com://twitter.com/redduck666
>
> >> On Wed, Jul 15, 2009 at 11:28 AM, Sonal Breed wrote:
>
> >> > Hi all,
> >> > I am using django.views.generic.date_based.archive_index in my url
> >> > patterns as below:
>
> >> > story_info_dict = {
> >> >      'queryset': CareStory.objects.all(),
> >> >      'date_field': 'date_created',
> >> >      }
>
> >> > urlpatterns = patterns('',
> >> > ..
>
> >> >  (r'^story/index/?$',
> >> > 'django.views.generic.date_based.archive_index', story_info_dict),
>
> >> > )
>
> >> > Now, the actual queryset that I intend to pass is
> >> > story_info_dict = {
> >> >      'queryset': CareStory.objects.filter(user=user),
> >> >      'date_field': 'date_created',
> >> >      }
>
> >> > But since it is in urls.py, I cannot figure out how am I going to pass
> >> > the user variable dynamically and have the filtering done.
>
> >> > Any help on this will be really appreciated.
>
> >> > Thanks in advance,
> >> > Sonal.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Dynamic var passing in queryset for date_based.archive_index

2009-07-15 Thread Almir Karic

IMHO you are vastly over complicating things :),
http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/
this should help you

python/django hacker & sys admin
http://almirkaric.com & http://twitter.com/redduck666



On Wed, Jul 15, 2009 at 1:42 PM, Sonal Breed wrote:
>
> Hello Almir,
> Thanks for your comment. I added following in my wrapper view:
>
> @login_required()
> def story_index(request, username, d={}):
>   Stroy Index"""
>  d['this_user'] = user = get_model(User, username=username)
>  if not user: return find_user(username)
>
>  d["story_index"] = Story.objects.filter(user=user)
>  d['latest'] = archive_index(request, CareStory.objects.filter
> (user=user), 'date_created')
>
>  #return render(request, 'care_story_index.html', d)
>  return render(request, 'social/carestory_archive.html', d)
>
> Now, the page is redirected to carestory_archive.html, which is simply
> {% for story in latest %}
> {{ story.title }}
> Published on {{ story.date_created|date:"F j, Y" }}
> {% endfor %}
>
> But it does not parse the html elements, namely  html tags like 
> and 
> are displayed simply like text.
>
> Any inputs on this?
>
> Thanks a lot,
> Sonal.
>
> On Jul 15, 12:11 pm, Almir Karic  wrote:
>> I would make an wrapper view that sets up the queryset and calls the
>> generic view.
>>
>> python/django hacker & sys 
>> adminhttp://almirkaric.com://twitter.com/redduck666
>>
>> On Wed, Jul 15, 2009 at 11:28 AM, Sonal Breed wrote:
>>
>> > Hi all,
>> > I am using django.views.generic.date_based.archive_index in my url
>> > patterns as below:
>>
>> > story_info_dict = {
>> >      'queryset': CareStory.objects.all(),
>> >      'date_field': 'date_created',
>> >      }
>>
>> > urlpatterns = patterns('',
>> > ..
>>
>> >  (r'^story/index/?$',
>> > 'django.views.generic.date_based.archive_index', story_info_dict),
>>
>> > )
>>
>> > Now, the actual queryset that I intend to pass is
>> > story_info_dict = {
>> >      'queryset': CareStory.objects.filter(user=user),
>> >      'date_field': 'date_created',
>> >      }
>>
>> > But since it is in urls.py, I cannot figure out how am I going to pass
>> > the user variable dynamically and have the filtering done.
>>
>> > Any help on this will be really appreciated.
>>
>> > Thanks in advance,
>> > Sonal.
>>
>>
> >
>

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

2009-07-15 Thread Eugene Mirotin

Never mind.
If you wish to understand the regex stuff (and you really have to :),
read this tutorial:
http://www.regular-expressions.info/tutorial.html


On Jul 15, 2:50 am, theiviaxx  wrote:
> awesome, thats exactly what i needed.  im still trying to figure out
> regex stuff.
>
> Thank you!
>

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

2009-07-15 Thread Sonal Breed

Hello Almir,
Thanks for your comment. I added following in my wrapper view:

@login_required()
def story_index(request, username, d={}):
   Stroy Index"""
  d['this_user'] = user = get_model(User, username=username)
  if not user: return find_user(username)

  d["story_index"] = Story.objects.filter(user=user)
  d['latest'] = archive_index(request, CareStory.objects.filter
(user=user), 'date_created')

  #return render(request, 'care_story_index.html', d)
  return render(request, 'social/carestory_archive.html', d)

Now, the page is redirected to carestory_archive.html, which is simply
{% for story in latest %}
{{ story.title }}
Published on {{ story.date_created|date:"F j, Y" }}
{% endfor %}

But it does not parse the html elements, namely  html tags like 
and 
are displayed simply like text.

Any inputs on this?

Thanks a lot,
Sonal.

On Jul 15, 12:11 pm, Almir Karic  wrote:
> I would make an wrapper view that sets up the queryset and calls the
> generic view.
>
> python/django hacker & sys 
> adminhttp://almirkaric.com://twitter.com/redduck666
>
> On Wed, Jul 15, 2009 at 11:28 AM, Sonal Breed wrote:
>
> > Hi all,
> > I am using django.views.generic.date_based.archive_index in my url
> > patterns as below:
>
> > story_info_dict = {
> >      'queryset': CareStory.objects.all(),
> >      'date_field': 'date_created',
> >      }
>
> > urlpatterns = patterns('',
> > ..
>
> >  (r'^story/index/?$',
> > 'django.views.generic.date_based.archive_index', story_info_dict),
>
> > )
>
> > Now, the actual queryset that I intend to pass is
> > story_info_dict = {
> >      'queryset': CareStory.objects.filter(user=user),
> >      'date_field': 'date_created',
> >      }
>
> > But since it is in urls.py, I cannot figure out how am I going to pass
> > the user variable dynamically and have the filtering done.
>
> > Any help on this will be really appreciated.
>
> > Thanks in advance,
> > Sonal.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Base Class Inheritance w/ Model Methods

2009-07-15 Thread Andrew D. Ball

On Wed, Jul 15, 2009 at 06:35:06AM -0700, LeeRisq wrote:
> 
> So I'm hitting a beginner's snag here. I have six models that I need
> to contain essentially all the same attributes. I created a base class
> and then created the child classes respectively. Some of the child
> classes will contain additional attributes to the base class, but the
> rest only need what is defined within the base class.
> 
> Is there a required minimum number of attributes that a child class
> must have to validate? For instance, can the child class have zero
> attributes because it inherits all of them from the base class?
Yes.
> 
> 
> > 

-- 
===
Andrew D. Ball
ab...@americanri.com
Software Engineer
American Research Institute, Inc.
http://www.americanri.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
-~--~~~~--~~--~--~---



usernames for auth.User are too restrictive for my company's clients

2009-07-15 Thread Andrew D. Ball

Good afternoon.

Here's the username field from the latest Django trunk's 
django.contrib.auth.models module:

username = models.CharField(_('username'), max_length=30, unique=True, 
help_text=_("Required. 30 characters or fewer. Alphanumeric characters only 
(letters, digits and underscores)."))

Why is the format of the username so restrictive?  The company I work for
has clients with usernames that contain spaces, email addresses, possibly even
non-ASCII characters.  I would love to use the standard User model, but I can't
dictacte the format of the usernames of our clients' own systems.

Is there any way to work around this?  We have already implemented our own
user model, but I would like to use the standard Django one to make integration
with apps like Satchmo more feasible.

Peace,
Andrew
-- 
===
Andrew D. Ball
ab...@americanri.com
Software Engineer
American Research Institute, Inc.
http://www.americanri.com/

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



Re: Done? Database -> Python objects -> JSON -> JavaScript 'class instances'

2009-07-15 Thread jfine

Oops.  Pressed the button too soon.

> Django can also, of course, serialize a whole database into JSON.  A
> more ambitious task is to turn that JSON into a linked collection of
> database objects.

Should be JavaScript objects (of course).

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

2009-07-15 Thread Some Guy

I should add my django versions too

dev: 1.1 beta 1 SVN-11082

Deploy: 1.1 beta 1


On Jul 15, 12:12 pm, Some Guy  wrote:
> Hi,
> I seem to have a problem where various contrib elements are throwing a
> template error "dict objects are unhashable"
> I'm seeing it in admin, comments, etc. Both on my dev setup and
> deployed.
>
> The line of code always seems to be  File "/Library/Python/2.5/site-
> packages/django/utils/datastructures.py", line 269, in setlistdefault
>     if key not in self:
>
> How am I the only one experiencing this? :-)
>
> Dev: devserver, Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12),
> sqlite3
>
> Deployed: apache2/modpython, Python 2.5.2 (r252:60911, Jul 31 2008,
> 17:31:22), sqlite3
>
> 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
-~--~~~~--~~--~--~---



Done? Database -> Python objects -> JSON -> JavaScript 'class instances'

2009-07-15 Thread jfine

Hi

Django can, of course, serialize database objects into JSON:
http://docs.djangoproject.com/en/dev/topics/serialization/

I'd like to turn that JSON into JavaScript objects.  I'd like, of
course, a Formula object to be turned into an 'instance of the Formula
class'. (The quotes are because JavaScript doesn't really have classes
and instances.)

Django can also, of course, serialize a whole database into JSON.  A
more ambitious task is to turn that JSON into a linked collection of
database objects.

Does this sound interesting? Has something like this been done
already?

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



Dict objects are unhashable errors

2009-07-15 Thread Some Guy

Hi,
I seem to have a problem where various contrib elements are throwing a
template error "dict objects are unhashable"
I'm seeing it in admin, comments, etc. Both on my dev setup and
deployed.

The line of code always seems to be  File "/Library/Python/2.5/site-
packages/django/utils/datastructures.py", line 269, in setlistdefault
if key not in self:

How am I the only one experiencing this? :-)

Dev: devserver, Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12),
sqlite3

Deployed: apache2/modpython, Python 2.5.2 (r252:60911, Jul 31 2008,
17:31:22), sqlite3

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: Dynamic var passing in queryset for date_based.archive_index

2009-07-15 Thread Almir Karic

I would make an wrapper view that sets up the queryset and calls the
generic view.


python/django hacker & sys admin
http://almirkaric.com & http://twitter.com/redduck666



On Wed, Jul 15, 2009 at 11:28 AM, Sonal Breed wrote:
>
> Hi all,
> I am using django.views.generic.date_based.archive_index in my url
> patterns as below:
>
> story_info_dict = {
>      'queryset': CareStory.objects.all(),
>      'date_field': 'date_created',
>      }
>
> urlpatterns = patterns('',
> ..
>
>  (r'^story/index/?$',
> 'django.views.generic.date_based.archive_index', story_info_dict),
>
> )
>
> Now, the actual queryset that I intend to pass is
> story_info_dict = {
>      'queryset': CareStory.objects.filter(user=user),
>      'date_field': 'date_created',
>      }
>
> But since it is in urls.py, I cannot figure out how am I going to pass
> the user variable dynamically and have the filtering done.
>
>
> Any help on this will be really appreciated.
>
> Thanks in advance,
> Sonal.
> >
>

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

2009-07-15 Thread Ian Clelland



On Jul 14, 8:23 am, Benjamin Kreeger 
wrote:
> I was using PostgreSQL at first, but then I found information about
> reading data across databases only with MySQL, so I'm using MySQL for
> the time being.
>
> Now, I don't have a database set for P1 yet because it's just
> displaying reStructuredText files; if I were to set up that site to
> access P2's database (in P1's settings.py file), would I be able to
> (eek) do raw SQL to get the data to display the way I want? Or would
> there be an easier way to do that WITHOUT raw SQL, and WITHOUT
> duplicating that model declared on P2?

I didn't realise that P1 didn't have a database at all -- if that's
the case, then you can just use the credentials from P2 (the
DATABASE_* lines from settings.py) in P1's settings. You can define
the same models -- it's as simple as installing the same apps that P2
uses, there should be no duplication of code, and you'll have access
to all of the P2 data from P1.

If P1 needs its own database, however, (and you're using MySQL, and
your databases are on the same server), then you can use this patch to
django/db/backends/mysql/base.py (this is based on the 1.0.x branch;
other branches should be similar)

===
--- django/db/backends/mysql/base.py(revision 10742)
+++ django/db/backends/mysql/base.py(working copy)
@@ -143,7 +143,7 @@
 def quote_name(self, name):
 if name.startswith("`") and name.endswith("`"):
 return name # Quoting once is enough.
-return "`%s`" % name
+return ".".join(["`%s`" % name_part for name_part in
name.split(".")])

 def random_function_sql(self):
 return 'RAND()'


That will let you define, in your P1 models, a complete table name
like this:

class Example(models.Model):
... fields ...

class Meta:
db_table = 'p2_database.table_name'

And mysql will get the data from the right database. No raw SQL
required.

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



Dynamic var passing in queryset for date_based.archive_index

2009-07-15 Thread Sonal Breed

Hi all,
I am using django.views.generic.date_based.archive_index in my url
patterns as below:

story_info_dict = {
  'queryset': CareStory.objects.all(),
  'date_field': 'date_created',
  }

urlpatterns = patterns('',
..

  (r'^story/index/?$',
'django.views.generic.date_based.archive_index', story_info_dict),

)

Now, the actual queryset that I intend to pass is
story_info_dict = {
  'queryset': CareStory.objects.filter(user=user),
  'date_field': 'date_created',
  }

But since it is in urls.py, I cannot figure out how am I going to pass
the user variable dynamically and have the filtering done.


Any help on this will be really appreciated.

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



Re: Error: ce is not defined

2009-07-15 Thread Sonal Breed

I will keep you posted, Joost, on this issue...

On Jul 15, 2:43 am, Joost Cassee  wrote:
> On Jul 14, 10:51 pm,SonalBreed  wrote:
>
> > After I made TINYMCE_COMPRESSOR as False, I could get tinymce toolbar.
> > However, the style dropdown is showing empty, and there are couple of
> > other things I would like to have, like spell checker and color.
> > Have to go through tinymce docs, do u have any tips?
>
> Setting the TinyMCE options (as documented in the TinyMCE wiki [1]) in
> TINYMCE_DEFAULT_CONFIG, as you have done, should just work. You will
> need a language pack for every language in LANGUAGES and the Enchant
> library as explained in the django-tinymce documentation [2].
>
> [1]http://wiki.moxiecode.com/index.php/TinyMCE:Configuration
> [2]http://django-tinymce.googlecode.com/svn/trunk/docs/.build/html/insta...
>
> There have been reports that django-tinymce has a problem with
> languages with non-ASCII characters. I'm still trying to reproduce
> this.
>
> If you have more specific questions I may be able to help you
> better. :-)
>
> Regards,
>
> Joost
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: PyOhio - Python Regional Conference

2009-07-15 Thread Alex Gaynor

On Wed, Jul 15, 2009 at 12:56 PM, Fred
Chevitarese wrote:
> Record this !!! And put on Youtube for us!!! Whe´re in Brazil!!!
>
> Thanks! ;)
>
> 2009/7/15 Alex Gaynor 
>>
>> PyOhio:
>> Dates: 25th - 26th July
>> More info: http://www.pyohio.org/Home
>>
>> Later this month will be the 2nd Python regional conference in
>> Columbus, OH. This year the conference will feature two full days of
>> talks as well as sprints. There will be general web framework talks,
>> including one by Mark Ramm (Choosing a web technology stack), general
>> Python talks and also two Django talks.
>>
>> The date of the sprints has yet to be nailed down, but they will
>> probably be on the Friday and Saturday of the conference weekend. We
>> will be having a Django sprint, which will likely coincide with the
>> head of the 1.2 development cycle. The timing makes it a perfect
>> opportunity to work on the pony you've always wanted.
>>
>> If you're interested in attending the Django sprint, please sign up
>> for yourself here: http://www.pyohio.org/Sprints/Projects/Django
>> (you'll need to be registered and logged in).
>>
>> For further general sprint information you can go to:
>> http://www.pyohio.org/Sprints/
>>
>> Hope to see you there!
>>
>> Alex
>>
>> --
>> "I disapprove of what you say, but I will defend to the death your
>> right to say it." -- Voltaire
>> "The people's good is the highest law." -- Cicero
>> "Code can always be simpler than you think, but never as simple as you
>> want" -- Me
>>
>>
>
>
>
> --
> http://chevitarese.wordpress.com
>
> Fred Chevitarese - GNU/Linux
>
> >
>

Fred,

I believe the plan is to record at least 1 track of the conference.
If and when those videos make their way online I'll be sure to post a
link here.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



DjangoCon '09 Talks and Registration

2009-07-15 Thread Robert Lofthouse

Hi all,

Registration: Just a reminder that early-bird registration ends this
Sunday. The prices will increase around $80 after that (http://
www.djangocon.org/conference/pricing/).

Call for Proposals: The deadline for you to get your talk submissions
in is August 7th (http://www.djangocon.org/conference/talk/
information/). We will confirm the acceptance/rejection of your talk
a.s.a.p and I'm looking to get the schedule up on August 8th.

You can register for the conference here: http://djangocon09.eventbrite.com
Submit a talk here after reading the talk information page:
http://www.djangocon.org/conference/talk/

DjangoCon '09 Dates:

8th - 10th - Conference Days
11th - 12th - Sprint Days

http://www.djangocon.org/

Regards

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

2009-07-15 Thread Fred Chevitarese
Record this !!! And put on Youtube for us!!! Whe´re in Brazil!!!

Thanks! ;)

2009/7/15 Alex Gaynor 

>
> PyOhio:
> Dates: 25th - 26th July
> More info: http://www.pyohio.org/Home
>
> Later this month will be the 2nd Python regional conference in
> Columbus, OH. This year the conference will feature two full days of
> talks as well as sprints. There will be general web framework talks,
> including one by Mark Ramm (Choosing a web technology stack), general
> Python talks and also two Django talks.
>
> The date of the sprints has yet to be nailed down, but they will
> probably be on the Friday and Saturday of the conference weekend. We
> will be having a Django sprint, which will likely coincide with the
> head of the 1.2 development cycle. The timing makes it a perfect
> opportunity to work on the pony you've always wanted.
>
> If you're interested in attending the Django sprint, please sign up
> for yourself here: http://www.pyohio.org/Sprints/Projects/Django
> (you'll need to be registered and logged in).
>
> For further general sprint information you can go to:
> http://www.pyohio.org/Sprints/
>
> Hope to see you there!
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
>
> >
>


-- 
http://chevitarese.wordpress.com

Fred Chevitarese - GNU/Linux

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



PyOhio - Python Regional Conference

2009-07-15 Thread Alex Gaynor

PyOhio:
Dates: 25th - 26th July
More info: http://www.pyohio.org/Home

Later this month will be the 2nd Python regional conference in
Columbus, OH. This year the conference will feature two full days of
talks as well as sprints. There will be general web framework talks,
including one by Mark Ramm (Choosing a web technology stack), general
Python talks and also two Django talks.

The date of the sprints has yet to be nailed down, but they will
probably be on the Friday and Saturday of the conference weekend. We
will be having a Django sprint, which will likely coincide with the
head of the 1.2 development cycle. The timing makes it a perfect
opportunity to work on the pony you've always wanted.

If you're interested in attending the Django sprint, please sign up
for yourself here: http://www.pyohio.org/Sprints/Projects/Django
(you'll need to be registered and logged in).

For further general sprint information you can go to:
http://www.pyohio.org/Sprints/

Hope to see you there!

Alex

--
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Re: Multiple Instances of Django

2009-07-15 Thread Tom Evans

On Wed, 2009-07-15 at 09:38 -0700, Caitlin Colgrove wrote:
> I have two instances of django running under apache.  One in /portal
> and one in /beta/portal.  They use two different code bases and two
> different databases, although some of the data is replicated between
> the two.  If I am logged in to one Django instance it interferes with
> the other.  Presumably this is due to some setting (maybe a cookie
> setting?) that is the same for both instances.  I can't figure out how
> to avoid this situation, and a brief survey of the documentation
> hasn't helped.  Can someone suggest a solution?
> 
> Thanks in advance.
> Caitlin

See
http://docs.djangoproject.com/en/dev/topics/http/sessions/#session-cookie-name

Cheers

Tom


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 implement a custom field (or relation) which supports List of Strings

2009-07-15 Thread Dudley Fox

I want to create a new type of field for django models that is
basically a ListOfStrings. So in your model code you would have the
following:

models.py:

   from django.db import models

   class ListOfStringsField(???):
   ???

   class myDjangoModelClass():
   myName = models.CharField(max_length=64)
   myFriends = ListOfStringsField() #

other.py:

   myclass = myDjangoModelClass()
   myclass.myName = "bob"
   myclass.myFriends = ["me", "myself", "and I"]

   myclass.save()

   id = myclass.id

   loadedmyclass = myDjangoModelClass.objects.filter(id__exact=id)

   myFriendsList = loadedclass.myFriends
   # myFriendsList is a list and should equal ["me", "myself", "and I"]


My first attempt at this looks like the following, and appears to work
as I expect:
==
class ListValueDescriptor(object):

   def __init__(self, lvd_parent, lvd_model_name, lvd_value_type,
lvd_unique, **kwargs):
  """
 This descriptor object acts like a django field, but it will accept
 a list of values, instead a single value.
 For example:
# define our model
class Person(models.Model):
   name = models.CharField(max_length=120)
   friends = ListValueDescriptor("Person", "Friend",
"CharField", True, max_length=120)

# Later in the code we can do this
p = Person("John")
p.save() # we have to have an id
p.friends = ["Jerry", "Jimmy", "Jamail"]
...
p = Person.objects.get(name="John")
friends = p.friends
# and now friends is a list.
 lvd_parent - The name of our parent class
 lvd_model_name - The name of our new model
 lvd_value_type - The value type of the value in our new model
This has to be the name of one of the valid django
model field types such as 'CharField', 'FloatField',
or a valid custom field name.
 lvd_unique - Set this to true if you want the values in the list to
 be unique in the table they are stored in. For
 example if you are storing a list of strings and
 the strings are always "foo", "bar", and "baz", your
 data table would only have those three strings listed in
 it in the database.
 kwargs - These are passed to the value field.
  """
  self.related_set_name = lvd_model_name.lower() + "_set"
  self.model_name = lvd_model_name
  self.parent = lvd_parent
  self.unique = lvd_unique

  # only set this to true if they have not already set it.
  # this helps speed up the searchs when unique is true.
  kwargs['db_index'] = kwargs.get('db_index', True)

  filter = ["lvd_parent", "lvd_model_name", "lvd_value_type", "lvd_unique"]

  evalStr = """class %s (models.Model):\n""" % (self.model_name)
  evalStr += """value = models.%s(""" % (lvd_value_type)
  evalStr += self._params_from_kwargs(filter, **kwargs)
  evalStr += ")\n"
  if self.unique:
 evalStr += """parent = models.ManyToManyField('%s')\n"""
% (self.parent)
  else:
 evalStr += """parent = models.ForeignKey('%s')\n""" % (self.parent)
  evalStr += "\n"
  evalStr += """self.innerClass = %s\n""" % (self.model_name)

  print evalStr

  exec (evalStr) # build the inner class

   def __get__(self, instance, owner):
  value_set = instance.__getattribute__(self.related_set_name)
  l = []
  for x in value_set.all():
 l.append(x.value)

  return l

   def __set__(self, instance, values):
  value_set = instance.__getattribute__(self.related_set_name)
  for x in values:
 value_set.add(self._get_or_create_value(x))

   def __delete__(self, instance):
  pass # I should probably try and do something here.


   def _get_or_create_value(self, x):
  if self.unique:
 # Try and find an existing value
 try:
return self.innerClass.objects.get(value=x)
 except django.core.exceptions.ObjectDoesNotExist:
pass

  v = self.innerClass(value=x)
  v.save() # we have to save to create the id.
  return v

   def _params_from_kwargs(self, filter, **kwargs):
  """Given a dictionary of arguments, build a string which
  represents it as a parameter list, and filter out any
  keywords in filter."""
  params = ""
  for key in kwargs:
 if key not in filter:
value = kwargs[key]
params += "%s=%s, " % (key, value.__repr__())

  return params[:-2] # chop off the last ', '

class Person(models.Model):
   name = models.CharField(max_length=120)
   friends = ListValueDescriptor("Person", "Friend", "CharField",
True, max_length=120
==

However, I think it could be made a bit cleaner if it could inherit
from the 

Multiple Instances of Django

2009-07-15 Thread Caitlin Colgrove

I have two instances of django running under apache.  One in /portal
and one in /beta/portal.  They use two different code bases and two
different databases, although some of the data is replicated between
the two.  If I am logged in to one Django instance it interferes with
the other.  Presumably this is due to some setting (maybe a cookie
setting?) that is the same for both instances.  I can't figure out how
to avoid this situation, and a brief survey of the documentation
hasn't helped.  Can someone suggest a solution?

Thanks in advance.
Caitlin

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

2009-07-15 Thread Alex Gaynor
On Wed, Jul 15, 2009 at 11:35 AM, Emily Rodgers <
emily.kate.rodg...@googlemail.com> wrote:

>
>
>
> On Jul 15, 4:19 pm, Emily Rodgers 
> wrote:
> > On Jul 15, 2:46 pm, "Richard E. Cooke"  wrote:
> >
> > > OK.  Before I get flamed!
> >
> > > I neglected to search THIS group before I posted.
> >
> > > So, I see some chatter about being able to instansiate a second DB
> > > connector.  Great.
> >
> > > Now, how about where the best examples of that are?
> >
> > > And what impact, if any, does this have on the rest of Django?
> >
> > > My boss is starting to weaken too:  "Maybe its not so bad having
> > > Django tables added"
> >
> > Hi Richard,
> >
> > I have been having a go at this lately [1], and what I posted seems to
> > work to an extent, but I am currently having some m2m field problems
> > (not problems with foreign keys though), so what I posted may be
> > flawed.
> >
> > Alex G is working on getting proper support added to django for google
> > summer of code 2009, so hopefully it will be in a future release of
> > django :-)
> >
> > Em
> >
> > [1]
> http://groups.google.com/group/django-users/browse_thread/thread/af3a...
>
> I have figured out why the m2m field problems were happening (although
> not fixed it elegantly yet). When I figure out how to prevent the
> problem, I will reply to the other thread (where my suggested
> workaround it).
>
> Em
> >
>
Unfortunately because of the way m2ms are done in Django right now working
with any db besides the default is nearly impossible (they import a raw
connection and do queries).  I have a branch on github where I've rewritten
m2ms to use an internal model so we don't have this problem.
Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you want"
-- Me

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



Re: accessing multiple dbs?

2009-07-15 Thread Emily Rodgers



On Jul 15, 4:19 pm, Emily Rodgers 
wrote:
> On Jul 15, 2:46 pm, "Richard E. Cooke"  wrote:
>
> > OK.  Before I get flamed!
>
> > I neglected to search THIS group before I posted.
>
> > So, I see some chatter about being able to instansiate a second DB
> > connector.  Great.
>
> > Now, how about where the best examples of that are?
>
> > And what impact, if any, does this have on the rest of Django?
>
> > My boss is starting to weaken too:  "Maybe its not so bad having
> > Django tables added"
>
> Hi Richard,
>
> I have been having a go at this lately [1], and what I posted seems to
> work to an extent, but I am currently having some m2m field problems
> (not problems with foreign keys though), so what I posted may be
> flawed.
>
> Alex G is working on getting proper support added to django for google
> summer of code 2009, so hopefully it will be in a future release of
> django :-)
>
> Em
>
> [1]http://groups.google.com/group/django-users/browse_thread/thread/af3a...

I have figured out why the m2m field problems were happening (although
not fixed it elegantly yet). When I figure out how to prevent the
problem, I will reply to the other thread (where my suggested
workaround it).

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

2009-07-15 Thread danielA

Resolved.

In this method:


 formset_funcionario = modelformset_factory

(Funcionario,formset=func_set,max_num=7,extra=1)

Django seems to create a new class dinamycally called: [name_of_model]
Form

In the case above, tha class created would be:
django.forms.models.FuncionarioForm


If I want that the validation of each form in the formset respects a
validation of a one Form especifically, I have to pass the class of
this Form in the method modelformset_factory.

formset_funcionario = modelformset_factory

(Funcionario,form=FuncionarioForm,formset=func_set,max_num=7,extra=1)

This way, when I call the method is_valid() from formset_funcionario,
the validation methods of the Form FormFuncionario will be executed.






On 15 jul, 11:54, danielA  wrote:
> I have a Model;
>
> class Funcionario(models.Model):
>     nome = models.CharField(max_length=200)
>     email = models.CharField(max_length=100)
>     data_nasc = models.DateField('Data de Nascimento')
>     salario = models.FloatField()
>     observacao = models.CharField(max_length=500)
>
> I have a ModelForm for this Model
>
> class FuncionarioForm(ModelForm):
>     email = MyEmailField()
>
>     class Meta:
>         model = Funcionario
>
>     def clean_email(self):
>         data = self.cleaned_data['email']
>
>         if data != 'meuem...@gmail.com':
>             raise forms.ValidationError("ops, cleanEmail")
>
>         return data
>
> And I have a FormSet for this same Model
>
> class FuncionarioFormSet(BaseModelFormSet):
>     def __init__(self, *args, **kwargs):
>         self.queryset = Funcionario.objects.all()
>         super(FuncionarioFormSet, self).__init__(*args, **kwargs)
>
> Validation for the ModelForm goes fine:
>
>            When I call the is_valid() method from FuncionarioForm
> django does:
>
>            1. First calls the clean() method of each Field.
>            2. Calls the clean_email() method on FuncionarioForm
>            3. Call the clean() method on FuncionarioForm
>
> What I want it´s that steps above be repeated on validation of
> FuncionarioFormSet.
>
> Django actually does this according my code:
>
>          When I call the is_valid() method from FuncionarioFormSet
> Django does:
>
>           1. Calls the clean() method of each Field.
>           2. Call the clean() method of FuncionarioFormSet.
>
> It´s possible create clean_field methods for the validation of a
> ModelFormSet?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: code of models from oracle to mysql

2009-07-15 Thread Ian Kelly

On Jul 15, 7:07 am, Karen Tracey  wrote:
> On Wed, Jul 15, 2009 at 4:18 AM, pho...@gmail.com  wrote:
>
> > the code of models:
> >    mgsyxs = models.DecimalField(decimal_places=-127, null=True,
> > max_digits=126, db_column='MGSYXS', blank=True) # Field name made
> > lowercase.
>
> > i appreciate for your suggestion.
>
> decimal_places=-127 doesn't look right, I don't think that value should be
> lower than 0.  What is this field defined as in your original (Oracle?) db?
> It's possible that inspectdb is not working properly for whatever it you
> have in your original DB.

DecimalField(decimal_places=-127, max_digits=126) is what the Oracle
introspection returns for float columns, since that's how the database
describes them.  If you change them to FloatField you should be okay.

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

2009-07-15 Thread martin f krafft
also sprach Shawn Milochik  [2009.07.15.1722 +0200]:
> > Any reason why you can't do 'sudo -u otheruser bash -l' or even  
> > 'sudo su
> > - otheruser'? Seems strange to be able to sudo to root, but unable to
> > sudo to a role account.
> 
> 
> No, I don't see a reason not to do it that way. I just can't directly  
> su to the other user due to the lack of a password.

sudo -u otheruser -i

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
if voting could really change things, it would be illegal.
 -- revolution books, new york
 
spamtraps: madduck.bo...@madduck.net


digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)


Re: 1.1 request

2009-07-15 Thread Russell Keith-Magee

On Wed, Jul 15, 2009 at 10:54 PM, Up2L8 wrote:
>
> Is there any way Ticket #10977 could get rolled up into the 1.1
> release?
>
> Using the intersection and union operators seems borked for some
> applications and it sounds like this should fix it.

I'll take a look tomorrow if I get time, but no promises.

>From initial inspection, this is an edge case with a workaround, so it
isn't critical for v1.1. If 1.1 is ever going to get out the door,
we're going to need to live with some bugs. However, given that there
is a patch with a test, it's worth me having a quick look to see if I
can slip it in.

Yours,
Russ Magee %-)

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



Re: Deployment Tool Recommendation

2009-07-15 Thread Shawn Milochik
> 
> Any reason why you can't do 'sudo -u otheruser bash -l' or even  
> 'sudo su
> - otheruser'? Seems strange to be able to sudo to root, but unable to
> sudo to a role account.


No, I don't see a reason not to do it that way. I just can't directly  
su to the other user due to the lack of a password.

But those options (while syntactically different) are functionally  
identical. Probably better than they way I'm doing it though, because  
there are fewer steps.


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

2009-07-15 Thread Emily Rodgers



On Jul 15, 2:46 pm, "Richard E. Cooke"  wrote:
> OK.  Before I get flamed!
>
> I neglected to search THIS group before I posted.
>
> So, I see some chatter about being able to instansiate a second DB
> connector.  Great.
>
> Now, how about where the best examples of that are?
>
> And what impact, if any, does this have on the rest of Django?
>
> My boss is starting to weaken too:  "Maybe its not so bad having
> Django tables added"

Hi Richard,

I have been having a go at this lately [1], and what I posted seems to
work to an extent, but I am currently having some m2m field problems
(not problems with foreign keys though), so what I posted may be
flawed.

Alex G is working on getting proper support added to django for google
summer of code 2009, so hopefully it will be in a future release of
django :-)

Em


[1] 
http://groups.google.com/group/django-users/browse_thread/thread/af3a77225594a28c
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Deployment Tool Recommendation

2009-07-15 Thread Tom Evans

On Wed, 2009-07-15 at 10:38 -0400, Shawn Milochik wrote:
> I need to set up a one-click deployment from development to  
> production. What tool(s) are currently best-of-breed in the Django  
> community? Thanks in advance.
> 

I use fabric, but its not exactly best of breed. It does the job quite
well though, and is getting better.

> The tool must be able to automate the following manual process:
> 
> 1. Log into the production server via ssh, using a user ID which  
> requires a password (no public key encryption).
> 
> 2. Run 'sudo bash' then 'su - otheruser,' where otheruser is the ID  
> under which Django runs. I can't log in via ssh directly
> as this user for security reasons, and they have no password, so I  
> can't directly su to that account

Any reason why you can't do 'sudo -u otheruser bash -l' or even 'sudo su
- otheruser'? Seems strange to be able to sudo to root, but unable to
sudo to a role account.

> .
> 
> 3. As 'otheruser':
>  killall python
>  cd $SITE
>  ./manage.py migrate
>  ./manage.py runfcgi host=127.0.0.1 port=8100 -- 
> settings=companyname.web.sitename.settings
>  ./manage.py runfcgi host=127.0.0.1 port=8200 -- 
> settings=companyname.web.othersite.settings
>  ./manage.py runfcgi host=127.0.0.1 port=8300 -- 
> settings=companyname.web.coolsite.settings
>  ./manage.py runfcgi host=127.0.0.1 port=8400 -- 
> settings=companyname.web.funsite.settings
> 
> 4. (Possibly optional but highly desirable):
>   kill and restart nginx, which requires satisfying the prompts for the  
> passkeys for each SSL certificate we use.
> 

Fabric currently requires specific password prompt detection for each
app that requires passwords. I doubt it has it for nginx, it probably
doesn't look like a SSH password prompt.

Cheers

Tom


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

2009-07-15 Thread Up2L8

On Jul 15, 8:54 am, Up2L8  wrote:
> Is there any way Ticket #10977 could get rolled up into the 1.1
> release?
>
> Using the intersection and union operators seems borked for some
> applications and it sounds like this should fix it.

I guess I should mention that it seems that a workaround exists using
set(QS1) & set(QS2).  This evaluates properly (where QS1 & QS2 does
not).
Probably not the best implementation since it doesn't condense into a
single query but sufficient for my purposes.

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



ModelFormSet validation

2009-07-15 Thread danielA

I have a Model;

class Funcionario(models.Model):
nome = models.CharField(max_length=200)
email = models.CharField(max_length=100)
data_nasc = models.DateField('Data de Nascimento')
salario = models.FloatField()
observacao = models.CharField(max_length=500)


I have a ModelForm for this Model


class FuncionarioForm(ModelForm):
email = MyEmailField()

class Meta:
model = Funcionario

def clean_email(self):
data = self.cleaned_data['email']

if data != 'meuem...@gmail.com':
raise forms.ValidationError("ops, cleanEmail")

return data


And I have a FormSet for this same Model


class FuncionarioFormSet(BaseModelFormSet):
def __init__(self, *args, **kwargs):
self.queryset = Funcionario.objects.all()
super(FuncionarioFormSet, self).__init__(*args, **kwargs)



Validation for the ModelForm goes fine:

   When I call the is_valid() method from FuncionarioForm
django does:

   1. First calls the clean() method of each Field.
   2. Calls the clean_email() method on FuncionarioForm
   3. Call the clean() method on FuncionarioForm


What I want it´s that steps above be repeated on validation of
FuncionarioFormSet.

Django actually does this according my code:

 When I call the is_valid() method from FuncionarioFormSet
Django does:

  1. Calls the clean() method of each Field.
  2. Call the clean() method of FuncionarioFormSet.


It´s possible create clean_field methods for the validation of a
ModelFormSet?

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

2009-07-15 Thread Up2L8

Is there any way Ticket #10977 could get rolled up into the 1.1
release?

Using the intersection and union operators seems borked for some
applications and it sounds like this should fix 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: I need to get psycopg2 installed on Mac OS X 10.5

2009-07-15 Thread Juan Pablo Romero Méndez

I remember that there were some issues, but unfortunately I didn't
document how I resolved them :(

  Juan Pablo

2009/7/14 Kevin :
>
> Thanks a lot Juan!  It works fine on my machine.  Would you be able to
> share your compilation steps?
>
> On Jul 14, 7:32 am, Juan Pablo Romero Méndez 
> wrote:
>> I don't know if it will run in your machine, but here is one compiled
>> for Python2.5, MacOS X 10.5.7, and PostgreSQL 8.3.
>>
>> Regards,
>>
>>   Juan Pablo
>>
>> 2009/7/14 Kevin :
>>
>>
>>
>>
>>
>> > I need to get psycopg2 installed on Mac OS X 10.5
>>
>> > I have read every install guide I could find and I still do not have
>> > it working. I have developer tools installed. I am running MacPython
>> > 2.6.2 and PostgreSQL 8.4 downloaded 
>> > fromhttp://www.enterprisedb.com/products/pgdownload.do
>>
>> > On my production machine (Debian) I did a simple atp-get and it
>> > worked. Why is it so much harder on Mac OS X?  I am very near ripping
>> > my hair out because I have wasted too much time and I do not
>> > understand why psycopg2 does not work on my machine.
>>
>> > Below are my notes from three attempts to install psycopg2.  I have
>> > read other threads that suggest installing Python, PostgreSQL, and
>> > psycopg2 from MacPorts.  I do not want to use MacPorts.  I do not see
>> > why I need to use a completely different installation of Python to use
>> > a simple database driver.
>>
>> > For my first attempt I followed the instructions listed here:
>> >http://jasonism.org/weblog/2008/nov/06/getting-psycopg2-work-mac-os-x...
>> > It told me to add these lines to setup.cfg:
>>
>> > include_dirs=/Library/PostgreSQL/8.3/include
>> > library_dirs=/Library/PostgreSQL/8.3/lib
>>
>> > I then ran python setup.py build and got this error:
>>
>> > $ python setup.py build
>> > running build
>> > running build_py
>> > creating build
>> > creating build/lib.macosx-10.3-fat-2.6
>> > creating build/lib.macosx-10.3-fat-2.6/psycopg2
>> > copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>> > copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>> > copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>> > copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>> > copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>> > copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>> > copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>> > running build_ext
>> > error: No such file or directory
>>
>> > ===
>>
>> > For my next attempt I followed the instructions listed here:
>> >http://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/
>> > It told me to run this:
>>
>> > PATH=$PATH:/Library/PostgresPlus/8.3/bin/ sudo easy_install psycopg2
>>
>> > This resulted in this error: (I substituted "8.4" for "8.3" because my
>> > version of PostgreSQL is newer)
>>
>> > $ PATH=$PATH:/Library/PostgreSQL/8.4/bin/ sudo easy_install psycopg2
>> > Password:
>> > Searching for psycopg2
>> > Readinghttp://pypi.python.org/simple/psycopg2/
>> > Readinghttp://initd.org/projects/psycopg2
>> > Readinghttp://initd.org/pub/software/psycopg/
>> > Best match: psycopg2 2.0.11
>> > Downloadinghttp://initd.org/pub/software/psycopg/psycopg2-2.0.11.tar.gz
>> > Processing psycopg2-2.0.11.tar.gz
>> > Running psycopg2-2.0.11/setup.py -q bdist_egg --dist-dir /tmp/
>> > easy_install-dUXtsI/psycopg2-2.0.11/egg-dist-tmp-1008XV
>> > warning: no files found matching '*.html' under directory 'doc'
>> > warning: no files found matching 'MANIFEST'
>> > /usr/libexec/gcc/i686-apple-darwin9/4.0.1/as: assembler (/usr/bin/../
>> > libexec/gcc/darwin/i386/as or /usr/bin/../local/libexec/gcc/darwin/
>> > i386/as) for architecture i386 not installed
>> > /usr/libexec/gcc/powerpc-apple-darwin9/4.0.1/as: assembler (/usr/
>> > bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/
>> > darwin/ppc/as) for architecture ppc not installed
>> > Installed assemblers are:
>> > /usr/bin/../libexec/gcc/darwin/ppc64/as for architecture ppc64
>> > /usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
>> > Installed assemblers are:
>> > /usr/bin/../libexec/gcc/darwin/ppc64/as for architecture ppc64
>> > /usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
>> > lipo: can't open input file: /var/tmp//ccSK6sd7.out (No such file or
>> > directory)
>> > error: Setup script exited with error: command 'gcc' failed with exit
>> > status 1
>> > Exception TypeError: TypeError("'NoneType' object is not callable",)
>> > in > > 0x9e3910>> ignored
>> > Exception TypeError: TypeError("'NoneType' object is not callable",)
>> > in > > 0x9e3970>> ignored
>>
>> > ===
>>
>> > For my third attempt I installed the binary of psycopg2 from
>> >http://pythonmac.org/packages/py25-fat/index.html
>> > I thought it worked, but 

Re: tagging question about django-tagging

2009-07-15 Thread Alex Gaynor
On Wed, Jul 15, 2009 at 9:31 AM, joep  wrote:

>
> I'm new to both python and django, so please excuse my ignorance if
> this is obvious. I have a tagged model which I would like to form a
> tag cloud. I am using the following
>
>t = Tag.objects.cloud_for_model(Post,
>filters=dict(
>blog__slug=blog_slug,
>publish__lte=datetime.datetime.now(),
>expiry__gt=datetime.datetime.now(),
>)
>)
>
> This is fine except most of the expiry fields are None (i.e., never
> expire), but I can't figure out how to add these back into the
> queryset filters. In other words, I want
>
>   expiry__gt=datetime.datetime.now() OR expiry=None
>
> Again, this may be obvious, but I haven't figured it out.
>
>
>
> >
>
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objectsexplains
how to do queries with OR clauses.
Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you want"
-- Me

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



Deployment Tool Recommendation

2009-07-15 Thread Shawn Milochik

I need to set up a one-click deployment from development to  
production. What tool(s) are currently best-of-breed in the Django  
community? Thanks in advance.

The tool must be able to automate the following manual process:

1. Log into the production server via ssh, using a user ID which  
requires a password (no public key encryption).

2. Run 'sudo bash' then 'su - otheruser,' where otheruser is the ID  
under which Django runs. I can't log in via ssh directly
as this user for security reasons, and they have no password, so I  
can't directly su to that account.

3. As 'otheruser':
 killall python
 cd $SITE
 ./manage.py migrate
 ./manage.py runfcgi host=127.0.0.1 port=8100 -- 
settings=companyname.web.sitename.settings
 ./manage.py runfcgi host=127.0.0.1 port=8200 -- 
settings=companyname.web.othersite.settings
 ./manage.py runfcgi host=127.0.0.1 port=8300 -- 
settings=companyname.web.coolsite.settings
 ./manage.py runfcgi host=127.0.0.1 port=8400 -- 
settings=companyname.web.funsite.settings

4. (Possibly optional but highly desirable):
kill and restart nginx, which requires satisfying the prompts for the  
passkeys for each SSL certificate we use.




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



tagging question about django-tagging

2009-07-15 Thread joep

I'm new to both python and django, so please excuse my ignorance if
this is obvious. I have a tagged model which I would like to form a
tag cloud. I am using the following

t = Tag.objects.cloud_for_model(Post,
filters=dict(
blog__slug=blog_slug,
publish__lte=datetime.datetime.now(),
expiry__gt=datetime.datetime.now(),
)
)

This is fine except most of the expiry fields are None (i.e., never
expire), but I can't figure out how to add these back into the
queryset filters. In other words, I want

   expiry__gt=datetime.datetime.now() OR expiry=None

Again, this may be obvious, but I haven't figured it out.



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



Re: Forms: Set default value

2009-07-15 Thread Fred Chevitarese
I guess you can use the choices in the form that you´ve created!

class AuthorForm(forms.Form):
name = forms.CharField(max_length=100)
title = forms.CharField(max_length=3,
widget=forms.Select(choices=TITLE_CHOICES))
birth_date = forms.DateField(required=False)

Take a look here 

There´s an explanation for what you desire!




2009/7/15 Wiiboy 

>
> Sorry, I was little unclear above.  I need to set the default for a
> form.
> >
>


-- 
http://chevitarese.wordpress.com

Fred Chevitarese - GNU/Linux

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



Firefox doesn't receive response

2009-07-15 Thread alecs

I have faced with interesting issue: I have some views which process
files (deleting them recursively or saving many files). When I upload
or delete many files response is not received by firefox ... I just
press "Upload files" (sumbit upload form) button, and nothing happens
with this page (but it should render return render_to_response
('success.html', variables)). But the files are saved (or deleted),
i.e. view woks, but response is 'lost'.
Everything works ok in Safari, IE6&8, Opera 10b1, but not in Firefox
2&3

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



Re: Forms: Set default value

2009-07-15 Thread Wiiboy

Sorry, I was little unclear above.  I need to set the default for a
form.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: accessing multiple dbs?

2009-07-15 Thread Richard E. Cooke

OK.  Before I get flamed!

I neglected to search THIS group before I posted.


So, I see some chatter about being able to instansiate a second DB
connector.  Great.

Now, how about where the best examples of that are?

And what impact, if any, does this have on the rest of Django?

My boss is starting to weaken too:  "Maybe its not so bad having
Django tables added"



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



Base Class Inheritance w/ Model Methods

2009-07-15 Thread LeeRisq

So I'm hitting a beginner's snag here. I have six models that I need
to contain essentially all the same attributes. I created a base class
and then created the child classes respectively. Some of the child
classes will contain additional attributes to the base class, but the
rest only need what is defined within the base class.

Is there a required minimum number of attributes that a child class
must have to validate? For instance, can the child class have zero
attributes because it inherits all of them from the base class?


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

2009-07-15 Thread The Danny Bos

Agreed, I should get used to using Forms.
So I gave it a go, the new problem I have is out of my three fields,
two need to be hidden and have values automatically assigned from the
page they're on. This is freaking me out.

Now I have:

# forms.py
class RatingForm(forms.Form):
record = forms.CharField(widget=forms.HiddenInput)
critic = forms.CharField(widget=forms.HiddenInput)
rating = forms.ChoiceField(choices=RATING_CHOICES)

#views.py
def record_detail(request):
if request.method == 'POST':
form = RatingForm(request.POST)
if form.is_valid():
record_rating = Rating()

record_rating.rating = form.cleaned_data['rating']
record_rating.record = 
record_rating.writer = 
record_rating.save()

return HttpResponseRedirect('/')
else:
...


How do I get the User.ID (as you'll need to be logged in), into that
hidden field or the DB. And also the Record.ID from the page I was
just on.

Know what I mean. Am I way off?
I'm new to this, so any detailed help is very welcome.

Thanks again,


d



On Jul 15, 2:37 am, Lakshman Prasad  wrote:
> > It runs OK (no errors) but doesn't save a single thing
>
>      It has to run without errors because you have enclosed the whole thing
> in try.
>
>      You have to coerce the record_id and user_id into int before assigning
> to the model fields, for it to save.
>
> On Tue, Jul 14, 2009 at 9:45 PM, The Danny Bos  wrote:
>
>
>
>
>
>
>
> > Heya, am trying to simply save 3 values to a database, without using
> > Forms.
>
> > In the Template:
>
> > 
> >        
> >        
> >        Rate This: {% for n in numbers %} > value="{{ n }}">{{ n }}{% endfor %}
> >        
> > 
>
> > In the View:
>
> > from mysite.rating.models import Rating
> > def critics_rating(request):
> >        try:
> >                record_id = request.POST['record_id']
> >                user_id = request.POST['user_id']
> >                rating_val = request.POST['rating']
>
> >                rating = Rating()
> >                rating.rating = rating_val
> >                rating.item = record_id
> >                rating.writer = user_id
> >                rating.save()
>
> >                return HttpResponseRedirect('/')
> >        except:
> >                pass
> >        obj = Record.objects.get(id=record)
> >        return render_to_response('record/detail.html', {'object_detail':
> > obj}, context_instance=RequestContext(request))
>
> > It runs OK (no errors) but doesn't save a single thing, also it goes
> > back to the 'detail.html' page fine, but when you hit reload, it sends
> > the data again. Again, not saving.
>
> > Any ideas what's wrong with this?
> > I've done a lot of searching but all people seem to use the Forms
> > widget, I was thinking as this is only three fields I'd skip that.
> > Silly?
>
> --
> Regards,
> Lakshman
> becomingguru.com
> lakshmanprasad.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
-~--~~~~--~~--~--~---



accessing multiple dbs?

2009-07-15 Thread Richard E. Cooke

The answer is not jumping out at me, so I'm going to post it here in
case its a simple answer.

I want to access an existing DB on a remote server using Postgres.  My
boss is not crazy about having Django "polluting" this existing -
large - db with its internal guts.

But I don't see how to specify a SECOND db connection in Django.
There is only one Settings.py file.

Can I instantiate a second connector?  And will doing so allow me to
take advantage of the admin interface?

Or, if I make my own connection, and use Django's db models (assuming
I can even do that without conflict) will I still be able to
"comfortably" program the Django way?

Or maybe if I make a second connection, it has to be all by hand -
using my own classes.  No tie-in to Django's niceties.

Or is this a "deal breaker"?  Where Django really only works if all
"application" data is in the same db as all "site" data?


Thanks in Advance!
Richard Cooke
Turnkey Automation Inc.

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

2009-07-15 Thread Karen Tracey
On Wed, Jul 15, 2009 at 4:18 AM, pho...@gmail.com  wrote:

>
> Hi, all
>
> i have used the command 'manage.py inspectdb' to generate code of
> models.
> then i want to use the code to create dbtable in mysql, and i got
> errormessage:
>Traceback (most recent call last):
> [snip]
>  File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line
> 35, in defau
> lterrorhandler
>raise errorclass, errorvalue
> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your
> SQL syntax
> ; check the manual that corresponds to your MySQL server version for
> the right s
> yntax to use near '-127) NULL,\n`MGSYXS` numeric(126, -127) NULL,
> \n`MGSY
> KC` numeric(126, -127' at line 17")
>
> the code of models:
>mgsyxs = models.DecimalField(decimal_places=-127, null=True,
> max_digits=126, db_column='MGSYXS', blank=True) # Field name made
> lowercase.
>
> i appreciate for your suggestion.


decimal_places=-127 doesn't look right, I don't think that value should be
lower than 0.  What is this field defined as in your original (Oracle?) db?
It's possible that inspectdb is not working properly for whatever it you
have in your original DB.

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: Optional user foreign key - for tracking viewing history

2009-07-15 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-07-15, o godz. 12:24, przez R C:

> I would like to track the viewing history for users to my site to see
> which blog entries are being viewed by whom.  And I would like to
> track the user who is viewing it *IF* they are logged in, otherwise I
> would like to ignore the user field (see models below)
>
> [models.py]
> class Entry(models.Model):
>title = models.CharField(maxlength=250)
>slug = models.SlugField(
> maxlength=250,
> prepopulate_from=('title'),
> unique_for_date='pub_date'
>)
>body = models.TextField()
>pub_date = models.DateTimeField(default=datetime.now())
>
> class ViewHistory(models.Model):
>entry = models.ForeignKey(Entry)
>user = models.ForeignKey(User, blank=True)

Should be:
user = models.ForeignKey(User, blank=True, null=True)

(blank is only for admin validation).

>timestamp = models.DateTimeField(auto_now=True,editable=False)

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


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

2009-07-15 Thread Fred Chevitarese
Yes!! That will be good!!
hello gustavo!! I like your blog very much !!! ;)

Fred Chevitarese - GNU/Linux
http://chevitarese.wordpress.com

2009/7/14 Gustavo Henrique 

>
> +1, too
>
> I thinks interesting record in video all about that.
> This important for consolidate the Django with all developers in the world.
>
>
>
> --
> Gustavo Henrique
> Site: http://www.gustavohenrique.net
> Blog: http://blog.gustavohenrique.net
>
> >
>


-- 
http://chevitarese.wordpress.com

Fred Chevitarese - GNU/Linux

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



Re: Forms: Set default value

2009-07-15 Thread Fred Chevitarese
You can set the default choice in the model like this.
SEARCH_CHOICES = (
('G', 'google'),
('Y', 'Yahoo'),
('L', 'Live Search'),
)

Now, your model will be set like this...

class anything(models.Model):
 title = models.CharField(max_length = 80)
 search_engine = models.CharField(max_length = 1, choices =
SEARCH_CHOICES, default = 'google')


Hope it help!!

Fred Chevitarese - GNU/Linux
http://chevitarese.wordpress.com

2009/7/15 Wiiboy 

>
> Hi,
> I'm defining a form model, and I have a choice field.  I have the
> values in order, and I want one value (in the middle of the values in
> order) to be the default.  How do I do that?
>
> Passing initial= anything doesn't work.
> >
>


-- 
http://chevitarese.wordpress.com

Fred Chevitarese - GNU/Linux

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

2009-07-15 Thread Daniel Roseman

On Jul 15, 10:27 am, veasna bunhor  wrote:
> Dear All,
>
> I have spent 2 hours to search about how to use Datime Format and Comment
> Spacing in Django, but i still found it . Does anybody know how to do this ?
> Could you please tell me about that?
>
> Best regards,
>
> Veasna

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
(which is the top result on Google for 'django date format', so I
don't know how it could possibly take two hours to find)

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



Re: newbie question information about js

2009-07-15 Thread Daniel Roseman

On Jul 15, 9:14 am, luca72  wrote:
> Hello and thanks for your help.
> I think that i need context, i attach my test file:
>
> from django.shortcuts import render_to_response
> from off_bert.offerte.forms import RichiestaForm
> from django.http import HttpResponseRedirect
>
> def richiesta(request):
>     if request.method == 'POST':
>         form = RichiestaForm(request.POST)
>         if form.is_valid():
>             processo_richiesta()
>     else :
>         form = RichiestaForm()
>         return render_to_response('richiedi.html',{'form': form})
>
> def processo_richiesta():
>     from django.template import Template, Context
>     t = Template('ciao, {{scritto}}')
>     c = Context({"scritto": """script type="text/javascript">
>                                                alert("ok") script>"""})
>
>     t.render(c)
>
> But don't work
>
> can you tell me some sample to look
>
> Thanks
>
> Luca
>

Again, "doesn't work" isn't a very useful thing to say - it would be
more helpful to describe what actually happens.

However, there are a couple of things wrong with the code you have
posted. Firstly, when you call processo_richiesta(), you don't
actually do anything with the rendered template. I think you mean
'return processo_richiesta()', which will return the rendered template
as the response so that it is displayed.

Secondly, auto-escaping will mean that your script tags will not work.
You'll need to either use "mark_safe" in your context definition, or
the "safe" filter in your template. See here for more information:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping

Thirdly, the final line of your view needs to be one indent to the
left, so that it is caught in the case that the form is posted but not
valid.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Optional user foreign key - for tracking viewing history

2009-07-15 Thread R C

Hi,

I would like to track the viewing history for users to my site to see
which blog entries are being viewed by whom.  And I would like to
track the user who is viewing it *IF* they are logged in, otherwise I
would like to ignore the user field (see models below)

[models.py]
class Entry(models.Model):
title = models.CharField(maxlength=250)
slug = models.SlugField(
 maxlength=250,
 prepopulate_from=('title'),
 unique_for_date='pub_date'
)
body = models.TextField()
pub_date = models.DateTimeField(default=datetime.now())

class ViewHistory(models.Model):
entry = models.ForeignKey(Entry)
user = models.ForeignKey(User, blank=True)
timestamp = models.DateTimeField(auto_now=True,editable=False)

The problem is that I cannot save the ViewHistory unless the user is
logged in.

Apparently Django does not allow a blank user field (even it is
specified in the model) and I get the following error:
(1048, "Column 'user_id' cannot be null")

If I try to use an AnonymousUser object then Django complains:
ValueError: Cannot assign "": "ViewHistory.user" must be a "User" instance.

Can anyone help me understand how to have a model with an optional
foreign key to the django.contrib.auth.models User object?

Thanks,

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

2009-07-15 Thread Joshua Partogi
I think that django gae patch does not enable you to use django model
because gae does not use dbms on the backend.

On Wed, Jul 15, 2009 at 7:38 PM, Vishwajeet  wrote:

>
> Hi,
>
> Thanks for the link I am using the helper but helper does not suggest
> anything about models other than just saying that you have to change
> your model.
>
>
-- 
http://blog.scrum8.com
http://twitter.com/scrum8

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



Re: Error: ce is not defined

2009-07-15 Thread Joost Cassee

On Jul 14, 10:51 pm, Sonal Breed  wrote:

> After I made TINYMCE_COMPRESSOR as False, I could get tinymce toolbar.
> However, the style dropdown is showing empty, and there are couple of
> other things I would like to have, like spell checker and color.
> Have to go through tinymce docs, do u have any tips?

Setting the TinyMCE options (as documented in the TinyMCE wiki [1]) in
TINYMCE_DEFAULT_CONFIG, as you have done, should just work. You will
need a language pack for every language in LANGUAGES and the Enchant
library as explained in the django-tinymce documentation [2].

[1] http://wiki.moxiecode.com/index.php/TinyMCE:Configuration
[2] 
http://django-tinymce.googlecode.com/svn/trunk/docs/.build/html/installation.html#id1

There have been reports that django-tinymce has a problem with
languages with non-ASCII characters. I'm still trying to reproduce
this.

If you have more specific questions I may be able to help you
better. :-)

Regards,

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

2009-07-15 Thread Vishwajeet

Hi,

Thanks for the link I am using the helper but helper does not suggest
anything about models other than just saying that you have to change
your model.

On Jul 15, 12:00 am, Matteo Rosati  wrote:
> Hello friend,
> maybe you can consider using the Goole App Engine helper for Django.
>
> http://code.google.com/p/google-app-engine-django/
>
> when you download the necessary files, read the README file and read how to
> deploy a pre existing django application in google AE without modifying your
> files (except for the settings); this is explained in "Installing the helper
> into an existing project" in the README file!
>
> i hope this helps you!
>
> bye,
> Matteo
>
> 2009/7/14 Vishwajeet 
>
>
>
> > Hi All,
>
> > I am planning to host my django application on google app engine; I
> > have completed the application using django but now when I decided to
> > host it on google app engine I need to changed models and all it
> > reference to app engines framework; I have googled alot but have not
> > found much information on migrating models and how to go about it. I
> > found nifty examples but that does not cover the all
> > If any of you out there have any experience in same I would appreciate
> > if you can share the same.
>
> --
> Matteo Rosati
> Web:http://wwwstud.dsi.unive.it/~mrosati
> PGP:http://wwwstud.dsi.unive.it/~mrosati/pgp.html
> GNU/Linux registered user #398557
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



DateTime Format & Spacing

2009-07-15 Thread veasna bunhor
Dear All,

I have spent 2 hours to search about how to use Datime Format and Comment
Spacing in Django, but i still found it . Does anybody know how to do this ?
Could you please tell me about that?

Best regards,

Veasna

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

2009-07-15 Thread alecs

 for file in request.FILES.getlist('file'):

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



code of models from oracle to mysql

2009-07-15 Thread pho...@gmail.com

Hi, all

i have used the command 'manage.py inspectdb' to generate code of
models.
then i want to use the code to create dbtable in mysql, and i got
errormessage:
Traceback (most recent call last):
  File "C:\vincent\wd\django\mysite\mysite\manage.py", line 11, in

execute_manager(settings)
  File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg
\django\core\m
anagement\__init__.py", line 340, in execute_manager
utility.execute()
  File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg
\django\core\m
anagement\__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg
\django\core\m
anagement\base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
  File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg
\django\core\m
anagement\base.py", line 219, in execute
output = self.handle(*args, **options)
  File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg
\django\core\m
anagement\base.py", line 348, in handle
return self.handle_noargs(**options)
  File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg
\django\core\m
anagement\commands\syncdb.py", line 80, in handle_noargs
cursor.execute(statement)
  File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg
\django\db\bac
kends\util.py", line 19, in execute
return self.cursor.execute(sql, params)
  File "c:\python25\lib\site-packages\django-1.0.2_final-py2.5.egg
\django\db\bac
kends\mysql\base.py", line 83, in execute
return self.cursor.execute(query, args)
  File "C:\Python25\lib\site-packages\MySQLdb\cursors.py", line 167,
in execute
self.errorhandler(self, exc, value)
  File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line
35, in defau
lterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your
SQL syntax
; check the manual that corresponds to your MySQL server version for
the right s
yntax to use near '-127) NULL,\n`MGSYXS` numeric(126, -127) NULL,
\n`MGSY
KC` numeric(126, -127' at line 17")

the code of models:
mgsyxs = models.DecimalField(decimal_places=-127, null=True,
max_digits=126, db_column='MGSYXS', blank=True) # Field name made
lowercase.

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



Re: newbie question information about js

2009-07-15 Thread luca72

Hello and thanks for your help.
I think that i need context, i attach my test file:

from django.shortcuts import render_to_response
from off_bert.offerte.forms import RichiestaForm
from django.http import HttpResponseRedirect

def richiesta(request):
if request.method == 'POST':
form = RichiestaForm(request.POST)
if form.is_valid():
processo_richiesta()
else :
form = RichiestaForm()
return render_to_response('richiedi.html',{'form': form})

def processo_richiesta():
from django.template import Template, Context
t = Template('ciao, {{scritto}}')
c = Context({"scritto": """script type="text/javascript">
   alert("ok")"""})

t.render(c)

But don't work

can you tell me some sample to look

Thanks

Luca

On 14 Lug, 20:07, Shawn Milochik  wrote:
> On Jul 14, 2009, at 12:30 PM,luca72wrote:
>
>
>
> > Hello
> > I have a question in my view fiole i have this
>
> > def myfunct()
> >     do this...
> > now i need only to return a js alert message on the same page
> > is it possible?
>
> We need more information. Are you calling myfunct() via an AJAX call?  
> I don't see a request in the argument list, but is that because you  
> left it out, or is this not a "view" function (receives request and  
> returns a response)?
>
> Your function executes server-side, and JavaScript (obviously)  
> executes client-side. Python can't do the alert box, but it can:
>
> 1. Render a template containing the JavaScript.
> 2. Pass the JavaScript text into a templatt, via the Context.
> 3. Return a JSON value via AJAX to the template's JavaScript (you have  
> to bind the handler in the JavaScript, preferably using jQuery for  
> ease-of-use) that passes the message to be used for the alert.
>
> I hope this helps. If not, please send more relevant detail. Pretend  
> you're explaining the problem to someone who has no idea what you're  
> talking about, because we don't.
>
> Shawn
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MultiFileWidget

2009-07-15 Thread alecs

Hi! I'm trying to use http://www.djangosnippets.org/snippets/583/ and
getting an error 'str' object has no attribute 'name'.
It happens on this line:

logging.debug(request.FILES)
for file in request.FILES['file']:
filename = file.name

Using firepy ( logging.debug) I see this dictionary:

, ]}>

So what is wrong ? And why 'str' ?
Maybe it's a silly question, but I'm a newbie :)

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