Re: WebFaction warning

2009-11-27 Thread Prashanth
Hi Kennath,

On Sat, Nov 28, 2009 at 11:14 AM, Kenneth Gonsalves  wrote:
>
> Please refrain from spreading FUD from one instance.

what do you mean? He is not spreading FUD, service is what we all pay
for, if it happens it is, let that be one or multiple instances. He is
just sharing his bad experience.

-- 
regards,
Prashanth
twitter: munichlinux
blog: prashanthblog.appspot.com
irc: munichlinux, JSLint, munichpython.

--

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: inspectdb throws "_mysql_exceptions.Warning: Can't read dir of './test/' (errno: 13)"

2009-11-27 Thread NicoEchániz
I started a new thread because google groups does not let me reply
this old post, but I'm sending this just in case someone else stumbles
upon this issue.

On Jan 30, 2:32 pm, "dick...@gmail.com"  wrote:
> pretty basic database i created using the "polls" tutorial, and now
> trying to testinspectdb(which i need to run against a legacy db).
> (fwiw, i tried creating a test dir, and didn't help)
>
> thanks,

In my case the problem was related to wrong permissions in my
databases directory:
/var/lib/mysql (on gentoo)
I had a subdirectory there with root:root privileges instead of
mysql:mysql. Changing that, solved the problem.

It had nothing to do with inspectdb or Django whatsoever, but the
Warning was preventing inspectdb from working correctly.


cheers,

NicoEchániz

--

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: Restrict admin to superusers only

2009-11-27 Thread Mike Dewhirst
chefsmart wrote:
> Is there a way to allow only superusers to login to and use the admin
> section? Users with is_staff = True do exist and that can't be changed
> because this app is in use and makes use of is_staff in some other
> way.

I believe so. Create a group (say no_admin?) with no permissions and put 
each of your is_staff=True users into that group. At the same time 
remove all their personally assigned permissions.

Should do the trick.

I would create a test user and try it out to ensure things still work 
properly.

Mike

> 
> Can this be achieved without changing the code in contrib.admin or
> contrib.auth?
> 
> --
> 
> 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: WebFaction warning

2009-11-27 Thread Kenneth Gonsalves
On Saturday 28 Nov 2009 10:58:27 am digicase wrote:
> A warning to anyone using or about to purchase WebFaction hosting. Our
> shared server (web44) went down on Thursday and it is only now, 40
> hours later that they have been able to restore the server to anything
> near working order.
> 

these things happen. bitbucket got hosed - it does not mean that we should 
swear off them. Even django had a security scare. Djangosnippets chews up 
registrations at times. True, webfaction still does not offer mercurial - but 
their rating is justified. Please refrain from spreading FUD from one instance.
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

--

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.




WebFaction warning

2009-11-27 Thread digicase
A warning to anyone using or about to purchase WebFaction hosting. Our
shared server (web44) went down on Thursday and it is only now, 40
hours later that they have been able to restore the server to anything
near working order.

I am sad to report this, as up until now I had complete faith and
trust in them. That has been lost over the past few days. Support were
not transparent, status updates rare and vague.

Furthermore their daily backup of our home folder was corrupted, which
is probably as much as a lesson to me as a bad mark for Webfaction.

All in all a sorry episode for what is supposedly the best place to
host Django sites, according to http://djangofriendly.com/hosts/

--

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.




Restrict admin to superusers only

2009-11-27 Thread chefsmart
Is there a way to allow only superusers to login to and use the admin
section? Users with is_staff = True do exist and that can't be changed
because this app is in use and makes use of is_staff in some other
way.

Can this be achieved without changing the code in contrib.admin or
contrib.auth?

--

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: django on jython

2009-11-27 Thread Prashanth
On Sat, Nov 28, 2009 at 6:20 AM, Xbiton  wrote:
> by setting the DATABASE_ENGINE = 'doj.backends.zxjdbc.mysql' and
> starting

You just say the engine as mysql

\> Error was: No module named mysql
>
\

Its clearly the issue "No module name mysql" install python-mysql
using easy-install or download and compile.


-- 
regards,
Prashanth
twitter: munichlinux
blog: prashanthblog.appspot.com
irc: munichlinux, JSLint, munichpython.

--

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.




django on jython

2009-11-27 Thread Xbiton
Hi,
I've installed djando on jython, which seems to work nice. I've only a
problem using the django-jython
sql package which I installed and by making some tests, seems to work
properly.

by setting the DATABASE_ENGINE = 'doj.backends.zxjdbc.mysql' and
starting
jython manage.py runserver I recive somes errors:

Validating models...
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "/Users/saverioscavelli/jython2.5.1/Lib/site-packages/django/
core/management/commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
  File "/Users/saverioscavelli/jython2.5.1/Lib/site-packages/django/
core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
  File "/Users/saverioscavelli/jython2.5.1/Lib/site-packages/django/
core/management/validation.py", line 22, in get_validation_errors
from django.db import models, connection
  File "/Users/saverioscavelli/jython2.5.1/Lib/site-packages/django/db/
__init__.py", line 41, in 
backend = load_backend(settings.DATABASE_ENGINE)
  File "/Users/saverioscavelli/jython2.5.1/Lib/site-packages/django/db/
__init__.py", line 37, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured:
'doj.backends.zxjdbc.mysql' isn't an available database backend.
Available options are: 'dummy', 'mysql', 'oracle', 'postgresql',
'postgresql_psycopg2', 'sqlite3'
Error was: No module named mysql

please help.

Xaver

--

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 as new and files

2009-11-27 Thread Tim Valenta
Does the newly created model lack a path entirely, or does it have a
path that points to a false location?  In other words, is the right
path making it to the database, yet not to the filesystem to copy the
file?  Also, since you didn't mention anything about it, I would
remind you that a proper test would include trying to make a change to
the FileField.  If you don't try to change it, yet push "Save as new",
it won't be uploading the file again, so it won't be part of the list
of fields that it's manipulating.  And that might be where the problem
lies.  Could you confirm your suspicion from any playing around you
can do?

If you're sure that you really are setting it up for success yet it
fails anyway,  you might consider overriding "save_model" on your
ModelAdmin, so that you can play with the values and see what's going
on:

# ... in your ModelAdmin subclass
def save_model(self, request, obj, form, change):
super( **YourClassName**, self).save_model(self, request,
object, form, change)

# Check if a file upload is present on this save request
if 'your_file_field_name' in request.FILES:

# FileField object, already saved and
# migrated to the supposedly correct "upload_to" location
obj.your_file_field_name

Hope that gets some cogs turning.. :)

Tim

On Nov 27, 7:12 pm, Pawel Pilitowski  wrote:
> Hey,
>
> Mainly I would like to know what the intended behavior of "save as  
> new" is supposed to be, if it is supposed to copy the files, I will  
> look further into why its not working for me.
>
> I was assuming that it would, and didn't find anything in the  
> documentation to the contrary. If it is the desired behavior, any  
> suggestion on a good way to copy the images from one object to the  
> next? custom save() or save_model()? or should i be overwriting  
> something else?
>
> Regards,
>
> Pawel.

--

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.




Retrieving a subclass instance when all you have is its parent class instance

2009-11-27 Thread Rodrigo Cea
I have a parent Class "ComponentBase", with abstract=False, that many
other classes extend.
The parent Class has a ForeignKey relation to another class, "Band".

It is convenient to be able to get a list of all of a band's
components without having to explicitly list each component class.

I am doing this currently like so:

class ComponentBase(models.Model):
   band = models.ForeignKey(Band)
   ...
class Meta:
abstract = False

def subclass(self):
try: return self.complogo
except: pass
try: return self.compnota
except: pass
try: return self.compalbumfotos
except: pass
...

where Complogo, Compnota, etc., are ComponentBase's sublclasses, like
so:

class CompLogo(ComponentBase):


. With this, I can take an instance of Band and do:

components = ComponentBase.objects.filter(band=band_instance)

which populates "components" with all of the band's ComponentBase
instances, and then for each one call subclass() to retrieve the
actual component, e.g. Complogo().

The thing is the number of components will likely increase in the
future, and it feels messy to keep extending the try/except list. Is
there a more compact and less verbose way of retrieving a subclass
instance when all you have is its parent class instance?

--

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: Cannot assign None, does not allow null values

2009-11-27 Thread Tim Valenta
You've got a lot of models in that file.  Which one are you trying to
save when it throws the error?

By the way, I notice that your "ItemWithMedia" class is probably
creating a database table.. if you never need to manipulate it direct
(ie, you only make subclasses of it), I might suggest putting this in
the definition:

class ItemWithMedia(models.Model):
# ... all of your old stuff goes here
class Meta:
abstract = True

That way Django knows it's just a base class.

Not sure what the problem is, yet...

On Nov 27, 3:27 pm, onoxo  wrote:
> btw. here is a full code:
>
> models.pyhttp://snipt.net/vedran/django-models-cannot-assign-none?key=ba151d53...
>
> admin.pyhttp://snipt.net/vedran/django-admin-cannot-assign-none?key=53222b89c...
>
> so... when i go to create new Actual item i get this error:
> Cannot assign None: "Actual.published" does not allow null values.
>
> On Nov 27, 10:57 pm, onoxo  wrote:
>
>
>
> > i get this error when i try to create new item in admin site.
>
> > here is my models.py
> > import datetime
> > from django.db import models
> > from tinymce import models as tinymce_models
> > from filebrowser.fields import FileBrowseField
>
> > class ItemWithMedia(models.Model):
> >     created = models.DateTimeField(auto_now_add=True)
> >     modified = models.DateTimeField(auto_now=True)
>
> > class Actual(ItemWithMedia):
> >     published = models.DateField('Published')
> >     title_hr = models.CharField('(hr)', max_length=200)
> >     title_en = models.CharField('(en)', max_length=200)
> >     body_text_hr = models.TextField('(hr)')
> >     body_text_en = models.TextField('(en)')
>
> >     def __unicode__(self):
> >         return self.title_hr
>
> >     class Meta:
> >         verbose_name = "Aktualno"
> >         verbose_name_plural = "Aktualni"
> >         ordering = ['-published']
>
> > what could be the problem?

--

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 as new and files

2009-11-27 Thread Pawel Pilitowski
Hey,

Mainly I would like to know what the intended behavior of "save as  
new" is supposed to be, if it is supposed to copy the files, I will  
look further into why its not working for me.

I was assuming that it would, and didn't find anything in the  
documentation to the contrary. If it is the desired behavior, any  
suggestion on a good way to copy the images from one object to the  
next? custom save() or save_model()? or should i be overwriting  
something else?

Regards,

Pawel.

--

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: Cannot assign None, does not allow null values

2009-11-27 Thread onoxo
btw. here is a full code:

models.py
http://snipt.net/vedran/django-models-cannot-assign-none?key=ba151d53cbe8e7c6fd8cfd7993c72897

admin.py
http://snipt.net/vedran/django-admin-cannot-assign-none?key=53222b89cf415d0a0a7750f1510ab8a1

so... when i go to create new Actual item i get this error:
Cannot assign None: "Actual.published" does not allow null values.




On Nov 27, 10:57 pm, onoxo  wrote:
> i get this error when i try to create new item in admin site.
>
> here is my models.py
> import datetime
> from django.db import models
> from tinymce import models as tinymce_models
> from filebrowser.fields import FileBrowseField
>
> class ItemWithMedia(models.Model):
>     created = models.DateTimeField(auto_now_add=True)
>     modified = models.DateTimeField(auto_now=True)
>
> class Actual(ItemWithMedia):
>     published = models.DateField('Published')
>     title_hr = models.CharField('(hr)', max_length=200)
>     title_en = models.CharField('(en)', max_length=200)
>     body_text_hr = models.TextField('(hr)')
>     body_text_en = models.TextField('(en)')
>
>     def __unicode__(self):
>         return self.title_hr
>
>     class Meta:
>         verbose_name = "Aktualno"
>         verbose_name_plural = "Aktualni"
>         ordering = ['-published']
>
> what could be the problem?

--

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.




style guide/autoformatter/linter for Django templates?

2009-11-27 Thread Steve Howell
I am wondering if there is a style guide anywhere for writing Django
templates.  Also, are there programs to automatically format your
templates...to indent block tags, for example?  I know there are
autoformatters for HTML, but I am not aware of any tools that handle
Django tags.  Also, it would be nice to have a command line tool that
detected unbalanced tags before rendering occurs, knowing, of course,
that that task is a little complicated due to conditionals.

Here is example code that I would wish to reformat:

{% load i18n %}

{% if show_save %}{% endif %}
{% if show_delete_link %}{% trans "Delete" %}{% endif
%}
{% if show_save_as_new %}{%endif%}
{% if show_save_and_add_another %}{% endif %}
{% if show_save_and_continue %}{% endif %}


It seems like this would be more readable.  The if statements get
indented, except where they are inside an HTML tag.  Also the
statements inside the div get indented.

{% load i18n %}

{% if show_save %}

{% endif %}
{% if show_delete_link %}
{% trans "Delete" %}
{% endif %}
{% if show_save_as_new %}

{%endif%}
{% if show_save_and_add_another %}

{% endif %}
{% if show_save_and_continue %}

{% endif %}


--

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.




Cannot assign None, does not allow null values

2009-11-27 Thread onoxo
i get this error when i try to create new item in admin site.

here is my models.py
import datetime
from django.db import models
from tinymce import models as tinymce_models
from filebrowser.fields import FileBrowseField

class ItemWithMedia(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)

class Actual(ItemWithMedia):
published = models.DateField('Published')
title_hr = models.CharField('(hr)', max_length=200)
title_en = models.CharField('(en)', max_length=200)
body_text_hr = models.TextField('(hr)')
body_text_en = models.TextField('(en)')

def __unicode__(self):
return self.title_hr

class Meta:
verbose_name = "Aktualno"
verbose_name_plural = "Aktualni"
ordering = ['-published']

what could be the problem?

--

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: Setting a fontName in a style

2009-11-27 Thread Karen Tracey
On Fri, Nov 27, 2009 at 2:53 AM, adelaide_mike
wrote:

> One final question if I may (well I hope its the last).
>
> In my  standard report generating view I need to use Arial font (for
> example).
>
> I have studied the reportlab docs (Paragraphs chapter) for hours and
> tried all sorts of guesses as to how to do it.  Nothing I have tried
> works. My fault.  Now insightful enough.
>
> I have the following in my report generating view (which works a
> treat) and I am sure there is a simple alteration that will change the
> font.  But there is no example in the docs AFAIK.
>
> stylesheet = getSampleStyleSheet()
> normalstyle = stylesheet['Normal']
>
> Any offers?
>
>
I suspect you might get more help on purely reportlab questions from a
reportlab-centered mailing list.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Installation Problem on Mac OS Leopard

2009-11-27 Thread Christophe Pettus

On Nov 27, 2009, at 1:01 PM, Eric wrote:
> Why doesn't
> Mac have an easy way to install stuff.

I think we'll need a bit more information about the problem you're  
having; installing Django 1.1 on my Leopard MacBook Pro was entirely  
painless.  What errors are you getting at which steps?

--
-- Christophe Pettus
x...@thebuild.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-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: better error handling in templatetags?

2009-11-27 Thread KONTRA, Gergely
Thanks. With a one-line patch now I can debug templatetags :)))

Oh dear, target milestone is 1.2 I don't know why is it so slow.

Gergo
+-[ Gergely Kontra  ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+



On Fri, Nov 27, 2009 at 17:22, Karen Tracey  wrote:
> On Fri, Nov 27, 2009 at 5:58 AM, KONTRA, Gergely 
> wrote:
>>
>> Seems like you built your own project, and not using my zip.
>
> Yes, because just cut and pasting the template tag into my existing working
> test project seemed easier than downloading a zip file.  But even after
> retrieving the zip file and working from that (I had to remove the
> references to admin in the urls.py file since admin isn't in the
> INSTALLED_APPS setting) I still see the original traceback reflected in the
> message, so the difference between what you and I see is not due to
> differences in the projects.
>
>>
>>
>>
>> However, the result IS different.
>>
>> In my traceback I do not have any snippet referencing customtag.py.
>>
>> See my trace: http://dpaste.com/hold/125819/
>
> Hmm.  Your traceback shows you are using Python 2.6.  If I switch to that,
> then I see the behavior you are describing.  For some reason under Python
> 2.6 the exception value is being truncated at the end of the first line, so
> the original traceback is getting lost.
>
> There is a ticket open on the whole exception wrapping behavior of handing
> exceptions that occur during template rendering:
>
> http://code.djangoproject.com/ticket/11461
>
> I have not looked in detail at how things behave with the proposed patches,
> partly because since I've been seeing the original exception the wrapping
> behavior did not strike me as quite that bad.  Perhaps you can try out the
> patches, see if they improve things for your environment, and give some
> feedback.
>
> Karen
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.




Installation Problem on Mac OS Leopard

2009-11-27 Thread Eric
I'm trying to get Django installed and I can't figure out why its not
working. I purchased the book Djang 1.0 web site development and the
install instructions in the book are identical to instructions on the
Django site. It seems simple enough but for some reason I always catch
hell when it comes to these things. I did exactly what I was told to
do I ran the command (tar xzvf Django-1.1.1.tar.gz) from the terminal
and I got an error that said No Such Directory was found and some
other stuff.

I Googled info on how to install Django on Mac OS and was surprised to
find almost no straightforward way to install it. I really would like
to try Django but I can't even get this thing installed. Why doesn't
Mac have an easy way to install stuff. Can someone please help me
figure out what the problem is. 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: Issue when saving a model form

2009-11-27 Thread jul
thank you.
Excluding city from the ModelForm seems to work as well...

class AddRestaurantForm(ModelForm):

rating = forms.IntegerField(widget=forms.Select(choices =
RATING_CHOICE), required=False)
city = forms.CharField(max_length=100)

class Meta:
model = Restaurant
exclude = ('slug', 'city')


On Nov 27, 9:10 pm, Steve Howell  wrote:
> I am not fully tracking to the problem here, but when it comes to
> overriding save() behavior on forms, I find the following helper to be
> handy:
>
> def build_instance_from_form(model_form):
>     instance = model_form.save(commit=False)
>     return instance
>
> Then in your view code do something like this:
>
>    restaurant = build_instance_from_form(form)
>    # fix up data like city
>    restaurant.save()
>
> This can help you avoid all the complexity of overriding save() on the
> form object and delegating to super(), etc., at least in some cases.

--

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: Issue when saving a model form

2009-11-27 Thread Steve Howell
I am not fully tracking to the problem here, but when it comes to
overriding save() behavior on forms, I find the following helper to be
handy:

def build_instance_from_form(model_form):
instance = model_form.save(commit=False)
return instance

Then in your view code do something like this:

   restaurant = build_instance_from_form(form)
   # fix up data like city
   restaurant.save()

This can help you avoid all the complexity of overriding save() on the
form object and delegating to super(), etc., at least in some cases.

--

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: admin for "regular" users - still a bad idea?

2009-11-27 Thread Count László de Almásy
On Nov 27, 12:30 am, Skylar Saveland 
wrote:
> ha, reading lists on mobile ... I didn't even see that you said that
> each user has their own table (still hard to see exactly how this is
> efficient/possible/done though).  

what do you mean? i just meant that in my database, sales transactions
are stored in multiple tables, one for each company or user, like

sales_company1
sales_company2

etc..

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Issue when saving a model form

2009-11-27 Thread jul
The problem is that city name is not unique.
Can I pass the city instance in the overrided AddRestaurantForm's save
method?
thank you

On Nov 27, 5:12 pm, Tim Valenta  wrote:
> Try overriding your AddRestaurantForm's "save" method:
>
>     def save(self, commit=True):
>         self.instance.city = get_object_or_404(City,
> name=self.instance.city)
>
>         # Finish by passing control back to the normal Django flow:
>         super(AddRestaurantForm, self).save(commit)
>
> I think that'd work.  Sometimes 'super' causes recursion errors in
> Django, so if that gives you problems, try calling the method all by
> itself:
>
>         # Finish by passing control back tot he normal Django flow:
>         forms.ModelForm.save(self, commit)
>
> Tim
>
> On Nov 27, 8:57 am, jul  wrote:
>
> > Previous post wasn't finished. Wrong key :(
> > Here's the complete one:
>
> > Hi,
>
> > I've got the ModelForm and Model shown below.
> > I'm overriding the 'city' field to get a CharField instead of a City
> > foreign key.
> > When saving the Restaurant instance, it returns ""Restaurant.city"
> > must be a "City" instance".
> > How can I save the Restaurant instance with the City instance got or
> > created before?
>
> > Thanks
>
> > def addRestaurant(request):
>
> >     if request.user.is_authenticated():
>
> >         if request.method == 'POST':
>
> >             form = AddRestaurantForm(request.POST)
>
> >             if form.is_valid():
>
> >                 geonameID = request.POST.get('city_geonameId','')
> >                 country = Country.objects.get(code=request.POST.get
> > ('city_countryCode',''))
> >                 city, created = City.objects.get_or_create
> > (geonameID=geonameID, country = country, name = form.cleaned_data
> > ['city'])
>
> >                 if created: #stuff
>
> >                 city.save()
>
> >                 new_restaurant = form.save
> > (commit=False)
> >                 new_restaurant.city = city
>
> > class AddRestaurantForm(ModelForm):
>
> >     rating = forms.IntegerField(widget=forms.Select(choices =
> > RATING_CHOICE), required=False)
> >     city = forms.CharField(max_length=100)
>
> >     class Meta:
> >         model = Restaurant
> >         exclude = ('slug')
>
> > class Restaurant(models.Model):
>
> >     name = models.CharField(max_length=100)
> >     country=models.ForeignKey(Country)
> >     city=models.ForeignKey(City)
> >     street=models.CharField(max_length=100)
> >     street_number=models.PositiveSmallIntegerField()
> >     phone_number=models.CharField(max_length=16, blank=True,
> > null=True)
> >     price_range=models.PositiveSmallIntegerField(blank=True,
> > null=True)
> >     category=models.ManyToManyField(Category, blank=True, null=True)
> >     tag=models.ManyToManyField(Tag, blank=True, null=True)
> >     slug = models.SlugField(unique=True)
>
> >     def get_absolute_url(self):
> >         return "/restaurant/%s/" % self.slug
>
> >     def __unicode__(self):
> >         return self.name
>
> >     def save(self):
> >         self.slug = slugify(self.name)
> >         super(Restaurant, self).save()

--

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: CSRF gone haywire

2009-11-27 Thread Tim Valenta
Okay... so here's the problem.

I've been using a template override for change_form.html to always
check the object-tools block and add things in there.  I tried to be
more modular about it, but it never seemed to work out quite right.
So I'm overriding the entire template on my own, and I must have
copied the template from admin-ui (where, as pointed out, and as I
knew already, admin-ui doesn't implement the CSRF system).
Consequently, my overridden template was working great, until I got
off of the admin-ui branch.  Everything started failing like crazy :)

Lesson to be learned: Don't accidentally copy a template from a
branch.


Also, I've figured out just now while rereading the reply I got, that
"AFAIK" must mean "as far as I know".  Please... can we not use
ridiculous short forms for a language that works better when not
profusely abbreviated?  That would have been a hundred times harder to
figure out if I were a not a native speaker of English.  I can handle
a few of those, like IMHO, but I can't say that I've come across
"AFAIK" often enough to compute that in record time.

Tim

On Nov 27, 10:22 am, Tim Valenta  wrote:
> > AFAIK admin uses CSRF by default in SVN version.
>
> I'm sorry, but I have no idea what that means.  What is "AFAIK"?
>
> I've read that page you've linked to, and I fail to see what I've done
> wrong (since I didn't explicitly *do* anything).
>
> Tim
>
> On Nov 27, 10:18 am, rebus_  wrote:
>
>
>
> > 2009/11/27 Tim Valenta :
>
> > > Has anybody else experienced a senseless failure of the dev trunk's
> > > CSRF verification?  Very suddenly this morning, Django won't let me
> > > change anything in my admin sites.  I didn't update my copy of the SVN
> > > trunk, but as soon as I took myself off of the admin-ui branch, it
> > > flipped out.
>
> > > Step by step, all I did was move my copy of the main trunk to
> > > "_django" instead of "django".  I then uncompressed the admin-ui
> > > branch to "django" as a replacement.  All was well.  There are some
> > > broken "Add new item" links in that branch, and I got sick of it not
> > > working.  So I moved my admin-ui trunk to "admin-ui" for safekeeping,
> > > and then put back my original copy of the main trunk.
>
> > > Everything seemed right and good in the world, but for some reason the
> > > changelist view wouldn't show any items in its list.  Every model
> > > suffered from the lack of display.  It was weird.  It showed a correct
> > > total number of items that *should* have been in the list, but no
> > > items were present.  The HTML was literally not there.
>
> > > And when I jump directly to a changeform page via the id I knew I was
> > > working with, the page would should up, but saving the model keeps
> > > triggering the CSRF error response.  I don't think the CSRF token is
> > > being rendered in the changeform.
>
> > > Has anybody else experienced this?  I seriously haven't touched my
> > > copy of the main trunk between my little adventure with the admin-ui
> > > branch.  For good measure, I updated the repository just now, and it
> > > didn't fix it.  I removed all of the .pyc files in the Django
> > > directory and my project home.
>
> > > I'm just totally at a loss for what happened.  I've dropped the
> > > database and rebuilt it... no luck.  I'm ready to swear that I didn't
> > > change anything at all, and I don't use the CSRF system explicitly, so
> > > it's not like I've got bad imports.
>
> > > Any help?
>
> > AFAIK admin uses CSRF by default in SVN version.
>
> >http://docs.djangoproject.com/en/dev/ref/contrib/csrf/

--

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: mixed Case Field names in the database columns

2009-11-27 Thread Tim Langeman
Thanks!

Don't know how I missed it in the docs.

-Tim

On Nov 27, 11:28 am, Karen Tracey  wrote:
> On Fri, Nov 27, 2009 at 9:26 AM, Tim Langeman wrote:
>
> > I know that there is a setting to configure the db_table in django,
> > but I haven't found any similar setting for the field names.
>
> There is one:
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#db-column
>
> Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: CSRF gone haywire

2009-11-27 Thread Tim Valenta
> AFAIK admin uses CSRF by default in SVN version.

I'm sorry, but I have no idea what that means.  What is "AFAIK"?

I've read that page you've linked to, and I fail to see what I've done
wrong (since I didn't explicitly *do* anything).

Tim

On Nov 27, 10:18 am, rebus_  wrote:
> 2009/11/27 Tim Valenta :
>
>
>
>
>
> > Has anybody else experienced a senseless failure of the dev trunk's
> > CSRF verification?  Very suddenly this morning, Django won't let me
> > change anything in my admin sites.  I didn't update my copy of the SVN
> > trunk, but as soon as I took myself off of the admin-ui branch, it
> > flipped out.
>
> > Step by step, all I did was move my copy of the main trunk to
> > "_django" instead of "django".  I then uncompressed the admin-ui
> > branch to "django" as a replacement.  All was well.  There are some
> > broken "Add new item" links in that branch, and I got sick of it not
> > working.  So I moved my admin-ui trunk to "admin-ui" for safekeeping,
> > and then put back my original copy of the main trunk.
>
> > Everything seemed right and good in the world, but for some reason the
> > changelist view wouldn't show any items in its list.  Every model
> > suffered from the lack of display.  It was weird.  It showed a correct
> > total number of items that *should* have been in the list, but no
> > items were present.  The HTML was literally not there.
>
> > And when I jump directly to a changeform page via the id I knew I was
> > working with, the page would should up, but saving the model keeps
> > triggering the CSRF error response.  I don't think the CSRF token is
> > being rendered in the changeform.
>
> > Has anybody else experienced this?  I seriously haven't touched my
> > copy of the main trunk between my little adventure with the admin-ui
> > branch.  For good measure, I updated the repository just now, and it
> > didn't fix it.  I removed all of the .pyc files in the Django
> > directory and my project home.
>
> > I'm just totally at a loss for what happened.  I've dropped the
> > database and rebuilt it... no luck.  I'm ready to swear that I didn't
> > change anything at all, and I don't use the CSRF system explicitly, so
> > it's not like I've got bad imports.
>
> > Any help?
>
> AFAIK admin uses CSRF by default in SVN version.
>
> http://docs.djangoproject.com/en/dev/ref/contrib/csrf/

--

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: CSRF gone haywire

2009-11-27 Thread rebus_
2009/11/27 Tim Valenta :
> Has anybody else experienced a senseless failure of the dev trunk's
> CSRF verification?  Very suddenly this morning, Django won't let me
> change anything in my admin sites.  I didn't update my copy of the SVN
> trunk, but as soon as I took myself off of the admin-ui branch, it
> flipped out.
>
> Step by step, all I did was move my copy of the main trunk to
> "_django" instead of "django".  I then uncompressed the admin-ui
> branch to "django" as a replacement.  All was well.  There are some
> broken "Add new item" links in that branch, and I got sick of it not
> working.  So I moved my admin-ui trunk to "admin-ui" for safekeeping,
> and then put back my original copy of the main trunk.
>
> Everything seemed right and good in the world, but for some reason the
> changelist view wouldn't show any items in its list.  Every model
> suffered from the lack of display.  It was weird.  It showed a correct
> total number of items that *should* have been in the list, but no
> items were present.  The HTML was literally not there.
>
> And when I jump directly to a changeform page via the id I knew I was
> working with, the page would should up, but saving the model keeps
> triggering the CSRF error response.  I don't think the CSRF token is
> being rendered in the changeform.
>
> Has anybody else experienced this?  I seriously haven't touched my
> copy of the main trunk between my little adventure with the admin-ui
> branch.  For good measure, I updated the repository just now, and it
> didn't fix it.  I removed all of the .pyc files in the Django
> directory and my project home.
>
> I'm just totally at a loss for what happened.  I've dropped the
> database and rebuilt it... no luck.  I'm ready to swear that I didn't
> change anything at all, and I don't use the CSRF system explicitly, so
> it's not like I've got bad imports.
>
> Any help?
>

AFAIK admin uses CSRF by default in SVN version.

http://docs.djangoproject.com/en/dev/ref/contrib/csrf/

--

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.




CSRF gone haywire

2009-11-27 Thread Tim Valenta
Has anybody else experienced a senseless failure of the dev trunk's
CSRF verification?  Very suddenly this morning, Django won't let me
change anything in my admin sites.  I didn't update my copy of the SVN
trunk, but as soon as I took myself off of the admin-ui branch, it
flipped out.

Step by step, all I did was move my copy of the main trunk to
"_django" instead of "django".  I then uncompressed the admin-ui
branch to "django" as a replacement.  All was well.  There are some
broken "Add new item" links in that branch, and I got sick of it not
working.  So I moved my admin-ui trunk to "admin-ui" for safekeeping,
and then put back my original copy of the main trunk.

Everything seemed right and good in the world, but for some reason the
changelist view wouldn't show any items in its list.  Every model
suffered from the lack of display.  It was weird.  It showed a correct
total number of items that *should* have been in the list, but no
items were present.  The HTML was literally not there.

And when I jump directly to a changeform page via the id I knew I was
working with, the page would should up, but saving the model keeps
triggering the CSRF error response.  I don't think the CSRF token is
being rendered in the changeform.

Has anybody else experienced this?  I seriously haven't touched my
copy of the main trunk between my little adventure with the admin-ui
branch.  For good measure, I updated the repository just now, and it
didn't fix it.  I removed all of the .pyc files in the Django
directory and my project home.

I'm just totally at a loss for what happened.  I've dropped the
database and rebuilt it... no luck.  I'm ready to swear that I didn't
change anything at all, and I don't use the CSRF system explicitly, so
it's not like I've got bad imports.

Any help?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Django + Cherokee Web Server

2009-11-27 Thread hcarvalhoalves
On Nov 27, 5:56 am, Jarek Zgoda  wrote:
> Wiadomo¶æ napisana w dniu 2009-11-27, o godz. 00:31, przez  
> hcarvalhoalves:
>
> > I'm able to configure Cherokee to run my Django project correctly,
> > using the included wizard. The problem is, if an exception is thrown,
> > Cherokee just shows a "Unhandled Exception" page. I figured out that
> > if I run fcgi with debug=true, then I get a stacktrace from Flup, but
> > I wanted the default Django behaviour (showing debug pages when
> > DEBUG=TRUE on settings.py), similar to Apache or the development
> > server.
>
> This is not the response from web server, nor Django - this page is  
> served by Flup. This indicates the error at the stage of loading  
> Django machinery (eg. some problem with settings.py) and can not be  
> passed to Django's error handling because Django is simply not yet  
> loaded or not initialized properly. The only possible way to get any  
> debugging information is to turn on FastCGI debug.
>
> --
> Artificial intelligence stands no chance against natural stupidity
>
> Jarek Zgoda, R, Redefine
> jarek.zg...@redefine.pl

I understand it's a debug page from Flup, but it shouldn't be: the
exception is not caused by settings or anything, in fact, it's an
IOError exception thrown because my view tries to access some file
that doesn't exist. But with the development server, I get the
stacktrace with Django's debug page for this same case. So I was
wondering why now the exception is going up one layer and getting
caught by Flup instead.

--

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: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-27 Thread Andy McKay
On 09-11-27 4:41 AM, Allen wrote:
> Dear Bruno
>
> Great to hear that there are other ZOPE users among us.

More than you might think ;)

> When I work with ZOPE I code with dtml. I only found out about ZPT
> when I quiz ZOPE and never got familiar with it afterwords. The first
> thing they teach you when working with ZOPE is to combine segment of
> web pages with. With this I could type use
> some page with other tags or javascript/css and it will all render
> normally.

The include tag will include a chunk of another template and is a simple 
way include a HTML snippet for re-use:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#include

> I want to create a application that uses minimal html files. At the
> present stage of development, coded everything into one html and save
> all the static data into the database.
>
> I want to know about re-rendering a django tag/javascript/css is
> because I want to allow my users to use a web interface to type in
> their contents and custom tag that I created and save it back to the
> database.

So users should be typing in some HTML, that becomes part of a model and 
you then render the model back out.

As for the custom tag you can compile that back out like this:

http://docs.djangoproject.com/en/dev/ref/templates/api/#compiling-a-string

> If everything work accordingly, the custom tag will activate and put
> javascript/googleMap api onto the page and display a google map. But
> sadly it didn't gone according to plan and instead the page only
> displayed the tag as if it was just text.

To be honest this is one of the things I did in my first or second Zope 
project which seems about 4 bazillion years ago. Users could enter these 
custom tags into the HTML area and magic would happen. Sadly it didn't 
work out very well.

I would recommend a simple "add map to this page" button myself that 
twiddles a model attribute.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/
   Whistler conference: http://clearwind.ca/djangoski/

--

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: mixed Case Field names in the database columns

2009-11-27 Thread Karen Tracey
On Fri, Nov 27, 2009 at 9:26 AM, Tim Langeman wrote:

> I know that there is a setting to configure the db_table in django,
> but I haven't found any similar setting for the field names.
>

There is one:

http://docs.djangoproject.com/en/dev/ref/models/fields/#db-column

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Best UI for letting users select an item from a large selection of records?

2009-11-27 Thread David De La Harpe Golden
Stodge wrote:
> Thanks. I have the DataTables plugin working so I can filter my
> records. Now I just need to work out how to select specific ones from
> the table and work with them.
> 

Well, that depends a bit on what you want. if you, say, used javascript
 to directly populate a field in a html form when the user clicks on a
row in the datatable, you're pretty firmly tied to functioning
javascript, but it should be straightforward enough.
http://www.datatables.net/examples/example_select_single_row.html

One thing to consider could be actual click-through html links on each
row in the table that go to a small helper view taking the ticket and
relevant requirement as parameters that performs the desired
association, possibly after prompting for confirmation, then redirect
back to the main page.  At first glance, that might seem unpleasant,
because the user apparently navigates away - However once you have got
that basic interaction working, you can go back and use jquery to
intercept clicking the link and make the request in an ajax manner so
that the user doesn't navigate away from the main page.  Django has
request.is_ajax() you can use in the helper view to detect and respond
appropriately to ajax requests from jquery.   This approach has the
advantage of progressive enhancement (or graceful degradation) like
datatables itself - the ui doesn't become unusable just because
javascript is disabled, it just gets clunkier.  It also means you can
focus on getting something working , then worry about javascript
wierdness.  The ticket object also kinda has to already exist for this
approach to be simple, but you can have separate "ticket add" and
"ticket edit" views with the former only asking for a subset of
essential fields, say.














--

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: better error handling in templatetags?

2009-11-27 Thread Karen Tracey
On Fri, Nov 27, 2009 at 5:58 AM, KONTRA, Gergely wrote:

> Seems like you built your own project, and not using my zip.
>

Yes, because just cut and pasting the template tag into my existing working
test project seemed easier than downloading a zip file.  But even after
retrieving the zip file and working from that (I had to remove the
references to admin in the urls.py file since admin isn't in the
INSTALLED_APPS setting) I still see the original traceback reflected in the
message, so the difference between what you and I see is not due to
differences in the projects.


>

However, the result IS different.
>
> In my traceback I do not have any snippet referencing customtag.py.
>
> See my trace: http://dpaste.com/hold/125819/
>

Hmm.  Your traceback shows you are using Python 2.6.  If I switch to that,
then I see the behavior you are describing.  For some reason under Python
2.6 the exception value is being truncated at the end of the first line, so
the original traceback is getting lost.

There is a ticket open on the whole exception wrapping behavior of handing
exceptions that occur during template rendering:

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

I have not looked in detail at how things behave with the proposed patches,
partly because since I've been seeing the original exception the wrapping
behavior did not strike me as quite that bad.  Perhaps you can try out the
patches, see if they improve things for your environment, and give some
feedback.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Issue when saving a model form

2009-11-27 Thread Tim Valenta
Try overriding your AddRestaurantForm's "save" method:

def save(self, commit=True):
self.instance.city = get_object_or_404(City,
name=self.instance.city)

# Finish by passing control back to the normal Django flow:
super(AddRestaurantForm, self).save(commit)

I think that'd work.  Sometimes 'super' causes recursion errors in
Django, so if that gives you problems, try calling the method all by
itself:

# Finish by passing control back tot he normal Django flow:
forms.ModelForm.save(self, commit)

Tim

On Nov 27, 8:57 am, jul  wrote:
> Previous post wasn't finished. Wrong key :(
> Here's the complete one:
>
> Hi,
>
> I've got the ModelForm and Model shown below.
> I'm overriding the 'city' field to get a CharField instead of a City
> foreign key.
> When saving the Restaurant instance, it returns ""Restaurant.city"
> must be a "City" instance".
> How can I save the Restaurant instance with the City instance got or
> created before?
>
> Thanks
>
> def addRestaurant(request):
>
>     if request.user.is_authenticated():
>
>         if request.method == 'POST':
>
>             form = AddRestaurantForm(request.POST)
>
>             if form.is_valid():
>
>                 geonameID = request.POST.get('city_geonameId','')
>                 country = Country.objects.get(code=request.POST.get
> ('city_countryCode',''))
>                 city, created = City.objects.get_or_create
> (geonameID=geonameID, country = country, name = form.cleaned_data
> ['city'])
>
>                 if created: #stuff
>
>                 city.save()
>
>                 new_restaurant = form.save
> (commit=False)
>                 new_restaurant.city = city
>
> class AddRestaurantForm(ModelForm):
>
>     rating = forms.IntegerField(widget=forms.Select(choices =
> RATING_CHOICE), required=False)
>     city = forms.CharField(max_length=100)
>
>     class Meta:
>         model = Restaurant
>         exclude = ('slug')
>
> class Restaurant(models.Model):
>
>     name = models.CharField(max_length=100)
>     country=models.ForeignKey(Country)
>     city=models.ForeignKey(City)
>     street=models.CharField(max_length=100)
>     street_number=models.PositiveSmallIntegerField()
>     phone_number=models.CharField(max_length=16, blank=True,
> null=True)
>     price_range=models.PositiveSmallIntegerField(blank=True,
> null=True)
>     category=models.ManyToManyField(Category, blank=True, null=True)
>     tag=models.ManyToManyField(Tag, blank=True, null=True)
>     slug = models.SlugField(unique=True)
>
>     def get_absolute_url(self):
>         return "/restaurant/%s/" % self.slug
>
>     def __unicode__(self):
>         return self.name
>
>     def save(self):
>         self.slug = slugify(self.name)
>         super(Restaurant, self).save()

--

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: add permission by name instead of number

2009-11-27 Thread Tim Valenta
You can expand your .add() statement slightly, by passing it an object
instead of an id:

request.user.user_permissions.add(Permission.objects.get(name='some
permission name'))

You could alternatively do a lookup with the "codename='some_name'"
instead of the human-readable name.  The codename is arguably less
prone to change than the straight "name" parameter.

Just be sure to import the Permission model.  It in
django.contrib.auth.models

Tim

On Nov 26, 2:59 am, Adonis  wrote:
> Hi,
>
> I have been going through the permission documentation and i know i
> can assign users with permissions like this,
>
> *
> request.user.user_permissions.add(1)
> *
>
> But having 100 or more permissions i find this method a bit weird. Is
> not there a way to say,
>
> *
> request.user.user_permissions.add('auth.delete_permission') or what i
> found in an other post,
> *
>
> *
> def get_permission_object(perm_label):
>     from django.contrib.contenttypes.models import ContentType
>     from django.contrib.auth.models import Permission
>     app_label,perm_code_name = perm_label.split('.')
>     content_type = ContentType.objects.get(app_label=app_label)
>     perm = Permission.objects.get
> (content_type=content_type,codename=perm_code_name)
>     return perm
>
> def add_perm_to_user(user,perm_label):
>     user.user_permissions.add(get_permission_object(perm_label))
>     user.save()
>     return user
> *
>
> Any suggestions?
> 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-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: distinct related objects

2009-11-27 Thread Tim Valenta
It looks like the problem is that you're trying to group by
Technology, but your queryset is in Projects.  You could experiment
with the "regroup" template tag
( http://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup
)

It's a little hard to understand at first, but I think it's pretty
much what you're trying to do.  You would be able to remove the
".distinct" part of your query because dictionary keys are already
can't be doubled.

Hope that helps.

Tim

On Nov 26, 7:04 am, andreas schmid  wrote:
> hi,
>
> i have a question about retrieving related objects avoiding double entries.
> actually i have 3 models:
>     topics
>     projects
>     technologies
>
> the projects model has foreignkeys to topics and technologies. i have a
> view for the topic detail like this:
>
>     def topic_detail(request, slug):
>         topic = get_object_or_404(Topic, slug=slug)
>         return object_list(request,
>                            queryset=topic.project_set.all(),
>                            paginate_by=20,
>                            template_name='FSlabs/topic_detail.html',
>                            extra_context={ 'topic': topic })
>
> in the template i can loop trough the projects and  get those  assigned
> to this topic.
> but im having problems to retrieve the technologies used by those
> projects without having double entries.
>
> i tried this in the template with a list for every project
> assigned...which of course is not what i want:
>
>     {% for project in object_list  %}
>             {% for technology in project.technologies.distinct %}
>                 {{
>     technology.title }}
>                 {% if forloop.last %}{% else %}
>                 {% ifequal forloop.revcounter0 1 %}and {% else %}, {%
>     endifequal %}
>                 {% endif %}
>             {% endfor %}
>         {% endfor %}
>
> can somebody point me to the right way to get what i need?
>
> thx

--

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.




Issue when saving a model form

2009-11-27 Thread jul
Previous post wasn't finished. Wrong key :(
Here's the complete one:


Hi,

I've got the ModelForm and Model shown below.
I'm overriding the 'city' field to get a CharField instead of a City
foreign key.
When saving the Restaurant instance, it returns ""Restaurant.city"
must be a "City" instance".
How can I save the Restaurant instance with the City instance got or
created before?

Thanks

def addRestaurant(request):

if request.user.is_authenticated():

if request.method == 'POST':

form = AddRestaurantForm(request.POST)

if form.is_valid():

geonameID = request.POST.get('city_geonameId','')
country = Country.objects.get(code=request.POST.get
('city_countryCode',''))
city, created = City.objects.get_or_create
(geonameID=geonameID, country = country, name = form.cleaned_data
['city'])

if created: #stuff

city.save()

new_restaurant = form.save
(commit=False)
new_restaurant.city = city




class AddRestaurantForm(ModelForm):

rating = forms.IntegerField(widget=forms.Select(choices =
RATING_CHOICE), required=False)
city = forms.CharField(max_length=100)

class Meta:
model = Restaurant
exclude = ('slug')

class Restaurant(models.Model):

name = models.CharField(max_length=100)
country=models.ForeignKey(Country)
city=models.ForeignKey(City)
street=models.CharField(max_length=100)
street_number=models.PositiveSmallIntegerField()
phone_number=models.CharField(max_length=16, blank=True,
null=True)
price_range=models.PositiveSmallIntegerField(blank=True,
null=True)
category=models.ManyToManyField(Category, blank=True, null=True)
tag=models.ManyToManyField(Tag, blank=True, null=True)
slug = models.SlugField(unique=True)

def get_absolute_url(self):
return "/restaurant/%s/" % self.slug

def __unicode__(self):
return self.name

def save(self):
self.slug = slugify(self.name)
super(Restaurant, self).save()

--

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: How can I change the values of select options created by a ModelForm?

2009-11-27 Thread Tim Valenta
You could tell Django to designate the 'code' field as the primary
key, which will automatically make it unique.  Any forms will then be
forced to identify by the code, rather than some numeric id:

class Country(models.Model):
code = models.CharField(max_length=5, primary_key=True)
name = models.CharField(max_length=100, unique=True)

Hope that helps!  There is another way to do it as well, but I opted
to keep it simple.

Tim

On Nov 26, 10:28 am, jul  wrote:
> hi,
>
> I'm generating, using ModelForm, a form from a Restaurant model, which
> has a Country field.
> Country has a 'code' and a 'name' fields.
> When the form is created in my template, the values of the select
> options are the Country ids. How can I replace them by the Country
> 'code' values. Is it possible to choose which field is used as the
> value by overriding the Country field in the ModelForm?
>
> thanks
>
> I have that:
>
> Country:  id="id_country">
> -
> Andorra
> United Arab Emirates
> Afghanistan
>
> and I want that:
>
> Country:  id="id_country">
> -
> Andorra
> United Arab Emirates
> Afghanistan
>
> Models and ModelForm:
>
> class Country(models.Model):
>     code = models.CharField(max_length=5, unique=True)
>     name = models.CharField(max_length=100, unique=True)
>
>     class Meta:
>         verbose_name_plural = 'Countries'
>
>     def __unicode__(self):
>         return self.name
>
> class Restaurant(models.Model):
>
>     name = models.CharField(max_length=100)
>     country=models.ForeignKey(Country)
>     city=models.ForeignKey(City)
>     street=models.CharField(max_length=100)
>     street_number=models.PositiveSmallIntegerField()
>     phone_number=models.CharField(max_length=16, blank=True,
> null=True)
>     price_range=models.PositiveSmallIntegerField(blank=True,
> null=True)
>     category=models.ManyToManyField(Category, blank=True,
> null=True)
>     tag=models.ManyToManyField(Tag, blank=True, null=True)
>     slug = models.SlugField(unique=True)
>
>     def get_absolute_url(self):
>         return "/restaurant/%s/" % self.slug
>
>     def __unicode__(self):
>         return self.name
>
>     def save(self):
>         self.slug = slugify(self.name)
>         super(Restaurant, self).save()
>
> class AddRestaurantForm(ModelForm):
>
>     class Meta:
>         model = Restaurant
>         exclude = ('slug')

--

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.




Issue when saving a model form

2009-11-27 Thread jul
Hi,

I've got the ModelForm and Model shown below.
I'm overriding the 'city' field to get a CharField instead of a City
foreign key.

def addRestaurant(request):

if request.user.is_authenticated():

if request.method == 'POST':

form = AddRestaurantForm(request.POST)

if form.is_valid():

geonameID = request.POST.get('city_geonameId','')
country = Country.objects.get(code=request.POST.get
('city_countryCode',''))
city, created = City.objects.get_or_create
(geonameID=geonameID, country = country, name = form.cleaned_data
['city'])

if created:





print "hello1"
city.save()



class AddRestaurantForm(ModelForm):

rating = forms.IntegerField(widget=forms.Select(choices =
RATING_CHOICE), required=False)
city = forms.CharField(max_length=100)

class Meta:
model = Restaurant
exclude = ('slug')




class Restaurant(models.Model):

name = models.CharField(max_length=100)
country=models.ForeignKey(Country)
city=models.ForeignKey(City)
street=models.CharField(max_length=100)
street_number=models.PositiveSmallIntegerField()
phone_number=models.CharField(max_length=16, blank=True,
null=True)
price_range=models.PositiveSmallIntegerField(blank=True,
null=True)
category=models.ManyToManyField(Category, blank=True, null=True)
tag=models.ManyToManyField(Tag, blank=True, null=True)
slug = models.SlugField(unique=True)

def get_absolute_url(self):
return "/restaurant/%s/" % self.slug

def __unicode__(self):
return self.name

def save(self):
self.slug = slugify(self.name)
super(Restaurant, self).save()

--

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: better error handling in templatetags?

2009-11-27 Thread Tim Valenta
spite* us all.

Sorry :)

On Nov 27, 8:27 am, Tim Valenta  wrote:
> Django is forced to catch your errors, and then bubble them back up to
> you.  If you notice, none of the traceback lines are even in your
> code-- it's all in Python libs or an Django code.  The issue is that
> you're not seeing raw exceptions, but instead you're seeing reproduced
> exceptions.
>
> I agree that template tags are had to debug, especially when it's a
> big complex tag that goes wrong all of the sudden.  However, don't
> forget that it's just a Python object or method, just why not fire up
> the shell and import it, testing it out?  Step through it with input
> that you *know* you're getting, and use the Django modules to create
> dummy contexts if needed (although you could probably get away with
> just Python dict objects, since the template rendering engine won't
> actually be involved).
>
> Fixing the reporting would be amazingly welcome by many of us, but
> it's not like it's a simple matter of printing a single debug variable
> that accidentally got omitted.  I don't know enough about how Django
> bubbles exceptions, so I can't say much more on the subject, but it's
> clear to me that it's not something that they're doing on purpose to
> spit us all.
>
> Tim
>
> On Nov 27, 3:58 am, "KONTRA, Gergely"  wrote:
>
>
>
> > Seems like you built your own project, and not using my zip.
>
> > However, the result IS different.
>
> > In my traceback I do not have any snippet referencing customtag.py.
>
> > See my trace:http://dpaste.com/hold/125819/
>
> > thanks
> > Gergo
> > +-[ Gergely Kontra  ]--+
> > |   |
> > | Mobile:(+36 20)356 9656   |
> > |   |
> > +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
>
> > On Fri, Nov 27, 2009 at 04:38, Karen Tracey  wrote:
> > > On Thu, Nov 26, 2009 at 6:02 PM, KONTRA, Gergely 
> > > wrote:
>
> > >> My problem is the error handling of django in templatetags, not the
> > >> specific dummy error, which I programmed:
>
> > >> @register.simple_tag
> > >> def current_time():
> > >>        1/0
> > >>        return unicode(datetime.datetime.now())
>
> > >> What annoys me, that you cannot find the line number of the error,
> > >> just a message, that somewhere there is an error rendering the
> > >> current_time tag.
>
> > > With DEBUG=True, TEMPLATE_DEBUG=DEBUG, I get a TemplateSyntaxError debug
> > > page with exception value:
>
> > > Caught an exception while rendering: integer division or modulo by zero
>
> > > Original Traceback (most recent call last):
> > >   File "d:\u\kmt\django\trunk\django\template\debug.py", line 71, in
> > > render_node
> > >     result = node.render(context)
> > >   File "d:\u\kmt\django\trunk\django\template\__init__.py", line 909, in
> > > render
> > >     return func(*resolved_vars)
> > >   File "D:\u\kmt\software\web\playground\ttt\templatetags\tstuff.py", line
> > > 6, in current_time
> > >     1/0
> > > ZeroDivisionError: integer division or modulo by zero
>
> > > So I am seeing the line number of the error reported.  It's (somewhat
> > > annoyingly) not actually in the traceback portion of the page, but it is 
> > > on
> > > the page.  Are you seeing something different?
>
> > > Karen
>
> > > --
>
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-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: better error handling in templatetags?

2009-11-27 Thread Tim Valenta
Django is forced to catch your errors, and then bubble them back up to
you.  If you notice, none of the traceback lines are even in your
code-- it's all in Python libs or an Django code.  The issue is that
you're not seeing raw exceptions, but instead you're seeing reproduced
exceptions.

I agree that template tags are had to debug, especially when it's a
big complex tag that goes wrong all of the sudden.  However, don't
forget that it's just a Python object or method, just why not fire up
the shell and import it, testing it out?  Step through it with input
that you *know* you're getting, and use the Django modules to create
dummy contexts if needed (although you could probably get away with
just Python dict objects, since the template rendering engine won't
actually be involved).

Fixing the reporting would be amazingly welcome by many of us, but
it's not like it's a simple matter of printing a single debug variable
that accidentally got omitted.  I don't know enough about how Django
bubbles exceptions, so I can't say much more on the subject, but it's
clear to me that it's not something that they're doing on purpose to
spit us all.

Tim

On Nov 27, 3:58 am, "KONTRA, Gergely"  wrote:
> Seems like you built your own project, and not using my zip.
>
> However, the result IS different.
>
> In my traceback I do not have any snippet referencing customtag.py.
>
> See my trace:http://dpaste.com/hold/125819/
>
> thanks
> Gergo
> +-[ Gergely Kontra  ]--+
> |   |
> | Mobile:(+36 20)356 9656   |
> |   |
> +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
>
>
>
> On Fri, Nov 27, 2009 at 04:38, Karen Tracey  wrote:
> > On Thu, Nov 26, 2009 at 6:02 PM, KONTRA, Gergely 
> > wrote:
>
> >> My problem is the error handling of django in templatetags, not the
> >> specific dummy error, which I programmed:
>
> >> @register.simple_tag
> >> def current_time():
> >>        1/0
> >>        return unicode(datetime.datetime.now())
>
> >> What annoys me, that you cannot find the line number of the error,
> >> just a message, that somewhere there is an error rendering the
> >> current_time tag.
>
> > With DEBUG=True, TEMPLATE_DEBUG=DEBUG, I get a TemplateSyntaxError debug
> > page with exception value:
>
> > Caught an exception while rendering: integer division or modulo by zero
>
> > Original Traceback (most recent call last):
> >   File "d:\u\kmt\django\trunk\django\template\debug.py", line 71, in
> > render_node
> >     result = node.render(context)
> >   File "d:\u\kmt\django\trunk\django\template\__init__.py", line 909, in
> > render
> >     return func(*resolved_vars)
> >   File "D:\u\kmt\software\web\playground\ttt\templatetags\tstuff.py", line
> > 6, in current_time
> >     1/0
> > ZeroDivisionError: integer division or modulo by zero
>
> > So I am seeing the line number of the error reported.  It's (somewhat
> > annoyingly) not actually in the traceback portion of the page, but it is on
> > the page.  Are you seeing something different?
>
> > Karen
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-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.




mixed Case Field names in the database columns

2009-11-27 Thread Tim Langeman
I'm trying to query my Postgres database through an ODBC data source
in Windows (Excel & Access).

I've found that Excel does not like mixed case field names and the
recommendation for linked SQL servers is to use all lower case names.
I assume this also applies to other types of connections with the
windows ODBC driver.
  
http://www.postgresonline.com/journal/index.php?/archives/46-Setting-up-PostgreSQL-as-a-Linked-Server-in-Microsoft-SQL-Server-64-bit.html

I know that there is a setting to configure the db_table in django,
but I haven't found any similar setting for the field names.  What
approach would you recommend to address this problem.  It seems that
my options are:

1) rename all the fields to lower case in django and in the db
2) find a way to continue to use mixed case in my application but
change the tables
3) find a way to get the ODBC driver to handle mixed cases so that
everything can stay mixed case

-Tim Langeman
Akron, PA

--

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.




RuntimeError: class.__dict__ not accessible in restricted mode

2009-11-27 Thread Gabriel Rossetti
Hello everyone,

I keep on getting this error with mod_python:

*RuntimeError: class.__dict__ not accessible in restricted mode

*I read that I have to set :

PythonInterpreter main_interpreter

in my httpd.conf, but this doesn't seam to work. Here is my httpd.conf :



 ServerName srv1.myapp1.com

 
  SetHandler mod_python
  PythonInterpreter main_interpreter
  PythonHandler django.core.handlers.modpython
  PythonDebug Off
  PythonAutoReload Off
  SetEnv DJANGO_SETTINGS_MODULE myapp1.settings
  PythonPath "['/var/www/mysite1', 
'/var/lib/python-support/python2.5/django'] + sys.path"
 





 ServerName srv2.myapp2.com

 
 SetHandler mod_python
 PythonInterpreter main_interpreter2
 PythonHandler django.core.handlers.modpython
 PythonDebug Off
 PythonAutoReload Off
 SetEnv DJANGO_SETTINGS_MODULE myapp2.settings
 PythonPath "['/var/www/mysite2', 
'/var/lib/python-support/python2.5/django'] + sys.path"
 



does someone get this? Thank you, Gabriel

--

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: applying a patch

2009-11-27 Thread paulh
Thanks to everybody who replied, in the end I downloaded git, cloned
the django repository with with git clone and applied the patch with
git apply and it all worked well.

Paul Hide

On 26 Nov, 12:26, Tim Chase  wrote:
> rebus_ wrote:
> >> diff --git a/django/contrib/admin/media/js/admin/
> >> RelatedObjectLookups.js b/django/contrib/admin/media/js/admin/
> >> RelatedObjectLookups.js
> >> index 1bc78f8..3941752 100644
> >> --- a/django/contrib/admin/media/js/admin/RelatedObjectLookups.js
> >> +++ b/django/contrib/admin/media/js/admin/RelatedObjectLookups.js
>
> >> so I guess that explains it, but I thought django used used svn!
>
> > Django uses SVN as the official repository, but AFAIK git is often
> > used for development of new features etc cos it is not centralized and
> > it is very simple to create branches in it and so on.
>
> > For patching on windows you could use either gnuwin32 [1] or unxutils
> > [2] for comand line, both of which should be able to usepatchfiles
> > produced by any diff (svn, git or just diff) like Tim said:
>
> >patch-p0 < /path/to/patch.diff
>
> TortoiseSVN has an option for "ApplyPatch" that should behave
> similarly.
>
> -tim

--

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: Best UI for letting users select an item from a large selection of records?

2009-11-27 Thread Margie Roginski
After much struggling on this same topic, I found that autocomplete
was by far better than a dropdown or a set of chained dropdowns.  I
looked at a variety of jquery autocomplete packages, and eventually
settled on this one, which has worked very well for me:

http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/

It is unfortunately maintained in a somewhat haphazard way (as you'll
see from the blog that that link takes you to).  But on firefox at
least, I find that the 1.1 verson works fine.  It has the nice feature
that the user can put in multiple entries.  For example, in my case, I
have an autocomplete field where teh user needs to be able to enter
one or more names of users, and this package allowed that whereas the
standard one on the jquery site only allowed you to enter one.

Margie

On Nov 26, 5:47 am, Stodge  wrote:
> I have a Ticket model that has a Requirement foreign key. The problem
> is, there could be hundreds of requirements. Offering the user a drop
> down combo box of requirements to choose from isn't the best option.
> So how would you let the user select one record from a large
> selection? What UI widget(s) would you use?
>
> I suppose I could create an auto-complete text box widget that offers
> a list of requirements that matches what they typed. But that's a lot
> of work for someone who doesn't know Javascript (though I do have
> JQuery plugged into my app) and I don't want to spend hours coding it
> to find out it's not the best solution. Any suggestions appreciated.
>
> Thanks

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Best UI for letting users select an item from a large selection of records?

2009-11-27 Thread Stodge
Thanks. I have the DataTables plugin working so I can filter my
records. Now I just need to work out how to select specific ones from
the table and work with them.

On Nov 26, 9:31 am, David De La Harpe Golden
 wrote:
> Stodge wrote:
> > Offering the user a drop
> > down combo box of requirements to choose from isn't the best option.
>
> Rant: combo box /means/ a text entry widget plus dropdown menu "combo".
>  For some reason web developers in particular seem prone to using it to
> mean a dropdown alone (html forms sadly lack built-in combo boxes, of
> course)http://en.wikipedia.org/wiki/Combo_box
>
> > I suppose I could create an auto-complete text box widget that offers
> > a list of requirements that matches what they typed. But that's a lot
> > of work for someone who doesn't know Javascript (though I do have
> > JQuery plugged into my app)
>
> If you're using jquery there are quite a few ready-made jquery plugins
> that mean you can make a combo box (for various ideas of what
> a combo box is or should be) quickly. Kinda one of the points of jquery
> is the large array of plugins, though with the usual problems of plugins
> - variable quality and design.
>
> Here's a couple of 
> examples:http://phone.witamean.net/sexy-combo/examples/index.htmlhttp://www.fairwaytech.com/Technology/FlexBoxDemo.aspx#demo8
> see the jquery plugins list:http://plugins.jquery.com/
> search for "combo" or "autocomplete" or "autosuggest".
>
> OTOH, a combo box might still be a cramped interface. One could
> e.g. present a filterable table with the likes of 
> dataTables.http://www.datatables.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.




extend queryset field lookups for time

2009-11-27 Thread Hinnack
Hi,

how would I extend the field lookup to get somethnng like this:

SELECT ... WHERE EXTRACT('hour' FROM pub_date) > 20
what is for MYSQL:
SELECT ... WHERE HOUR(pub_date) > 20
to get all entries where the timepart of pub_date is grater then 8pm


and how would I change the existing of YEAR, MONTH, DAY for > and <...

regards

-- Hinnack

--

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.




[no subject]

2009-11-27 Thread Nadae Ivar BADIO
Morning 
I'm novice in django and i want to install my apllication on my server 
production whos on ubuntu i mean install my aplli on apache and i have this 
error:
MOD_PYTHON ERROR

ProcessId:  3230
Interpreter:'127.0.1.1'

ServerName: '127.0.1.1'
DocumentRoot:   '/var/www'

URI:'/mysite'
Location:   '/mysite'
Directory:  None
Filename:   '/var/www/mysite'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in 
HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229, in 
_process_target
result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128, in 
_execute_target
result = object(arg)

  File "/var/lib/python-support/python2.6/django/core/handlers/modpython.py", 
line 228, in handler
return ModPythonHandler()(req)

  File "/var/lib/python-support/python2.6/django/core/handlers/modpython.py", 
line 191, in __call__
self.load_middleware()

  File "/var/lib/python-support/python2.6/django/core/handlers/base.py", line 
31, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "/var/lib/python-support/python2.6/django/conf/__init__.py", line 28, in 
__getattr__
self._import_settings()

  File "/var/lib/python-support/python2.6/django/conf/__init__.py", line 59, in 
_import_settings
self._target = Settings(settings_module)

  File "/var/lib/python-support/python2.6/django/conf/__init__.py", line 94, in 
__init__
raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does 
it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)

ImportError: Could not import settings 'mysite.settings' (Is it on sys.path? 
Does it have syntax errors?): No module named mysite.settings

--

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: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-27 Thread Allen
Dear Bruno

Great to hear that there are other ZOPE users among us.

When I work with ZOPE I code with dtml. I only found out about ZPT
when I quiz ZOPE and never got familiar with it afterwords. The first
thing they teach you when working with ZOPE is to combine segment of
web pages with . With this I could prepare
some page with other tags or javascript/css and it will all render
normally.

I was kind of disappointed that I didn't find any thing similar here
and page inheritance is still new to me so I didn't consider it first.

I want to create a application that uses minimal html files. At the
present stage of development, I coded everything into one html and
save all the static data into the database.

I want to know about re-rendering a django tag/javascript/css is
because I want to allow my users to use a web interface to input their
own contents and custom tag that I created and save it back to the
database.

If everything work accordingly, the custom tag will activate and put
javascript/googleMap api onto the page and display a google map. But
sadly it didn't gone according to plan and instead the page only
displayed the tag as if it was just text.

So.. does anyone have any idea how I could solve this problem?

Allen


On Nov 27, 6:06 pm, bruno desthuilliers
 wrote:
> On 27 nov, 09:35, Allen  wrote:
>
> > Dear Andy McKay
> > Thanks for the input and you're right, I shouldn't do it this way.
>
> > I use to use ZOPE for a couple of years and it has to abilities to
> > integrate multiple static webpages just by write a tag with the static
> > webpage filename similar to the filter tag.
>
> ZPT or dtml ? I've done my share of Zope / ZPT (and still do when
> someone points a gun at me), and from memory I don't see what you're
> talking about...
>
> > But I just started django
> > a month ago and I didn't see function of this sort except for page
> > inheritance.
>
> Well, there's an include tag, but if that's not what you're after, you
> can write your own cutom tag.
>
> > I have consider using page inheritance but I just not use to it.
>
> You should, definitly. Page inheritance work mostly like the "page
> macro" pattern in ZPT - except it's way cleaner.
>
> > That's why I place it in the database. This is just my temporary fix
> > for the time being and I know eventually I find a problem with this
> > way soon of later.
>
> Well, putting template code in the DB is not necessarily totally dumb
> - but you need to explicitely render it, which is not supported OOTB,
> so you either have to do it in the view or write some custom tag /
> filters to take care of the rendering.
>
> You'll find relevant doc here:
>
> http://docs.djangoproject.com/en/dev/ref/templates/api/#ref-templates...http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howt...

--

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: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-27 Thread Allen
Dear Bruno

Great to hear that there are other ZOPE users among us.

When I work with ZOPE I code with dtml. I only found out about ZPT
when I quiz ZOPE and never got familiar with it afterwords. The first
thing they teach you when working with ZOPE is to combine segment of
web pages with . With this I could prepare
some page with other tags or javascript/css and it will all render
normally.

I was kind of disappointed that I didn't find any thing similar here
and page inheritance is still new to me so I didn't consider
it first.

I want to create a application that uses minimal html files. At the
present stage of development, coded everything into one html and save
all the static data into the database.

I want to know about re-rendering a django tag/javascript/css is
because I want to allow my users to use a web interface to create
their own contents and with custom tag that I created and save it back
to the
database.

If everything work accordingly, the custom tag will activate and put
javascript/googleMap api onto the page and display a google map. But
sadly it didn't gone according to plan and the page only
displayed the tag as if it was just text.

So.. does anyone have any idea how I could solve this problem?

Allen



On Nov 27, 6:06 pm, bruno desthuilliers
 wrote:
> On 27 nov, 09:35, Allen  wrote:
>
> > Dear Andy McKay
> > Thanks for the input and you're right, I shouldn't do it this way.
>
> > I use to use ZOPE for a couple of years and it has to abilities to
> > integrate multiple static webpages just by write a tag with the static
> > webpage filename similar to the filter tag.
>
> ZPT or dtml ? I've done my share of Zope / ZPT (and still do when
> someone points a gun at me), and from memory I don't see what you're
> talking about...
>
> > But I just started django
> > a month ago and I didn't see function of this sort except for page
> > inheritance.
>
> Well, there's an include tag, but if that's not what you're after, you
> can write your own cutom tag.
>
> > I have consider using page inheritance but I just not use to it.
>
> You should, definitly. Page inheritance work mostly like the "page
> macro" pattern in ZPT - except it's way cleaner.
>
> > That's why I place it in the database. This is just my temporary fix
> > for the time being and I know eventually I find a problem with this
> > way soon of later.
>
> Well, putting template code in the DB is not necessarily totally dumb
> - but you need to explicitely render it, which is not supported OOTB,
> so you either have to do it in the view or write some custom tag /
> filters to take care of the rendering.
>
> You'll find relevant doc here:
>
> http://docs.djangoproject.com/en/dev/ref/templates/api/#ref-templates...http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howt...

--

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: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-27 Thread Allen
Dear Bruno

Great to hear that there are other ZOPE users among us.

When I work with ZOPE I code with dtml. I only found out about ZPT
when I quiz ZOPE and never got familiar with it afterwords. The first
thing they teach you when working with ZOPE is to combine segment of
web pages with . With this I could type use
some page with other tags or javascript/css and it will all render
normally.

I was kind of disappointed that I didn't find any thing similar here
and page inheritance is still new to me to adopt so I didn't consider
it first.

I want to create a application that uses minimal html files. At the
present stage of development, coded everything into one html and save
all the static data into the database.

I want to know about re-rendering a django tag/javascript/css is
because I want to allow my users to use a web interface to type in
their contents and custom tag that I created and save it back to the
database.

If everything work accordingly, the custom tag will activate and put
javascript/googleMap api onto the page and display a google map. But
sadly it didn't gone according to plan and instead the page only
displayed the tag as if it was just text.

So.. does anyone have any idea how I could solve this problem?

Allen



> > I use to use ZOPE for a couple of years and it has to abilities to
> > integrate multiple static webpages just by write a tag with the static
> > webpage filename similar to the filter tag.
>
> ZPT or dtml ? I've done my share of Zope / ZPT (and still do when
> someone points a gun at me), and from memory I don't see what you're
> talking about...
>
> > But I just started django
> > a month ago and I didn't see function of this sort except for page
> > inheritance.
>
> Well, there's an include tag, but if that's not what you're after, you
> can write your own cutom tag.
>
> > I have consider using page inheritance but I just not use to it.
>
> You should, definitly. Page inheritance work mostly like the "page
> macro" pattern in ZPT - except it's way cleaner.
>
> > That's why I place it in the database. This is just my temporary fix
> > for the time being and I know eventually I find a problem with this
> > way soon of later.
>
> Well, putting template code in the DB is not necessarily totally dumb
> - but you need to explicitely render it, which is not supported OOTB,
> so you either have to do it in the view or write some custom tag /
> filters to take care of the rendering.
>
> You'll find relevant doc here:
>
> http://docs.djangoproject.com/en/dev/ref/templates/api/#ref-templates...http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howt...

--

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.




Handling IntegrityError on transaction middleware commit

2009-11-27 Thread Ryan
I had an IntegrityError come up on transaction commit (using postgres)
today on a production site -- trying to insert an invalid foreign key
value (an admin deleted something she shouldn't have).  The problem
was that instead of emailing me the exception like usual, django
logged the exception to my apache (using mod_wsgi) error log and then
that apache process was semi-broken for about half and hour, refusing
to recognize session cookies or log anyone in, but also not throwing
up any exceptions either.

I realize that I should be validating my data before saving it, but
I'll admit I don't guard against every eventuality.  My question is,
should I be doing something in my code to prevent this kind of poor
exception handling, or should I file a bug against django?  I would
certainly prefer the whole server not to break when the transaction
commit fails for whatever reason -- it should rollback the transaction
and give a 500 error page.

Here's the middleware tuple from my settings.py:

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)

Any thoughts?  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: better error handling in templatetags?

2009-11-27 Thread KONTRA, Gergely
Seems like you built your own project, and not using my zip.

However, the result IS different.

In my traceback I do not have any snippet referencing customtag.py.

See my trace: http://dpaste.com/hold/125819/

thanks
Gergo
+-[ Gergely Kontra  ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+



On Fri, Nov 27, 2009 at 04:38, Karen Tracey  wrote:
> On Thu, Nov 26, 2009 at 6:02 PM, KONTRA, Gergely 
> wrote:
>>
>> My problem is the error handling of django in templatetags, not the
>> specific dummy error, which I programmed:
>>
>> @register.simple_tag
>> def current_time():
>>        1/0
>>        return unicode(datetime.datetime.now())
>>
>> What annoys me, that you cannot find the line number of the error,
>> just a message, that somewhere there is an error rendering the
>> current_time tag.
>>
>
> With DEBUG=True, TEMPLATE_DEBUG=DEBUG, I get a TemplateSyntaxError debug
> page with exception value:
>
> Caught an exception while rendering: integer division or modulo by zero
>
> Original Traceback (most recent call last):
>   File "d:\u\kmt\django\trunk\django\template\debug.py", line 71, in
> render_node
>     result = node.render(context)
>   File "d:\u\kmt\django\trunk\django\template\__init__.py", line 909, in
> render
>     return func(*resolved_vars)
>   File "D:\u\kmt\software\web\playground\ttt\templatetags\tstuff.py", line
> 6, in current_time
>     1/0
> ZeroDivisionError: integer division or modulo by zero
>
> So I am seeing the line number of the error reported.  It's (somewhat
> annoyingly) not actually in the traceback portion of the page, but it is on
> the page.  Are you seeing something different?
>
> Karen
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-27 Thread bruno desthuilliers


On 27 nov, 09:35, Allen  wrote:
> Dear Andy McKay
> Thanks for the input and you're right, I shouldn't do it this way.
>
> I use to use ZOPE for a couple of years and it has to abilities to
> integrate multiple static webpages just by write a tag with the static
> webpage filename similar to the filter tag.

ZPT or dtml ? I've done my share of Zope / ZPT (and still do when
someone points a gun at me), and from memory I don't see what you're
talking about...

> But I just started django
> a month ago and I didn't see function of this sort except for page
> inheritance.

Well, there's an include tag, but if that's not what you're after, you
can write your own cutom tag.

> I have consider using page inheritance but I just not use to it.

You should, definitly. Page inheritance work mostly like the "page
macro" pattern in ZPT - except it's way cleaner.

> That's why I place it in the database. This is just my temporary fix
> for the time being and I know eventually I find a problem with this
> way soon of later.

Well, putting template code in the DB is not necessarily totally dumb
- but you need to explicitely render it, which is not supported OOTB,
so you either have to do it in the view or write some custom tag /
filters to take care of the rendering.

You'll find relevant doc here:

http://docs.djangoproject.com/en/dev/ref/templates/api/#ref-templates-api
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags

--

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: Ajax with jquery, 2 load in the same event, work not OK on apache2 server...strange because work ok with runserver, on localhost

2009-11-27 Thread Tom Evans
On Fri, Nov 27, 2009 at 8:08 AM, NMarcu  wrote:

> Hello all,
>
>I have something like this:
>
> $( '#operators_list_div' ).html( '' ).load( '{% url
> add_save_view %}',{'action':'action',});
> $( '#address_list' ).html( '' ).load( '{% url add_save_view %}',
> {'action':'address_list',});
>
> In view I have like this, that don't work on:
>
> #list of availible address for controller
>ca_list = []
>ca_available = []
>ca = klass.objects.all()
>for i in ca:
>ca_list.append(i.id)
>for i in range(1,255):
>if i not in ca_list:
>ca_available.append(i)
>env['add_avail'] = ca_available
>
> First load add something in a table(klass modell). The second view
> just pass to view and do the code abouve. I need to check the datas
> from the table and make a list with availible id. If in first load add
> an id 3, afther the second load, I don't need 3, in the env
> ['add_avail']. This work ok, when run on localhost with django seerver
> (runserver), but, when I run project on other server, under apache2,
> the list: env['add_avail'], is the same like in first load, even if
> after the first load id is added. Somebody know what can be the
> problem?
>
>
Not really, you're not making much sense :o

However, when you run it from runserver, the server runs single
process/single thread, and when you run it with apache, it runs multi
process/multi thread. The former can only handle one request at a time, and
handles them in request order. The latter will process multiple requests
simulataneously.

Does that help?

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




database charset

2009-11-27 Thread Kresimir Tonkovic
Just an experience...

I created a database in mysql not caring much for charsets, and run
manage.py syncdb. All tables were created with the default charset
(iso-8892-1 swedish). Later I noticed my croatian chars were not
right, so I altered some tables and varchar fields to use utf8. This
worked well, so I made a small script to run these alter tables on all
tables/fields.

Next day I could not login to the admin - it complained that I had
cookies disabled. Googling this led me to a library conflict with php-
mhash, which I tried to solve but with no success. The servers error
log also complained about invalid padding in base64 encoded strings...
Much later I started backtracing all my steps and after I altered the
auth_session table back to iso-8859-1 things worked again.

Observations:

- If utf8 is the default in django, I think it would help if all
database operations were run with explicit charset options. I.e.
create table ( ... x varchar(100) charset utf8,...) charset utf8;
- It is not clear to me why changing the charset on auth_session would
break things. Keys and data are base64 encoded and use only ascii
anyway, so switching between iso-8859-1 and utf8 should change
nothing.

Hope this helps some poor soul in the future :-)

--
Krešimir Tonković
Multimodus d.o.o.
www.multimodus.hr

--

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: OT : SetHandler mod_python vs SetHandler python-program

2009-11-27 Thread Graham Dumpleton


On Nov 27, 8:21 pm, Gabriel Rossetti 
wrote:
> Hello everyone,
>
> this is a bit off-topic, in my apache2 httpd.conf, I see some poeple use
> "SetHandler mod_python" and others (as mentioned in the docs) use
> "SetHandler python-program", what is the difference?

Nothing. They both achieve the same thing.

>From memory earlier versions of mod_python had only 'python-program'.
Later version at some point also introduced ability to use
'mod_python'. I don't know the reasoning for that though.

Graham

--

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.




OT : SetHandler mod_python vs SetHandler python-program

2009-11-27 Thread Gabriel Rossetti
Hello everyone,

this is a bit off-topic, in my apache2 httpd.conf, I see some poeple use 
"SetHandler mod_python" and others (as mentioned in the docs) use 
"SetHandler python-program", what is the difference?

Thank you,
Gabriel

--

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: Write debug error to file

2009-11-27 Thread Gabriel Rossetti
No, I thought that was just for administrative stuff. I'll give that a 
try, thanks!

Gabriel

akonsu wrote:
> hello,
>
> if you set the admin email address and the necessary email parameters
> in your config file then django will send an email with all the
> details to the admin when an exception is thrown. would this be
> sufficient?
>
> konstantin
>
> On Nov 26, 11:15 am, Gabriel Rossetti 
> wrote:
>   
>> Hello everyone,
>>
>> I'd like to write the django error page (when debug == true) to a file
>> and return a page with that link instead of the actual page. The reason
>> I'd like to do this is to be able to debug a facebook app because fb
>> seams to filter/block the error page. Does anyone know how to do that?
>>
>> Thanks,
>> Gabriel
>> 
>
> --
>
> 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: Write debug error to file

2009-11-27 Thread Gabriel Rossetti
Cool, I'll have a look, I was looking for something like that for when 
my site is in production, thanks!

Gabriel

Andy McKay wrote:
> You should take a look at Arecibo which has been used by a few  
> Facebook apps for that very readson. It has full Django libraries and  
> if you don't use it a full example of how to use middleware to process  
> an error.
>
> http://areciboapp.com
>
> --
>Andy McKay
>www.clearwind.ca
>
> On 2009-11-26, at 8:15 AM, Gabriel Rossetti  
>  wrote:
>
>   
>> Hello everyone,
>>
>> I'd like to write the django error page (when debug == true) to a file
>> and return a page with that link instead of the actual page. The  
>> reason
>> I'd like to do this is to be able to debug a facebook app because fb
>> seams to filter/block the error page. Does anyone know how to do that?
>>
>> Thanks,
>> Gabriel
>>
>> --
>>
>> 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.
>
>
>   

--

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: Django-1.1.1 builtin Development WebServer crashes with a core dump

2009-11-27 Thread lbockhold
Hi Tim, thanks for your respond,

I am doing the tutorial that comes now to set up the admin page.

The browser does not open the webpage:
http://dexhh022.ham.de.eu.airbus.corp:1026/admin/
Browser: Respond : Server not found .. At the same time the
Development server just quits

Workaround:Is it possible to just set up production web server like
apache2 ?

Web Browser and Development server are on diffrent Machines!

But the development server just quits without an error message on the
console:
th1...@dexhh022: /do/pro/T/kpi/Scripts/django/mysite > python
manage.py runserver dexhh022.ham.de.eu.airbus.corp:1026
Validating models...
0 errors found

Django version 1.1.1, using settings 'mysite.settings'
Development server is running at http://dexhh022.ham.de.eu.airbus.corp:1026/
Quit the server with CONTROL-C.

-> core file



#


On 24 Nov., 22:22, Tim Valenta  wrote:
> It's not very clear what is happening.  If you start a brand new
> project, there won't be any URLs for you to visit yet.  It will most
> probably give you the error page, telling you that there is no URL
> matching the query.
>
> A better copy-and-paste would be what the browser is displaying.
>
> I hope I've understood properly,
>
> Tim
>
> On Nov 24, 10:24 am, lbockhold  wrote:
>
>
>
> > Hello users,
> > I am new to django, just installed Django-1.1.1.tar.gz
> > but:
>
> > Machine HPUX:
> > th...@dex: /home/th18bl > uname -a
> > HP-UX dex B.11.11 U 9000/785 4042425557 unlimited-user license
>
> > python:
> > th...@dex: /home/th18bl > python
> > ActivePython 2.6.2.2 (ActiveState Software Inc.) based on
> > Python 2.6.2 (r262:71600, Apr 21 2009, 15:06:28) [C] on hp-ux11
> > Type "help", "copyright", "credits" or "license" for more information.
> > dd
> > 1.django-admin.py startproject mysite "ok"
> > 2. python manage.py runserver "ok"
> >     Validating models ...
> >     0 errors found
> >     ...
> >     Quit the server ...
> > 3. But when I use a browser to go to that page - the Dev. Server just
> > quits and writes a big "core" file!
>
> > Thanks for help
>
> > Greetings Lars- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

--

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: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-27 Thread Allen
Dear Andy McKay
Thanks for the input and you're right, I shouldn't do it this way.

I use to use ZOPE for a couple of years and it has to abilities to
integrate multiple static webpages just by write a tag with the static
webpage filename similar to the filter tag. But I just started django
a month ago and I didn't see function of this sort except for page
inheritance.

I have consider using page inheritance but I just not use to it.
That's why I place it in the database. This is just my temporary fix
for the time being and I know eventually I find a problem with this
way soon of later.

But I still want to know if I can re-render a string with tag in it so
it will show up the right way.

Andy, can you redirect me to that doc page?

Allen





On Nov 27, 1:23 pm, Andy McKay  wrote:
> > Can anyone tell me how I can load the content and execute/render the
> > javascript, css styling, template tags/filters?
>
> You really shouldn't be doing this. Onestringis everything on your  page? You 
> can use the Template library to re-rendera template and  
> that's discussed in the templating docs - but I wonder why you are  doing 
> that in the first place.
>
>
>
> > Allen
>
> > --
>
> > 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.




Ajax with jquery, 2 load in the same event, work not OK on apache2 server...strange because work ok with runserver, on localhost

2009-11-27 Thread NMarcu
Hello all,

I have something like this:

$( '#operators_list_div' ).html( '' ).load( '{% url
add_save_view %}',{'action':'action',});
$( '#address_list' ).html( '' ).load( '{% url add_save_view %}',
{'action':'address_list',});

In view I have like this, that don't work on:

#list of availible address for controller
ca_list = []
ca_available = []
ca = klass.objects.all()
for i in ca:
ca_list.append(i.id)
for i in range(1,255):
if i not in ca_list:
ca_available.append(i)
env['add_avail'] = ca_available

First load add something in a table(klass modell). The second view
just pass to view and do the code abouve. I need to check the datas
from the table and make a list with availible id. If in first load add
an id 3, afther the second load, I don't need 3, in the env
['add_avail']. This work ok, when run on localhost with django seerver
(runserver), but, when I run project on other server, under apache2,
the list: env['add_avail'], is the same like in first load, even if
after the first load id is added. Somebody know what can be the
problem?

--

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.