Re: rollback transaction without an exception when transaction is tied to http requests

2009-06-25 Thread Frédéric Hébert

2009/6/26 sico :
>
> Hi
>

Hi

> Is it possible to rollback the transaction without raising an
> exception when the transactions are tied to http requests??

What do you mean ?
You use raw sql in  a view ?


> I'm writing several records in one post call, if any fail I'd like to
> rollback the transaction but return a nice error message to the user.
> Surely I'm missing something as this seems quite a simple
> requirement...

AFAIK, django automatically rollbacks your transaction when you use
its orm (and surely raises an exception).
If you use raw sql you can surely use try ... except around the Python
DB API call

>
> thanks in advance
> Simon


Frédéric

> >
>



-- 
http://www.openidfrance.fr/fhebert

--~--~-~--~~~---~--~~
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: Very bad experience in Django...

2009-06-25 Thread Lars Stavholm

Chris Withers wrote:
> steveneo wrote:
>> I try to use Django in a new project. Honestly, it is very bad
>> experience. It looks not boosting my development speed. Today, I
>> almost give up and begin to look up another Python framework
> 
> Go for it :-)

+1
/L

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



Re: django apps that implement ticket filtering?

2009-06-25 Thread Margie

Yeah, I just thought maybe I could leverage some existing code that
would support AND and OR of filters and provide an interface where the
user can add filters as needed.  It seems to me that creating an
interface where you AND and OR filters is not so simple.  But that's
not really a django issue - just thought someone here might have some
ideas.

Margie

On Jun 25, 3:27 pm, lzantal  wrote:
> Hi,
>
> You could submit all the filters from an html form and in your view  
> function loop through the request.Post and build the queries if the  
> Post value is not empty.Using django.db.models.Q
>
> Laszlo Antalhttp://www.antalconsulting.com
> Office: 208-699-7508
>
> On Jun 25, 2009, at 2:32 PM, Margie  wrote:
>
>
>
> > I am trying to implement a specialized ticketing system in django.  At
> > a high level, it has many similarities to the django bug tracking
> > system, which I believe is implemented using trac.
>
> > I have coded the models models and the associated django code that
> > lets people create their tickets.  Now I'm at the point where I want
> > to implement queries.  IE, let the user choose filters (and and or
> > them together hopefully) that let you, for example, "find all tickets
> > owned by Joe, created after 6/15/09, with status open".  Nothing too
> > new here.  In looking for models of this functionality, I find the
> > trac system to be fairly straighforward, from a user perspective.  But
> > of course, it isn't written in django.  I looked at their html and
> > javascript templates and found them very hard to wade through.  I'm
> > wondering if anyone knows of any open source django apps that do
> > something similar?  In particular, I'm interested in the html
> > templates and associated javascript/jquery to make the filters
> > "dynamic", as that is the area I am sort of weak in.
>
> > Thanks for any pointers!
>
> > Margie
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "python manage.py runserver" tutorial error

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 11:57 PM, Steve1234  wrote:

>
> I installed psycopg2 as you suggest, however I still have the same
> error.  The error complains about psycopg not psycopg2, did I get the
> wrong module?  Or something else?
> >
>
In your settings.py make sure you have postressql_psycopg2 set as your
DATABASE_ENGINE.

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

--~--~-~--~~~---~--~~
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: Hard linking an image

2009-06-25 Thread koranthala



On Jun 26, 2:21 am, Kevin Teague  wrote:
> Presumably you already have all of the data required to generate a
> chart on the server? If so, then store the chart data in a model, and
> just reference it by id. e.g.
>
> 
>
> (or w/ a pretty URL: )
>
> And create a Chart object and store it before sending out the HTML
> response. Then update your chart view so that it fetches that object
> and uses it as input to generate the graph.

The data required to create the chart is calculated from the server. I
can create a model and store it, but when should I delete the same?
Once the image is created? In case the image is not created - say full
page did not load - before that the user closed it etc. In such case,
how do I delete the stored data?

Also, is it good to store these temperory data in models?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



rollback transaction without an exception when transaction is tied to http requests

2009-06-25 Thread sico

Hi

Is it possible to rollback the transaction without raising an
exception when the transactions are tied to http requests??
I'm writing several records in one post call, if any fail I'd like to
rollback the transaction but return a nice error message to the user.
Surely I'm missing something as this seems quite a simple
requirement...

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



Re: "python manage.py runserver" tutorial error

2009-06-25 Thread Steve1234

I installed psycopg2 as you suggest, however I still have the same
error.  The error complains about psycopg not psycopg2, did I get the
wrong module?  Or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Writing a reusable app

2009-06-25 Thread Kenneth Gonsalves

On Friday 26 June 2009 09:54:04 Joshua Partogi wrote:
> I'm currently also splitting up my django apps to be reusable. What is your
> main reason to have full batteries ? For some people that is already
> running django, it is more ideal to go minimalistic because then it will be
> easier to plug into existing django apps.

well, personal experience. I have an app which I have been planning to release 
from about january 2007. The app has been ready since then, but I have not 
formally released it because I was doing the minimalist thingie. I now realise 
that this goes against the open source creed - commit early and commit often. 
By putting it up as it is, user feedback is there, people will fork and the 
work will get done. (and also if the app is useless, then no one will respond 
and I can save time). So I suggest you just publish it and take it from there.
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: Writing a reusable app

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 11:24 PM, Joshua Partogi wrote:

> Hi Kenneth,
>
> I'm currently also splitting up my django apps to be reusable. What is your
> main reason to have full batteries ? For some people that is already running
> django, it is more ideal to go minimalistic because then it will be easier
> to plug into existing django apps.
>
> Regards,
>
> On Fri, Jun 26, 2009 at 2:18 PM, Kenneth Gonsalves  > wrote:
>
>>
>> On Thursday 25 June 2009 19:21:15 nabucosound wrote:
>> > So how do u guys think I should target it? Minimalistic or full-
>> > batteries included?
>>
>> full batteries
>>
>>
>
> --
> Join Scrum8.com.
>
> http://scrum8.com/member/jpartogi/
> http://scrum8.com/blog/jpartogi/
> http://twitter.com/scrum8
>
>
> >
>
I think the best solution is to try to follow the guidlines James sets out
here: http://www.youtube.com/watch?v=A-S0tqpPga4

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

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



Re: Writing a reusable app

2009-06-25 Thread Joshua Partogi
Hi Kenneth,

I'm currently also splitting up my django apps to be reusable. What is your
main reason to have full batteries ? For some people that is already running
django, it is more ideal to go minimalistic because then it will be easier
to plug into existing django apps.

Regards,

On Fri, Jun 26, 2009 at 2:18 PM, Kenneth Gonsalves
wrote:

>
> On Thursday 25 June 2009 19:21:15 nabucosound wrote:
> > So how do u guys think I should target it? Minimalistic or full-
> > batteries included?
>
> full batteries
>
>

-- 
Join Scrum8.com.

http://scrum8.com/member/jpartogi/
http://scrum8.com/blog/jpartogi/
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: Writing a reusable app

2009-06-25 Thread Kenneth Gonsalves

On Thursday 25 June 2009 19:21:15 nabucosound wrote:
> So how do u guys think I should target it? Minimalistic or full-
> batteries included?

full batteries
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: TimeField and null

2009-06-25 Thread adrian

Thanks for that clear explanation, and your solution works great!

Adrian

On Jun 24, 9:23 pm, Karen Tracey  wrote:
> On Wed, Jun 24, 2009 at 3:57 PM, adrian  wrote:
>
> > I need a time field that can be None.
>
> > I define the field so that Null is legal in the DB:
>
> > time_end = models.TimeField(blank=True, null=True)
>
> > The form field is:
>
> > time_end = forms.ChoiceField(required=False, choices=END_TIME_CHOICES)
>
> > and END_TIME_CHOICES is:
>
> > END_TIME_CHOICES = (
> >    (None, 'End Time Unknown'),
> >    (datetime.time(0,0), '12:00 Midnight'),
> >    (datetime.time(0,30), '12:30 AM'),
> >    (datetime.time(1,0), '1:00 AM'),
> >    (datetime.time(1,30), '1:30 AM'),
> >  etc,
> > )
>
> > My question is why does this field give a validation error when None
> > is selected, saying:
>
> > ValidationError at /event/add_event/
>
> > Enter a valid time in HH:MM[:ss[.uu]] format.
>
> The problem is that your empty choice None becomes the string "None" when it
> is rendered as an HTML select input element, and comes back in the POST data
> as a the string "None", not Python's None, so the model TimeField tries to
> parse the string value "None" as a time and fails.  First way that comes to
> mind to fix it is to change your None to an empty string in
> END_TIME_CHOICES, and use a TypedChoiceField with empty_value set to None
> for your form field:
>
>     time_end = forms.TypedChoiceField(required=False,
> choices=END_TIME_CHOICES, empty_value=None)
>
> 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: "python manage.py runserver" tutorial error

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 10:56 PM, Steve1234  wrote:

>
> > That's the module for Postgres.  What OS are you on?  If you can tell
> > us then we can give you specific instructions for installing the
> > module.
> I am running  Ubuntu 9, Postges 8.3.7, Python 2.6.2.  I installed
> Django using subversion.
>
> >
>
On ubuntu all you should need to do is sudo apt-get install python-psycopg2
and you'll be good to go.

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

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



Re: "python manage.py runserver" tutorial error

2009-06-25 Thread Steve1234

> That's the module for Postgres.  What OS are you on?  If you can tell
> us then we can give you specific instructions for installing the
> module.
I am running  Ubuntu 9, Postges 8.3.7, Python 2.6.2.  I installed
Django using subversion.

--~--~-~--~~~---~--~~
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: Global objects

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 10:42 PM, diogobaeder  wrote:

>
> Let me explain myself better: I have some menus in my site, and they
> appear all along the front-end pages. One of these menus must have a
> list of objects.
>
> Considering that I have a "base.html" that has these menus, how can I
> pass the objects to it, without having to fetch the objects in each
> view of the site?
>
> Thanks!
>
> Diogo
>
>
>
> On Jun 25, 8:39 pm, Diogo Baeder  wrote:
> > Hi,
> >
> > I'm trying to set up a global model object list, to populate a part of a
> > menu in my site. How can I do it? How can I instantiate the model object
> > list, so that it is available to all the views?
> >
> > Thanks!
> >
> > Diogo
> >
>
See my answer in this thread:
http://groups.google.com/group/django-users/browse_frm/thread/1656392a27d97e8a#the
same techniques should work for you.

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

--~--~-~--~~~---~--~~
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: Global objects

2009-06-25 Thread diogobaeder

Let me explain myself better: I have some menus in my site, and they
appear all along the front-end pages. One of these menus must have a
list of objects.

Considering that I have a "base.html" that has these menus, how can I
pass the objects to it, without having to fetch the objects in each
view of the site?

Thanks!

Diogo



On Jun 25, 8:39 pm, Diogo Baeder  wrote:
> Hi,
>
> I'm trying to set up a global model object list, to populate a part of a
> menu in my site. How can I do it? How can I instantiate the model object
> list, so that it is available to all the views?
>
> Thanks!
>
> Diogo
--~--~-~--~~~---~--~~
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: Using Signals as hooks

2009-06-25 Thread Wiiboy

Question: how often should I have a cron job work to send emails?  Or
should I just have it so that a few items from a task DB are done each
request (e.g. split up emails into groups, and email them a few per
request)?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using Signals as hooks

2009-06-25 Thread Wiiboy

Thanks.

On the topic of scaling, my site hasn't even been publicly released
yet.  However, I'll keep your advice in mind as I work on it, to keep
it "future-proof".
--~--~-~--~~~---~--~~
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: Trouble rendering a ManyToManyField with CheckBoxSelectMultiple widget

2009-06-25 Thread Rodrigo Cea

Stupid mistake, I had to use a MultipleChoiceField instead of a plain
ChoiceField.

styles= forms.MultipleChoiceField (widget=forms.CheckboxSelectMultiple
(),

--~--~-~--~~~---~--~~
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: TinyMCE django admin

2009-06-25 Thread Dhruv Adhia
Yep you got me :)
I am quite familier with django now, but haven't tried forms till now!!

Thanks!

On Thu, Jun 25, 2009 at 4:59 PM, Joost Cassee  wrote:

>
> On Jun 25, 7:08 pm, Dhruv Adhia  wrote:
>
> > I was just googling and came across all those old hacky ways to integrate
> > tinymce which I finally did yesterday. Its working. But yes if its
> something
> > builtin now I should go for that. However I dont know If I can easily
> change
> > the properties that way for the editor. Right now in the Hacky way I
> change
> > plugins,themes,skins stuff and it shows up the changes. Can we do this
> with
> > widgets?
>
> Yes, you can. Just slow down a little ;-) and read the django-tinymce
> documentation. You may also want to look at the Django forms
> documentation if you're new to Django. It is possible to set project-
> wide TinyMCE configuration options in settings.py and override them in
> the widget initializer.
>
> Regards,
>
> Joost
> >
>


-- 
Dhruv Adhia
http://thirdimension.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
-~--~~~~--~~--~--~---



Trouble rendering a ManyToManyField with CheckBoxSelectMultiple widget

2009-06-25 Thread Rodrigo Cea

I am rendering a ManyToManyField with a CheckboxSelectMultiple widget
like so:

class CreateBandForm(ModelForm):
styles= forms.ChoiceField(widget=forms.CheckboxSelectMultiple(),
choices=[(i,i) for i in Style.objects.all()])

class Meta:
model = Band
fields = ['name','styles']

This renders fine, but when I select a few choices (say 'latin
american' and 'rhythm and blues') and submit the form, I get the
following validation error:

 Select a valid choice. [u'latin american', u'rhythm and blues']
is not one of the available choices.

I have tried various permutations for "choices", including choices=
[(i.id,i) for i in Estilo.objects.all()], with no luck so far.

Thanks,

Rodrigo
--~--~-~--~~~---~--~~
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: One to Many+foreign key Query: best way to build the optimal result

2009-06-25 Thread Sam Walters
Thanks for the help.

I think you are on the right track however i could not get this to work.
Maybe an example query using cursor.execute would help so you can see what i
am trying to do.

def sqlAllEventsMenu():
cursor = connection.cursor()
cursor.execute("""
SELECT events_event.id, events_event.start, events_event.title,
events_location.state_id, events_location.name
FROM events_event LEFT JOIN events_location
ON events_event.id = events_location.id
""")
return convertToDictionary(cursor)


On Fri, Jun 19, 2009 at 4:11 PM, BenW  wrote:

>
> I'm not sure I completely understand the problem, but I'll give it a
> stab:
>
> events = Event.objects.filter(start__gte=datetime.today())
> locations = Location.objects.filter(location__in=events)
>
> results = [
>   {'start': loc.location.start, 'title': loc.location.title, 'id':
> loc.location.id, 'state_id': loc.state.id, 'name': loc.name} \
>   for loc in locations.iterator()
> ]
>
> render_to_response('template.htm', {'results': results})
>
> I run a query similar to this one on a 50,000 record table and it only
> takes ~0.30 seconds, and that includes Json serialization!
>
> On Jun 17, 5:00 pm, Sam Walters  wrote:
> > Here is the essentials from my models.py file:
> >
> 
> > class Event (models.Model):
> > contact = models.CharField(max_length=100)
> > email = models.CharField(max_length=100)
> > url = models.CharField(max_length=100)
> > title = models.CharField(max_length=100)
> > start = models.DateTimeField('date time when')
> > end = models.DateTimeField('date till')
> >
> > class Location (models.Model):
> > name = models.CharField(max_length=50)
> > state = models.ForeignKey(State)
> > location = models.ForeignKey(Event)
> >
> 
> > This is a One-to-Many Relationship where an Event can have one or more
> > Locations.
> >
> > The problem i need to solve is in the 'views.py' I want to be able to
> > query 'Event' such that i retrieve an arbitrary subset of events AND
> > any associated Locations and return only the relevant fields to the
> > template layer.
> >
> > The most standard use for this database will be to get all events from
> > today into the future and their associated locations. On average there
> > would be say 25 event rows returned and perhaps 27 locations as some
> > events have more than one location.
> >
> 
> > e_future = Event.objects.filter(start__gte = datetime.today())
> >
> 
> > having readhttp://docs.djangoproject.com/en/dev/topics/db/queries/
> >
> > i realise i can use a reverse foreign key to access an item in the
> > Location table:
> >
> 
> > for e in e_future:
> > e_location=e.location_set.all()
> >
> 
> > From here it gets messy as i have to deal with the individual event
> > elements 'e' out of a queryset 'e_future' and then reassemble the
> > elements back into a queryset *i dont know how to do this* so my
> > method can return the selected columns:
> >
> 
> > e_future_subset = e_future.values('start', 'title','id',)
> > e_location_subset = e_location.values('state_id', 'name',)
> >
> 
> > Then i have to combine the two objects 'e_future_subset' and
> > 'e_location_subset' (which i believe are dictionaries) and return the
> > result.
> >
> 
> > e_all = e_future_subset + e_location_subset
> > return render_to_response('events.html', { 'e_all': e_all,})
> >
> 
> >
> > As you can see I have been researching the solution and i'm stuck only
> > on a couple of points.
> > Surely this is one of the most common requirements for a django setup
> > where the 'model.py' describes a number of related tables 'one-to-
> > many' 'one-to-one' or 'many-to-many' relationships, a query (or number
> > of queries) are made and results are returned from multiple tables
> > based on an entry's 'id' and accessed through foreign-key pointers.
> >
> > Any help would be greatly appreciated as I seem to have a handle on
> > everything else in my django pr

Weird transaction issue in apache?

2009-06-25 Thread Jay Wineinger

I have an Order model and a Payment model (which FK's to Order as
"payments").  I have a handler for post_delete on Payment which sends
a custom signal which may do some updating on Order.  The problem I'm
seeing is that when I delete a Payment, the custom signal handler can
still query for the deleted payment.  It seems to work fine and as
expected through the shell but when run via apache (mod_wsgi/python2.6/
mysql5 with innodb) my handler cannot update because the payment that
should be deleted is still showing up in queries.

Here is the whole thing with models,views,urls, shell test, and apache
test. http://dpaste.com/hold/59869/

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



Re: "python manage.py runserver" tutorial error

2009-06-25 Thread Wayne Koorts

> I am getting an error working through "Writing your first Django app,
> part 1" tutorial.  "python manage.py runserver" generates the error:
>
> ...raise ImproperlyConfigured("Error loading psycopg module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading psycopg
> module: No module named psycopg
>
> How do I fix this so psycopy module can be found?

That's the module for Postgres.  What OS are you on?  If you can tell
us then we can give you specific instructions for installing the
module.

Regards,
Wayne

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



"python manage.py runserver" tutorial error

2009-06-25 Thread Steve1234

I am getting an error working through "Writing your first Django app,
part 1" tutorial.  "python manage.py runserver" generates the error:

...raise ImproperlyConfigured("Error loading psycopg module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg
module: No module named psycopg

How do I fix this so psycopy module can be found?

--~--~-~--~~~---~--~~
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: TinyMCE django admin

2009-06-25 Thread Joost Cassee

On Jun 25, 7:08 pm, Dhruv Adhia  wrote:

> I was just googling and came across all those old hacky ways to integrate
> tinymce which I finally did yesterday. Its working. But yes if its something
> builtin now I should go for that. However I dont know If I can easily change
> the properties that way for the editor. Right now in the Hacky way I change
> plugins,themes,skins stuff and it shows up the changes. Can we do this with
> widgets?

Yes, you can. Just slow down a little ;-) and read the django-tinymce
documentation. You may also want to look at the Django forms
documentation if you're new to Django. It is possible to set project-
wide TinyMCE configuration options in settings.py and override them in
the widget initializer.

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: SESSION_EXPIRE_AT_BROWSER_CLOSE and normal cookie

2009-06-25 Thread humble

you didn't specify max_age in response.set_cookie('myname', data),
which assumes None by default. Therefore that cookie expires when
browsers closes.

On Jun 25, 3:58 pm, pr  wrote:
> Hello,
>
> When I set SESSION_EXPIRE_AT_BROWSER_CLOSE to True, Django
> automatically remove not only my session cookie (sessionid) but also
> any others cookies creating by using response.set_cookie('myname',
> data). Why? I want to keep all cookies without session cookie.
>
> 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
-~--~~~~--~~--~--~---



Global objects

2009-06-25 Thread Diogo Baeder

Hi,

I'm trying to set up a global model object list, to populate a part of a 
menu in my site. How can I do it? How can I instantiate the model object 
list, so that it is available to all the views?

Thanks!

Diogo

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



Setting up Django, Apache and Nginx on Windows Vista

2009-06-25 Thread Duvalfan23

I am a new user to Django and want to set it up with Apache, Nginx,
and MySQL on Windows Vista for testing. I will set up on Linux once I
get a shared hosting account. Does anyone know a website that explains
this very well from start to finish on Vista? Or can someone explain
how to do this on Windows? I have searched far and wide and all I see
is how to set up on Linux. Any help would be greatly appreciated...
Thanks!

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



importing cjson/numpy/scipy causes crash

2009-06-25 Thread Parrellel

Hello,

Whenever I try to import any of the above into the view into my site
it shoots back with:

Caught an exception while rendering: Could not import AECOM.ofc.views.
Error was: DLL load failed: The specified module could not be found.

And in the apache log:

[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=2612): Exception occurred processing WSGI script 'D:/Work/Peter/
AECOM/apache/django.wsgi'.
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line
239, in __call__
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1] response =
self.get_response(request)
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\site-packages\\django\\core\\handlers\\base.py", line
67, in get_response
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1] response =
middleware_method(request)
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\site-packages\\django\\middleware\\common.py", line
57, in process_request
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]
_is_valid_path("%s/" % request.path_info)):
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\site-packages\\django\\middleware\\common.py", line
142, in _is_valid_path
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]
urlresolvers.resolve(path)
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\site-packages\\django\\core\\urlresolvers.py", line
246, in resolve
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1] return
get_resolver(urlconf).resolve(path)
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\site-packages\\django\\core\\urlresolvers.py", line
181, in resolve
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1] sub_match =
pattern.resolve(new_path)
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\site-packages\\django\\core\\urlresolvers.py", line
124, in resolve
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1] return
self.callback, args, kwargs
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\site-packages\\django\\core\\urlresolvers.py", line
133, in _get_callback
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1] raise
ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str
(e))
[Thu Jun 25 16:53:46 2009] [error] [client 127.0.0.1]
ViewDoesNotExist: Could not import AECOM.ofc.views. Error was: DLL
load failed: The specified module could not be found.

Initially the page being returned was View Does Not Exist this has
been replaced with an Internal Server Error.

Removing the import removes the problem.

If anyone could help that would be excellent,

Parrellel

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



SESSION_EXPIRE_AT_BROWSER_CLOSE and normal cookie

2009-06-25 Thread pr

Hello,

When I set SESSION_EXPIRE_AT_BROWSER_CLOSE to True, Django
automatically remove not only my session cookie (sessionid) but also
any others cookies creating by using response.set_cookie('myname',
data). Why? I want to keep all cookies without session cookie.

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: django apps that implement ticket filtering?

2009-06-25 Thread lzantal

Hi,

You could submit all the filters from an html form and in your view  
function loop through the request.Post and build the queries if the  
Post value is not empty.Using django.db.models.Q

Laszlo Antal
http://www.antalconsulting.com
Office: 208-699-7508

On Jun 25, 2009, at 2:32 PM, Margie  wrote:

>
> I am trying to implement a specialized ticketing system in django.  At
> a high level, it has many similarities to the django bug tracking
> system, which I believe is implemented using trac.
>
> I have coded the models models and the associated django code that
> lets people create their tickets.  Now I'm at the point where I want
> to implement queries.  IE, let the user choose filters (and and or
> them together hopefully) that let you, for example, "find all tickets
> owned by Joe, created after 6/15/09, with status open".  Nothing too
> new here.  In looking for models of this functionality, I find the
> trac system to be fairly straighforward, from a user perspective.  But
> of course, it isn't written in django.  I looked at their html and
> javascript templates and found them very hard to wade through.  I'm
> wondering if anyone knows of any open source django apps that do
> something similar?  In particular, I'm interested in the html
> templates and associated javascript/jquery to make the filters
> "dynamic", as that is the area I am sort of weak in.
>
> Thanks for any pointers!
>
> Margie
> >

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



django apps that implement ticket filtering?

2009-06-25 Thread Margie

I am trying to implement a specialized ticketing system in django.  At
a high level, it has many similarities to the django bug tracking
system, which I believe is implemented using trac.

I have coded the models models and the associated django code that
lets people create their tickets.  Now I'm at the point where I want
to implement queries.  IE, let the user choose filters (and and or
them together hopefully) that let you, for example, "find all tickets
owned by Joe, created after 6/15/09, with status open".  Nothing too
new here.  In looking for models of this functionality, I find the
trac system to be fairly straighforward, from a user perspective.  But
of course, it isn't written in django.  I looked at their html and
javascript templates and found them very hard to wade through.  I'm
wondering if anyone knows of any open source django apps that do
something similar?  In particular, I'm interested in the html
templates and associated javascript/jquery to make the filters
"dynamic", as that is the area I am sort of weak in.

Thanks for any pointers!

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



Re: Django ORM exhibiting caching like behavior in a non web based daemon script

2009-06-25 Thread afrobeard

I'm using MySQL 5.1.33
I shifted the db engine to MyISAM from INNODB and everything worked
like a charm. Then I switched it back to INNODB to test the pythonic
workarounds from
http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d/55fa3724d2754013?#55fa3724d2754013

'set transaction isolation level read committed' did not fix the
problem, however 'set autocommit=1' did give the daemon realtime
visibility into what the web interface was doing.

Thanks for you help and for giving me something exciting to play with
over the weekend :)

On Jun 26, 2:52 am, Karen Tracey  wrote:
> On Thu, Jun 25, 2009 at 4:48 PM, afrobeard  wrote:
>
> > Thanks for the reply Alex, however I beleive I might have
> > miscommunicated the problem a big. The actual format of the daemon is
> > somewhat like this:-
>
> > 1while True:
> > 2    rs = Inqueue.objects.filter(processed = 0).order_by('-timestamp')
> > 3    for item in rs:
> > 4.1          processitem(item)
> > 4.2          item.delete()
> > 5    sleep
>
> What database are you using?  This sounds more like a transaction isolation
> problem than a caching issue.
>
> 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: MemoryError on bigs list of items

2009-06-25 Thread Frédéric Hébert

2009/6/25 Andrew Fong :
>
> To clarify, you're displaying a list of 1000+ models on a single page,
> yes?
>

Yes, i will change that as soon as I could.

> My understanding is that the debug_toolbar analyzes each SQL query and
> keeps each result in memory before rendering everything in the
> template. I don't know how your query works, but let's take an extreme
> case and say your request executes 1000+ queries. In addition to
> keeping 1000 models in memory, the debug_toolbar now has to also
> contain the query data for 1000 queries. If you have a small amount of
> memory, this could eat it up pretty quick.
>

I understand that. But, what's bother me is that this very same list
have worked well before (with an average of two seconds of loading) on
the same server.
Indeed when I has activated debug_toolbar on my PC, lists were very
slow to display (about ten seconds and more) but there was not a
Memory error.

My validation server is virtualized. I will see with my admin the
amount of memory on it.

> I don't think setting MaxRequestsPerChild = 1 would do anything to
> cause a MemoryError. It should actually help, since if you're
> restarting the process after just 1 request, any memory leaks won't
> have time to build up.
No, indeed. A MaxRequestPerChild set to 1 don't change anything


Many thanks for your reply,

>
> -- Andrew
>

Frédéric

> On Jun 25, 1:15 pm, Frédéric Hébert  wrote:
>> Hi there,
>>
>>  I'm facing with a curious problem.
>>
>>  I've an project which is hosted on three differents servers :
>>
>>  one (my local PC) :
>> debian lenny /
>> python 2.5.2 / django 1.0.2 final
>> apache 2.2.9 / mod_python 3.3.1-7
>>
>>  the two others (production and validation server) :
>> OpenSUSE 11.1 /
>> python 2.6.2 / django 1.0.2 final
>> apache 2.2.10 / mod_python 3.3.x-x
>>
>>  Two months ago, I've launched this project both on production server
>> and validation server.
>>  Neither validation server nor production server caused me any
>> trouble.
>>
>> Today, to test something, I've installed debug_toolbar extension and
>> set MaxRequestPerChild to 1 in Apache's conf file, both on my local
>> dev PC and on the validation server.
>>
>> When I want to display two long list (1000+ items each) i get a
>> MemoryError one time out of two. The remainder of project goes fine.
>>
>>  I've resetted MaxRequestPerChild to 1 (default value on OpenSUSE)
>> and commented out debug_toolbar's things in my settings, restart
>> Apache. But error happened again on the validation server.
>>
>>  On my local PC, it works well, with debug_toolbar and MaxReq.. set or
>> not.
>>
>> I've pasted the traceback  herehttp://dpaste.com/hold/59667/
>>
>>  AFAICS, an exception occurs when django tries to render a debug
>> template
>>
>> Here is an exerpt of my vhost conf file on OpenSUSE :
>>  DocumentRoot /srv/www/enseignements-dev.ehess.fr/ue
>>
>>     
>>       SetHandler python-program
>>       PythonHandler django.core.handlers.modpython
>>       SetEnv DJANGO_SETTINGS_MODULE ue.settings_dev
>>       PythonDebug On
>>       PythonPath "['/srv/www/enseignements-dev.ehess.fr/', '/srv/www/
>> enseignements-dev.ehess.fr/ue/'] + sys.path"
>>     
>>
>> Many thanks in advance,
>>
>>  Frédéric
> >
>



-- 
http://www.openidfrance.fr/fhebert

--~--~-~--~~~---~--~~
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: Hard linking an image

2009-06-25 Thread Kevin Teague

Presumably you already have all of the data required to generate a
chart on the server? If so, then store the chart data in a model, and
just reference it by id. e.g.



(or w/ a pretty URL: )

And create a Chart object and store it before sending out the HTML
response. Then update your chart view so that it fetches that object
and uses it as input to generate the graph.

--~--~-~--~~~---~--~~
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: objects in memory that don't time out?

2009-06-25 Thread qwcode

> If they are non mutable, is thread safety even an issue?
I guess I really wanted to just say "If your intention is to use
thread-safe globals..."

thanks for your help on this.

btw, I guess my question could have been asked in terms of whether a
singleton pattern is possible... I saw that someone had asked about
that earlier and got a similar reponse about multiple processes etc..
--~--~-~--~~~---~--~~
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: djangoplus widget

2009-06-25 Thread jhugo

I found a sample contained in a rar archive with a media file included
(2 css and js) which the svn source does not have.
I changed my urls, forms and base.html to reflect that from the
example but when i reload the page it changes the default m2m field
with a text field with a plus sign next to it. If i try to add
something nothing happens.

Here's the example:

forms.py

from django import forms

from apps.spares.models import Category, Spare
from ajax_m2m_widget import AjaxMultiSelect

class MyForm(forms.Form):
spares = forms.Field(widget=AjaxMultiSelect(db_field.verbose_name,
Spare, '/spares/spare/auto/'))
categories = forms.Field(widget=AjaxMultiSelect
(db_field.verbose_name, Category, '/spares/category/auto/'))

urls.py

from django.conf.urls.defaults import *

from apps.utils.ajax_m2m_widget import auto_complete_view
from models import Spare, Category

def spare_auto_query_func(q):
return Spare.objects.filter(name__startswith=q)

def category_auto_query_func(q):
return Category.objects.filter(name__startswith=q)

urlpatterns = patterns('apps.spares.views',
(r'^spare/auto/$', auto_complete_view, {'query_func':
spare_auto_query_func, 'desc_field': 'name', 'id_field': 'id'}),

(r'^category/auto/$', auto_complete_view, {'query_func':
category_auto_query_func, 'desc_field': 'name', 'id_field': 'id'}),

last i added the fallowing to my base.html







thanks,

regards,

On Jun 25, 11:45 am, jhugo  wrote:
> I want to use this widget instead of the default one from the many to
> many field but don't know how to. Do you have an example that can get
> me started.
>
> Thanks,
>
> - Hugo
>
> On Jun 25, 11:39 am, "Gabriel ."  wrote:
>
> > On Thu, Jun 25, 2009 at 12:33 PM, jhugo wrote:
>
> > > Hi,
>
> > > I am trying to use the ajax_m2m_widget from djangoplus but there is
> > > very little information could anyone help me?
>
> > > Thanks,
>
> > That depends of what kind of help do you need. Please be more specific.
>
> > --
> > Kind Regards
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Handling a reusable form in multiple views

2009-06-25 Thread Rajesh D



On Jun 25, 4:43 pm, delino  wrote:
> Hi,
>
> I have a simple scenario using Django 0.96 and am looking for a
> cleaner solution than what I currently have:
>
> I want to include a simple submission form (a few simple fields) on
> most pages of my site. I have the form action set to '.' so that
> validation can be done in place and errors displayed to the user. I am
> currently checking for the POST and either handling it or creating a
> new form in each of these views and then passing the form to each of
> my templates, e.g.
>
> def example_page(request):
>         if request.method == 'POST':
>                 form = SubmitMeForm(request.POST)
>                 if form.is_valid():
>                         # do your thing
>                         return HttpResponseRedirect('/done/')
>         else:
>                 form = SubmitMeForm()
>
>         variables = RequestContext(request, {
>                         'submitMeForm': form,
>                         })
>         return render_to_response('somePage.html', variables)
>
> I have 2 issues with this:
>
> 1 - I have to include this code in each and every view that represents
> a page that has this template. There has to be a simpler way of doing
> it.
>
> 2 - What if one of these pages has another Django form in it? I now
> have to handle the fact that the POST could have resulted from this
> form OR the other one. How would I do that?

You could add your form to your request context using a context
processor under a key other than 'form' (so it doesn't clash with
forms defined by your other views). This way, your context processor
will make this form available globally. Secondly, instead of posting
this common form to '.', post it to a dedicated view that only knows
how to process this common form.

-RD


>
> TIA
> -- delino
--~--~-~--~~~---~--~~
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: Activate Admin Tutorial 2

2009-06-25 Thread Divesh Gidwani


On Jun 25, 4:49 pm, Karen Tracey  wrote:
> On Thu, Jun 25, 2009 at 4:29 PM, Divesh Gidwani  wrote:
>
> > Hey Guys,
>
> > I'm new to Django and computer programming and am currently following
> > a tutorial from this website:
>
> >http://www.zabada.com/tutorials/django-quick-start.php
>
> I wouldn't recommend that.  From a brief look that tutorial is based on
> Django 0.96, and unless you are supporting old code written for that level
> you do not want to be starting out with such an old base.  There are many
> things that changed between 0.96 and 1.0 in a backwards-incompatible way
> (one of which has led to your problem), you are much better off starting
> with 1.0.  Why not use the official Django tutorial, which is updated to
> match the current code (or you can use the version for the latest official
> release, depending on what level of Django you decide to go with):
>
> http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01
>
> Karen

Hey Karen,

Thanks a ton for that. I used the activate admin way suggested in
tutorial 2 of the djangoproject website and that worked just great!

I'm sure this Django journey is not going to be very smooth, and i'll
keep having questions along the way, especially since this is my first
ever programming experience. Thanks to people like you, it becomes a
lot easier.

Thanks once again.

Divesh
--~--~-~--~~~---~--~~
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: Can base.html template contain dynamic content if used by direct_to_template

2009-06-25 Thread Pete-Sitedesign

OK Thanks for that. I have worked out that the context_processors
route is best for this one but the template_tags is ideal for another
part I was working on.

Thanks for the help.

Regards Pete

On Jun 25, 9:29 pm, Alex Gaynor  wrote:
> On Thu, Jun 25, 2009 at 3:27 PM, Pete-Sitedesign <
>
>
>
> peter.king.sitedes...@googlemail.com> wrote:
>
> > On Jun 25, 9:22 pm, Alex Gaynor  wrote:
> > > On Thu, Jun 25, 2009 at 12:23 PM, Pete-Sitedesign <
>
> > > peter.king.sitedes...@googlemail.com> wrote:
>
> > > > I want to build a site which has latest news on the side of all the
> > > > pages, I wanted to build the pages using simple templates (static
> > > > content) and then reference them using the direct_to_template in the
> > > > urls file.
>
> > > > Since each template extends base how can I get base to contain the
> > > > latest news or do I have to write a view for each template and pass
> > > > the news into them?
>
> > > > Sorry for the newbie question.
>
> > > There are 2 ways to do this, either a) a template context process, which
> > > bsaically adds something to the context of all templates rendered, or b)
> > an
> > > inclusion tag which basically let's you do an include but with a new
> > context
> > > that you can create dynamically.
>
> > > 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
>
> > Thanks for that. I was have just been playing with the
> > context_processors way which is great since it provides the data to
> > all templates.
> > Could you explain the include idea a bit further please.
> > Do you mean {% include some_other_template.html %} then how do I
> > handle the URL to trigger a view to populate that included template
> > with the content?
>
> > PS Thanks for the reply.
>
> > regards Pete
>
> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#incl...
> the docs on inclusion tags, they explain it better than I could :)
>
> 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
--~--~-~--~~~---~--~~
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: Hard linking an image

2009-06-25 Thread Rajesh D



On Jun 25, 9:43 am, koranthala  wrote:
> Hi,
>     I have a chart which I generate on the fly.
>     Basically, I have hard linked an image. The image src contains GET
> parameters, which is used to generate the chart image via matplotlib.
> The resultant image is returned back as 'Content-Type' = 'image/png',
> and thus the chart is displayed.
>      i.e.  is there in
> HTML - created using templates. The parameters key1, key2, field1,
> field2 etc are used to create the image.
>
>     Now, this was working perfectly till now. Now, I need to create a
> huge chart with lot of keys and fields. But, when I tried the same
> mechanism, it failed because it is above the maximum characters
> supported by GET. Even though I could not find any specific spec which
> mentioned the max char limit, I understand that many browsers support
> very less characters only ~300.

I believe Firefox and Safari support around 8000 characters but IE 7.0
goes to only around 2000.

>
>     In such a case, how can I create the chart on the fly? Is there a
> way to send the data as POST while hardlinking?
> Since I am getting the
> values and generating the links using templates, I cannot think of too
> many options. What si the usual mechanism used by fellow Djangoites?

May be try to replicate what Google Charts API does?

http://code.google.com/apis/chart/

In particular, look at their various Data encoding options.

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



Re: Django ORM exhibiting caching like behavior in a non web based daemon script

2009-06-25 Thread Karen Tracey
On Thu, Jun 25, 2009 at 4:48 PM, afrobeard  wrote:

>
> Thanks for the reply Alex, however I beleive I might have
> miscommunicated the problem a big. The actual format of the daemon is
> somewhat like this:-
>
> 1while True:
> 2rs = Inqueue.objects.filter(processed = 0).order_by('-timestamp')
> 3for item in rs:
> 4.1  processitem(item)
> 4.2  item.delete()
> 5sleep
>

What database are you using?  This sounds more like a transaction isolation
problem than a caching issue.

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: Django ORM exhibiting caching like behavior in a non web based daemon script

2009-06-25 Thread Craig Kimerer
Which backend are you using?  If you happen to be using MySQL with InnoDB,
and you haven't altered the default settings you are probably using an
isolation level of REPEATABLE-READ.

You can read more about that setting here
http://dev.mysql.com/doc/refman/5.0/en/set-transaction.html#isolevel_repeatable-read

If that is your issue there are two suggestions on how to solve the problem
here
http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d/55fa3724d2754013?#55fa3724d2754013
.

Craig

On Thu, Jun 25, 2009 at 1:48 PM, afrobeard  wrote:

>
> Thanks for the reply Alex, however I beleive I might have
> miscommunicated the problem a big. The actual format of the daemon is
> somewhat like this:-
>
> 1while True:
> 2rs = Inqueue.objects.filter(processed = 0).order_by('-timestamp')
> 3for item in rs:
> 4.1  processitem(item)
> 4.2  item.delete()
> 5sleep
>
>
>
> On Jun 26, 2:32 am, Alex Gaynor  wrote:
> > On Thu, Jun 25, 2009 at 3:31 PM, afrobeard  wrote:
> >
> > > I have a problem where I'm using Django, specifically the ORM in a non
> > > web based daemon script to process some data from a site, by setting
> > > the environment variables respectively so that it knows where the
> > > settings module is, etc
> >
> > > I'm running the following query:-
> >
> > > Inqueue.objects.filter(processed = 0).order_by('-timestamp')
> >
> > > Now the thing is that it gets the right results the first time, but if
> > > someone makes a change on the site that the script itself is unaware
> > > of, it does not get new items that were added onto the site until the
> > > script is restarted. It behaves as if it's using some caching system.
> >
> > > Everything works fine on an Ubuntu server, however not on windows
> > > machines. I'm not sure why, the python and django versions are the
> > > same on both systems.
> >
> > > Can anybody point me to what could be causing this behavior?
> >
> > > Thanks in advance
> >
> > When a queryset is iterated over it stores the data so if you iterate
> over
> > the same queryset object again it doesn't do another DB query.  If you
> want
> > to iterate over a new one instead of the current one you can just do
> > queryset.all() and then you won't be going through the cache.
> >
> > 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
> >
>

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



Handling a reusable form in multiple views

2009-06-25 Thread delino

Hi,

I have a simple scenario using Django 0.96 and am looking for a
cleaner solution than what I currently have:

I want to include a simple submission form (a few simple fields) on
most pages of my site. I have the form action set to '.' so that
validation can be done in place and errors displayed to the user. I am
currently checking for the POST and either handling it or creating a
new form in each of these views and then passing the form to each of
my templates, e.g.

def example_page(request):
if request.method == 'POST':
form = SubmitMeForm(request.POST)
if form.is_valid():
# do your thing
return HttpResponseRedirect('/done/')
else:
form = SubmitMeForm()

variables = RequestContext(request, {
'submitMeForm': form,
})
return render_to_response('somePage.html', variables)


I have 2 issues with this:

1 - I have to include this code in each and every view that represents
a page that has this template. There has to be a simpler way of doing
it.

2 - What if one of these pages has another Django form in it? I now
have to handle the fact that the POST could have resulted from this
form OR the other one. How would I do that?

TIA
-- delino

--~--~-~--~~~---~--~~
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: Activate Admin Tutorial 2

2009-06-25 Thread Karen Tracey
On Thu, Jun 25, 2009 at 4:29 PM, Divesh Gidwani  wrote:

>
> Hey Guys,
>
> I'm new to Django and computer programming and am currently following
> a tutorial from this website:
>
> http://www.zabada.com/tutorials/django-quick-start.php
>

I wouldn't recommend that.  From a brief look that tutorial is based on
Django 0.96, and unless you are supporting old code written for that level
you do not want to be starting out with such an old base.  There are many
things that changed between 0.96 and 1.0 in a backwards-incompatible way
(one of which has led to your problem), you are much better off starting
with 1.0.  Why not use the official Django tutorial, which is updated to
match the current code (or you can use the version for the latest official
release, depending on what level of Django you decide to go with):

http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01

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: Django ORM exhibiting caching like behavior in a non web based daemon script

2009-06-25 Thread afrobeard

Thanks for the reply Alex, however I beleive I might have
miscommunicated the problem a big. The actual format of the daemon is
somewhat like this:-

1while True:
2rs = Inqueue.objects.filter(processed = 0).order_by('-timestamp')
3for item in rs:
4.1  processitem(item)
4.2  item.delete()
5sleep



On Jun 26, 2:32 am, Alex Gaynor  wrote:
> On Thu, Jun 25, 2009 at 3:31 PM, afrobeard  wrote:
>
> > I have a problem where I'm using Django, specifically the ORM in a non
> > web based daemon script to process some data from a site, by setting
> > the environment variables respectively so that it knows where the
> > settings module is, etc
>
> > I'm running the following query:-
>
> > Inqueue.objects.filter(processed = 0).order_by('-timestamp')
>
> > Now the thing is that it gets the right results the first time, but if
> > someone makes a change on the site that the script itself is unaware
> > of, it does not get new items that were added onto the site until the
> > script is restarted. It behaves as if it's using some caching system.
>
> > Everything works fine on an Ubuntu server, however not on windows
> > machines. I'm not sure why, the python and django versions are the
> > same on both systems.
>
> > Can anybody point me to what could be causing this behavior?
>
> > Thanks in advance
>
> When a queryset is iterated over it stores the data so if you iterate over
> the same queryset object again it doesn't do another DB query.  If you want
> to iterate over a new one instead of the current one you can just do
> queryset.all() and then you won't be going through the cache.
>
> 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
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Writing a reusable app

2009-06-25 Thread Rajesh D



On Jun 25, 9:51 am, nabucosound  wrote:
> Hi all:
>
> I am refactoring a django app to make it reusable and share it open
> sourced to the world. There is a lot code which I think it is optional
> and maybe not everybody will want to use, like some model fields, url
> patterns of view functions. so my initial approach is to release only
> the minimal version and let them add whatever they need.
>
> But then a question arises, regarding maintenance and update of the
> application in the projects where the app is gonna live. When I will
> release further versions with bufixes or new features, then should
> these people download the app, and maybe do a merge with their
> modified versions? That would be against the philosophy of a django
> app for me, that is, to be de-coupled from other parts of the project.
> Also conflicts may appear, if my next app versions differ a lot from
> previous ones.
>
> The opposite approach I have seen in other apps is to include
> everything the developer considers suitable. But doing this means
> forcing people to include useless stuff for their projects, like model
> fields they won't never use in their database schema, for example.
>
> So how do u guys think I should target it? Minimalistic or full-
> batteries included?

You could go minimalistic but built model extension support into your
app the way Django let's you extend it's user model with user
profiles:

Here's an old write up on this by James Bennett:
http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/

Here's another (newer) article that shows how model inheritence could
be used to achieve similar results:
http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/

-RD


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



Django contract available (200 hours estimated) £6000 GBP

2009-06-25 Thread Pete-Sitedesign

We have a contract available for offer.

We have been left with a project which our programmers started (about
quarter way complete) for one of our clients. Our programmers have now
left us so we are left with a client wanting the project finishing.

It would need someone with quite a bit of Django programming
experience to finish.

It is a Courses booking system holding customer details and course
details with resource scheduling.
It MAY need to hook into Google API's like Google calendar.

There is still £6000 GBP to be paid to the person who is willing to
finish the project.
We are based in Wolverhampton, West Midlands as is our client not that
location is important. Remote working is fine.

If this is of interest to anyone then please provide examples of your
work and contact detail then I will get in touch with you and provide
the specification document.

PS I don't mind if a group of people want to work together on this
project as long as they can prove how this would benefit the project
without leaving room for drop-outs.

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



Re: Django ORM exhibiting caching like behavior in a non web based daemon script

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 3:31 PM, afrobeard  wrote:

>
> I have a problem where I'm using Django, specifically the ORM in a non
> web based daemon script to process some data from a site, by setting
> the environment variables respectively so that it knows where the
> settings module is, etc
>
> I'm running the following query:-
>
> Inqueue.objects.filter(processed = 0).order_by('-timestamp')
>
> Now the thing is that it gets the right results the first time, but if
> someone makes a change on the site that the script itself is unaware
> of, it does not get new items that were added onto the site until the
> script is restarted. It behaves as if it's using some caching system.
>
> Everything works fine on an Ubuntu server, however not on windows
> machines. I'm not sure why, the python and django versions are the
> same on both systems.
>
> Can anybody point me to what could be causing this behavior?
>
> Thanks in advance
> >
>
When a queryset is iterated over it stores the data so if you iterate over
the same queryset object again it doesn't do another DB query.  If you want
to iterate over a new one instead of the current one you can just do
queryset.all() and then you won't be going through the cache.

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

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



Django ORM exhibiting caching like behavior in a non web based daemon script

2009-06-25 Thread afrobeard

I have a problem where I'm using Django, specifically the ORM in a non
web based daemon script to process some data from a site, by setting
the environment variables respectively so that it knows where the
settings module is, etc

I'm running the following query:-

Inqueue.objects.filter(processed = 0).order_by('-timestamp')

Now the thing is that it gets the right results the first time, but if
someone makes a change on the site that the script itself is unaware
of, it does not get new items that were added onto the site until the
script is restarted. It behaves as if it's using some caching system.

Everything works fine on an Ubuntu server, however not on windows
machines. I'm not sure why, the python and django versions are the
same on both systems.

Can anybody point me to what could be causing this behavior?

Thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Can base.html template contain dynamic content if used by direct_to_template

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 3:27 PM, Pete-Sitedesign <
peter.king.sitedes...@googlemail.com> wrote:

>
> On Jun 25, 9:22 pm, Alex Gaynor  wrote:
> > On Thu, Jun 25, 2009 at 12:23 PM, Pete-Sitedesign <
> >
> > peter.king.sitedes...@googlemail.com> wrote:
> >
> > > I want to build a site which has latest news on the side of all the
> > > pages, I wanted to build the pages using simple templates (static
> > > content) and then reference them using the direct_to_template in the
> > > urls file.
> >
> > > Since each template extends base how can I get base to contain the
> > > latest news or do I have to write a view for each template and pass
> > > the news into them?
> >
> > > Sorry for the newbie question.
> >
> > There are 2 ways to do this, either a) a template context process, which
> > bsaically adds something to the context of all templates rendered, or b)
> an
> > inclusion tag which basically let's you do an include but with a new
> context
> > that you can create dynamically.
> >
> > 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
>
> Thanks for that. I was have just been playing with the
> context_processors way which is great since it provides the data to
> all templates.
> Could you explain the include idea a bit further please.
> Do you mean {% include some_other_template.html %} then how do I
> handle the URL to trigger a view to populate that included template
> with the content?
>
> PS Thanks for the reply.
>
> regards Pete
> >
>
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tagsare
the docs on inclusion tags, they explain it better than I could :)

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

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



Activate Admin Tutorial 2

2009-06-25 Thread Divesh Gidwani

Hey Guys,

I'm new to Django and computer programming and am currently following
a tutorial from this website:

http://www.zabada.com/tutorials/django-quick-start.php

Everything worked until the activate the admin part.

My code to activate the admin in my records/urls.py is as such:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^djangotest/', include('djangotest.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(divesh.records.urls)),
)

I don't exactly know what i'm doing, so please help.

divesh is my username
records is the app

This is the error i get when i try to runserver and display the page.
I am a newbie.

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/servers/basehttp.py", line 278, in
run
self.result = application(self.environ, self.start_response)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/servers/basehttp.py", line 636, in
__call__
return self.application(environ, start_response)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/handlers/wsgi.py", line 241, in
__call__
response = self.get_response(request)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/handlers/base.py", line 73, in
get_response
response = middleware_method(request)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/middleware/common.py", line 56, in
process_request
if (not _is_valid_path(request.path_info) and

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/middleware/common.py", line 142, in
_is_valid_path
urlresolvers.resolve(path)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 257, in
resolve
return get_resolver(urlconf).resolve(path)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 184, in
resolve
for pattern in self.url_patterns:

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 208, in
_get_url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 203, in
_get_urlconf_module
self._urlconf_module = import_module(self.urlconf_name)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/utils/importlib.py", line 35, in
import_module
__import__(name)

  File "/Users/Divesh/djangotest/djangotest/../djangotest/urls.py",
line 16, in 
(r'^admin/', include(divesh.records.urls)),

NameError: name 'divesh' is not defined

Please help. thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Using formfield_overrides to add TinyMCE

2009-06-25 Thread Brian Neal

On Jun 25, 2:33 pm, Pes  wrote:
> Hi All,
>
> I feel like there’s something simple I’m overlooking here. I can't
> seem to get TinyMCE to work when I use the built-in widget from Django-
> TinyMCE. This works if I uncomment the Media class at the bottom, but
> the widget version of TinyMCE simply doesn't show up. Is there a
> better way to tell the formfield to render with the TinyMCE widget
> instead of formfield_overrides?
>

Maybe off-topic, but what are the advantages to using django-tinymce?
It was easy to use tinymce without any 3rd party support. I'm using
tinymce in some public views, in the admin, and on the admin for
flatpages. It was easy to do an in all cases without any external app
or code.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can base.html template contain dynamic content if used by direct_to_template

2009-06-25 Thread Pete-Sitedesign

On Jun 25, 9:22 pm, Alex Gaynor  wrote:
> On Thu, Jun 25, 2009 at 12:23 PM, Pete-Sitedesign <
>
> peter.king.sitedes...@googlemail.com> wrote:
>
> > I want to build a site which has latest news on the side of all the
> > pages, I wanted to build the pages using simple templates (static
> > content) and then reference them using the direct_to_template in the
> > urls file.
>
> > Since each template extends base how can I get base to contain the
> > latest news or do I have to write a view for each template and pass
> > the news into them?
>
> > Sorry for the newbie question.
>
> There are 2 ways to do this, either a) a template context process, which
> bsaically adds something to the context of all templates rendered, or b) an
> inclusion tag which basically let's you do an include but with a new context
> that you can create dynamically.
>
> 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

Thanks for that. I was have just been playing with the
context_processors way which is great since it provides the data to
all templates.
Could you explain the include idea a bit further please.
Do you mean {% include some_other_template.html %} then how do I
handle the URL to trigger a view to populate that included template
with the content?

PS Thanks for the reply.

regards Pete
--~--~-~--~~~---~--~~
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: Can base.html template contain dynamic content if used by direct_to_template

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 12:23 PM, Pete-Sitedesign <
peter.king.sitedes...@googlemail.com> wrote:

>
> I want to build a site which has latest news on the side of all the
> pages, I wanted to build the pages using simple templates (static
> content) and then reference them using the direct_to_template in the
> urls file.
>
> Since each template extends base how can I get base to contain the
> latest news or do I have to write a view for each template and pass
> the news into them?
>
> Sorry for the newbie question.
>
> >
>
There are 2 ways to do this, either a) a template context process, which
bsaically adds something to the context of all templates rendered, or b) an
inclusion tag which basically let's you do an include but with a new context
that you can create dynamically.

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

--~--~-~--~~~---~--~~
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: Using Signals as hooks

2009-06-25 Thread Rajesh D



On Jun 25, 12:54 am, Wiiboy  wrote:
> I'm a bit of a noob at Web Devlopment (as you already know if you've
> read any of my posts on here).
>
> I've read that using hooks in key places in a website can help ease
> future development.  Can/Should Django's signals be used for that
> purpose?
>
> If so, to what extent should they be used?  For example, on my site
> where users submit articles for a newsletter, one place to put a hook
> would be after an article is submitted.  Would sending emails to
> admins about the new submission, as well as emails to the users who
> subscribe to be notified of new submissions be put in a separate
> function, as part of the hook, or part of the page?

This really depends on how many users have subscribed. If it's in the
thousands then sending an email inline (be it via signal hooks or
directly in a view or in a model.save) is going to cause some problems
to the user who just submitted an article; that user will now have to
wait for the entire emailing loop to complete before his/her request
completes. So if you have scalability concerns like this, you might
want to look at an offline-messaging-based architecture where a signal
hook writes out a special message to a work queue, an offline/cron
scheduled job periodically reads from the work queue and gets the
heavy weight lifting done without bogging down your HTTP requests.

Going back to your original question, signals are a great way to hook
in event driven functionality into your apps. It allows you to keep
your event processing code separate from your models, forms, or views.
That's usually a good thing. Signals also allow you to add processing
to a third-party django app without modifying the app's code.



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



Using formfield_overrides to add TinyMCE

2009-06-25 Thread Pes

Hi All,

I feel like there’s something simple I’m overlooking here. I can't
seem to get TinyMCE to work when I use the built-in widget from Django-
TinyMCE. This works if I uncomment the Media class at the bottom, but
the widget version of TinyMCE simply doesn't show up. Is there a
better way to tell the formfield to render with the TinyMCE widget
instead of formfield_overrides?

the admin model:

from django.db import models
from django.contrib import admin
from models import Entry
from tinymce.widgets import TinyMCE

class EntryAdmin(admin.ModelAdmin):
list_display = ('title', 'pub_date','enable_comments',
'status')
search_fields = ['title', 'body_html']
list_filter = ('pub_date', 'enable_comments', 'status')
prepopulated_fields = {"slug" : ('title',)}
fieldsets = (
(None, {'fields': (('title', 'status'), 'body_html', 
('pub_date',
'enable_comments'), 'tags', 'slug')}),
)
formfield_overrides = {
models.TextField: {'widget': TinyMCE},
}
#class Media:
#js = ['js/tiny_mce/tiny_mce.js']
#js = ['js/tiny_mce/tiny_mce.js', 'js/textareas.js']

admin.site.register(Entry, EntryAdmin)

Here's the separate full model for Entry:

from django.db import models
from django.contrib.syndication.feeds import Feed
from django.contrib.sitemaps import Sitemap
#import markdown
from tagging.fields import TagField
from tagging.models import Tag

# Create your models here.

class Entry(models.Model):
title = models.CharField(max_length=200)
slug = models.SlugField(
unique_for_date='pub_date',
help_text='Automatically built from the title.'
)
body_html = models.TextField(blank=True)
#body_markdown = models.TextField() #note, if you're using
Markdown, include this field, otherwise just go with body_html
pub_date = models.DateTimeField('Date published')
tags = TagField()
enable_comments = models.BooleanField(default=True)
PUB_STATUS = (
(0, 'Draft'),
(1, 'Published'),
)
status = models.IntegerField(choices=PUB_STATUS, default=0)

class Meta:
ordering = ('-pub_date',)
get_latest_by = 'pub_date'
verbose_name_plural = 'entries'

def __unicode__(self):
return u'%s' %(self.title)

def get_absolute_url(self):
return "/blog/%s/%s/" %(self.pub_date.strftime("%Y/%b/
%d").lower(), self.slug)

#def save(self):
#self.body_html = markdown.markdown(self.body_markdown,
safe_mode = False)
# super(Entry, self).save()

def get_previous_published(self):
return self.get_previous_by_pub_date(status__exact=1)

def get_next_published(self):
return self.get_next_by_pub_date(status__exact=1)

def get_tags(self):
return Tag.objects.get_for_object(self)



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



Yet another schema managing idea

2009-06-25 Thread Dan Radez

I have been looking for a way to apply and manage my model changes to my 
db schema. This came out of a brainstorm yesterday afternoon. Just 
wanted to pass the idea through the community to see where it fits, if 
anywhere, upstream.

The general idea is to save sqlall output from manage.py. You then 
maintain sql files named after your apps and their versions.  Then just 
run the script against two of your files with the sqlall content in it. 
It takes the diff of two files and generates sql statements that will 
upgrade your schema from one version to another.

I went back and captured sqlall from a couple previous releases and used 
them to write the code. The proof-of-concept can modify columns, create 
and drop tables and add contraints and indexes. All in mysql at the 
moment. Haven't investigated supporting other databases yet.

I realize that other tools can do this too. I just wanted something 
small that only generated syntax. Is there anything I've missed that 
already does this and is more mature? Does anyone else like the idea of 
this style of schema management?

General example of use:
$ ./manage.py syncdb # initial install
$ ./manage.py sqlall appname > schemas/appname-1.1.0.sql
###  make modifications to model ###
$ ./manage.py sqlall appname > schemas/appname-1.2.0.sql
$ cd schemas
$ ./gen-db-update-script.py appname-1.1.0.sql appname-1.2.0.sql > 
update-appname-1.1.0to1.2.0.sql
$ cat update-appname-1.1.0to1.2.0.sql
CREATE TABLE `appname_tableone` (
 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
 `group_id` integer NOT NULL,
 `content_type_id` integer NOT NULL,
 `object_id` integer UNSIGNED NOT NULL,
)
;
ALTER TABLE `appname_tabletwo` ADD COLUMN `prune_count` integer NOT NUL;
ALTER TABLE `appname_tabletwo` ADD COLUMN `prune_age` integer NOT NULL;
ALTER TABLE `appname_tabletwo` ADD COLUMN `prune_inactive` integer NOT NULL;
ALTER TABLE `appname_tablethree` MODIFY COLUMN `arch_id` integer NOT NULL;
$ mysql -u someuser -p databasename < update-appname-1.1.0to1.2.0.sql

Radez

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



Re: Need help

2009-06-25 Thread amy

I had this same problem...the user and pass were fine but no users
could authenticate on any DB, regardless of settings.

Turns out my issue was only that I needed to add the string
"localhost" to the host parameter.

It's odd since the comments specifically state to leave it blank for
localhost...but oh well. It worked.

DATABASE_HOST = 'localhost' # Set to empty string for
localhost. Not used with sqlite3.

Odd.

On May 31, 6:14 am, Tim Chase  wrote:
> mizan rahman wrote:
> > No, i've checked that i've created a user named "djangouser" and the
> > problem still exist what will i do? Plz help me
>
> and you've checked that the password in settings.py is correct?
> You only confirmed one of the two problems I suggested.
>
> If both are correct, you may have to include the section of your
> pg_hba.conf that defines access permissions.  It usually looks
> something like
>
> ##
> local   all         postgres                          ident sameuser
>
> # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
>
> # "local" is for Unix domain socket connections only
> local   all         all                               ident sameuser
> # IPv4 local connections:
> host    all         all         127.0.0.1/32          md5
> # IPv6 local connections:
> host    all         all         ::1/128               md5
> ##
>
> along with information about how your connecting in Django (to
> localhost, to the local machine by IP address, to a remote
> machine, etc)
>
> -tkc

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



Can base.html template contain dynamic content if used by direct_to_template

2009-06-25 Thread Pete-Sitedesign

I want to build a site which has latest news on the side of all the
pages, I wanted to build the pages using simple templates (static
content) and then reference them using the direct_to_template in the
urls file.

Since each template extends base how can I get base to contain the
latest news or do I have to write a view for each template and pass
the news into them?

Sorry for the newbie question.

--~--~-~--~~~---~--~~
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: Escaping forward slashes in URLs

2009-06-25 Thread Rajesh D



On Jun 25, 12:52 pm, Andrew Fong  wrote:
> Question: When is it necessary to escape a forward slash? I'm dealing
> with these two situations in my templates -- assume the next context
> variable is a URL of some sort.
>
> 
>
> http://en.wikipedia.org/wiki/URL_encoding#Percent-encoding_reserved_characters

quote: In the "query" component of a URI, for example, "/" is still
considered a reserved character but it normally has no reserved
purpose, unless a particular URI scheme says otherwise. The character
does not need to be percent-encoded when it has no reserved purpose. /
quote

-RD


--~--~-~--~~~---~--~~
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: Rendered output from a template tag

2009-06-25 Thread Daniele Procida

On Thu, Jun 25, 2009, Daniel Roseman  wrote:

>> To do this, I think I need my function to call another template to
>> render it appropriately - is that correct?

>The best thing to do here is to use an 'inclusion tag'

Thanks, I'm looking at that now, because the solution I came up with is
also injecting:

Content-Type: text/html; charset=utf-8

into my page.

Daniele


--~--~-~--~~~---~--~~
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: MemoryError on bigs list of items

2009-06-25 Thread Andrew Fong

To clarify, you're displaying a list of 1000+ models on a single page,
yes?

My understanding is that the debug_toolbar analyzes each SQL query and
keeps each result in memory before rendering everything in the
template. I don't know how your query works, but let's take an extreme
case and say your request executes 1000+ queries. In addition to
keeping 1000 models in memory, the debug_toolbar now has to also
contain the query data for 1000 queries. If you have a small amount of
memory, this could eat it up pretty quick.

I don't think setting MaxRequestsPerChild = 1 would do anything to
cause a MemoryError. It should actually help, since if you're
restarting the process after just 1 request, any memory leaks won't
have time to build up.

-- Andrew

On Jun 25, 1:15 pm, Frédéric Hébert  wrote:
> Hi there,
>
>  I'm facing with a curious problem.
>
>  I've an project which is hosted on three differents servers :
>
>  one (my local PC) :
> debian lenny /
> python 2.5.2 / django 1.0.2 final
> apache 2.2.9 / mod_python 3.3.1-7
>
>  the two others (production and validation server) :
> OpenSUSE 11.1 /
> python 2.6.2 / django 1.0.2 final
> apache 2.2.10 / mod_python 3.3.x-x
>
>  Two months ago, I've launched this project both on production server
> and validation server.
>  Neither validation server nor production server caused me any
> trouble.
>
> Today, to test something, I've installed debug_toolbar extension and
> set MaxRequestPerChild to 1 in Apache's conf file, both on my local
> dev PC and on the validation server.
>
> When I want to display two long list (1000+ items each) i get a
> MemoryError one time out of two. The remainder of project goes fine.
>
>  I've resetted MaxRequestPerChild to 1 (default value on OpenSUSE)
> and commented out debug_toolbar's things in my settings, restart
> Apache. But error happened again on the validation server.
>
>  On my local PC, it works well, with debug_toolbar and MaxReq.. set or
> not.
>
> I've pasted the traceback  herehttp://dpaste.com/hold/59667/
>
>  AFAICS, an exception occurs when django tries to render a debug
> template
>
> Here is an exerpt of my vhost conf file on OpenSUSE :
>  DocumentRoot /srv/www/enseignements-dev.ehess.fr/ue
>
>     
>       SetHandler python-program
>       PythonHandler django.core.handlers.modpython
>       SetEnv DJANGO_SETTINGS_MODULE ue.settings_dev
>       PythonDebug On
>       PythonPath "['/srv/www/enseignements-dev.ehess.fr/', '/srv/www/
> enseignements-dev.ehess.fr/ue/'] + sys.path"
>     
>
> Many thanks in advance,
>
>  Frédéric
--~--~-~--~~~---~--~~
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: Rendered output from a template tag

2009-06-25 Thread Daniel Roseman

On Jun 25, 6:52 pm, "Daniele Procida" 
wrote:
> I created a simple_tag:
>
> def news_for_this_page(page):
>     if page.entity_set.all(): # check page belongs to an entity first
>         e = page.entity_set.all()[0] # first entity will be only one
>         newslist = []
>         for item in e.newsitem_set.all(): # get entity's news items
>             newslist.append(item.headline) # add them to the list      
>         return newslist
>     else:
>         return "No news is good news"
>
> What this spits back into the page is:
>
>     [u'Man bites dog', u'Dog bites man', u'Nixon resigns']
>
> so obviously I need to process that list, making it a  and putting
> in the links before sending that to the template.
>
> To do this, I think I need my function to call another template to
> render it appropriately - is that correct?
>
> Are there any shortcuts in this process?
>
> For example, to use my template tag I use {% news_for_this_page entity
> %}. It would be neater to use something like {% news_for_this_page %},
> since entity will always be set.
>
> Thanks,
>
> Daniele

The best thing to do here is to use an 'inclusion tag', which as the
documentation says is a template tag that renders another template. So
you'd define a small template with just the html for rendering your
news list, then pass that as the argument to the decorator when
defining the tag. The function then returns a dictionary context, as
you would use in a view.

The second thing you can do with the inclusion tag - to answer your
other question - is to use the decorator with takes_context=True. Then
it will take a single parameter, context, which is the parent
template's context,  so you don't need to pass in your object
explicitly.

@register.inclusion_tag('newslist.html', takes_context=True)
def news_for_this_page(context):
...
return {'newslist': newslist}

See the documentation:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags
--
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: Rendered output from a template tag

2009-06-25 Thread Michael
On Thu, Jun 25, 2009 at 1:52 PM, Daniele Procida
wrote:

>
> I created a simple_tag:
>
> def news_for_this_page(page):
>if page.entity_set.all(): # check page belongs to an entity first
>e = page.entity_set.all()[0] # first entity will be only one
>newslist = []
>for item in e.newsitem_set.all(): # get entity's news items
>newslist.append(item.headline) # add them to the list
>return newslist
>else:
>return "No news is good news"
>
> What this spits back into the page is:
>
>[u'Man bites dog', u'Dog bites man', u'Nixon resigns']
>
> so obviously I need to process that list, making it a  and putting
> in the links before sending that to the template.
>
> To do this, I think I need my function to call another template to
> render it appropriately - is that correct?
>
> Are there any shortcuts in this process?
>
> For example, to use my template tag I use {% news_for_this_page entity
> %}. It would be neater to use something like {% news_for_this_page %},
> since entity will always be set.
>

Inclusion tags might help you out with the template idea, but generally for
variables like this I like to put them in context like this:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#setting-a-variable-in-the-context

Those docs should help you out a lot. Also the default tags are pretty good
examples to look at:
http://code.djangoproject.com/browser/django/trunk/django/template/defaulttags.py

Hope that helps,

Michael

--~--~-~--~~~---~--~~
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: Using Signals as hooks

2009-06-25 Thread Wiiboy

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



Re: Django and PyAMF - RemotingError

2009-06-25 Thread Thomas Hill
IIRC, pyAMF tries to turn all python objects into amf related ones upon
output. What you may be seeing here is that querysets aren't able to make it
through this conversion. Check your apache error logs for the stacktrace, if
you have one, or like Randy said, set Debug = True.

On Thu, Jun 25, 2009 at 6:23 AM, Randy Barlow wrote:

>
> Noxxan wrote:
> > I'm trying to place in my app an amf gateway,
> > so I make one gateway with code:
> >
> > #-*- coding: utf-8 -*-
> > from pyamf.remoting.gateway.django import DjangoGateway
> >
> > from my.views import some_view
> >
> > services = {
> > 'some_service.hello': some_view.get_smt,
> > }
> >
> > echoGateway = DjangoGateway(services)
> >
> > there's also file some_view.py, with content:
> >
> > #-*- coding: utf-8 -*-
> > from module.models import MyOwnModel
> >
> > def get_smt(request):
> > return MyOwnModel.objects.all()
> >
> > And here's the problem, I receive an error message:
> >
> > pyamf.remoting.RemotingError: HTTP Gateway reported status 500
> > Internal Server Error
> >
> > When I change return of get_smt view to, by example return 123,
> > error didn't occur.
> >
> > I have PyAmf 0.4.2, Python 2.5.2 and latest stable Django.
> >
> > What may causes the problem?
>
> Many things can cause the problem you are seeing.  I would suggest to
> turn Debug=True, and then navigate to the URL for that view.  You should
> be able to see a traceback, which will give you a better clue about what
> the problem is.
>
> >
>

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



Rendered output from a template tag

2009-06-25 Thread Daniele Procida

I created a simple_tag:

def news_for_this_page(page):
if page.entity_set.all(): # check page belongs to an entity first
e = page.entity_set.all()[0] # first entity will be only one
newslist = []
for item in e.newsitem_set.all(): # get entity's news items
newslist.append(item.headline) # add them to the list   
return newslist
else:
return "No news is good news"

What this spits back into the page is: 

[u'Man bites dog', u'Dog bites man', u'Nixon resigns']

so obviously I need to process that list, making it a  and putting
in the links before sending that to the template.

To do this, I think I need my function to call another template to
render it appropriately - is that correct?

Are there any shortcuts in this process? 

For example, to use my template tag I use {% news_for_this_page entity
%}. It would be neater to use something like {% news_for_this_page %},
since entity will always be set.

Thanks,

Daniele


--~--~-~--~~~---~--~~
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: Where to put form definitions?

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 12:12 PM, Technicalbard  wrote:

>
> My reading of the documentation isn't clear on where form definitions
> could or should be defined.  Is it better to define forms inside an
> apps views.py file, or should I put the form definitions into a
> separate forms.py file and import it into the views as necessary?  The
> latter seems more reusable.  Does anyone have reasons to do otherwise?
> >
>
There is no requirement on where they need to be, you could put them in
purple_hippos.py for all Django cares :).  However, in practice most people
put them in forms.py, since it's a nice clean, obvious place for them.

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

--~--~-~--~~~---~--~~
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: Will future Django releases support multiple databases?

2009-06-25 Thread Alex Gaynor
On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
wrote:

>
> > Right now, Django doesn't seem to support the multiple
> > databases on the same server or different servers.  Will that
> > feature be available out of the box for future releases?
>
> You may want to eavesdrop on the Django Developers group (as
> opposed to this Django Users group) where Alex Gaynor has been
> posting updates on his GSoC project to add multi-DB support to
> Django[1].  There are several aspects to multi-DB support[2] but
> I believe he's addressing some of the more common use-cases.  You
> can even follow along if you like to live dangerously as I
> believe he's got a public repository for his code on GitHub.
>
> -tim
>
> [1]
>
> http://groups.google.com/group/django-developers/search?group=django-developers&q=alex+gaynor+%28multi-db+OR+multiple-database%29
>
> [2]
>
> http://groups.google.com/group/django-users/browse_thread/thread/663046559fd0f9c1/
> for my posted concerns
>
>
>
>
>
> >
>
I have both a public code repository on github at github.com/alex/django/ as
well as a branch in Django's SVN at branches/soc2009/multidb.  The best
place to find out about the work is the django-developers list, where I have
sent any number of emails discussing both the overall design, as well as the
status.

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

--~--~-~--~~~---~--~~
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: Why is (db) Field.form_class hardcoded to TypedChoiceField if field has choices?

2009-06-25 Thread Flo Ledermann

I am sorry folks, I just found the corresponding issue:

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

however, i would still be interested in discussing the reasons behind
this - and why the patch provided in the ticket did't get applied
yet ;)

flo

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



Why is (db) Field.form_class hardcoded to TypedChoiceField if field has choices?

2009-06-25 Thread Flo Ledermann

Hi all,

I am trying to implement a "FlagField" that can be used to store
binary flags in a single integer value in the DB. The approach that
looks most promising is subclassing Integer Field, pass in some
choices as possible flags (which will be internally converted into the
appropriate bitmasks) and use subclasses of MultipleChoiceField and
CheckboxSelectMultiple as form field and widget, respectively.

This all works nicely besides the fact that the formfield() method of
Field forces the Field to use TypedChoiceField as the form_class if
choices are present (django/db/models/fields/__init__.py:326). So
there is no way for me to use my own form_class unless I override this
whole (otherwise perfectly suitable) method. The workaround I have
taken is to use a different name instead of 'choices', but I would
prefer to stick with this name as it is intuitive in the django
context. (One could argue that choices should be reserved for cases
where a single item should be chosen form choices, but I doubt this
would be a worthwile distinction and there is nothing in the code/docs
that suggest this).

My proposal would be to change the formfields() method to check, if
choices are defined, if form_class is a subclass of ChoiceField an if
so, leave it alone. Otherwise the default (TypedChoiceField) can be
used as it is the case now. What do you people think?

I could open a ticket if feedback here suggests so. All other
suggenstions regarding my code are welcome!

All the best,

flo ledermann


Here is my (working) code:
--
# fields.py
from django.db.models import IntegerField
from django.forms import BooleanField

import forms

class FlagField(IntegerField):
def __init__(self, flags, **kwargs):
# i would like to use 'choices' instead of flags, but this is
impossible
assert flags, "%ss must have flags argument set." %
self.__class__.__name__
self.flags = flags
super(FlagField, self).__init__(**kwargs)

def formfield(self, **kwargs):

defaults = {'form_class': forms.FlagField,
'choices': self.flags }

defaults.update(kwargs)
# this has to be done because admin assigns a widget to
IntegerFields,
# which we do not want here
defaults.pop('widget', None)

return super(FlagField, self).formfield(**defaults)

--
# forms.py
from django.forms import MultipleChoiceField, CheckboxSelectMultiple,
SelectMultiple
from django.utils.encoding import force_unicode

class FlagWidget(CheckboxSelectMultiple):

def render(self, name, value, attrs=None, choices=()):
flags = []
for i, flag in enumerate(self.choices):
if value & 1< 0: flags.append(flag[0])
return super(FlagWidget, self).render(name, flags, attrs,
choices)

def value_from_datadict(self, data, files, name):

raw = super(FlagWidget, self).value_from_datadict(data, files,
name)
if raw == None: return None

value = 0

for i, flag in enumerate(self.choices):
if flag[0] in raw: value += 1

MemoryError on bigs list of items

2009-06-25 Thread Frédéric Hébert

Hi there,

 I'm facing with a curious problem.

 I've an project which is hosted on three differents servers :

 one (my local PC) :
debian lenny /
python 2.5.2 / django 1.0.2 final
apache 2.2.9 / mod_python 3.3.1-7

 the two others (production and validation server) :
OpenSUSE 11.1 /
python 2.6.2 / django 1.0.2 final
apache 2.2.10 / mod_python 3.3.x-x

 Two months ago, I've launched this project both on production server
and validation server.
 Neither validation server nor production server caused me any
trouble.

Today, to test something, I've installed debug_toolbar extension and
set MaxRequestPerChild to 1 in Apache's conf file, both on my local
dev PC and on the validation server.

When I want to display two long list (1000+ items each) i get a
MemoryError one time out of two. The remainder of project goes fine.

 I've resetted MaxRequestPerChild to 1 (default value on OpenSUSE)
and commented out debug_toolbar's things in my settings, restart
Apache. But error happened again on the validation server.

 On my local PC, it works well, with debug_toolbar and MaxReq.. set or
not.

I've pasted the traceback  here http://dpaste.com/hold/59667/

 AFAICS, an exception occurs when django tries to render a debug
template

Here is an exerpt of my vhost conf file on OpenSUSE :
 DocumentRoot /srv/www/enseignements-dev.ehess.fr/ue


  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  SetEnv DJANGO_SETTINGS_MODULE ue.settings_dev
  PythonDebug On
  PythonPath "['/srv/www/enseignements-dev.ehess.fr/', '/srv/www/
enseignements-dev.ehess.fr/ue/'] + sys.path"



Many thanks in advance,

 Frédéric

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



Where to put form definitions?

2009-06-25 Thread Technicalbard

My reading of the documentation isn't clear on where form definitions
could or should be defined.  Is it better to define forms inside an
apps views.py file, or should I put the form definitions into a
separate forms.py file and import it into the views as necessary?  The
latter seems more reusable.  Does anyone have reasons to do otherwise?
--~--~-~--~~~---~--~~
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: TinyMCE django admin

2009-06-25 Thread Dhruv Adhia
Hey Joost,

I was just googling and came across all those old hacky ways to integrate
tinymce which I finally did yesterday. Its working. But yes if its something
builtin now I should go for that. However I dont know If I can easily change
the properties that way for the editor. Right now in the Hacky way I change
plugins,themes,skins stuff and it shows up the changes. Can we do this with
widgets?

Thanks,

On Thu, Jun 25, 2009 at 12:38 AM, Joost Cassee  wrote:

>
> On Jun 24, 6:51 pm, Dhruv Adhia  wrote:
>
> > Second part is working.
>
> Great!
>
> > I am new to those firebug stuff. Can you guide me to docs?
>
> Firebug can be found at [1]. The docs are there as well. Basically you
> enable Javascript debugging for your site and watch for errors in the
> Firebug console.
>
> [1] http://getfirebug.com/
>
> Is there a reason why you are not using the django-tinymce widget to
> render the BlogPost.body field?
>
> Regards,
>
> Joost
> >
>


-- 
Dhruv Adhia
http://thirdimension.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
-~--~~~~--~~--~--~---



Escaping forward slashes in URLs

2009-06-25 Thread Andrew Fong

Question: When is it necessary to escape a forward slash? I'm dealing
with these two situations in my templates -- assume the next context
variable is a URL of some sort.



http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Very bad experience in Django...

2009-06-25 Thread Jon Raphaelson


> you'll see it doesn't say anything about the validation behavior being
> dependent on the widget in use.  So it doesn't matter what widget you use,
> if you want to be able to validate False as a valid value, then you need to
> include required=False in the form field definition.

To be completely fair, the documentation says specifically:

> Validates that the check box is *checked* (i.e. the value is True) if the 
> field has required=True.

and

> If you want to include a *checkbox* in your form that can be either *checked 
> or unchecked*, you must remember to pass in required=False when creating the 
> BooleanField.

I can definitely understand how someone new to the framework, trying
to use a custom widget to do HiddenFields (which is more arcane that
it should be IMO, but that's off topic) and reading the BooleanField
docs could get confused about using them _without a checkbox widget_.
I'm going to open a ticket against the doc here and submit a first
pass at a documentation patch. Confusion is worth fixing IMO.

- Jon

--~--~-~--~~~---~--~~
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: Trouble with extra statement in Django 0.96

2009-06-25 Thread Realpolitik

I have since discovered that I can use the following:

585 if len(name) > 0:
586 members = MemberRole.objects.filter(
   Q(member__first_name = 'John') |
   Q(member__last_name = 'John'),
587 start_date__lte = today,
588 end_date__gte = today,
589 )

Except I am still curious about the .extra() issue I was having before
as it will allow me to use regular expressions (which were not
introduced as __regex until 1.0)

On Jun 25, 10:47 am, Realpolitik  wrote:
> Hello, I'm using Django 0.96 and it is not possible to upgrade to
> 1.1/2 yet. I am attempting to perform the following function: "Get all
> of the MemberRole objects filtered by start date and end date, and
> also filtered by the Member's (foreign key relationship) first name OR
> last name.
>
> MemberRole: start_date, end_date, member (foreign key)
> Member: first_name, last_name
>
> 585     if len(name) > 0:
> 586         members = MemberRole.objects.select_related
> ('member').filter(
> 587             start_date__lte = today,
> 588             end_date__gte = today,
> 589         ).extra(
> 590             where=['(congress_member.first_name = %s OR
> congress_member.last_name =%s)'],
> 591             params=[name, name],
> 592             #tables=[Member._meta.db_table],
> 593         )
>
> The error I get is:
>
> Exception Value:        missing FROM-clause entry for table
> "congress_member" LINE 1: ...bers", "congress_roles",
> "congress_states" WHERE (congress_m... ^
>
> I get the same error whether I use congress_member or member in the
> where statement.
--~--~-~--~~~---~--~~
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: djangoplus widget

2009-06-25 Thread jhugo

I want to use this widget instead of the default one from the many to
many field but don't know how to. Do you have an example that can get
me started.

Thanks,

- Hugo

On Jun 25, 11:39 am, "Gabriel ."  wrote:
> On Thu, Jun 25, 2009 at 12:33 PM, jhugo wrote:
>
> > Hi,
>
> > I am trying to use the ajax_m2m_widget from djangoplus but there is
> > very little information could anyone help me?
>
> > Thanks,
>
> That depends of what kind of help do you need. Please be more specific.
>
> --
> Kind Regards
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: djangoplus widget

2009-06-25 Thread Gabriel .

On Thu, Jun 25, 2009 at 12:33 PM, jhugo wrote:
>
> Hi,
>
> I am trying to use the ajax_m2m_widget from djangoplus but there is
> very little information could anyone help me?
>
> Thanks,
>

That depends of what kind of help do you need. Please be more specific.

-- 
Kind Regards

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



djangoplus widget

2009-06-25 Thread jhugo

Hi,

I am trying to use the ajax_m2m_widget from djangoplus but there is
very little information could anyone help me?

Thanks,

-Hugo
--~--~-~--~~~---~--~~
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: passing template variable to templatetags

2009-06-25 Thread plungerman

you must use the django.template.resolve_variable method:

obj = Foo.objects.get(id=resolve_variable(self.id, context))

which would be called within the render method of you templatetag
class, which contains the "context" from the view.


On Jun 21, 10:44 pm, Joru  wrote:
> Is it possible to resolve tag value(in this is group.id) inside
> templatetags(tag_model(parser,token)) function without having it
> render in subclass of django.template.Node?
> Please give me some solution
>
> On Jun 20, 4:32 pm, Joru  wrote:
>
>
>
> > Hi,
>
> > Suppose I had templatetags
> >  {% tag_model tags.tag as tags with group=group.id %)
>
> > in my templatetags I define tag_model as a follow
> >       def tag_model(parser, token):
> >              bits = token.contents.split()
> >              len_bits = len(bits)
> >              name, value = bits[i].split('=')
>
> > when I did {{ group.id }} this give me a id group value
> > but when I do int(group.id) inside tag_model, the group.id is not well
> > passed to the function, instead I get a group.id as a string
> > How to get group.id value well passed inside tag_model?

--~--~-~--~~~---~--~~
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: Will future Django releases support multiple databases?

2009-06-25 Thread Tim Chase

> Right now, Django doesn't seem to support the multiple
> databases on the same server or different servers.  Will that
> feature be available out of the box for future releases?

You may want to eavesdrop on the Django Developers group (as 
opposed to this Django Users group) where Alex Gaynor has been 
posting updates on his GSoC project to add multi-DB support to 
Django[1].  There are several aspects to multi-DB support[2] but 
I believe he's addressing some of the more common use-cases.  You 
can even follow along if you like to live dangerously as I 
believe he's got a public repository for his code on GitHub.

-tim

[1]
http://groups.google.com/group/django-developers/search?group=django-developers&q=alex+gaynor+%28multi-db+OR+multiple-database%29

[2]
http://groups.google.com/group/django-users/browse_thread/thread/663046559fd0f9c1/
for my posted concerns





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



Isolating Django Models

2009-06-25 Thread Blaine Booher
Hey everyone,
  I was wondering the best way to isolate django models so they can be used
in other python applications.  I have seen the django extensions, which are
very helpful.  But a 'job' is still coupled to the django environment.
Ideally I'd like to do this:

* Write some function foo() that uses mysite.myapp.models
* Be able to import that function into a pure python script.  So I could run
'python myscript.py' and it could run foo() without any errors.

I have done the following hack, which lets me import the models, but I get a
strange error when I try to access the database:

# this is in /project/app/scripts/
import sys, os
os.environ['DJANGO_SETTINGS_MODULE'] = 'datamanager.settings'
sys.path.append('../../../') # Add top level project path (for settings)
sys.path.append('../../') # Add app level to path
from myapp.models import mymodel
# At this point I am good to go, until I try to access the database.
>>> mymodel.objects

>>> mymodel.objects.all()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line
147, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line
224, in __getitem__
qs = self._clone()
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line
601, in _clone
query = self.query.clone()
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 195, in clone
obj.__dict__.update(kwargs)
TypeError: descriptor '__dict__' for 'Empty' objects doesn't apply to
'BaseQuery' object

Does anyone else do this kind of thing?

Blaine

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



Re: Sessions Not working.

2009-06-25 Thread Antoni Aloy

2009/6/25 lc :
>
> Production Box spec: mandrake 10.1.1,  python2.3,
> libmysql15-5.0.1,   MySQL1.0,  Django 1.0.
>
> can't get sessions to work. My site (and sessions) works on my
> development box with a more or less current version of ubuntu, when I
> copy over the project to the production box it does not work. I have
> run "python manage.py syncdb" and the database is created correctly, I
> have made sure the settings.py is correct, but Djangos debug page
> states there is "No Cookie Data" when I navigate to the site.


Are your working with sessionss? That is, are your working with the
session object and saving there some information? On the afirmative
case check the object you're using, perhaps is a lazy object or a non
serializable one.

You can check also where are saving your sesion data. Are you sure
you're saving it in the database?

>From your configuration I just see python2.3 too old for my
preferences. You should also use Django 1.0.2 as its the last estable
version (if you don't want to work in the cutting edge of course).

Hope it helps!
-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Pyfacebook + Dreamhost

2009-06-25 Thread R C

Hi Everyone

I cannot for the life of me get Pyfacebook to work with Dreamhost.  It
is a problem with the middleware and the fact that at Dreamhost you
have to use fcgi (instead of mod_python for example).

Any help would be greatly appreciated


ERROR MESSAGE BELOW

ImproperlyConfiguredPython 2.4.4: /usr/bin/python
Thu Jun 25 16:57:16 2009

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.
 /mnt/local/home/webmaster/django.x.com/fcgi.py in run
(self=)
  578 """Runs the handler, flushes the streams, and ends the
request."""
  579 try:
  580 protocolStatus, appStatus = self.server.handler
(self)
  581 except:
  582 traceback.print_exc(file=self.stderr)
protocolStatus undefined, appStatus undefined, self = , self.server = , self.server.handler =
>
 /mnt/local/home/webmaster/django.x.com/fcgi.py in handler
(self=, req=)
 1264 try:
 1265 try:
 1266 result = self.application(environ,
start_response)
 1267 try:
 1268 for data in result:
result = None, self = , self.application =
, environ =
{'AUTH_TYPE': 'Basic', 'DH_USER': 'webmaster', 'DOCUMENT_ROOT': '/home/
webmaster/django.x.com', 'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_CONNECTION': 'keep-
alive', ...}, start_response = 
 /home/webmaster/local/django/django_src/django/core/handlers/wsgi.py
in __call__(self=,
environ={'AUTH_TYPE': 'Basic', 'DH_USER': 'webmaster',
'DOCUMENT_ROOT': '/home/webmaster/django.x.com',
'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/
xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_CONNECTION': 'keep-
alive', ...}, start_response=)
  228 # Check that middleware is still uninitialised.
  229 if self._request_middleware is None:
  230 self.load_middleware()
  231 self.initLock.release()
  232
self = ,
self.load_middleware = >
 /home/webmaster/local/django/django_src/django/core/handlers/base.py
in load_middleware(self=)
   40 mod = import_module(mw_module)
   41 except ImportError, e:
   42 raise exceptions.ImproperlyConfigured, 'Error
importing middleware %s: "%s"' % (mw_module, e)
   43 try:
   44 mw_class = getattr(mod, mw_classname)
exceptions = ,
exceptions.ImproperlyConfigured = , mw_module =
'facebook.djangofb', e = 

ImproperlyConfigured: Error importing middleware facebook.djangofb:
"No module named facebook.djangofb"
  args = ('Error importing middleware facebook.djangofb: "No
module named facebook.djangofb"',)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Trouble with extra statement in Django 0.96

2009-06-25 Thread Realpolitik

Hello, I'm using Django 0.96 and it is not possible to upgrade to
1.1/2 yet. I am attempting to perform the following function: "Get all
of the MemberRole objects filtered by start date and end date, and
also filtered by the Member's (foreign key relationship) first name OR
last name.

MemberRole: start_date, end_date, member (foreign key)
Member: first_name, last_name

585 if len(name) > 0:
586 members = MemberRole.objects.select_related
('member').filter(
587 start_date__lte = today,
588 end_date__gte = today,
589 ).extra(
590 where=['(congress_member.first_name = %s OR
congress_member.last_name =%s)'],
591 params=[name, name],
592 #tables=[Member._meta.db_table],
593 )

The error I get is:

Exception Value:missing FROM-clause entry for table
"congress_member" LINE 1: ...bers", "congress_roles",
"congress_states" WHERE (congress_m... ^

I get the same error whether I use congress_member or member in the
where statement.

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



Sessions Not working.

2009-06-25 Thread lc

Production Box spec: mandrake 10.1.1,  python2.3,
libmysql15-5.0.1,   MySQL1.0,  Django 1.0.

can't get sessions to work. My site (and sessions) works on my
development box with a more or less current version of ubuntu, when I
copy over the project to the production box it does not work. I have
run "python manage.py syncdb" and the database is created correctly, I
have made sure the settings.py is correct, but Djangos debug page
states there is "No Cookie Data" when I navigate to the site.

I also tried installing latter versions of python, Django, MySQLdb,
mod_python and apache but same problem. It seems to be a problem with
Django or Python because the problem persists even when I run  "python
manage.py runserver" and axis my site from there.

This means users can't login which renders the site useless. I can't
change production box unfortunately.

Any help would be appreciated.

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



Re: Get Users' Groups

2009-06-25 Thread Daniel Roseman

On Jun 25, 2:45 pm, Gil Sousa  wrote:
> Hi!
>
> I searched on documentation but I didn't see anything related with
> managing users' groups, I want to do something like a "staff page" and
> for that I need to get a list of groups, I need to get the NAME of
> each group and I need to get the list of members of each group. How
> can I do this?
>
> I am using the User and Group django Models.
>
> Thanks!

It's just a normal ManyToMany relationship between user and group. So
you can do:

{% for group in groups %}
{{ group.name }} - {{ group.user_set.all }}
{% endfor %}
--
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
-~--~~~~--~~--~--~---



Will future Django releases support multiple databases?

2009-06-25 Thread Thierry

Right now, Django doesn't seem to support the multiple databases on
the same server or different servers.  Will that feature be available
out of the box for future releases?
--~--~-~--~~~---~--~~
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: Very bad experience in Django...

2009-06-25 Thread Karen Tracey
On Thu, Jun 25, 2009 at 9:46 AM, Chris Withers wrote:

>
> steveneo wrote:
> > BooleanField limits only to CheckBox?  But I set
> > widget=HiddenField It does not report error. HTML renders
> > correctly, but actually, you can not use like that?!
>
> Didn't you hear me: I said go find another framework, Django obviously
> sucks because one new user can't get his head around it ;-)
>

Please don't be rude. Perhaps your emoticon at the end was intended to
convey a light comical tone but tone is extremely hard to convey in email
and telling someone to go away because they've expressed some frustration
strikes me as rude.  Everyone is free to simply not respond to anyone they
feel is expressing unreasonable frustration; I don't see that it helps
matters much to try to tell them they are being unreasonable.

To the original poster, if you read the documentation on
django.forms.BooleanField:

http://docs.djangoproject.com/en/dev/ref/forms/fields/#booleanfield

you'll see it doesn't say anything about the validation behavior being
dependent on the widget in use.  So it doesn't matter what widget you use,
if you want to be able to validate False as a valid value, then you need to
include required=False in the form field definition.

(There was a huge long contentious discussion about required=True implying a
BooleanField value must be True in order for the field to pass validation --
you could find in the ticket tracker if you looked for it.  Not everyone
agrees with the choice made, but it was clearly an issue where not everyone
was going to agree no matter what decision was made.  It's been made and
won't be changed and the way to make your case work is simply pass
required=False on the form field definition.)

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: Very bad experience in Django...

2009-06-25 Thread Richard Shebora
Chris,

I don't know you.  But I hope your day gets a little better and your
problems lighter.

Sincerely,
Richard

On 6/25/09, Chris Withers  wrote:
>
>
> steveneo wrote:
> > BooleanField limits only to CheckBox?  But I set
> > widget=HiddenField It does not report error. HTML renders
> > correctly, but actually, you can not use like that?!
>
>
> Didn't you hear me: I said go find another framework, Django obviously
> sucks because one new user can't get his head around it ;-)
>
>
> Chris
>
> --
> Simplistix - Content Management, Zope & Python Consulting
> - http://www.simplistix.co.uk
>
> >
>


-- 

Thanks,
Richard Shebora


Information in this transmission is privileged and confidential.
It is intended for the use of the individual or entity named above.
Any review, dissemination, disclosure, alteration,  printing,
circulation or transmission of this email or it's attachments
is prohibited and unlawful.


--~--~-~--~~~---~--~~
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: Very bad experience in Django...

2009-06-25 Thread Xavier Ordoquy

On Thu, 2009-06-25 at 06:43 -0700, steveneo wrote:
> BooleanField limits only to CheckBox?  But I set
> widget=HiddenField It does not report error. HTML renders
> correctly, but actually, you can not use like that?!

http://docs.djangoproject.com/en/dev/ref/forms/fields/#booleanfield

You should have read that section, esp:

"Validates that the check box is checked (i.e. the value is True) if the
field has required=True."

and the note following:

"Since all Field subclasses have required=True by default, the
validation condition here is important. If you want to include a
checkbox in your form that can be either checked or unchecked, you must
remember to pass in required=False when creating the BooleanField"

By saying you have a very bad experience with Django because you didn't
read the documentation there's not much we can do for 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
-~--~~~~--~~--~--~---



Writing a reusable app

2009-06-25 Thread nabucosound

Hi all:

I am refactoring a django app to make it reusable and share it open
sourced to the world. There is a lot code which I think it is optional
and maybe not everybody will want to use, like some model fields, url
patterns of view functions. so my initial approach is to release only
the minimal version and let them add whatever they need.

But then a question arises, regarding maintenance and update of the
application in the projects where the app is gonna live. When I will
release further versions with bufixes or new features, then should
these people download the app, and maybe do a merge with their
modified versions? That would be against the philosophy of a django
app for me, that is, to be de-coupled from other parts of the project.
Also conflicts may appear, if my next app versions differ a lot from
previous ones.

The opposite approach I have seen in other apps is to include
everything the developer considers suitable. But doing this means
forcing people to include useless stuff for their projects, like model
fields they won't never use in their database schema, for example.

So how do u guys think I should target it? Minimalistic or full-
batteries included?

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



Re: Very bad experience in Django...

2009-06-25 Thread Chris Withers

steveneo wrote:
> BooleanField limits only to CheckBox?  But I set
> widget=HiddenField It does not report error. HTML renders
> correctly, but actually, you can not use like that?!

Didn't you hear me: I said go find another framework, Django obviously 
sucks because one new user can't get his head around it ;-)

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk

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



Get Users' Groups

2009-06-25 Thread Gil Sousa

Hi!

I searched on documentation but I didn't see anything related with
managing users' groups, I want to do something like a "staff page" and
for that I need to get a list of groups, I need to get the NAME of
each group and I need to get the list of members of each group. How
can I do this?

I am using the User and Group django Models.

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



Re: Very bad experience in Django...

2009-06-25 Thread steveneo

BooleanField limits only to CheckBox?  But I set
widget=HiddenField It does not report error. HTML renders
correctly, but actually, you can not use like that?!




On Jun 25, 11:22 pm, Chris Withers  wrote:
> steveneo wrote:
> > I try to use Django in a new project. Honestly, it is very bad
> > experience. It looks not boosting my development speed. Today, I
> > almost give up and begin to look up another Python framework
>
> Go for it :-)
>
> Chris
>
> --
> Simplistix - Content Management, Zope & Python Consulting
>             -http://www.simplistix.co.uk
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Hard linking an image

2009-06-25 Thread koranthala

Hi,
I have a chart which I generate on the fly.
Basically, I have hard linked an image. The image src contains GET
parameters, which is used to generate the chart image via matplotlib.
The resultant image is returned back as 'Content-Type' = 'image/png',
and thus the chart is displayed.
 i.e.  is there in
HTML - created using templates. The parameters key1, key2, field1,
field2 etc are used to create the image.

Now, this was working perfectly till now. Now, I need to create a
huge chart with lot of keys and fields. But, when I tried the same
mechanism, it failed because it is above the maximum characters
supported by GET. Even though I could not find any specific spec which
mentioned the max char limit, I understand that many browsers support
very less characters only ~300.

In such a case, how can I create the chart on the fly? Is there a
way to send the data as POST while hardlinking? Since I am getting the
values and generating the links using templates, I cannot think of too
many options. What si the usual mechanism used by fellow Djangoites?

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



Re: How to use MEDIA_URL on flatpages content?

2009-06-25 Thread Panu Tangchalermkul

I think I got your concept, converting all MEDIA_URL to corresponding
url before displaying.
But I still curious to know where should I put this code in the
project?

I've been thinking and can only come up with a way, by creating a new
middleware replicating FlatpageFallbackMiddleware
but instead of calling a view in django.contrib, it will call my new
view that has been modified by your suggestion.

However, I don't like this method. It forces me to copy an entire
django's view, which i think it's not a future-proof.

Your suggestion?


On Jun 25, 4:41 pm, Rama Vadakattu  wrote:
> Please ignore the last line..
>
> On Jun 25, 2:40 pm, Rama Vadakattu  wrote:
>
> > you can put {{MEDIA_URL}}
>
> > but while displaying instead of displaying it directly  just do the
> > below
>
> > from django.template.loader import render_to_string
> > from django.template import Context, Template
>
> > t = Template("flat page content goes here")
> > newflatpage = t.render({},context_instance=RequestContext(request))
> > #above is the new flat page where media url are replaced by their
> > corresponding urls
>
> > subject = render_to_string('',{},RequestContext(request))
>
> > On Jun 25, 12:53 pm, Panu Tangchalermkul  wrote:
>
> > > In the content of my flatpage, there's a picture to be displayed that
> > > it was stored in django media folder. I want to link to this file
> > > without having to specify its url directly. Instead, I want to use
> > > something like {{MEDIA_URL}} when editing the content via django-
> > > admin. I know I can use it normally on flatpage template but how about
> > > on the content?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >