Re: Using a non-DB backend

2010-10-15 Thread Sam Lai
On 16 October 2010 00:21, Damir Dezeljin  wrote:
> Hi.
> I'm working on an application tat communicates with embedded devices
> connected to the LAN. The devices are controlled by a central server written
> in C++. Django is used for the front-end or better to say the GUI for the
> server.
> Part of the data the user needs access too are stored in the database, hence
> the Django DB API to access this data; however, there are certain data and
> actions that requires direct communication with the C++ server. The
> communication is implemented using CORBA (OmniORBpy). E.g. of a situation
> where the CORBA interface between the GUI and the server is needed is the
> flush of devices configuration or update of the following and this should be
> real time and not implemented polling the DB.
> Currenly I'm instantiating the CORBA interface to my server in the views.py.
> I'm wondering if there is a better way to do it as I just don't see how
> could I put the CORBA interface in the Model part of the GUI? << I'm still
> confused by MVC approaches certain frameworks like CakePHP use. I think
> Django is not such a framework; however, I still think I should somehow
> separate the data layer from the business logic (bottomline: Django is still
> kind of a MVC framework). How can I do this?
> Of course I would also like to solve the problem I'm currently facing:
> Let's suppose both the C++ server and Django web site are up and running. If
> the C++ server is restarted the web page doesn't work any more until when I
> restart the web server too. I instantiate the CORBA object in a global
> scope; however, I thought there is no persistence for the Django code
> between the web browser calls. Am I right? Why the connection to CORBA
> ceases working in such a case? << with e.g. C++ or Python stand-alone
> clients the connection is reestablished each time the script / program / ...
> is executed.

That is an implementation detail left up to the web server. If you are
using mod-wsgi, then instances are reused for future requests (by
default), hence your problem.

There may also be some thread-safety issues with instantiating the
CORBA object in the global scope you may want to think about. I'd
probably instantiate the CORBA object once per request by doing so
inside the view (or by instantiating another class that does that, as
well as provide methods to access properties).

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

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



Re: mysql and Django

2010-10-15 Thread David
I think there is some confusion here. I'm guessing you are using mysql-
python v1.2.1 since a 1.x mysql version would probably date back to
the mid to late 90s. Ask the admin if it is possible to upgrade mysql-
python for which you do not need to upgrade MySQL itself or even take
down the database. It is also possible to build mysql-python against
the newer MySQL (there's probably a special option on mysql-python's
setup.py) yourself. As long as the newer version is in your PYTHONPATH
Django will pick it up.

On Oct 15, 1:39 pm, emma  wrote:
> Hi, the linux server of my company has mysql 1.2.1, which is too old
> for Django. However, the administrator didn't want to upgrade it. I
> have to install mysql 5.1.51 under my home directory. I did that
> successfully, but Django still complain about the older mysql. Do you
> know if there is a way to configure it so Django knows the path of the
> new mysql? Thanks.

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



Re: modelformset_factory, initial, and queryset

2010-10-15 Thread Tim Valenta
I have a model like such:
class Response(models.Model):
raw_text = models.TextField()
respondent = models.ForeignKey('auth.User')

Response has a related model attached to it:
class Code(models.Model):
response = models.ForeignKey(Response)
coded_answer = models.IntegerField()

The idea is that Responses come in as typed text, and then are
processed and assigned standardized Codes to represent the meaning
contained in the text.

Now, it greatly simplifies my life if I can use a normal formset to
represent the main Response objects gathered on a page for processing,
using the 'queryset' parameter to scope the Responses being handled.
I'm making use of the admin's filtered select widget in a ModelForm
for the Response model, like so:
class ResponseCodingForm(forms.ModelForm):
codes = forms.MultipleChoiceField(choices=[yada yada],
widget=FilteredSelectMultiple('Codes', false))
class Meta:
model = Response
fields = ['raw_text']

As you can see, the form only represents the "raw_text" field, but
adds a virtualized field called "codes" to the mix, which I want to
manage myself.  That is, I want to inject data values into it when I
create my formset, as you will soon see.  This approach works great
for when I render the formset, properly placing a field for "codes" on
my forms.  Naturally, the value of this field gets POSTed back to my
view, which I happily read from my form's cleaned_data attribute,
processing as I see fit.

But when it comes time to instantiate my formset, I can't find a way
to pump my own values into this "codes" field on the form.  Here is
the relevant part of the view:
responses = Response.objects.filter( yada yada)
ResponseCodingFormSet = modelformset_factory(Response,
form=ResponseCodingForm, extra=0)
initial = [{
'codes': list(response.code_set.values_list('id', flat=True)),
} for response in responses]

if request.method == 'POST':
# handle validation and save operations
else:
formset = ResponseCodingFormSet(queryset=responses,
initial=initial)


I realize that what I'm doing could be handled by some inline
formsets, but I really wanted to leverage that FilteredSelectMultiple
widget to represent my related model association.

No matter what I do, the formset's value for any of the objects'
"codes" field is empty.

On Oct 14, 3:09 am, Daniel Roseman  wrote:
> On Oct 14, 10:32 am, Tim Valenta  wrote:
>
>
>
>
>
>
>
>
>
> > This is driving me mad, so I must ask the community, in hopes of a
> > workaround:
>
> > I've got a simple formset of models on a page, generated by
> > modelformset_factory.  This particular page will never create forms--
> > it only modifies existing ones.  Therefore the queryset I pass into
> > the formset constructor gets built, and everything works great.
>
> > I've added a field to the formset, but Django seems perfectly happy to
> > totally ignore whatever initial data I want to supply for this
> > 'virtual' field that I've added.  It seems that I've got absolutely no
> > mechanism for setting a dynamically-generated value as a pre-computed
> > field value.
>
> > My situation is that I want to represent an many-to-many relationship
> > on this 'virtual' field, which doesn't actually exist on my model.
> > When the form is submitted, I can easily intercept the values sent and
> > do what I will with them.  However, when the page refreshes after a
> > submission, I cannot for the life of me inject this data back into the
> > form.  As of right now, my select-multiple widget is quite blank, no
> > matter what I do.
>
> > Help?  I've literally been at this for hours off and on.
>
> Can you show some code? It would help to understand what you're doing.
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: use django authentication for non-django pages

2010-10-15 Thread clee
On Oct 15, 2:12 am, bowlby  wrote:
> We're hosting a small site on our own server. On the server we have
> some pages that are non-django (for example munin to see server
> statistics). Is there a way to use django's authentication mechanism
> to reserve access to these pages to users who have an account?

There are several ways to do this.
If you just want django to replace the .htaccess file,  you can use
mod_wsgi with django for authentication. See
http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms.
-C

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



Re: iPhone posting FILEs = "Invalid content length"

2010-10-15 Thread Mike Krieger
Hey Eric!

We're using ASI & Django and seeing the same thing.

Was setting shouldAttemptPersistentConnection enough to make the
problem go away? About 1/50 of our requests fail with this bug.

Thanks!
Mike

On Oct 7, 11:21 am, Eric Chamberlain  wrote:
> We ran into the same error with ASIHTTPRequest, our fix was to turn off 
> persistent connections.
>
> On Sep 30, 2010, at 3:55 AM, Danny Bos wrote:
>
>
>
>
>
>
>
>
>
> > Hey there,
> > I've got a new error I'm totally stumped on. All searches are saying
> > it's a "http vs https" or similar.
> > I'd be keen to hear your thoughts.
>
> > Basically I've got an iPhone app sending a POST to a django app, it
> > contains one FILE.
> > Every now and then (very sporadically, about 1 in 5) one fails and I
> > get the below message.
>
> > 
> > Exception Type:
> > MultiPartParserError
> > 
> > 
> > Exception Value:
> > Invalid content length: 0
> > 
> > 
> > Exception Location:
> > /home/72999/data/python/django/django/http/multipartparser.py in
> > _init_, line 80
> > 
>
> > Any ideas?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



mysql and Django

2010-10-15 Thread emma
Hi, the linux server of my company has mysql 1.2.1, which is too old
for Django. However, the administrator didn't want to upgrade it. I
have to install mysql 5.1.51 under my home directory. I did that
successfully, but Django still complain about the older mysql. Do you
know if there is a way to configure it so Django knows the path of the
new mysql? Thanks.

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



How to get request.user when Django emails a 500 error report?

2010-10-15 Thread Margie Roginski
I finally turned off DEBUG on my site and got set up so that the
django code would email me the exceptions.  This is ultra-cool!  So I
got m first one in the mail today, and was hard-pressed to figure out
the user that ran into the error.  I don't find request.user anywhere
in the report.  Do I need to write the process_exception() middleware
and add it in myself?  Anyone have an example?!

Thanks!

Margie

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



PgWest 2010: Django + PostgreSQL Tutorial

2010-10-15 Thread Joshua D. Drake
Hello,

For those who might be interested there are several PostgreSQL + Django
talks happening at PgWest:

https://www.postgresqlconference.org/content/django-and-postgresql
https://www.postgresqlconference.org/content/speeding-django-and-other-python-apps-automatic-remoting-database-methods

You can register here:

https://www.postgresqlconference.org/content/pgwest-2010-registration

Joshua D. Drake

-- 
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

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



Re: MaxValueValidator to validate a model

2010-10-15 Thread refreegrata
Now works.
validators=[MaxValueValidator(Decimal('14.5'))

But I must to do an explicit declaration Decimal('14.5').

Somebody knows why?


On 15 oct, 18:13, refreegrata  wrote:
> Hello list. I want to validate the data in a field of a model.
>
> with this
> validators=[MaxValueValidator(14)]
> the field is correctly validated
>
> but with this
> validators=[MaxValueValidator(14.5)]
> always is invalid
>
> Somebody know how use the "MaxValueValidator" when the "max_value" is
> a decimal?
>
> thanks for read.

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



MaxValueValidator to validate a model

2010-10-15 Thread refreegrata
Hello list. I want to validate the data in a field of a model.

with this
validators=[MaxValueValidator(14)]
the field is correctly validated

but with this
validators=[MaxValueValidator(14.5)]
always is invalid

Somebody know how use the "MaxValueValidator" when the "max_value" is
a decimal?

thanks for read.

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



Re: Save Handlers and a newbie to Django

2010-10-15 Thread Devin M
Thanks everyone, I tried using some signal handlers but it wasn't
happening so I reverted to the override of the save method and now I
have it working.

Regards,
Devin Morin

On Oct 15, 8:56 am, Blue Cuenca  wrote:
>  On 10/15/2010 9:01 PM, Devin M wrote:> Hello everyone,
> >     I am writing a save handler in my models.py file to run a few
> > actions after a save. to do this I have a function called make_photos
> > and a connection to the post_save signal.
> > Here is my code:
>
> > 
> > The only problem i have with this code is that it runs every save. So
> > it creates a infinite loop of sorts and I dont know how to make it
> > perform this action once. Is there another signal I should use? Any
> > ideas?
>
> > Regards,
> > Devin M
>
> You may want to look at 
> this:http://snipt.net/danfreak/generate-thumbnails-in-django-with-pil/
>
> The snippet above overrides the save method.  Before calling the actual
> save (super), the thumbnail fields is dynamically created (using PIL).
> I am sure you can add code that will do the same thing for your "large"
> photo field.
>
> regards,
> Blue C

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



Re: Using a non-DB backend

2010-10-15 Thread Devin M
For more than one database it seems that you are able to do it
http://docs.djangoproject.com/en/dev/topics/db/multi-db/.
You could implement your device functions inside something like
myproject.device.functions if your not working with alot of data.
Or you can implement that in the database handler.

Regards,
Devin M
On Oct 15, 12:25 pm, Damir Dezeljin  wrote:
> Thanks.
>
> I read the docs you pointed med to and now I have few more questions:
> 1. Is it possible to use two or more different back-ends with a single
> Django project? For me it seems not.
>
> 2. After rethinking my needs I realized I need simple functions as e.g.
> FlushDevice(), GetServerUptime(), AssignUserToDevice(), etc. This doesn't
> really seem to be a lot of data so I'm wondering what do you suggest on how
> or where to implement the required interfaces?
>
> Sincerely,
>  Damir
>
> On Fri, Oct 15, 2010 at 15:35, Devin M  wrote:
> > Hello,
> > It looks like you want a custom database backend. On
> >http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#engine
> > they say
> > "You can use a database backend that doesn't ship with Django by
> > setting ENGINE to a fully-qualified path (i.e.
> > mypackage.backends.whatever). Writing a whole new database backend
> > from scratch is left as an exercise to the reader; see the other
> > backends for examples."
> > So i suppose you can look to the other backends for examples.
>
> > Regards,
> > Devin Morin
>
> > On Oct 15, 6:21 am, Damir Dezeljin  wrote:
> > > Hi.
>
> > > I'm working on an application tat communicates with embedded devices
> > > connected to the LAN. The devices are controlled by a central server
> > written
> > > in C++. Django is used for the front-end or better to say the GUI for the
> > > server.
>
> > > Part of the data the user needs access too are stored in the database,
> > hence
> > > the Django DB API to access this data; however, there are certain data
> > and
> > > actions that requires direct communication with the C++ server. The
> > > communication is implemented using CORBA (OmniORBpy). E.g. of a situation
> > > where the CORBA interface between the GUI and the server is needed is the
> > > flush of devices configuration or update of the following and this should
> > be
> > > real time and not implemented polling the DB.
>
> > > Currenly I'm instantiating the CORBA interface to my server in the
> > views.py.
> > > I'm wondering if there is a better way to do it as I just don't see how
> > > could I put the CORBA interface in the Model part of the GUI? << I'm
> > still
> > > confused by MVC approaches certain frameworks like CakePHP use. I think
> > > Django is not such a framework; however, I still think I should somehow
> > > separate the data layer from the business logic (bottomline: Django is
> > still
> > > kind of a MVC framework). How can I do this?
>
> > > Of course I would also like to solve the problem I'm currently facing:
> > > Let's suppose both the C++ server and Django web site are up and running.
> > If
> > > the C++ server is restarted the web page doesn't work any more until when
> > I
> > > restart the web server too. I instantiate the CORBA object in a global
> > > scope; however, I thought there is no persistence for the Django code
> > > between the web browser calls. Am I right? Why the connection to CORBA
> > > ceases working in such a case? << with e.g. C++ or Python stand-alone
> > > clients the connection is reestablished each time the script / program /
> > ...
> > > is executed.
>
> > > Thanks for any hint you may have,
> > >  Damir
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: F() and timedelta. Bug on django?

2010-10-15 Thread Marc Aymerich
On Fri, Oct 15, 2010 at 9:37 PM, Alec Shaner  wrote:

> doh! Just noticed that you already referenced ticket 10154 in your
> original post.



Well, I referenced the patch that I found searching with google, but
actually I didn't saw the ticket that it belongs to ;)

On the ticket there is another patch that handles "F() +- timedelta" for
Mysql, postgresql, sqlite and oracle :).
http://code.djangoproject.therecom/attachment/ticket/10154/10154.diff
It looks good, tomorrow I'll test it. I hope this patch will be merged to
trunk soon, then use of F() instances will have a greater sense than now :)

br


-- 
Marc

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



Re: F() and timedelta. Bug on django?

2010-10-15 Thread Alec Shaner
doh! Just noticed that you already referenced ticket 10154 in your
original post.

On Fri, Oct 15, 2010 at 3:16 PM, Alec Shaner  wrote:
> Interesting solution - after all that maybe it's more concise to just
> use the 'extra' filter instead since you're making it specific to
> mysql anyway, and you could use mysql date functions.
>
> By the way, in answer to your original question on this thread, there
> already is a ticket to add F() + timedelta.
>
> http://code.djangoproject.com/ticket/10154
>
> On Fri, Oct 15, 2010 at 2:48 PM, Marc Aymerich  wrote:
>>
>>
>> On Fri, Oct 15, 2010 at 7:54 PM, Alec Shaner  wrote:
>>>
>>> On Fri, Oct 15, 2010 at 1:26 PM, Marc Aymerich 
>>> wrote:
>>> >
>>> > Instead of use datatime.timedelta I convert it to string with this
>>> > format:
>>> >  MMDDHHMMSS and now all works fine with mysql :) Unfortunately this
>>> > part
>>> > of code doesn't be database independent :(
>>> >
>>> > Thank you very much alec!
>>> >
>>> > --
>>> > Marc
>>>
>>> No problem.
>>>
>>> So if you don't mind, what does your query filter look like now using
>>> the converted format?
>>>
>>
>> hi :)
>> this is the get_query_set method of my custom Manager:
>> def get_query_set(self):
>>     c=config.get('ignore_bill_period')
>>     #c is a dict like this {u'hours': u'00', u'seconds': u'00', u'minutes':
>> u'00', u'days': u'07'}
>>     ignore_period = c['days']+c['hours']+c['minutes']+c['seconds']
>>     delta_ignore_period = datetime.timedelta(days=int(c['days']),
>>         hours=int(c['hours']), minutes=int(c['minutes']),
>> seconds=int(c['seconds']))
>>     now_sub_ignore = datetime.datetime.now() - delta_ignore_period
>>     #IF db backend is MySQL:
>>     return super(pending_of_billManager,
>> self).get_query_set().filter(Q(cancel_date__isnull=False, \
>>         cancel_date__gt=F('register_date') + ignore_period) |
>> Q(cancel_date__isnull=True, \
>>         register_date__lt=now_sub_ignore))
>>     #ELSE:
>>     #return super(pending_of_billManager,
>> self).get_query_set().filter(Q(cancel_date__isnull=False, \
>>     #    cancel_date__gt=F('register_date') + delta_ignore_period) |
>> Q(cancel_date__isnull=True,
>>     #    register_date__lt=now_sub_ignore))
>> a lot of code for a simple query, but it's the best I can do :)
>> br
>> --
>> Marc
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>

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



Re: Using a non-DB backend

2010-10-15 Thread Damir Dezeljin
Thanks.

I read the docs you pointed med to and now I have few more questions:
1. Is it possible to use two or more different back-ends with a single
Django project? For me it seems not.

2. After rethinking my needs I realized I need simple functions as e.g.
FlushDevice(), GetServerUptime(), AssignUserToDevice(), etc. This doesn't
really seem to be a lot of data so I'm wondering what do you suggest on how
or where to implement the required interfaces?

Sincerely,
 Damir

On Fri, Oct 15, 2010 at 15:35, Devin M  wrote:

> Hello,
> It looks like you want a custom database backend. On
> http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#engine
> they say
> "You can use a database backend that doesn't ship with Django by
> setting ENGINE to a fully-qualified path (i.e.
> mypackage.backends.whatever). Writing a whole new database backend
> from scratch is left as an exercise to the reader; see the other
> backends for examples."
> So i suppose you can look to the other backends for examples.
>
> Regards,
> Devin Morin
>
> On Oct 15, 6:21 am, Damir Dezeljin  wrote:
> > Hi.
> >
> > I'm working on an application tat communicates with embedded devices
> > connected to the LAN. The devices are controlled by a central server
> written
> > in C++. Django is used for the front-end or better to say the GUI for the
> > server.
> >
> > Part of the data the user needs access too are stored in the database,
> hence
> > the Django DB API to access this data; however, there are certain data
> and
> > actions that requires direct communication with the C++ server. The
> > communication is implemented using CORBA (OmniORBpy). E.g. of a situation
> > where the CORBA interface between the GUI and the server is needed is the
> > flush of devices configuration or update of the following and this should
> be
> > real time and not implemented polling the DB.
> >
> > Currenly I'm instantiating the CORBA interface to my server in the
> views.py.
> > I'm wondering if there is a better way to do it as I just don't see how
> > could I put the CORBA interface in the Model part of the GUI? << I'm
> still
> > confused by MVC approaches certain frameworks like CakePHP use. I think
> > Django is not such a framework; however, I still think I should somehow
> > separate the data layer from the business logic (bottomline: Django is
> still
> > kind of a MVC framework). How can I do this?
> >
> > Of course I would also like to solve the problem I'm currently facing:
> > Let's suppose both the C++ server and Django web site are up and running.
> If
> > the C++ server is restarted the web page doesn't work any more until when
> I
> > restart the web server too. I instantiate the CORBA object in a global
> > scope; however, I thought there is no persistence for the Django code
> > between the web browser calls. Am I right? Why the connection to CORBA
> > ceases working in such a case? << with e.g. C++ or Python stand-alone
> > clients the connection is reestablished each time the script / program /
> ...
> > is executed.
> >
> > Thanks for any hint you may have,
> >  Damir
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: F() and timedelta. Bug on django?

2010-10-15 Thread Alec Shaner
Interesting solution - after all that maybe it's more concise to just
use the 'extra' filter instead since you're making it specific to
mysql anyway, and you could use mysql date functions.

By the way, in answer to your original question on this thread, there
already is a ticket to add F() + timedelta.

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

On Fri, Oct 15, 2010 at 2:48 PM, Marc Aymerich  wrote:
>
>
> On Fri, Oct 15, 2010 at 7:54 PM, Alec Shaner  wrote:
>>
>> On Fri, Oct 15, 2010 at 1:26 PM, Marc Aymerich 
>> wrote:
>> >
>> > Instead of use datatime.timedelta I convert it to string with this
>> > format:
>> >  MMDDHHMMSS and now all works fine with mysql :) Unfortunately this
>> > part
>> > of code doesn't be database independent :(
>> >
>> > Thank you very much alec!
>> >
>> > --
>> > Marc
>>
>> No problem.
>>
>> So if you don't mind, what does your query filter look like now using
>> the converted format?
>>
>
> hi :)
> this is the get_query_set method of my custom Manager:
> def get_query_set(self):
>     c=config.get('ignore_bill_period')
>     #c is a dict like this {u'hours': u'00', u'seconds': u'00', u'minutes':
> u'00', u'days': u'07'}
>     ignore_period = c['days']+c['hours']+c['minutes']+c['seconds']
>     delta_ignore_period = datetime.timedelta(days=int(c['days']),
>         hours=int(c['hours']), minutes=int(c['minutes']),
> seconds=int(c['seconds']))
>     now_sub_ignore = datetime.datetime.now() - delta_ignore_period
>     #IF db backend is MySQL:
>     return super(pending_of_billManager,
> self).get_query_set().filter(Q(cancel_date__isnull=False, \
>         cancel_date__gt=F('register_date') + ignore_period) |
> Q(cancel_date__isnull=True, \
>         register_date__lt=now_sub_ignore))
>     #ELSE:
>     #return super(pending_of_billManager,
> self).get_query_set().filter(Q(cancel_date__isnull=False, \
>     #    cancel_date__gt=F('register_date') + delta_ignore_period) |
> Q(cancel_date__isnull=True,
>     #    register_date__lt=now_sub_ignore))
> a lot of code for a simple query, but it's the best I can do :)
> br
> --
> Marc
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Legacy database with a table, which has no separate primary key

2010-10-15 Thread Alexander
Thank you for such a comprehensive answer.

I chose to add the field to the table. It seems to be the best
solution.

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



Re: F() and timedelta. Bug on django?

2010-10-15 Thread Marc Aymerich
On Fri, Oct 15, 2010 at 7:54 PM, Alec Shaner  wrote:

> On Fri, Oct 15, 2010 at 1:26 PM, Marc Aymerich 
> wrote:
> >
> > Instead of use datatime.timedelta I convert it to string with this
> format:
> >  MMDDHHMMSS and now all works fine with mysql :) Unfortunately this
> part
> > of code doesn't be database independent :(
> >
> > Thank you very much alec!
> >
> > --
> > Marc
>
> No problem.
>
> So if you don't mind, what does your query filter look like now using
> the converted format?
>
>
hi :)
this is the get_query_set method of my custom Manager:

def get_query_set(self):
c=config.get('ignore_bill_period')
#c is a dict like this {u'hours': u'00', u'seconds': u'00', u'minutes':
u'00', u'days': u'07'}

ignore_period = c['days']+c['hours']+c['minutes']+c['seconds']
delta_ignore_period = datetime.timedelta(days=int(c['days']),
hours=int(c['hours']), minutes=int(c['minutes']),
seconds=int(c['seconds']))
now_sub_ignore = datetime.datetime.now() - delta_ignore_period

#IF db backend is MySQL:
return super(pending_of_billManager,
self).get_query_set().filter(Q(cancel_date__isnull=False, \
cancel_date__gt=F('register_date') + ignore_period) |
Q(cancel_date__isnull=True, \
register_date__lt=now_sub_ignore))
#ELSE:
#return super(pending_of_billManager,
self).get_query_set().filter(Q(cancel_date__isnull=False, \
#cancel_date__gt=F('register_date') + delta_ignore_period) |
Q(cancel_date__isnull=True,
#register_date__lt=now_sub_ignore))

a lot of code for a simple query, but it's the best I can do :)

br
-- 
Marc

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



Re: F() and timedelta. Bug on django?

2010-10-15 Thread Alec Shaner
On Fri, Oct 15, 2010 at 1:26 PM, Marc Aymerich  wrote:
>
> Instead of use datatime.timedelta I convert it to string with this format:
>  MMDDHHMMSS and now all works fine with mysql :) Unfortunately this part
> of code doesn't be database independent :(
>
> Thank you very much alec!
>
> --
> Marc

No problem.

So if you don't mind, what does your query filter look like now using
the converted format?

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



Re: F() and timedelta. Bug on django?

2010-10-15 Thread Marc Aymerich
On Fri, Oct 15, 2010 at 5:02 PM, Alec Shaner  wrote:

> It should be clarified that this occurs on the mysql backend, but not
> the postgres backend. It has to do with how MySQL handles the DATETIME
> object. You can't add a timedelta, because it expects a double.
>
> I created a test app using a mysql backend and a Article model with
> created and updated datetime fields.
>
> created = 2010-10-15 09:13:02
> updated = 2010-10-15 09:18:43
>
> select created - updated from article_article
> +---+
> | updated - created |
> +---+
> |541.00 |
> +---+
>
> It's using the MMDDHHMMSS format of the datetime fields:
>
> 20101015091843 - 20101015091302 = 541
>
> The delta isn't constant either, here are two sets of times that are 5
> minutes apart:
>
> created=2010-10-15 09:00:00, updated=2010-10-15 09:05:00
> mysql: select created - updated yiels 500
>
> created=2010-10-15:09:59:00, updated=2010-10-15 10:04:00
> mysql: select created - updated yields 4500
>
> I haven't looked at the django mysql backend code, but based on this
> that warning is fatal in your case because it's definitely not doing
> what you want. And I don't see how you could write your query filter
> in its current format so that it is postgres/mysql agnostic



Instead of use datatime.timedelta I convert it to string with this format:
 MMDDHHMMSS and now all works fine with mysql :) Unfortunately this part
of code doesn't be database independent :(


Thank you very much alec!


-- 
Marc

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



Re: python highlighting in text input field

2010-10-15 Thread pixelcowboy
Yep, thats it man! That is great, thanks!

On Oct 14, 11:01 pm, Antoni Aloy  wrote:
> http://www.cdolivet.com/index.php?page=editArea=106bb5f73b60725d...
>
> This a javascript code editor. Perhaphs it would give you another 40%
>
> 2010/10/15 pixelcowboy :
>
>
>
>
>
> > Thanks, I guess this gets me halfway there! Still need to figure out
> > the highlighting for python.
>
> > On Oct 14, 12:34 pm, Antoni Aloy  wrote:
> >> Take a look at
>
> >>http://bitbucket.org/jezdez/django-dbtemplates/wiki/Home
>
> >> Hope it helps!
>
> >> 2010/10/14 pixelcowboy :
>
> >> > Is there any way to do this? I want the admin to be able to edit
> >> > python templates from the admin.
>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Django users" group.
> >> > To post to this group, send email to django-us...@googlegroups.com.
> >> > To unsubscribe from this group, send email to 
> >> > django-users+unsubscr...@googlegroups.com.
> >> > For more options, visit this group 
> >> > athttp://groups.google.com/group/django-users?hl=en.
>
> >> --
> >> 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Changing the Language does not work with Internet Explorer

2010-10-15 Thread Thomas Neumeier

Hi,

I've got a django site which uses the built in view to change the users 
language:

urls.py: (r'^i18n/', include('django.conf.urls.i18n')),
template:


{% csrf_token %}

{% for lang in LANGUAGES %}
{% ifequal lang.0 "de" %}
	src="{{STATIC_IMAGES_URL}}de.jpg" name="language" value="{{ lang.0 }}" />

{% else %}
src="{{STATIC_IMAGES_URL}}en.jpg" name="language" value="{{ lang.0 }}" />

{% endifequal %}
{% endfor %}



This works with Chrome, Firefox and Safari, but not with Internet 
Explorer (tested version 6, 8 and 9). Every time I hit the link, it just 
does not change the language.

It seems that IE does not set the cookie.
To check this, I tried to login in into the admin. This works, but there 
seems not to be set a cookie either (I cant find one in the folder).
How is the session_id set with setlang and admin and why does it work in 
the admin, but not in setlang?


Hoping for help
Thomas

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



Re: Legacy database with a table, which has no separate primary key

2010-10-15 Thread David De La Harpe Golden
On 15/10/10 12:15, Alexander wrote:

> As you can see the 'rating' table has no separate primary key field.

Yeah, that is pretty commonplace (though not presently supported by
django), the natural primary key for a table may be composite...

> Here are the models created by Django with some my corrections:
>

[remember to set 'managed = False' on models you don't want django to
automanage. And your model class names should really be singular]

> DatabaseError: column ratings.id does not exist
> LINE 1: SELECT "ratings"."id", "ratings"."userid",
> "ratings"."moviei...
> 
> Is there a way to tell Django, that 'Ratings' models does not have a
> separate primary key?

IFF you're only reading the data, not writing it, you can just flat out
lie to the django orm - make Rating unmanaged, tell it one of the
columns in Rating is the primary key (even if it's not really unique!),
and things may Happen To Work ...for reading.  But it _will_ break
horribly upon writing and is undoubtedly unsupported by the django
developers.

> Or my only option is to add the column to the
> 'ratings' table?
> 

That's a safer option if you can, and presently necessary if you want
writing to work via the django ORM for writing.  Though it may annoy
many a relational purist, possibly including your local DBA.

A generally more powerful but more complicated ORM for python exists -
sqlalchemy - and can cope with composite keys, but obviously you don't
then get integration with the rest of django (there is a
django-sqlalchemy project but it wasn't far along last time I looked at
it, which was quite some time ago mind 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Legacy database with a table, which has no separate primary key

2010-10-15 Thread Alexander
Thanks for your reply.

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



Re: Save Handlers and a newbie to Django

2010-10-15 Thread Blue Cuenca
 On 10/15/2010 9:01 PM, Devin M wrote:
> Hello everyone,
> I am writing a save handler in my models.py file to run a few
> actions after a save. to do this I have a function called make_photos
> and a connection to the post_save signal.
> Here is my code:
>
> 
> The only problem i have with this code is that it runs every save. So
> it creates a infinite loop of sorts and I dont know how to make it
> perform this action once. Is there another signal I should use? Any
> ideas?
>
> Regards,
> Devin M
>
You may want to look at this:
http://snipt.net/danfreak/generate-thumbnails-in-django-with-pil/

The snippet above overrides the save method.  Before calling the actual
save (super), the thumbnail fields is dynamically created (using PIL). 
I am sure you can add code that will do the same thing for your "large"
photo field.


regards,
Blue C

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



Re: fields in inner join

2010-10-15 Thread refreegrata
ok, thank for reply.

I think that with this query:

" AA.object.filter(...).select_related( field related in BB ) "

The impact in the performance is minimun

But with this query

" AA.object.filter(...).select_related() "

the impact is higher, because the first query do an unique "join", but
the second "join" can do multiple "join"s and I just need the AA
fields and the BB fields.

Is this idea correct?

On 15 oct, 12:27, Daniel Roseman  wrote:
> On Oct 15, 4:19 pm, refreegrata  wrote:
>
>
>
> > Hello, how can i get fields from different tables related for a
> > foreign key?
>
> > When I do a inner join like
>
> > AA.objects.filter(bb__field = ...) ...
>
> > I just can access to the AA fields, and not to fields in the other
> > table
>
> > in a normal query i can do something like "select AA.*, BB.* FROM. AA
> > inner join BB..."
> > but in django the resultant query is "select AA.* FROM. AA inner join
> > BB..."
>
> > Now i use select_related for solve this problem isn't recommended ,
> > because this query has an impact in the server performance. How i can
> > solve this?
>
> > Thanks for read, and sorry for my poor english.
>
> select_related *is* the answer to this question. Of cours all joins
> have an impact on server performance, because you're asking the
> database to do more work, but this is likely to be very very small,
> and there isn't a way of doing what you want without some form of
> join.
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



multi-database and south

2010-10-15 Thread Heigler
Hi,

I'm working on a project that uses 2 databases. I wrote a route for my
special database, that route should allow just some tables for syncdb,
and it works very well when i use ./manage.py syncdb --
database=my_other_db, however, i got some troubles with south, it
seems not respect my route, in other words, south creates all tables
of the default database, even when i use the "--database" arg at
migrate command.

In real world, my project is a browser game that have its own
database, the second database is just for a chat app and i don't want
to keep tables of my default db.

Someone know a way to fix that?

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



Re: F() and timedelta. Bug on django?

2010-10-15 Thread Marc Aymerich
On Fri, Oct 15, 2010 at 5:02 PM, Alec Shaner  wrote:

> It should be clarified that this occurs on the mysql backend, but not
> the postgres backend. It has to do with how MySQL handles the DATETIME
> object. You can't add a timedelta, because it expects a double.
>
> I created a test app using a mysql backend and a Article model with
> created and updated datetime fields.
>
> created = 2010-10-15 09:13:02
> updated = 2010-10-15 09:18:43
>
> select created - updated from article_article
> +---+
> | updated - created |
> +---+
> |541.00 |
> +---+
>
> It's using the MMDDHHMMSS format of the datetime fields:
>
> 20101015091843 - 20101015091302 = 541
>
> The delta isn't constant either, here are two sets of times that are 5
> minutes apart:
>
> created=2010-10-15 09:00:00, updated=2010-10-15 09:05:00
> mysql: select created - updated yiels 500
>
> created=2010-10-15:09:59:00, updated=2010-10-15 10:04:00
> mysql: select created - updated yields 4500
>
> I haven't looked at the django mysql backend code, but based on this
> that warning is fatal in your case because it's definitely not doing
> what you want. And I don't see how you could write your query filter
> in its current format so that it is postgres/mysql agnostic



Wow Alec! thanks for the hard work here!!

I inserted a print call in django code in order to see the exact query that
django executes to mysql db. This is the query:

SELECT `order_order`.`id`, `order_order`.`service_id`,
`order_order`.`entity_id`, `order_order`.`comment`, `order_order`.`size`,
`order_order`.`included`, `order_order`.`pack_id`, `order_order`.`price`,
`order_order`.`discount`, `order_order`.`renew`,
`order_order`.`register_date`, `order_order`.`cancel_date`,
`order_order`.`bill_id` FROM `order_order` WHERE
(`order_order`.`cancel_date` IS NOT NULL AND `order_order`.`cancel_date` <
 `order_order`.`register_date` + '3 0:0:0') LIMIT 21;

the problem is on the end of the query: `order_order`.`register_date` + '3
0:0:0'

If the field is a date, Django should use addtime() function instead of a
simple addition, otherwise it produces an unexpected result like you have
pointed on your mail:

> created=2010-10-15 09:00:00, updated=2010-10-15 09:05:00
> mysql: select created - updated yiels 500
>
> created=2010-10-15:09:59:00, updated=2010-10-15 10:04:00
> mysql: select created - updated yields 4500






-- 
Marc

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



Re: fields in inner join

2010-10-15 Thread Daniel Roseman
On Oct 15, 4:19 pm, refreegrata  wrote:
> Hello, how can i get fields from different tables related for a
> foreign key?
>
> When I do a inner join like
>
> AA.objects.filter(bb__field = ...) ...
>
> I just can access to the AA fields, and not to fields in the other
> table
>
> in a normal query i can do something like "select AA.*, BB.* FROM. AA
> inner join BB..."
> but in django the resultant query is "select AA.* FROM. AA inner join
> BB..."
>
> Now i use select_related for solve this problem isn't recommended ,
> because this query has an impact in the server performance. How i can
> solve this?
>
> Thanks for read, and sorry for my poor english.

select_related *is* the answer to this question. Of cours all joins
have an impact on server performance, because you're asking the
database to do more work, but this is likely to be very very small,
and there isn't a way of doing what you want without some form of
join.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Are AutoField primary keys re-used after deleting an object from the db?

2010-10-15 Thread Dirk
FYI: SQLite3 indeed re-uses primary keys if they are deleted from the
tail of the sequence. (So I'll have to use a UUID as a permanent id.)

Thanks for your support.
Dirk

On Oct 10, 5:57 am, Russell Keith-Magee 
wrote:
> On Sunday, October 10, 2010,Dirk wrote:
> > If I use
>
> > id = models.AutoField(primary_key=True)
>
> > can I be sure that if an object is removed from the db by calling
> > its .delete() method, the respective id will not be used for any
> > subsequent .save() on a new object?
>
> > My application relies on the fact that an object's id is unique over
> > all objects, even deleted ones.
>
> The behavior of AutoField key allocation is entirely dependent on the
> database you are using. You'll need to spend some quality time with
> the documentation for your chosen database to determine if an
> AutoField will do what you want.
>
> You may also want to investigate the use of UUIDs as a primary key.
> Django doesn't have a built in UUID Field, but there are some
> available as extension libraries.
>
> Yours,
> Russ Magee %-)

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



fields in inner join

2010-10-15 Thread refreegrata
Hello, how can i get fields from different tables related for a
foreign key?

When I do a inner join like

AA.objects.filter(bb__field = ...) ...

I just can access to the AA fields, and not to fields in the other
table

in a normal query i can do something like "select AA.*, BB.* FROM. AA
inner join BB..."
but in django the resultant query is "select AA.* FROM. AA inner join
BB..."

Now i use select_related for solve this problem isn't recommended ,
because this query has an impact in the server performance. How i can
solve this?

Thanks for read, and sorry for my poor english.

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



Re: Save Handlers and a newbie to Django

2010-10-15 Thread Devin M
Im just storing these files in standard ImageFields does the field
take care of that automagically?
And whats the best way to delete the files saved to tmp? should i do a
system call for rm?


On Oct 15, 7:41?am, Jonathan Barratt 
wrote:
> On 15 ?.?. 2010, at 21:35, Devin M wrote:
>
> > Ok its running in a infinite loop because im calling
> > self.*photo.save() and that starts this loop all over again. Maybe I
> > can add a field to the model like booleen resized and if its true dont
> > do any resizing but if its false then perform some resizing(aka run
> > the function)? also im going to have to delete these files when the
> > object is deleted too.
>
> You can also override the delete function to take care of deleting the files 
> when you're getting rid of the object...

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



Re: F() and timedelta. Bug on django?

2010-10-15 Thread Alec Shaner
It should be clarified that this occurs on the mysql backend, but not
the postgres backend. It has to do with how MySQL handles the DATETIME
object. You can't add a timedelta, because it expects a double.

I created a test app using a mysql backend and a Article model with
created and updated datetime fields.

created = 2010-10-15 09:13:02
updated = 2010-10-15 09:18:43

select created - updated from article_article
+---+
| updated - created |
+---+
|541.00 |
+---+

It's using the MMDDHHMMSS format of the datetime fields:

20101015091843 - 20101015091302 = 541

The delta isn't constant either, here are two sets of times that are 5
minutes apart:

created=2010-10-15 09:00:00, updated=2010-10-15 09:05:00
mysql: select created - updated yiels 500

created=2010-10-15:09:59:00, updated=2010-10-15 10:04:00
mysql: select created - updated yields 4500

I haven't looked at the django mysql backend code, but based on this
that warning is fatal in your case because it's definitely not doing
what you want. And I don't see how you could write your query filter
in its current format so that it is postgres/mysql agnostic


On Fri, Oct 15, 2010 at 7:01 AM, Marc Aymerich  wrote:
> This is a fork of this tread:
> http://groups.google.com/group/django-users/browse_thread/thread/5c6beb41fcf961a4
> I'm getting troubles combining instances of F() and timedelta. I'm working
> with the very last trunk revision (14232),
> I create a very simple model for troubleshoting the problem, the model is:
> class dates(models.Model):
>     date1 = models.DateField(auto_now_add=True)
>     date2 = models.DateField()
> And this is what I'm try to do:
 from test.dates.dates import dates
 from django.db.models import F
 import datetime

 dates.objects.filter(date1__gte=F('date2')+datetime.timedelta(minutes=3))
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
> 67, in __repr__
>     data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
> 82, in __len__
>     self._result_cache.extend(list(self._iter))
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
> 268, in iterator
>     for row in compiler.results_iter():
>   File "/usr/lib/python2.6/dist-packages/django/db/models/sql/compiler.py",
> line 675, in results_iter
>     for rows in self.execute_sql(MULTI):
>   File "/usr/lib/python2.6/dist-packages/django/db/models/sql/compiler.py",
> line 730, in execute_sql
>     cursor.execute(sql, params)
>   File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", line
> 18, in execute
>     return self.cursor.execute(sql, params)
>   File "/usr/lib/python2.6/dist-packages/django/db/backends/mysql/base.py",
> line 86, in execute
>     return self.cursor.execute(query, args)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 168, in
> execute
>     if not self._defer_warnings: self._warning_check()
>   File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 82, in
> _warning_check
>     warn(w[-1], self.Warning, 3)
> Warning: Truncated incorrect DOUBLE value: '0 0:3:0'
>
> On the parent
> thread http://groups.google.com/group/django-users/browse_thread/thread/5c6beb41fcf961a4 Alec
> reports that this works on their django installation.
> More over this pice of django code make use of
> it: http://code.djangoproject.com/attachment/ticket/10154/dateexpressions.diff
> Is this really a bug? it should be reported to django "bug tracker"?
> --
> Marc
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Save Handlers and a newbie to Django

2010-10-15 Thread Jonathan Barratt

On 15 ?.?. 2010, at 21:35, Devin M wrote:

> Ok its running in a infinite loop because im calling
> self.*photo.save() and that starts this loop all over again. Maybe I
> can add a field to the model like booleen resized and if its true dont
> do any resizing but if its false then perform some resizing(aka run
> the function)? also im going to have to delete these files when the
> object is deleted too.

You can also override the delete function to take care of deleting the files 
when you're getting rid of the object...


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



Re: Save Handlers and a newbie to Django

2010-10-15 Thread Jonathan Barratt
On 15 ?.?. 2010, at 20:01, Devin M wrote:

> Hello everyone,
>I am writing a save handler in my models.py file to run a few
> actions after a save. to do this I have a function called make_photos
> and a connection to the post_save signal.
> Here is my code:

> 
> The only problem i have with this code is that it runs every save. So
> it creates a infinite loop of sorts and I dont know how to make it
> perform this action once. Is there another signal I should use? Any
> ideas?

Admittedly I didn't check this idea against your code, but it just sprung to 
mind since the problem is the infinite loop: could you just define your own 
save method and do the necessary post-save work from there? My thought is that 
this would get out of the post_save signal-loop problem. See: 
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methods

Not sure that it'll let you do what you need, but you'll be able to tell 
whether that's the case or not quicker than I! :)

Good luck!
Jonathan

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



Re: Save Handlers and a newbie to Django

2010-10-15 Thread Devin M
Ok its running in a infinite loop because im calling
self.*photo.save() and that starts this loop all over again. Maybe I
can add a field to the model like booleen resized and if its true dont
do any resizing but if its false then perform some resizing(aka run
the function)? also im going to have to delete these files when the
object is deleted too.

On Oct 15, 6:01 am, Devin M  wrote:
> Hello everyone,
>     I am writing a save handler in my models.py file to run a few
> actions after a save. to do this I have a function called make_photos
> and a connection to the post_save signal.
> Here is my code:
> class Album(models.Model):
>     title = models.CharField(max_length=200)
>     date = models.DateField(blank=True, null=True)
>     desc = models.TextField(blank=True, null=True)
>     comments = models.BooleanField()
>     published = models.BooleanField(default=True)
>     tags = models.CharField(max_length=200, blank=True, null=True)
>     def __unicode__(self):
>         return u'%s' % (self.title)
>
> class Photo(models.Model):
>     title = models.CharField(max_length=200, default='Untitled Photo')
>     album = models.ForeignKey(Album, blank=True, null=True)
>     desc = models.TextField(blank=True, null=True)
>     date = models.DateField(blank=True, null=True)
>     comments = models.BooleanField()
>     published = models.BooleanField(default=True)
>     tags = models.CharField(max_length=200, blank=True, null=True)
>     thumb_photo = models.ImageField(upload_to='thumb_images',
> blank=True, null=True)
>     large_photo = models.ImageField(upload_to='large_images',
> blank=True, null=True)
>     original_photo = models.ImageField(upload_to='original_images',
> blank=True, null=True)
>     def makeimages(self):
>         (dirName, fileName) = os.path.split(self.original_photo.path)
>         (fileBaseName, fileExtension)=os.path.splitext(fileName)
>
>         #Save the thumbnail
>         thumb_width = 300
>         thumb_height = 300
>         thumb = Image.open(self.original_photo.path)
>         thumb.resize((thumb_width,thumb_height), Image.ANTIALIAS)
>         thumb_path = "/tmp/" + str(fileBaseName) + "_thumb.jpg"
>         thumb.save(thumb_path, "JPEG")
>         thumb_img_file = open(thumb_path, 'r')
>         thumb_file = File(thumb_img_file)
>         self.thumb_photo.save(str(fileBaseName) + '_thumb.jpg',
> thumb_file, save=True)
>         thumb_img_file.close()
>
>         #Save the large
>         large_width = 1024
>         large_height = 768
>         large = Image.open(self.original_photo.path)
>         large.resize((large_width,large_height), Image.ANTIALIAS)
>         large_path = "/tmp/" + str(fileBaseName) + "_large.jpg"
>         large.save(thumb_path, "JPEG")
>         large_img_file = open(thumb_path, 'r')
>         large_file = File(thumb_img_file)
>         self.thumb_photo.save(str(fileBaseName) + '_large.jpg',
> large_file, save=True)
>         large_img_file.close()
>
>         post_save.connect(makeimages)
>
> The only problem i have with this code is that it runs every save. So
> it creates a infinite loop of sorts and I dont know how to make it
> perform this action once. Is there another signal I should use? Any
> ideas?
>
> Regards,
> Devin M

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



Re: Pagination with bound form

2010-10-15 Thread Devin M
Wait looks like i made an error.
http://testsite.com/page/{%pk - 1%}>Previous Page
and you might not be able to use pk so see if you can use data.pk
let me know if it works.

Regards,
Devin M
On Oct 15, 6:56 am, Devin M  wrote:
> Oh you want just one record per page? Thats easy.
> urls.py
> (r'^page/(?P\d+)/$', 'data.views.pagelisting'),
>
> views.py
> def pagelisting(request, page_number):
>     data_list = Data.objects.filter(pk=page_number)
>     return render_to_response('list.html', {"data_list": data_list})
>
> template list.html
> {% if datalist %}
>     
>     {% for data in  datalist %}
>         {{ data.text }}
>     {% endfor %}
>     
> http://testsite.com/page/{%pk - 1%}>Next Page
> {% else %}
>     No data is available.
> {% endif %}
>
> On Oct 15, 6:43 am, David  wrote:
>
> > Hi Devin
>
> > Thank you for your reply.
>
> > I'm not sure if I've explained myself properly, or if I'm
> > misinterpreting your reply. What I am aiming for is a form containing
> > a single record. At the bottom of this form will be the pagination
> > tools << Prev 1 2 3 etc. which will enable the user to navigate
> > through the records individually in my form. I was hoping that the
> > pagination had the ability to know the current records primary key so
> > that I could render the form with a simple Data.objects.get(pk=1) this
> > would then achieve the desired effect (I think).

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



Re: Pagination with bound form

2010-10-15 Thread Devin M
Oh you want just one record per page? Thats easy.
urls.py
(r'^page/(?P\d+)/$', 'data.views.pagelisting'),

views.py
def pagelisting(request, page_number):
data_list = Data.objects.filter(pk=page_number)
return render_to_response('list.html', {"data_list": data_list})

template list.html
{% if datalist %}

{% for data in  datalist %}
{{ data.text }}
{% endfor %}

http://testsite.com/page/{%pk - 1%}>Next Page
{% else %}
No data is available.
{% endif %}

On Oct 15, 6:43 am, David  wrote:
> Hi Devin
>
> Thank you for your reply.
>
> I'm not sure if I've explained myself properly, or if I'm
> misinterpreting your reply. What I am aiming for is a form containing
> a single record. At the bottom of this form will be the pagination
> tools << Prev 1 2 3 etc. which will enable the user to navigate
> through the records individually in my form. I was hoping that the
> pagination had the ability to know the current records primary key so
> that I could render the form with a simple Data.objects.get(pk=1) this
> would then achieve the desired effect (I think).

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



Re: Pagination with bound form

2010-10-15 Thread David
Hi Devin

Thank you for your reply.

I'm not sure if I've explained myself properly, or if I'm
misinterpreting your reply. What I am aiming for is a form containing
a single record. At the bottom of this form will be the pagination
tools << Prev 1 2 3 etc. which will enable the user to navigate
through the records individually in my form. I was hoping that the
pagination had the ability to know the current records primary key so
that I could render the form with a simple Data.objects.get(pk=1) this
would then achieve the desired effect (I think).

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



Re: use django authentication for non-django pages

2010-10-15 Thread Devin M
You could use a template in django if your only serving some static
html. Otherwise if its php or something, make a template and restrict
it to admin and have the view render the php and spit it out to the
page context.

On Oct 15, 2:12 am, bowlby  wrote:
> We're hosting a small site on our own server. On the server we have
> some pages that are non-django (for example munin to see server
> statistics). Is there a way to use django's authentication mechanism
> to reserve access to these pages to users who have an account?
>
> Details:
> we have site say,www.test.comwhich is a django app. Then we 
> havewww.test.com/muninwhich serves static html-pages. These should only
> be accessible to django admin users. Normally we would use htpasswd
> but maybe there's a nicer solution.
>
> Thanks!

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



Re: Using a non-DB backend

2010-10-15 Thread Devin M
Hello,
It looks like you want a custom database backend. On
http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#engine
they say
"You can use a database backend that doesn't ship with Django by
setting ENGINE to a fully-qualified path (i.e.
mypackage.backends.whatever). Writing a whole new database backend
from scratch is left as an exercise to the reader; see the other
backends for examples."
So i suppose you can look to the other backends for examples.

Regards,
Devin Morin

On Oct 15, 6:21 am, Damir Dezeljin  wrote:
> Hi.
>
> I'm working on an application tat communicates with embedded devices
> connected to the LAN. The devices are controlled by a central server written
> in C++. Django is used for the front-end or better to say the GUI for the
> server.
>
> Part of the data the user needs access too are stored in the database, hence
> the Django DB API to access this data; however, there are certain data and
> actions that requires direct communication with the C++ server. The
> communication is implemented using CORBA (OmniORBpy). E.g. of a situation
> where the CORBA interface between the GUI and the server is needed is the
> flush of devices configuration or update of the following and this should be
> real time and not implemented polling the DB.
>
> Currenly I'm instantiating the CORBA interface to my server in the views.py.
> I'm wondering if there is a better way to do it as I just don't see how
> could I put the CORBA interface in the Model part of the GUI? << I'm still
> confused by MVC approaches certain frameworks like CakePHP use. I think
> Django is not such a framework; however, I still think I should somehow
> separate the data layer from the business logic (bottomline: Django is still
> kind of a MVC framework). How can I do this?
>
> Of course I would also like to solve the problem I'm currently facing:
> Let's suppose both the C++ server and Django web site are up and running. If
> the C++ server is restarted the web page doesn't work any more until when I
> restart the web server too. I instantiate the CORBA object in a global
> scope; however, I thought there is no persistence for the Django code
> between the web browser calls. Am I right? Why the connection to CORBA
> ceases working in such a case? << with e.g. C++ or Python stand-alone
> clients the connection is reestablished each time the script / program / ...
> is executed.
>
> Thanks for any hint you may have,
>  Damir

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



Re: Legacy database with a table, which has no separate primary key

2010-10-15 Thread Devin M
Wait... I just looked at your sql and it looks like you would need to
use multiple-column primary keys which are unsupported by django.
http://code.djangoproject.com/ticket/373

On Oct 15, 4:15 am, Alexander  wrote:
> I have a database, which among others has the following tables:
>
> CREATE TABLE users (
>   userId BIGINT PRIMARY KEY
> );
>
> CREATE TABLE movies (
>   movieId BIGINT PRIMARY KEY,
>   title varchar(255) NOT NULL
> );
>
> CREATE TABLE ratings (
>   userId BIGINT NOT NULL REFERENCES users(userId),
>   movieId BIGINT NOT NULL REFERENCES movies(movieId),
>   rating SMALLINT NOT NULL,
>   timestamp varchar(150) NOT NULL,
>   CONSTRAINT unique_userid_movieid UNIQUE(userId, movieId)
> );
>
> As you can see the 'rating' table has no separate primary key field.
>
> Here are the models created by Django with some my corrections:
>
> class Users(models.Model):
>     userid = models.BigIntegerField(primary_key=True)
>
>     def __unicode__(self):
>         return u"User %d" % self.userid
>
>     class Meta:
>         db_table = u'users'
>
> class Movies(models.Model):
>     movieid = models.BigIntegerField(primary_key=True)
>     title = models.CharField(max_length=255)
>     users = models.ManyToManyField(Users, through='Ratings',
> related_name="rated_movies")
>
>     def __unicode__(self):
>         return self.title
>
>     class Meta:
>         db_table = u'movies'
>
> class Ratings(models.Model):
>     user = models.ForeignKey(Users, db_column='userid')
>     movie = models.ForeignKey(Movies, db_column='movieid')
>     rating = models.SmallIntegerField()
>     timestamp = models.BigIntegerField()
>
>     def __unicode__(self):
>         return u"%d" % self.rating
>
>     class Meta:
>         db_table = u'ratings'
>         unique_together = (("user", "movie"),)
>
> So having these models i can do this:
>
> In [1]: from django_orm.movielens.models import *
> In [2]: u = Users.objects.get(pk=1)
> In [3]: u.rated_movies.all()
> Out[3]: [,..]
>
> or this:
>
> In [4]: m = Movies.objects.get(pk=1)
> In [5]: m.users.all().count()
> Out[5]: 2264
>
> But i can't get the "ratings" objects because trying this:
>
> Ratings.objects.filter(user=1)
>
> or this:
>
> u.ratings_set.all()
>
> causes the following error
>
> DatabaseError: column ratings.id does not exist
> LINE 1: SELECT "ratings"."id", "ratings"."userid",
> "ratings"."moviei...
>
> Is there a way to tell Django, that 'Ratings' models does not have a
> separate primary key? Or my only option is to add the column to the
> 'ratings' table?

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



Re: Help with Manager.

2010-10-15 Thread Alec Shaner
Sorry, not sure about that warning because I'm using a postgresql database.

On Fri, Oct 15, 2010 at 3:17 AM, Marc Aymerich  wrote:
>
>
> On Fri, Oct 15, 2010 at 3:39 AM, Alec Shaner  wrote:
>>
>> You can't add a datetime to another datetime - you want to add a
>> datetime.timedelta instance instead. Out of curiosity I just tested it
>> on one of my models and it does work, e.g.,
>>
>> MyModel.objects.filter(update_date__gt=F('entry_date')+timedelta(days=5))
>
>
> Hi Alec, thanks again for your answer :)
> When you executes this filter on a shell you don't get a warning ?
> This is what happens to me:

 order.objects.filter(cancel_date__isnull=False).filter(cancel_date__lt=F('register_date')
 + timedelta(days=3))
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
> 67, in __repr__
>     data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
> 82, in __len__
>     self._result_cache.extend(list(self._iter))
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
> 268, in iterator
>     for row in compiler.results_iter():
>   File "/usr/lib/python2.6/dist-packages/django/db/models/sql/compiler.py",
> line 672, in results_iter
>     for rows in self.execute_sql(MULTI):
>   File "/usr/lib/python2.6/dist-packages/django/db/models/sql/compiler.py",
> line 727, in execute_sql
>     cursor.execute(sql, params)
>   File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", line
> 18, in execute
>     return self.cursor.execute(sql, params)
>   File "/usr/lib/python2.6/dist-packages/django/db/backends/mysql/base.py",
> line 86, in execute
>     return self.cursor.execute(query, args)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 168, in
> execute
>     if not self._defer_warnings: self._warning_check()
>   File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 82, in
> _warning_check
>     warn(w[-1], self.Warning, 3)
> Warning: Truncated incorrect DOUBLE value: '3 0:0:0'
> It's only a warning, but I can't see the output queryset result, maybe it's
> a ""fatal"" warning? you know why this is happening?
> Thanks again!!
>
> --
> Marc
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Legacy database with a table, which has no separate primary key

2010-10-15 Thread Devin M
I did some quck googling and found this.
http://stackoverflow.com/questions/605896/django-querying-read-only-view-with-no-primary-key

This is the response from them that seems most helpful.

"all you need is a column that is guaranteed to be unique for every
row. Set that to be 'primary_key = True in your model and Django will
be happy."

Regards,
Devin Morin

On Oct 15, 4:15 am, Alexander  wrote:
> I have a database, which among others has the following tables:
>
> CREATE TABLE users (
>   userId BIGINT PRIMARY KEY
> );
>
> CREATE TABLE movies (
>   movieId BIGINT PRIMARY KEY,
>   title varchar(255) NOT NULL
> );
>
> CREATE TABLE ratings (
>   userId BIGINT NOT NULL REFERENCES users(userId),
>   movieId BIGINT NOT NULL REFERENCES movies(movieId),
>   rating SMALLINT NOT NULL,
>   timestamp varchar(150) NOT NULL,
>   CONSTRAINT unique_userid_movieid UNIQUE(userId, movieId)
> );
>
> As you can see the 'rating' table has no separate primary key field.
>
> Here are the models created by Django with some my corrections:
>
> class Users(models.Model):
>     userid = models.BigIntegerField(primary_key=True)
>
>     def __unicode__(self):
>         return u"User %d" % self.userid
>
>     class Meta:
>         db_table = u'users'
>
> class Movies(models.Model):
>     movieid = models.BigIntegerField(primary_key=True)
>     title = models.CharField(max_length=255)
>     users = models.ManyToManyField(Users, through='Ratings',
> related_name="rated_movies")
>
>     def __unicode__(self):
>         return self.title
>
>     class Meta:
>         db_table = u'movies'
>
> class Ratings(models.Model):
>     user = models.ForeignKey(Users, db_column='userid')
>     movie = models.ForeignKey(Movies, db_column='movieid')
>     rating = models.SmallIntegerField()
>     timestamp = models.BigIntegerField()
>
>     def __unicode__(self):
>         return u"%d" % self.rating
>
>     class Meta:
>         db_table = u'ratings'
>         unique_together = (("user", "movie"),)
>
> So having these models i can do this:
>
> In [1]: from django_orm.movielens.models import *
> In [2]: u = Users.objects.get(pk=1)
> In [3]: u.rated_movies.all()
> Out[3]: [,..]
>
> or this:
>
> In [4]: m = Movies.objects.get(pk=1)
> In [5]: m.users.all().count()
> Out[5]: 2264
>
> But i can't get the "ratings" objects because trying this:
>
> Ratings.objects.filter(user=1)
>
> or this:
>
> u.ratings_set.all()
>
> causes the following error
>
> DatabaseError: column ratings.id does not exist
> LINE 1: SELECT "ratings"."id", "ratings"."userid",
> "ratings"."moviei...
>
> Is there a way to tell Django, that 'Ratings' models does not have a
> separate primary key? Or my only option is to add the column to the
> 'ratings' table?

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



Using a non-DB backend

2010-10-15 Thread Damir Dezeljin
Hi.

I'm working on an application tat communicates with embedded devices
connected to the LAN. The devices are controlled by a central server written
in C++. Django is used for the front-end or better to say the GUI for the
server.

Part of the data the user needs access too are stored in the database, hence
the Django DB API to access this data; however, there are certain data and
actions that requires direct communication with the C++ server. The
communication is implemented using CORBA (OmniORBpy). E.g. of a situation
where the CORBA interface between the GUI and the server is needed is the
flush of devices configuration or update of the following and this should be
real time and not implemented polling the DB.

Currenly I'm instantiating the CORBA interface to my server in the views.py.
I'm wondering if there is a better way to do it as I just don't see how
could I put the CORBA interface in the Model part of the GUI? << I'm still
confused by MVC approaches certain frameworks like CakePHP use. I think
Django is not such a framework; however, I still think I should somehow
separate the data layer from the business logic (bottomline: Django is still
kind of a MVC framework). How can I do this?

Of course I would also like to solve the problem I'm currently facing:
Let's suppose both the C++ server and Django web site are up and running. If
the C++ server is restarted the web page doesn't work any more until when I
restart the web server too. I instantiate the CORBA object in a global
scope; however, I thought there is no persistence for the Django code
between the web browser calls. Am I right? Why the connection to CORBA
ceases working in such a case? << with e.g. C++ or Python stand-alone
clients the connection is reestablished each time the script / program / ...
is executed.

Thanks for any hint you may have,
 Damir

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



Re: Pagination with bound form

2010-10-15 Thread Devin M
So you have a page number thats getting passed from a url, right? and
then you want to display records based on that page number? you could
do something like this:
urls.py
(r'^page/(?P\d+)/$', 'data.views.pagelisting'),

views.py
def pagelisting(request, page_number):
records = range(page_number + 10)
data_list = Data.objects.filter(pk=records)
return render_to_response('list.html', {"formset": formset})

template list.html
{% if formset %}

{% for data in formset %}
{{ data.text }}
{% endfor %}

{% else %}
No data is available.
{% endif %}

Might not be 100 percent on the code but i hope it helps.

Regards,
Devin Morin


I think this would work because you can see them using an array in
http://docs.djangoproject.com/en/dev/topics/db/queries/#the-pk-lookup-shortcut

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



Save Handlers and a newbie to Django

2010-10-15 Thread Devin M
Hello everyone,
I am writing a save handler in my models.py file to run a few
actions after a save. to do this I have a function called make_photos
and a connection to the post_save signal.
Here is my code:
class Album(models.Model):
title = models.CharField(max_length=200)
date = models.DateField(blank=True, null=True)
desc = models.TextField(blank=True, null=True)
comments = models.BooleanField()
published = models.BooleanField(default=True)
tags = models.CharField(max_length=200, blank=True, null=True)
def __unicode__(self):
return u'%s' % (self.title)

class Photo(models.Model):
title = models.CharField(max_length=200, default='Untitled Photo')
album = models.ForeignKey(Album, blank=True, null=True)
desc = models.TextField(blank=True, null=True)
date = models.DateField(blank=True, null=True)
comments = models.BooleanField()
published = models.BooleanField(default=True)
tags = models.CharField(max_length=200, blank=True, null=True)
thumb_photo = models.ImageField(upload_to='thumb_images',
blank=True, null=True)
large_photo = models.ImageField(upload_to='large_images',
blank=True, null=True)
original_photo = models.ImageField(upload_to='original_images',
blank=True, null=True)
def makeimages(self):
(dirName, fileName) = os.path.split(self.original_photo.path)
(fileBaseName, fileExtension)=os.path.splitext(fileName)

#Save the thumbnail
thumb_width = 300
thumb_height = 300
thumb = Image.open(self.original_photo.path)
thumb.resize((thumb_width,thumb_height), Image.ANTIALIAS)
thumb_path = "/tmp/" + str(fileBaseName) + "_thumb.jpg"
thumb.save(thumb_path, "JPEG")
thumb_img_file = open(thumb_path, 'r')
thumb_file = File(thumb_img_file)
self.thumb_photo.save(str(fileBaseName) + '_thumb.jpg',
thumb_file, save=True)
thumb_img_file.close()

#Save the large
large_width = 1024
large_height = 768
large = Image.open(self.original_photo.path)
large.resize((large_width,large_height), Image.ANTIALIAS)
large_path = "/tmp/" + str(fileBaseName) + "_large.jpg"
large.save(thumb_path, "JPEG")
large_img_file = open(thumb_path, 'r')
large_file = File(thumb_img_file)
self.thumb_photo.save(str(fileBaseName) + '_large.jpg',
large_file, save=True)
large_img_file.close()

post_save.connect(makeimages)

The only problem i have with this code is that it runs every save. So
it creates a infinite loop of sorts and I dont know how to make it
perform this action once. Is there another signal I should use? Any
ideas?

Regards,
Devin M

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



Pagination with bound form

2010-10-15 Thread David
Hello

I need to be able to create a form that contains data from my
database. It also needs to have basic pagination at the bottom of the
form as there will be many records, and I would like my users to be
able to use pagination to access them (kind of like MS Access).

I can produce the form ok, and I can also do the pagination. But I
cannot do them both together ^^

Is there a way of passing the current member PK from pagination to the
form instance so that it know's what record to bind to ?

Thank you


def listing(request):
member = Member.objects.get(pk=1)
#paginator = Paginator(staff_list, 1)
#
#try:
#page = int(request.GET.get('page', '1'))
#except ValueError:
#page = 1
#
#try:
#members = paginator.page(page)
#except (EmptyPage, InvalidPage):
#members = paginator.page(paginator.num_pages)

formset = MemberForm(instance=member)
return render_to_response('list.html', {"formset": formset})

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



Re: Hosting many small Django websites

2010-10-15 Thread Venkatraman S
On Fri, Oct 15, 2010 at 5:26 PM, Brian Bouterse  wrote:

> One of the challenges of going the GAE route is that you need to modify
> your application slightly to work with their version of models.  Also, you
> can't ever run this code off of GAE, so it's kind of a lock-in in that
> respect.  That being said it does work very well.
>

For small websites I dont think its much of a problem. Especially, given
that the admin overhead is almost null.
On the code aspect, its not much of a problem too - just the syntax changes,
the semantics remain the same.

-V

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



Re: Hosting many small Django websites

2010-10-15 Thread Brian Bouterse
One of the challenges of going the GAE route is that you need to modify your
application slightly to work with their version of models.  Also, you can't
ever run this code off of GAE, so it's kind of a lock-in in that respect.
 That being said it does work very well.

Brian

On Thu, Oct 14, 2010 at 11:09 PM, Venkatraman S  wrote:

>
> On Fri, Oct 15, 2010 at 2:15 AM, Diederik van der Boor 
> wrote:
>
>>
>> I'm curious about using Django for many small web sites. Does this
>> require each site to run in a separate wsgi daemon process? If so, how
>> is it possible to keep memory usage shared?
>>
>
> Not exactly sure when you have to manage the linux box, but if you have to
> manage many small sites, i would recommend GAE.
> Best for deploying and managing(non sysad work) them without any hassles.
>
> -V-
> http://twitter.com/venkasub
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Brian Bouterse
ITng Services

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



Legacy database with a table, which has no separate primary key

2010-10-15 Thread Alexander
I have a database, which among others has the following tables:

CREATE TABLE users (
  userId BIGINT PRIMARY KEY
);

CREATE TABLE movies (
  movieId BIGINT PRIMARY KEY,
  title varchar(255) NOT NULL
);

CREATE TABLE ratings (
  userId BIGINT NOT NULL REFERENCES users(userId),
  movieId BIGINT NOT NULL REFERENCES movies(movieId),
  rating SMALLINT NOT NULL,
  timestamp varchar(150) NOT NULL,
  CONSTRAINT unique_userid_movieid UNIQUE(userId, movieId)
);

As you can see the 'rating' table has no separate primary key field.

Here are the models created by Django with some my corrections:

class Users(models.Model):
userid = models.BigIntegerField(primary_key=True)

def __unicode__(self):
return u"User %d" % self.userid

class Meta:
db_table = u'users'

class Movies(models.Model):
movieid = models.BigIntegerField(primary_key=True)
title = models.CharField(max_length=255)
users = models.ManyToManyField(Users, through='Ratings',
related_name="rated_movies")

def __unicode__(self):
return self.title

class Meta:
db_table = u'movies'

class Ratings(models.Model):
user = models.ForeignKey(Users, db_column='userid')
movie = models.ForeignKey(Movies, db_column='movieid')
rating = models.SmallIntegerField()
timestamp = models.BigIntegerField()

def __unicode__(self):
return u"%d" % self.rating

class Meta:
db_table = u'ratings'
unique_together = (("user", "movie"),)




So having these models i can do this:

In [1]: from django_orm.movielens.models import *
In [2]: u = Users.objects.get(pk=1)
In [3]: u.rated_movies.all()
Out[3]: [,..]

or this:

In [4]: m = Movies.objects.get(pk=1)
In [5]: m.users.all().count()
Out[5]: 2264

But i can't get the "ratings" objects because trying this:

Ratings.objects.filter(user=1)

or this:

u.ratings_set.all()

causes the following error

DatabaseError: column ratings.id does not exist
LINE 1: SELECT "ratings"."id", "ratings"."userid",
"ratings"."moviei...

Is there a way to tell Django, that 'Ratings' models does not have a
separate primary key? Or my only option is to add the column to the
'ratings' table?

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



F() and timedelta. Bug on django?

2010-10-15 Thread Marc Aymerich
This is a fork of this tread:
http://groups.google.com/group/django-users/browse_thread/thread/5c6beb41fcf961a4

I'm getting troubles combining instances of F() and timedelta. I'm working
with the very last trunk revision (14232),

I create a very simple model for troubleshoting the problem, the model is:

class dates(models.Model):
date1 = models.DateField(auto_now_add=True)
date2 = models.DateField()

And this is what I'm try to do:

>>> from test.dates.dates import dates
>>> from django.db.models import F
>>> import datetime
>>>
dates.objects.filter(date1__gte=F('date2')+datetime.timedelta(minutes=3))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
67, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
82, in __len__
self._result_cache.extend(list(self._iter))
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
268, in iterator
for row in compiler.results_iter():
  File "/usr/lib/python2.6/dist-packages/django/db/models/sql/compiler.py",
line 675, in results_iter
for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.6/dist-packages/django/db/models/sql/compiler.py",
line 730, in execute_sql
cursor.execute(sql, params)
  File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", line
18, in execute
return self.cursor.execute(sql, params)
  File "/usr/lib/python2.6/dist-packages/django/db/backends/mysql/base.py",
line 86, in execute
return self.cursor.execute(query, args)
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 168, in
execute
if not self._defer_warnings: self._warning_check()
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 82, in
_warning_check
warn(w[-1], self.Warning, 3)
Warning: Truncated incorrect DOUBLE value: '0 0:3:0'


On the parent thread
http://groups.google.com/group/django-users/browse_thread/thread/5c6beb41fcf961a4
Alec
reports that this works on their django installation.

More over this pice of django code make use of it:
http://code.djangoproject.com/attachment/ticket/10154/dateexpressions.diff

Is this really a bug? it should be reported to django "bug tracker"?

-- 
Marc

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



Re: I18n in Django model

2010-10-15 Thread Kenneth Gonsalves
On Thu, 2010-10-14 at 23:03 -0700, BlackMoses wrote:
> First table contains universal field which doesn't depends on
> language. Second contains fields that suposed to be in many languages,
> 'culture' field which store language code ('en', 'de' etc). Both
> tables are related with foreign keys of course. Then it is really easy
> to get some data for proper language (Symfony gives special mechanisms
> to get and set this data).
> My question is if there are any Django standards/tools that i should
> use for it? Or I have to take care with it on my own. 

try django-transmeta
-- 
regards
Kenneth Gonsalves

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



use django authentication for non-django pages

2010-10-15 Thread bowlby
We're hosting a small site on our own server. On the server we have
some pages that are non-django (for example munin to see server
statistics). Is there a way to use django's authentication mechanism
to reserve access to these pages to users who have an account?

Details:
we have site say, www.test.com which is a django app. Then we have
www.test.com/munin which serves static html-pages. These should only
be accessible to django admin users. Normally we would use htpasswd
but maybe there's a nicer solution.

Thanks!

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



Re: I18n in Django model

2010-10-15 Thread Jonathan Barratt
On 15 ?.?. 2010, at 13:03, BlackMoses wrote:

> have question if Django have support for I18n models.

> 

> My question is if there are any Django standards/tools that i should
> use for it? Or I have to take care with it on my own.

Yes there are standard tools, please see: 
http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/

Good luck,
Jonathan

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



Re: MySQL locking problem

2010-10-15 Thread Tom Evans
SHOW FULL PROCESSLIST;
EXPLAIN ;

On Thu, Oct 14, 2010 at 6:02 PM, Nick Arnett  wrote:
> I am having a problem with locking on MySQL and can't quite figure out
> what's causing it.  Although I have some scripts that do raw SQL, none of
> them are running, I see no other transactions in the process list, yet when
> I call save() on one of my objects, the transaction locks, seemingly
> forever.  Although most of my database tables are InnoDB, the one that I'm
> seeing this happen on is MyISAM (because I'm using full-text indexing on
> it).  So the table is getting locked somehow, but I sure can't see how, when
> there is nothing else in the processlist.
> mysql> show processlist;
> +-+-+-+---+-+--++--+
> | Id      | User          | Host            | db            | Command | Time
> | State  | Info
>                                     |
> +-+-+-+---+-+--++--+
> | 2755442 | narnett | localhost       | narnett_clar2 | Query   |    0 |
> NULL   | show processlist
>                                   |
> | 2764186 | narnett | localhost:54940 | narnett_clar2 | Query   |  547 |
> Locked | UPDATE `fm_posting` SET `author_id` = 5860, `posted` = '2009-09-28
> 00:00:00', `body` = 'This is the  |
> +-+-+-+---+-+--++--+
> Anybody have suggestions for tracking this down?
> Nick
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



I18n in Django model

2010-10-15 Thread BlackMoses
have question if Django have support for I18n models. For example in
Symfony when i create 'news' table there are 2 tables in fact :

news
  id
  date

news_i18n
  id
  culture
  title
  text

First table contains universal field which doesn't depends on
language. Second contains fields that suposed to be in many languages,
'culture' field which store language code ('en', 'de' etc). Both
tables are related with foreign keys of course. Then it is really easy
to get some data for proper language (Symfony gives special mechanisms
to get and set this data).
My question is if there are any Django standards/tools that i should
use for it? Or I have to take care with it on my own.

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



Re: Help with Manager.

2010-10-15 Thread Marc Aymerich
On Fri, Oct 15, 2010 at 3:39 AM, Alec Shaner  wrote:

> You can't add a datetime to another datetime - you want to add a
> datetime.timedelta instance instead. Out of curiosity I just tested it
> on one of my models and it does work, e.g.,
>
> MyModel.objects.filter(update_date__gt=F('entry_date')+timedelta(days=5))




Hi Alec, thanks again for your answer :)

When you executes this filter on a shell you don't get a warning ?

This is what happens to me:

>>>
order.objects.filter(cancel_date__isnull=False).filter(cancel_date__lt=F('register_date')
+ timedelta(days=3))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
67, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
82, in __len__
self._result_cache.extend(list(self._iter))
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line
268, in iterator
for row in compiler.results_iter():
  File "/usr/lib/python2.6/dist-packages/django/db/models/sql/compiler.py",
line 672, in results_iter
for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.6/dist-packages/django/db/models/sql/compiler.py",
line 727, in execute_sql
cursor.execute(sql, params)
  File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", line
18, in execute
return self.cursor.execute(sql, params)
  File "/usr/lib/python2.6/dist-packages/django/db/backends/mysql/base.py",
line 86, in execute
return self.cursor.execute(query, args)
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 168, in
execute
if not self._defer_warnings: self._warning_check()
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 82, in
_warning_check
warn(w[-1], self.Warning, 3)
Warning: Truncated incorrect DOUBLE value: '3 0:0:0'

It's only a warning, but I can't see the output queryset result, maybe it's
a ""fatal"" warning? you know why this is happening?

Thanks again!!

-- 
Marc

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



Re: python highlighting in text input field

2010-10-15 Thread Antoni Aloy
http://www.cdolivet.com/index.php?page=editArea=106bb5f73b60725d9a1657c4b0e42ca4

This a javascript code editor. Perhaphs it would give you another 40%

2010/10/15 pixelcowboy :
> Thanks, I guess this gets me halfway there! Still need to figure out
> the highlighting for python.
>
> On Oct 14, 12:34 pm, Antoni Aloy  wrote:
>> Take a look at
>>
>> http://bitbucket.org/jezdez/django-dbtemplates/wiki/Home
>>
>> Hope it helps!
>>
>> 2010/10/14 pixelcowboy :
>>
>> > Is there any way to do this? I want the admin to be able to edit
>> > python templates from the admin.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



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