Tuesday, November 30, 2010

Re: Weird problem after schema change

Nope, haven't defined anything interesting for admin. The field name
matches, as far as I know.

Frankly, though, given the length of time it takes for the server to
reply (owing to the huge number of entries for the m2m field), I guess
this really isn't worth fixing if it's more involved than a simple
check. Ah well.

Thanks,
Chris

On Nov 25, 7:07 pm, Venkatraman S <venka...@gmail.com> wrote:
> On Fri, Nov 26, 2010 at 6:30 AM, Chris Tandiono <chris.tandi...@gmail.com>wrote:
>
> > How can I get the date field to show up in the admin interface?
>
> Couple of checks:
> - have you defined any custom forms for admin?
> - Do the field names match properly?
>
> A good practice generally is : do a 'sqlall' before you make the change in
> your models.py and then again do the same after mod'ing your models.py file.
> Do a diff between the two output sqlall files.
>
> $python manage.py sqlall > before.txt
> $vim ...models.py
> $python manage.py sqlall > after.txt
>
> -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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Where's the form value set for comments framework/app

I looked into the code again and think I've found where the values
come from.

class CommentFormNode(BaseCommentNode):
"""Insert a form for the comment model into the context."""
...
return comments.get_form()
(ctype.get_object_for_this_type(pk=object_pk))

The comments.get_form() will return a CommentForm, which is a child
class of CommentSecurityForm from django.contrib.comments.form

class CommentSecurityForm(forms.Form):
...
def generate_security_data(self):
...
security_dict = {
'content_type' : str(self.target_object._meta),
'object_pk' : str(self.target_object._get_pk_val()),
'timestamp' : str(timestamp),
'security_hash' : self.initial_security_hash(timestamp),
}

So the content_type value is from target_object._meta

On Nov 30, 4:31 pm, photon <photo...@gmail.com> wrote:
> Mostly I followed the instruction ofhttp://docs.djangoproject.com/en/dev/ref/contrib/comments/

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

Re: Adding extra data in annotate()

For reference, it looks like D.Rosman has already wrote about the same
topic at http://blog.roseman.org.uk/.

Franco

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

Re: php script in django app

Oh ok. Thanks for the quick response. I guess I'll have to rewrite the
script in Python.

On Dec 1, 9:04 am, Javier Guerra Giraldez <jav...@guerrag.com> wrote:
> On Tue, Nov 30, 2010 at 10:51 PM, vamsy krishna <badguitar...@gmail.com> wrote:
> > I am trying to embed an Ajax call to load some RSS feeds using a PHP
> > script in my Django app. This does not work and it returns my actual
> > PHP code which is not getting executed. This works when I try the same
> > outside of Django in Apache.
>
> i guess that it doesn't work when using Django's dev server.
>
> - to execute PHP, you need a PHP interpreter
>
> - Django's devserver is a simple Python HTTP server that translates
> every request into WSGI calls to Django.
>
> so.... should it work?  no way
>
> --
> Javier

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

Front-End Web Development Position(s)

Hello all,

We at CaspianSolutions, have couple of full-time Front-End Web
Development positions with a start-up company here in Palo Alto.

Job Description:

• 4+ years of experience in an Engineering position.
• Experience in Django/Python highly desired.
• Deep knowledge of web: AJAX/JSON/Javascript/CSS 3/XHTML/HTML5/ Web
2.0 is highly desirable and required.
• Ideally would be well versed in both Django/Python and Front-end
engineering and capable of building easy-to-use, fast, flexible, front
end interface.
• BS in Computer Science or similar with high GPA.
• Must enjoy both working independently and enjoy working within a
close team setting.
• Have passion for social networks and comfortable working in a start-
up fast growing environment.
• The candidate will be amongst the first few members of the team. You
should have the commitment and passion for what you do.
• Salary: $90k-$130k for qualified candidates plus full benefits and
many other perks.

If this position sounds interesting to you, please feel free to send
your latest resume to
djangojobs@caspiansolutions.com or call us directly at 408-963-5134.

Thank you,

Caspian Solutions Inc.
Sunnyvale, CA
http://www.caspiansolutions.com


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

Re: php script in django app

On Tue, Nov 30, 2010 at 10:51 PM, vamsy krishna <badguitarist@gmail.com> wrote:
> I am trying to embed an Ajax call to load some RSS feeds using a PHP
> script in my Django app. This does not work and it returns my actual
> PHP code which is not getting executed. This works when I try the same
> outside of Django in Apache.

i guess that it doesn't work when using Django's dev server.

- to execute PHP, you need a PHP interpreter

- Django's devserver is a simple Python HTTP server that translates
every request into WSGI calls to Django.


so.... should it work? no way

--
Javier

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

php script in django app

Hi,

I am trying to embed an Ajax call to load some RSS feeds using a PHP
script in my Django app. This does not work and it returns my actual
PHP code which is not getting executed. This works when I try the same
outside of Django in Apache.

Can someone help me to get it working? Is it ok to use a PHP script in
a Django app? Or am I trying to stick a Ferrari in a box of Apples?

Thanks in advance.

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

Django 1.2.3, Oracle with Character Set WE8MSWIN1252 - 'utf8' codec can't decode bytes

Hi All,
 
On Oracle 10.2 with Character-Set set to WE8MSWIN1252,
 
When using Django, I try to select a Oracle row which contains a field with value as 'Páginas', i encounter the following error "'utf8' codec can't decode bytes "
 
Here is the trace from the python command prompt.
 
>>> tmlist = TerminologyMap.objects.filter(id=206)
>>> tmlist
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 68, in __repr__
    data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 83, in __len__
    self._result_cache.extend(list(self._iter))
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 269, in iterator
    for row in compiler.results_iter():
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/compiler.py", line 672, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/compiler.py", line 741, in <lambda>
    result = iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),
  File "/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py", line 552, in fetchmany
    for r in self.cursor.fetchmany(size)])
  File "/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py", line 625, in _rowfactory
    value = to_unicode(value)
  File "/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py", line 636, in to_unicode
    return force_unicode(s)
  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py", line 88, in force_unicode
    raise DjangoUnicodeDecodeError(s, *e.args)
django.utils.encoding.DjangoUnicodeDecodeError: 'utf8' codec can't decode bytes in position 1-3: invalid data. You passed in 'P\xe1ginas' (<type 'str'>)
 
Please let me know if I am doing something wrong here or if there is already a solution available for this encoding problem.
 
Regards,
Anurag

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

Re: Project management software



On Wed, Dec 1, 2010 at 2:45 AM, Baurzhan Ismagulov <ibr@radix50.net> wrote:
 I'd
ideally like to pick one of the projects developed in Django and develop
on top of it.

I agrees. There are projects that need cleanup, and moreover developing a PM mgmt app from scratch is too much
of an effort, unless you want to learn during the due course (but even then developing something smaller would do more justice - as
in, why develop something and then throw it ?) .

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

Re: Django, Python, AJAX position


On Wed, Dec 1, 2010 at 8:08 AM, Cal Leeming [Simplicity Media Ltd] <cal.leeming@simplicitymedialtd.co.uk> wrote:
1) The fact you've put the terms "my client" and "work permit" whilst using a gmail email address, that doesn't have your real name, kinda says a lot.
2) You've broadly used the term AJAX, without specifying what JS framework (if any) you wish to be used.
3) You've used and/or on HTML5, as if to say, django+python+ajax OR html5, wtf?

Please don't take any offense when I say your post is just noise and cancer.


and no mention of "web 2.0" ?? :(

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

Re: Error in ajax request

Noob question here: why would it need limit=5 if the funcion has default values?


Best regards,
Andre Terra

On Mon, Nov 29, 2010 at 20:17, Daniel Roseman <daniel@roseman.org.uk> wrote:
On Nov 29, 8:28 pm, James Matthews <nytrok...@gmail.com> wrote:
> Hi,
>
> When I use this rate limiterhttp://www.levigross.com/post/1721427025/django-rate-limitingand preform an
> ajax request I get this error
>
> django/middleware/common.py", line 84, in process_response
>     if response.status_code == 404:
> AttributeError: 'function' object has no attribute 'status_code'
>
> [CODE]
> @ratelimit
> @never_cache
> def ajaxrequester(request):
>     if request.is_ajax():
>         stuff = submitform(request.POST)
>         return HttpResponse("{'ok':200}",content_type="text/xml")
>     else:
>         return HttpResponseForbidden("You don't belong here")
> [/CODE]
>
> Any thoughts?

It looks like that is a callable decorator - it is intended to be
called immediately, with arguments:

@ratelimit(limit=5)
  ...etc...

You can tell it's meant to be used like this because of the extra
level of nested functions: normal decorators just return a function
(which calls the decorated function), but callable decorators return a
function (the actual decorator) which itself returns a function.

(Actually I'm not sure that 'callable decorator' is the right term
here, but I can't think of a better one. Is there a canonical name for
this sort of thing?)
--
DR.

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

Re: django to php

On Tue, 2010-11-30 at 12:56 +0530, Akash Mukherjee wrote:
> I have a webapp created in django. Now I want to convert the entire
> code into PHP. Is it possible?? If yes, how?

although I can sympathise with your problem - some suit has decided that
the code be in php? - it is unlikely that you will get an answer on this
list. The best thing would be to rewrite the app afresh in php. (or
change the urls into php sounding urls so the suit does not know what
you are doing)
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Django, Python, AJAX position

1) The fact you've put the terms "my client" and "work permit" whilst
using a gmail email address, that doesn't have your real name, kinda
says a lot.
2) You've broadly used the term AJAX, without specifying what JS
framework (if any) you wish to be used.
3) You've used and/or on HTML5, as if to say, django+python+ajax OR
html5, wtf?

Please don't take any offense when I say your post is just noise and cancer.

On 30/11/2010 15:37, Bita Bita wrote:
> My client is in an immediate need for a front end engineer who knows
> Django, Python, AJAX, and/or html5 . This is a full time position with
> a really good pay in Palo Alto, CA. Sent me your updated resume if
> interested. The candidate should have work permit.
>

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

Re: django to php

Too much noise!

To answer OPs question, you'd have to port the code to PHP manually.

On 01/12/2010 02:18, Steve Holden wrote:
> On 11/30/2010 9:15 PM, Kenneth Gonsalves wrote:
>> On Tue, 2010-11-30 at 13:53 -0500, CLIFFORD ILKAY wrote:
>>>> I have a webapp created in django. Now I want to convert the entire
>>>> code into PHP. Is it possible?? If yes, how?
>>> I have a Porsche that I'd like to trade for an ox cart. Any takers?
>>> Seriously, why would you want to do that?
>> well, if you are in a location where there is no one to maintain your
>> Porsche and has a surfeit of ox cart drivers ...
> Except, of course, that a thousand oxen can't travel at two thousand
> miles an hour. So there's no way to get "equivalent" performance. In
> most places I suspect the oxen would be more useful. The more so as the
> oil disappears.
>
> regards
> Steve

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

Re: django to php

On 11/30/2010 9:15 PM, Kenneth Gonsalves wrote:
> On Tue, 2010-11-30 at 13:53 -0500, CLIFFORD ILKAY wrote:
>>> I have a webapp created in django. Now I want to convert the entire
>>> code into PHP. Is it possible?? If yes, how?
>>
>> I have a Porsche that I'd like to trade for an ox cart. Any takers?
>> Seriously, why would you want to do that?
>
> well, if you are in a location where there is no one to maintain your
> Porsche and has a surfeit of ox cart drivers ...

Except, of course, that a thousand oxen can't travel at two thousand
miles an hour. So there's no way to get "equivalent" performance. In
most places I suspect the oxen would be more useful. The more so as the
oil disappears.

regards
Steve
--
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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

Re: django to php

On Tue, 2010-11-30 at 13:53 -0500, CLIFFORD ILKAY wrote:
> > I have a webapp created in django. Now I want to convert the entire
> > code into PHP. Is it possible?? If yes, how?
>
> I have a Porsche that I'd like to trade for an ox cart. Any takers?
> Seriously, why would you want to do that?

well, if you are in a location where there is no one to maintain your
Porsche and has a surfeit of ox cart drivers ...
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Issues importing models in between apps

heya,

Sorry to reply to myself, but I seem to have the split worked out,
using string syntax as suggested by Daniel, as you would for a FK to a
model not yet defined (http://docs.djangoproject.com/en/dev/ref/models/
fields/#foreignkey
).

It seems to work now, however, it is a bit messier than directly
referring to models by their name alone.

So the design question from my previous message still stands - is this
a candidate for splitting up across apps like this, or am I better off
going for a single app, and splitting up the models.py within there?
Or any other techniques you might recommend, to make the design more
logical and the models.py less unwieldly/large?

Cheers,
Victor

On Nov 30, 10:44 pm, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 30 nov, 07:01, Victor Hooi <victorh...@gmail.com> wrote:
>
> > Hi,
>
> > I had an application with a fairly large models.py file, which I split
> > up into separate apps to make it easier to manage.
>
> This won't address your problem but FWIW, you don't have to use
> separate apps just to split a models.py file - you can turn it into a
> models package, with the package's __init__.py used as a "facade" for
> the submodules (usual pythonic solution).
>
> But anyway:
>
> > Two of the apps are called "conferences" and "people", each with their
> > own models.py.
>
> > These two are fairly tightly entwined, they each refer to each other.
>
> If both models really depend that much on each other then they ought
> te live in a same module. Or perhaps there's room for improvement in
> your design but you don't give enough context.
>
> (snip typical circular deps symptom)
>
> > I'm not sure why this is happening - from the looks of it, it's
> > opening up conferences/models.py, then importing people.models.Person
> > from there, which inside of that tries to import Conference
>
> In Python almost everything happens at runtime. The import, class and
> def statements are executable statements, and they are executed - with
> every other top-level statement - when the module is first loaded.
>
> > Or is there a better way of creating multiple apps that all share
> > models?
>
> Put the interdependent models in a same app. The you can have other
> apps using these models too as long as there's no circular
> dependencies.
>
> A Django app doesn't have to define models or views or urls or
> whatever - you can have one app with models, and another vwith views
> and forms and whatnot depending on the first app's models.
>
> > The main reason I split it up was for logically separating all
> > the different models, they still all need to import/relate to each
> > other.
>
> Once again: if your models are tightly coupled, they ought to live in
> a same module.

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

Re: Issues importing models in between apps

heya,

Thanks to both for your advice.

Yeah, you're right, it's a somewhat unwanted circular dependency. It
was just the only way I could think of to deal with a somewhat
unwieldy/large models.py file.

Even using the string syntax, I hit a bunch of other issues, due to
how tightly the two models are coupled ('Accessor clashes with related
field...', the 'through' table for m2m needs to be imported etc.). So
it might be better to try and sort out the design issue first.

To give some context - it's a simple application for managing people's
attendance at conferences, and allocating accomodation to them.

* I have a 'People' app that has a models 'Person', along with models
for all their required information (allergies, special requirements,
spouse/children, contact numbers and addresses etc.).

* I have a 'Conferences' app that imports Person, and stores things
about their attendance, accommodation requests, what workshop they're
assigned to etc.

* I have a 'Facilities' app that manages all the various accomodation
sites and workshop rooms, and what they each provide. (e.g. how many
beds, how many seats etc.)

There's a few others, but those are the main ones.

Previously, I had this all in a single models.py inside Conferences.
However, it got a bit unwieldy, hence the split. However, they're all
still tightly coupled.

With the above information, would you still recommend putting it all
in a single app - or should I try and work out the issues from this
split? It did seem cleaner in separate apps.

Anyhow, from my understanding, I can split up the models.py file

http://code.djangoproject.com/ticket/4470
http://andrewwilkinson.wordpress.com/2009/01/20/placing-django-models-in-separate-files/

However, I'll need to add a Meta/app_label to each and every single
model in that file - is that right? Or is there a better way of
splitting up a models.py file across multiple files, or of somehow
organising this?

Cheers,
Victor

On Nov 30, 10:44 pm, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 30 nov, 07:01, Victor Hooi <victorh...@gmail.com> wrote:
>
> > Hi,
>
> > I had an application with a fairly large models.py file, which I split
> > up into separate apps to make it easier to manage.
>
> This won't address your problem but FWIW, you don't have to use
> separate apps just to split a models.py file - you can turn it into a
> models package, with the package's __init__.py used as a "facade" for
> the submodules (usual pythonic solution).
>
> But anyway:
>
> > Two of the apps are called "conferences" and "people", each with their
> > own models.py.
>
> > These two are fairly tightly entwined, they each refer to each other.
>
> If both models really depend that much on each other then they ought
> te live in a same module. Or perhaps there's room for improvement in
> your design but you don't give enough context.
>
> (snip typical circular deps symptom)
>
> > I'm not sure why this is happening - from the looks of it, it's
> > opening up conferences/models.py, then importing people.models.Person
> > from there, which inside of that tries to import Conference
>
> In Python almost everything happens at runtime. The import, class and
> def statements are executable statements, and they are executed - with
> every other top-level statement - when the module is first loaded.
>
> > Or is there a better way of creating multiple apps that all share
> > models?
>
> Put the interdependent models in a same app. The you can have other
> apps using these models too as long as there's no circular
> dependencies.
>
> A Django app doesn't have to define models or views or urls or
> whatever - you can have one app with models, and another vwith views
> and forms and whatnot depending on the first app's models.
>
> > The main reason I split it up was for logically separating all
> > the different models, they still all need to import/relate to each
> > other.
>
> Once again: if your models are tightly coupled, they ought to live in
> a same module.

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

Re: Django, Python, AJAX position

If we are able to work from home then I will for sure provide my
resume. Home = Canada

On Nov 30, 7:37 am, Bita Bita <bitab...@gmail.com> wrote:
> My client  is in an immediate need for a front end engineer who knows
> Django, Python, AJAX, and/or html5 . This is a full time position with
> a really good pay in Palo Alto, CA. Sent me your updated resume if
> interested. The candidate should have work permit.

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

Re: Loading CSS

Well - that's one way
A simpler way is to use your settings.py file to point to your media,
and remove all reference to .css from your url.py files

...

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/path_to_media_root/static_media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/static_media/'

...

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

Editing a many to many field in a save method

Hi, I've got the following model and I want it so that each delivery
has a default category of undefined

class Delivery(models.Model):
.....
categories = models.ManyToManyField(Category, blank = True, null =
True)
.....

Then if other categories are selected undefined is automatically
removed from the delivery's categories.
I thought I would be able to do this using the save method below, but
it doesn't work. If categories are none it doesn't add undefined and
if serveral are selected it doesn't remove undefined.

def save(self):
super(Delivery, self).save()
if self.categories.count() == 0:
undefined = Category.objects.get(name='undefined')
self.categories.add(undefined)
if self.categories.count() > 1:
undefined = Category.objects.get(name='undefined')
for category in self.categories.all():
if category == undefined:
self.categories.remove(undefined)
super(Delivery, self).save()

if i select/deselect them using the admin interface they work fine,
just not the changes i try to make in save. I'd appreciate any help, I
don't know if i've misunderstood something or if its something else.

thanks

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

Re: Project management software

On Tue, Nov 30, 2010 at 12:30:55PM -0800, tiemonster wrote:
> I finally had a chance to put a demo up online:
>
> http://freeshell.de/~mscahill/projects/
>
> Now obviously this isn't as pretty as it could be. It's meant to be
> installed within an existing application. I made a half-hearted effort
> to mock up something that would give you an idea of how it might look.
> Please log in and poke around. I'd love feedback, as well as some
> volunteers to make this really happen.
>
> If you're interested in contributing, or even in using the code, let
> me know either on-list, or by private e-mail. If there is some
> interest, I'll release the code under the GPL in January, and begin
> more active development.

I definitely need a tool for time tracking, ideally supporting Scrum (+
possibly PSP) project management, vacations, billing, access levels. I'd
ideally like to pick one of the projects developed in Django and develop
on top of it.

With kind regards,
Baurzhan.

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

Re: Adding extra data in annotate()

Ideally any proposed solution could also substitute the search for the
newest timestamp via Max() to be the largest Value.data float with
similar logic.

Franco

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

Re: Current Django 1.3 Alpha 2 Documentation as PDF

Of course I will do upgrade the doc.

BTW: Latest doc from SVN: http://ubuntuone.com/p/RY1/

On 30 Nov., 07:00, derek <gamesb...@gmail.com> wrote:
> Hmm.  So you're not planning to upgrade the doc when the final release
> is made...?!
>
> On Nov 25, 4:22 pm, "ckar...@googlemail.com" <ckar...@googlemail.com>
> wrote:
>
> > Okay, please remind me ;-)
>
> > On 25 Nov., 09:38, derek <gamesb...@gmail.com> wrote:
>
> > > Please post a link to the PDF when the final release is available.
>
> > > On Nov 21, 7:38 pm, "ckar...@googlemail.com" <ckar...@googlemail.com>
> > > wrote:
>
> > > > Sry for dublepost.
>
> > > > For those who don't want to install all the *tex* libraries. Here is
> > > > the link:http://ubuntuone.com/p/QFl/
>
> > > > Have fun with printing and reading ;-)
>
> > > > On 21 Nov., 18:00, "ckar...@googlemail.com" <ckar...@googlemail.com>
> > > > wrote:
>
> > > > > Are you interested in the current Django 1.3 Alpha 2 documentation as
> > > > > PDF?

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

Project management software

I finally had a chance to put a demo up online:

http://freeshell.de/~mscahill/projects/

Now obviously this isn't as pretty as it could be. It's meant to be
installed within an existing application. I made a half-hearted effort
to mock up something that would give you an idea of how it might look.
Please log in and poke around. I'd love feedback, as well as some
volunteers to make this really happen.

If you're interested in contributing, or even in using the code, let
me know either on-list, or by private e-mail. If there is some
interest, I'll release the code under the GPL in January, and begin
more active development.

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

Re: missing object in object_list generic view

Start by reading http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/ and finish by writing one (or many!) wrapper function(s) as suggested.

It will make your code 1) readable, 2) easier to debug, 3) extensible, 4) powerful, and 5) DRY.


Cheers,
Andre Terra

On Tue, Nov 30, 2010 at 17:20, Carlos Aboim <aboim2@gmail.com> wrote:
It's very strange, got this:
urls
info_dict = {
   'Queryset': Obra.objects.all (),
   }

(r'index / $ ',' django.views.generic.list_detail.object_list ',
info_dict, dict (name = "obras_index", template_object_name = 'obras',
paginate_by = 5)),

template
[...]
{% For book in the works%}
<h2> obra.numero {{}} </ h2>    ## example
[...]

and what appears in place of the list of objects paged out of 5 in 5,
is
"Page of"

I'm missing the queryset variable somehow

What can I do to solve the problem

thank you
Aboim

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

Adding extra data in annotate()

All,

I'm attempting to consolidate many orm queries into one. My models:

class Key (models.Model):
name = models.CharField()

class Value (models.Model):
data = models.FloatField()
timestamp = models.DateTimeField()
key = models.ForeignKey(Key)

Given a list of Key names, I am able to annotate the count of Value
objects associated. However, I would also like to construct a query
that will take a list of Key names and find an aggregate (Min, Max)
Value with additional annotations (timestamp).

Currently, it's an inefficient loop:

>>> # Simulate input parameters.
>>> key_names = ["key 1", "key 2", "key 3"]
>>> end = datetime.datetime.now()
>>> start = end - datetime.timedelta(days=-1)
>>>
>>> # output dict.
>>> lasts = {}
>>>
>>> for key_name in key_names:
... # Narrow down the Value objects by key name.
... qs = Value._default_manager.filter(key__name=key_name)
... # And by date range.
... qs = qs.filter(value__timestamp__range=(start, end))
... # Find the most recent timestamp.
... last = qs.aggregate(last=Max("timestamp"))["last"]
... # With the most recent timestamp, filter the queryset for
the matching record.
... value = qs.filter(timestamp=last)[0]
... # Append to output
... lasts[key_name] = {"timestamp" : value.timestamp, "data" :
value.data}
>>> lasts

Is there a more efficient way to aggregate and/or annotate all of the
latest Value data and timestamp object fields onto the associated Key
object?

TIA

Franco

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

Re: django to php

Because he can't drive stick.



Regards,
Andre Terra

On Tue, Nov 30, 2010 at 16:53, CLIFFORD ILKAY <clifford_ilkay@dinamis.com> wrote:
On 11/30/2010 02:26 AM, Akash Mukherjee wrote:
Hello,

I have a webapp created in django. Now I want to convert the entire
code into PHP. Is it possible?? If yes, how?

I have a Porsche that I'd like to trade for an ox cart. Any takers? Seriously, why would you want to do that?
--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6

<http://dinamis.com>
+1 416-410-3326


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

missing object in object_list generic view

It's very strange, got this:
urls
info_dict = {
'Queryset': Obra.objects.all (),
}

(r'index / $ ',' django.views.generic.list_detail.object_list ',
info_dict, dict (name = "obras_index", template_object_name = 'obras',
paginate_by = 5)),

template
[...]
{% For book in the works%}
<h2> obra.numero {{}} </ h2> ## example
[...]

and what appears in place of the list of objects paged out of 5 in 5,
is
"Page of"

I'm missing the queryset variable somehow

What can I do to solve the problem

thank you
Aboim

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

Re: django to php

On 11/30/2010 02:26 AM, Akash Mukherjee wrote:
> Hello,
>
> I have a webapp created in django. Now I want to convert the entire
> code into PHP. Is it possible?? If yes, how?

I have a Porsche that I'd like to trade for an ox cart. Any takers?
Seriously, why would you want to do that?
--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada M4N 3P6

<http://dinamis.com>
+1 416-410-3326

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

Re: Sample Auto Log Out Code

Many thanks. This worked swell, and I also set the cookies expire when
browser closed setting.

On Nov 24, 11:39 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Nov 24, 4:23 pm,octopusgrabbus<old_road_f...@verizon.net> wrote:
>
> > Sorry for the late reply. Most of my users will not remember to log
> > out. After, say four hours, I'd like to log them out, if of course
> > they're not already logged out.
>
> That's just a matter of setting session cookies to expire properly.
> You need to set SESSION_COOKIE_AGE to 14400 (=4*60*60) to get it to
> expire after four hours, instead of the default two weeks.
> --
> DR.

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

Loading CSS

I am running Django 1.2.3 -- python -c "import django; print
django.get_version()" I basically need to know what logs to look at to
fix a css file not loading.

I am trying to load a css file in my base template

<html>
<!-- Test Comment -->
<head>
<title>{% block title %}Town of Arlington Water Department AMR
System{% endblock %} </title>
<link rel="stylesheet" type="text/css" href="/static_media/
amr.css" />
</head>

Here's the css file -- you could say it's a "test file".

body{ background-color: gray;}
p { color: blue; }
h3{ color: white; }

In urls.py this is inserted into

urlpatterns = patterns('',

(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/home/amr/django'}),

Nothing loaded. Then, I tried setting STATIC_DOC_ROOT = '/home/amr/
django/static_media' in settings.py and in urls.py

from django.conf import settings
...
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_DOC_ROOT}),

and gotten this error

AttributeError at /

'Settings' object has no attribute 'STATIC_DOC_ROOT'

Thanks for any help or pointers.

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

Re: Django timestamp to Javascript timestamp

Thanks for the info guys, after I slept on it I went a different way.
Used a model manager that added a column to the row (p.js_timestamp =
time.mktime(p.datetime.timetuple()) * 1000)

Matt

On 29 Nov, 18:16, Matt Thompson <thompson...@gmail.com> wrote:
> Hello guys and girls,
>
> I'm looking to use Flot to graph some data I have in my Django app.
> I'd like to graph a time based query and need to get the time is
> Javascript format (milliseconds since 01/01/1970).
>
> I can get it into seconds\unix format, this is seconds since
> 01/01/1970, but not milliseconds.
>
> Can anyone help?
>
> Thanks,
> Matt

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

Re: nUnrouteable address

On Tue, Nov 30, 2010 at 5:01 PM, mangamonk <mark.herringer@gmail.com> wrote:
> here are my email configurations in settings.py
>
> EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
> EMAIL_HOST = 'smtp.domain.org'
> EMAIL_HOST_PASSWORD = 'password'
> EMAIL_HOST_USER = 'webmaster@domain.org'
> EMAIL_PORT = '587'
> DEFAULT_FROM_EMAIL = 'webmaster@domain.org'
> SERVER_EMAIL = 'webmaster@domain.org'
> # EMAIL_USE_TLS = 'True'
> EMAIL_SUBJECT_PREFIX = '[domain correspondance]'
>
> here is the output of tests from the command line.
>
> (mysite)mark@longsox:~/domain$ python manage.py retry_deferred
> 8 message(s) retried
>
> (mysite)mark@longsox:~/domain$ python manage.py send_mail
> ------------------------------------------------------------------------
> acquiring lock...
> acquired.
> sending message 'Confirm e-mail address for domain.org' to
> mark@emailaddrs.net
> message deferred due to failure: (550, 'Verification failed for
> <webmaster@localhost>\nUnrouteable address\nSender verify failed',
> 'webmaster@localhost')
>
> so basically pinax is not sending verification emails
>
> this pinax site is running on django 1.2 and the server ubuntu 10.04
> nginx fastcgi
>
> do I need to add the smtp server to the /etc/hosts file?
>

Your SMTP server is declining to accept mail from this sender. Either
reconfigure your SMTP server to allow this sender access, or
reconfigure django to send as an approved sender.

BTW, I know you are trying to anonymise domains and what not, but your
problem is that emails are submitted from address
'webmaster@localhost', which is mighty close to
'webmaster@domain.org'. It might be easier to explicitly state your
settings.

Cheers

Tom

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

nUnrouteable address

here are my email configurations in settings.py

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.domain.org'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_HOST_USER = 'webmaster@domain.org'
EMAIL_PORT = '587'
DEFAULT_FROM_EMAIL = 'webmaster@domain.org'
SERVER_EMAIL = 'webmaster@domain.org'
# EMAIL_USE_TLS = 'True'
EMAIL_SUBJECT_PREFIX = '[domain correspondance]'

here is the output of tests from the command line.

(mysite)mark@longsox:~/domain$ python manage.py retry_deferred
8 message(s) retried

(mysite)mark@longsox:~/domain$ python manage.py send_mail
------------------------------------------------------------------------
acquiring lock...
acquired.
sending message 'Confirm e-mail address for domain.org' to
mark@emailaddrs.net
message deferred due to failure: (550, 'Verification failed for
<webmaster@localhost>\nUnrouteable address\nSender verify failed',
'webmaster@localhost')

so basically pinax is not sending verification emails

this pinax site is running on django 1.2 and the server ubuntu 10.04
nginx fastcgi

do I need to add the smtp server to the /etc/hosts file?

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

Re: Django, Python, AJAX position

If nobody responded to you yesterday, you might want to revise the post with some more details, rather than just re-posting it. It's not worth most good developers' time to inquire about 2 sentence job posts that are really ambiguous...

On Tue, Nov 30, 2010 at 10:37 AM, Bita Bita <bitabita@gmail.com> wrote:
My client  is in an immediate need for a front end engineer who knows
Django, Python, AJAX, and/or html5 . This is a full time position with
a really good pay in Palo Alto, CA. Sent me your updated resume if
interested. The candidate should have work permit.

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

Re: Django timestamp to Javascript timestamp

I forgot to get miliseconds you just have to do:

datetime.getTime();

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

Re: Django timestamp to Javascript timestamp

You can use this format

{{date|date:"Y/m/d H:i:s"}}
d = new Date("2010/11/30 09:58:25");

The problem with ms is that Javascripts accepts only two decimals so
if you want to use miliseconds you can do something like this:

function to_datetime(datetime){
// from python >>> datetime.now().strftime("%d/%m/%Y %H:%M:%S.%f")
//transform datetime= "dd/mm/YYYY HH:MM:SS.ms" string to Date()
try{
datetime.getTime();}
catch(err){

var d_t = datetime.split(/[/\s:.]/);
var dmyHMS = new Array;
for(var i in d_t){
dmyHMS.push(parseFloat(d_t[i]));
}
var datetime = new Date(dmyHMS[2],
dmyHMS[1]-1,
dmyHMS[0],
dmyHMS[3],
dmyHMS[4],
dmyHMS[5],
dmyHMS[6]) ; <= you can truncate to two
decimals from python (%.2f) %value
}
return datetime


Now i'm working in a graph time based in canvas, tell me if you are
interested, and i'll send you the file

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

Django, Python, AJAX position

My client is in an immediate need for a front end engineer who knows
Django, Python, AJAX, and/or html5 . This is a full time position with
a really good pay in Palo Alto, CA. Sent me your updated resume if
interested. The candidate should have work permit.

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

Re: Error in ajax request

On 29/11/10 22:17, Daniel Roseman wrote:


> (Actually I'm not sure that 'callable decorator' is the right term
> here, but I can't think of a better one. Is there a canonical name for
> this sort of thing?)

PEP 318 just says "function that returns a decorator" (which is a bit of
a mouthful)

"The current syntax also allows decorator declarations to call a
function that returns a decorator:"

...

"The rationale for having a function that returns a decorator is that
the part after the @ sign can be considered to be an expression (though
syntactically restricted to just a function), and whatever that
expression returns is called."

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

Re: Javascript and template rendering problem

On 29/11/10 20:03, Anderson Goulart wrote:
> Hi,
>
> How can I render to a javascript code a variable set in a view?
> I tried {{ variable }} but it returns nothing in the html source code.
> When I put this {{ variable }} outside <script> tags it works perfectly.
> Any clues?
>

Since you do say it returns nothing, it's probably not what's wrong
(depending on how you inspected the source) but one thing to bear in
mind is escaping, remember to use

var foo="{{bar|escapejs}}";

to avoid little surprises on embedding stuff into js [1].

Another alternative to embed the value on the normal html side and pull
the value out with javascript/jquery. Not incredibly efficient, but
useful if you want a per-template-rendered value, but want to keep .js
files separate (embedded js in script tags has subtleties*) and unmunged
by any django templating.

* e.g. browsers do tend to muddle through given all sorts of peculiar
input of course, but beware xhtml vs. html - for xhtml, you must use
CDATA inside the script tag (or properly escape significant chars) [2],
whereas html 4 says to treat script specially [3] so you get away
without that, but then watch out for accidental embeddings of "</" which
will end your script. (draft html5 apparently [4] allows embedded "</",
ho hum))

[1] http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#escapejs

[2] http://www.w3.org/TR/xhtml1/#h-4.8
[3] http://www.w3.org/TR/REC-html40/types.html#type-cdata
[4]
http://stackoverflow.com/questions/4029341/dom-parser-that-allows-html5-style-in-script-tag

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

Re: django to php

Time better spent learning django :)

On Nov 30, 2010 9:24 AM, "Tom Evans" <tevans.uk@googlemail.com> wrote:
> On Tue, Nov 30, 2010 at 7:26 AM, Akash Mukherjee <akashmkj@gmail.com> wrote:
>> Hello,
>>
>> I have a webapp created in django. Now I want to convert the entire
>> code into PHP. Is it possible?? If yes, how?
>>
>> Thanks
>>
>> Akash
>>
>
> Anything is possible given enough resource. I am not aware of any
> tools that would automatically convert from django to PHP - I would
> doubt they exist, given the architectural differences between django
> and PHP.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django to php

On Tue, Nov 30, 2010 at 7:26 AM, Akash Mukherjee <akashmkj@gmail.com> wrote:
> Hello,
>
> I have a webapp created in django. Now I want to convert the entire
> code into PHP. Is it possible?? If yes, how?
>
> Thanks
>
> Akash
>

Anything is possible given enough resource. I am not aware of any
tools that would automatically convert from django to PHP - I would
doubt they exist, given the architectural differences between django
and PHP.

Cheers

Tom

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

Re: Where's the form value set for comments framework/app

On Nov 30, 8:31 am, photon <photo...@gmail.com> wrote:
> Mostly I followed the instruction ofhttp://docs.djangoproject.com/en/dev/ref/contrib/comments/
>
> While my code could run as expected, I cannot find when and where the
> field values in "form" are set before it's called in line 4~6 of the
> form.html as below. What I'm particularly interested in was the
> content_type field.
>
> Part of my code looks like this:
>
> detail.html:
>  21 {% load comments %}
>  22 {% get_comment_count for topic as comment_count %}
>  23 <p>{{ comment_count }} comments have been posted. </p>
>  24
>  25 {% render_comment_list for topic %}
>  26
>  27 {% render_comment_form for topic %}
>
> form.html under templates/comments/
>   1 {% load comments i18n %}
>   2 <form action="{% comment_form_target %}" method="post">{%
> csrf_token %}
>   3   {% if next %}<input type="hidden" name="next"
> value="{{ next }}" />{% endi    f %}
>   4   {% for field in form %}
>   5     {% if field.is_hidden %}
>   6       {{ field }}
> ...
>
> The source code of form.html when opened in a browser:
> ...
> <form action="/comments/post/" method="post"><div
> style='display:none'><input type='hidden' name='csrfmiddlewaretoken'
> value='7bc056d8f14034c257c49aa0b38763ce' /></div>
>
>       <input type="hidden" name="content_type" value="topics.topic"
> id="id_content_type" />
>       <input type="hidden" name="object_pk" value="1"
> id="id_object_pk" />
>       <input type="hidden" name="timestamp" value="1291103625"
> id="id_timestamp" />
>       <input type="hidden" name="security_hash"
> value="a4080f739cd016f4eaa2ed2bfb4b9f5e6c0ed313"
> id="id_security_hash" />
> ...

It's done by the render_comment_form tag itself, which is in
django.contrib.comments.templatetags.comments.
--
DR.

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

Re: 2 paypal forms in a view with django-paypal

2010/11/30 Alexandre González <agonzalezro@gmail.com>
It always show two forms but with the last one (five_form) but the update() works perfectly.

Try dcramer or johnboxall version of django-paypal - dcramer's is no more maintained i guess.

On a different note : were you able to add multiple items to the dict?
Also, i hear Encrypted form is better than PayPalPaymentsForm.

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

2 paypal forms in a view with django-paypal

Hi! I like to show 2 different paypal forms using django-paypal, this is my code:

def payments(request):
    paypal_dict = { 
        'amount': None,
        'business': settings.PAYPAL_RECEIVER_EMAIL,
        'item_name': None,
        'notify_url': settings.PAYPAL_NOTIFY,
        'return_url': settings.PAYPAL_RETURN,
        'cancel_return': settings.PAYPAL_CANCEL,
    }   
    paypal_dict.update({'amount': '1', 'item_name': 'Anual suscription')
    suscription_form = PayPalPaymentsForm(initial=paypal_dict)
    
    paypal_dict.update({'amount': '0.01', 'item_name': 'Buy 5 coins')
    five_form = PayPalPaymentsForm(initial=paypal_dict)
  
    return render_to_response("forms/paypal.html", {'five_form': five_form, 'suscription_form': suscription_form})


It always show two forms but with the last one (five_form) but the update() works perfectly.

--
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt and/or .pptx

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

Re: Choices vs. ForeignKeys (was: Django - Alternative to using NULLs? (for integer and FK fields).)

On Tuesday 30 November 2010 08:53:49 Todd Wilson wrote:
> Mike Dewhirst wrote, on 11/29/2010 10:33 PM:
> > I'm keeping track of companies, divisions and people with their
> > relationships. For example, divisions can be traded between companies
> > and people consult to companies or own trading entities. I can also keep
> > track of pretty much any relationship of interest.
> >
> > Hope this helps ...
> >
> > class Entity(models.Model):
> > """
> > Entities can be corporations or humans. entity_type indicates
> > which.
> > """
> > entity_type = models.CharField(max_length=MEDIUM, blank=False,
> >
> > choices=ENTITY_TYPES,
> > default=ENTITY_TYPES[0][0])
>
> Although this is not directly related to the question that started this
> thread, your example raises a question that I've had as I've read the
> documentation. Instead of hard-coding the entity types here, you are
> using a constant, presumably because you may want to introduce more
> entity types later. But what are the trade-offs bewteen representing
> types as CharFields with choices, as you are doing here, versus a
> separate table of types to which this model has a foreign-key
> relationship? I'm facing this decision in a number of different places
> in a Django application I'm working on.

I try to answer this one since I spent good deal of my precious time to think
the exactly same thing while back.

I rarely use strings for actual values. It's just for preformance point of
view. It makes database easy to read but if you do constant searches by some
field you want to index it. And strings don't index well.

So it's also possible, and personally I opt for to use type-kind stuff as
integer field.

class MyMode(models.Model)
SOME_CHOICES = ((1, 'Choice 1'),
(2, 'Choice 2'))
my_field = models.IntegerField(choices=SOME_CHOICES, default=1)

to get visible representation of my_field you can do using built-in feature of
Django ORM:

instance_of_mymodel.get_my_field_display()

But when to use choices and when fk?

I use choices is when I have a relatively fixed set of options that basically
don't change ever. It's just that adding new stuff involves so much including
deployment to customer environments.

Foreign key I use when ever data is meant to be changed or edited by end user
or it contains much more data than simple textual value.

And as known relational databases are meant to handle um.. relational data.
And they do that very well. So it's not much of a problem to add models for
that kind of a data.

--

Jani Tiainen

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

Re: Issues importing models in between apps

On 30 nov, 07:01, Victor Hooi <victorh...@gmail.com> wrote:
> Hi,
>
> I had an application with a fairly large models.py file, which I split
> up into separate apps to make it easier to manage.

This won't address your problem but FWIW, you don't have to use
separate apps just to split a models.py file - you can turn it into a
models package, with the package's __init__.py used as a "facade" for
the submodules (usual pythonic solution).


But anyway:

> Two of the apps are called "conferences" and "people", each with their
> own models.py.
>
> These two are fairly tightly entwined, they each refer to each other.

If both models really depend that much on each other then they ought
te live in a same module. Or perhaps there's room for improvement in
your design but you don't give enough context.

(snip typical circular deps symptom)

> I'm not sure why this is happening - from the looks of it, it's
> opening up conferences/models.py, then importing people.models.Person
> from there, which inside of that tries to import Conference

In Python almost everything happens at runtime. The import, class and
def statements are executable statements, and they are executed - with
every other top-level statement - when the module is first loaded.

> Or is there a better way of creating multiple apps that all share
> models?

Put the interdependent models in a same app. The you can have other
apps using these models too as long as there's no circular
dependencies.

A Django app doesn't have to define models or views or urls or
whatever - you can have one app with models, and another vwith views
and forms and whatnot depending on the first app's models.

> The main reason I split it up was for logically separating all
> the different models, they still all need to import/relate to each
> other.

Once again: if your models are tightly coupled, they ought to live in
a same module.

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

Re: Django - Alternative to using NULLs? (for integer and FK fields).

On Tue, Nov 30, 2010 at 4:11 AM, Lachlan Musicman <datakid@gmail.com> wrote:
> On Tue, Nov 30, 2010 at 12:28, Victor Hooi <victorhooi@gmail.com> wrote:
>> Hi,
>>
>> I'm wondering what the community's stance on using NULL in Django is?
>>
>> Say for example you have:
>>
>>    class Person(models.Model):
>>        street_address = models.CharField(max_length=50, blank=True)
>>        suburb = models.CharField(max_length=30)
>>        postcode = models.IntegerField()
>>        state = models.CharField(max_length=3)
>>        email = models.EmailField()
>>        mobile_phone_number = models.IntegerField(max_length=12)
>>        home_phone_number = models.IntegerField(max_length=10,
>> null=True, blank=True)
>>        work_phone_number = models.IntegerField(max_length=8,
>> null=True, blank=True)
>>
>>       spouse = models.ForeignKey('self', null=True, blank=True)
>>       children = models.ManyToManyField('self', null=True,
>> blank=True)
>>
>> For string fields like street_address, I can make these "blank=True",
>> and Django will store an empty string if the user leaves it blank.
>>
>> However, for integer fields like home_phone_number and
>> work_phone_number, I've had to make these "null=True" for the case
>> where somebody doesn't supply them (i.e. they're meant to be optional,
>> mobile is required).
>>
>> However, is there a better way of handling this case? (assuming I want
>> to keep these fields as integers).
>
>
> Is it possible to know why you would want to keep them as integers?
> Given that there are no mathematical functions that you would want to
> apply to them....
>
>
>> What about in the case of optional foreign keys (spouse and children)
>> - is there a better way of handling these, without using NULLs?
>
> As I understand it, foreign keys are kept in the db as follows:
>
> 1. table_Person
> 2. table_Person_children
> 3. table_Person_spouse

You understand it incorrectly. A foreign key on fooapp.FooModelA to
fooapp.FooModelB would be modelled in the database as an
integer/foreign key field (depending on engine) called foomodelb_id on
table fooapp_foomodela.

>
> table 2 has three columns: id, Person, Children
> table 3 has three columns: id, Person, Spouse
>
> or something to that effect.
>
> Therefore, if there is no Spouse or Child, there is no entry for
> Person in tables 2 or 3.

You are describing an m2m relationship, not a foreign key.


Cheers

Tom

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

Re: admin static doesn't work

Why dont you just copy the media folder to your project directory
instead of making loads of symlinks?

Rob

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

Re: Issues importing models in between apps

On Nov 30, 6:01 am, Victor Hooi <victorh...@gmail.com> wrote:
> Hi,
>
> I had an application with a fairly large models.py file, which I split
> up into separate apps to make it easier to manage.
>
> Two of the apps are called "conferences" and "people", each with their
> own models.py.
>
> These two are fairly tightly entwined, they each refer to each other.
>
> At the top of project_name/conferences/models.py, I have:
>
>     from django.db import models
>     from nextgen.people.models import Person
>
> At the top of project_name/people/models.py, I have:
>
>     from django.db import models
>     from project_name.conferences.models import Conference
>
> However, when I try to run ./manage.py validate, it gives me an error:
>
>       File "/sites/.virtualenvs/project_name/src/django/django/utils/
> importlib.py", line 35, in import_module
>         __import__(name)
>       File "/home/victorhooi/djangoProjects/project_name/../
> project_name/conferences/models.py", line 2, in <module>
>         from project_name.people.models import Person
>       File "/home/victorhooi/djangoProjects/project_name/../
> project_name/people/models.py", line 3, in <module>
>         from project_name.conferences.models import Conference
>     ImportError: cannot import name Conference
>
> I'm not sure why this is happening - from the looks of it, it's
> opening up conferences/models.py, then importing people.models.Person
> from there, which inside of that tries to import Conference - is it
> somehow clashing?
>
> Or is there a better way of creating multiple apps that all share
> models? The main reason I split it up was for logically separating all
> the different models, they still all need to import/relate to each
> other.
>
> Cheers,
> Victor

You have a circular dependency between conferences.models and
people.models - each file is trying to import the other one before it
can continue. Obviously, there's no way they can both depend on the
other.

The solution is not to import them at all. Usually the only reason to
do so is to refer to a model in the other module in a ForeignKey - but
you can use a variation of the string syntax to avoid this completely:

class Person(models.Model):
conferences = models.ManyToManyField('conferences.Conference')

--
DR.

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

Where's the form value set for comments framework/app

Mostly I followed the instruction of http://docs.djangoproject.com/en/dev/ref/contrib/comments/

While my code could run as expected, I cannot find when and where the
field values in "form" are set before it's called in line 4~6 of the
form.html as below. What I'm particularly interested in was the
content_type field.

Part of my code looks like this:

detail.html:
21 {% load comments %}
22 {% get_comment_count for topic as comment_count %}
23 <p>{{ comment_count }} comments have been posted. </p>
24
25 {% render_comment_list for topic %}
26
27 {% render_comment_form for topic %}

form.html under templates/comments/
1 {% load comments i18n %}
2 <form action="{% comment_form_target %}" method="post">{%
csrf_token %}
3 {% if next %}<input type="hidden" name="next"
value="{{ next }}" />{% endi f %}
4 {% for field in form %}
5 {% if field.is_hidden %}
6 {{ field }}
...


The source code of form.html when opened in a browser:
...
<form action="/comments/post/" method="post"><div
style='display:none'><input type='hidden' name='csrfmiddlewaretoken'
value='7bc056d8f14034c257c49aa0b38763ce' /></div>

<input type="hidden" name="content_type" value="topics.topic"
id="id_content_type" />
<input type="hidden" name="object_pk" value="1"
id="id_object_pk" />
<input type="hidden" name="timestamp" value="1291103625"
id="id_timestamp" />
<input type="hidden" name="security_hash"
value="a4080f739cd016f4eaa2ed2bfb4b9f5e6c0ed313"
id="id_security_hash" />
...

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

Re: Choices vs. ForeignKeys

Hallöchen!

Todd Wilson writes:

> [...]
>
> [...] Instead of hard-coding the entity types here, you are using
> a constant, presumably because you may want to introduce more
> entity types later. But what are the trade-offs bewteen
> representing types as CharFields with choices, as you are doing
> here, versus a separate table of types to which this model has a
> foreign-key relationship?

I find choices much easier. Additionally, they behave more nicely
in ModelForms as they create a proper widget automatically. I use
FKs only if I want to attach additional information to the choices.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: torsten.bronger@jabber.rwth-aachen.de
or http://bronger-jmp.appspot.com

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

admin static doesn't work

I've successfully managed to configure my django project on virtual
server :) The only problem 1 have by now are admin static files:/
I have no rights to /usr/lib/python2.5/site-packages/django/contrib/
admin/media. I created symlink, but permissions block it's display. I
there any way, to put my admin static files somewhere else and then
I'll make another symlink, but this time with correct rights.

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