Model question on subclass and parent class.

2010-06-05 Thread Ivan
I have a question on django model. I want to create a magazine model
that allow admin to add gadget, sport articles. And there are classes
for gadget, sport and food for adding only that specific article. How
to model this? I read through one to one field and many to many field.
I just could not get the magazine model right. Please guide.

Magazine
- sport (tennis)
- food (fast food)
- sport (swimming)
- food (sushi)

Sport
- tennis (sportA, sportC)
- swimming (sportB, sportC)

Food
- fast food (foodA, foodB)
- sushi (foodB, foodC)

class Food(models.Model):
name = models.CharField(max_length=100)

class FoodList(models.Model):
title = models.CharField(max_length=30)
foods = models.ManyToManyField(Food, blank=True)

class Sport(models.Model):
name = models.CharField(max_length=100)

class SportList(models.Model):
title = models.CharField(max_length=30)
sports = models.ManyToManyField(Sport, blank=True)

class Magazine(models.Model):
sportList = models.OneToOneField(SportList)
sportList = models.OneToOneField(SportList)



-- 
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 x Dreamhost

2010-07-13 Thread Ivan
Hi Alex,

I follow the steps in http://wiki.dreamhost.com/Django.
I manage to do it successfully.

Cheers,
Ivan



On Wed, Jul 14, 2010 at 6:52 AM, Alex s  wrote:
> Hi people,
>
> I just got a dreamhost account and I need to install Django there.
>
> I follow some usual links like wiki but I still have problems, the best
> instruction I found was
> http://jeffcroft.com/blog/2006/may/11/django-dreamhost/.
>
> Is there anyone here that install Django in dreamhost last days ?
>
> Thanks
> Alex
>
> --
> 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: how to install django-mingus blog? installed vrtualenv + virtualenvwrapper now I'm stuck

2010-07-16 Thread Ivan
Hi Justin,

What is the error message?

Cheers,
Ivan



On Sat, Jul 17, 2010 at 7:09 AM, justin jools  wrote:
> RE: http://djangoadvent.com/1.2/everything-i-hate-about-mingus/
> I tried following this to install Django-Mingus, it says it is easy
> but not for a newbie who knows nothing about virtualenv! tsk!
>
> I don't have pip so I ran easy_install
> 1. easy_install virtualenv... no problem
> 2. easy_instal virtualenvwrapper... no problem
> 3. mkvirtualenv myblog —-no-site-packages
> I get error: mkvirtualenv myblog —-no-site-packages
>
> What am I doing wrong...
>
> thanks for your 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.
>
>

-- 
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 to install django-mingus blog? installed vrtualenv + virtualenvwrapper now I'm stuck

2010-07-16 Thread Ivan
Hi Justin,

I guess, you are using Windows OS,

From
http://stackoverflow.com/questions/2615968/installing-virtualenvwrapper-on-windows
virtualenvwrapper does not work in Windows, unless you are using cygwin.

Alternate solution is Virtualenv Helper for Windows
(http://justindriscoll.us/2009/03/virtualenv-helper-for-windows.html)

Hope it helps.

Cheers,
Ivan



On Sat, Jul 17, 2010 at 7:42 AM, justin jools  wrote:
> Hi,
> sorry was
>
> c:\django>mkvirtualenv myblog
> 'mkvirtualenv' is not recognized as an internal or external command,
> operable program or batch file.
>
> but I figured out that on windows virtualenv myblog works
>
> but now (folowing tutorial as bottom),
> workon myblog porduces error:
>
> c:\django>workon myblog
> 'workon' is not recognized as an internal or external command,
> operable program or batch file.
>
> -
>
> mkvirtualenv myblog —-no-site-packages
> workon myblog
> cdvirtualenv
> git clone git://github.com/montylounge/django-mingus.git
> cd django-mingus/mingus
> pip install -r stable-requirements.txt
> cp local_settings.py.template local_settings.py
> ./manage.py syncdb
> ./manage.py loaddata test_data.json
> ./manage.py runserver
>
> On 16 July, 22:29, Ivan  wrote:
>> Hi Justin,
>>
>> What is the error message?
>>
>> Cheers,
>> Ivan
>>
>> On Sat, Jul 17, 2010 at 7:09 AM, justin jools  wrote:
>> > RE:http://djangoadvent.com/1.2/everything-i-hate-about-mingus/
>> > I tried following this to install Django-Mingus, it says it is easy
>> > but not for a newbie who knows nothing about virtualenv! tsk!
>>
>> > I don't have pip so I ran easy_install
>> > 1. easy_install virtualenv... no problem
>> > 2. easy_instal virtualenvwrapper... no problem
>> > 3. mkvirtualenv myblog —-no-site-packages
>> > I get error: mkvirtualenv myblog —-no-site-packages
>>
>> > What am I doing wrong...
>>
>> > thanks for your 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 
>> > 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.
>
>

-- 
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: Problem validating two forms in a view

2010-07-20 Thread Ivan
http://charlesleifer.com/blog/djangos-inlineformsetfactory-and-you/
might be the one you're looking for.

Cheers,
Ivan



On Wed, Jul 21, 2010 at 7:30 AM, Renne Rocha  wrote:
>  Hello all,
>
>  I want to create a page that the user will be able to include one
> 'Project', and several 'Ports' (related to this project). But I am
> having problems saving the Ports form, because the project_id isn't in
> the form yet.
>
>  I have the following models:
>
> class Project(models.Model):
>    name = models.CharField(max_length=100)
>
> class Port(models.Model):
>    description = models.CharField(max_length=20)
>    project = models.ForeignKey(Project)
>
>  And the following forms:
>
>  class ProjectForm(ModelForm):
>      class Meta:
>        model = Project
>
>  class PortForm(ModelForm):
>    class Meta:
>        model = Port
>        widgets = {
>            'project': HiddenInput() # Hidden because I can't choose
> the project yet
>        }
>
> And in the view that generate my form I have:
> def new_project(request):
>    PortFormSet = formset_factory(PortForm)
>    if request.method == 'POST':
>        project_form = ProjectForm(request.POST)
>        port_formset = PortFormSet(request.POST)
>        if project_form.is_valid():
>            new_project = project_form.save() # I have my new
> 'Project' instance here
>
>            for port_form in port_formset.forms:
>                # Here is my problem
>                if port_form.is_valid(): # Always return false because
> I haven't set the project_id
>                   ? # What should I put here to define the project_id?
>                   port_form.save()
>            return HttpResponseRedirect('/projects/')
>    else:
>        # Create the form and return to the template
>
> Thank you!
>
>   Renne Rocha
>   renne.ro...@gmail.com
>   http://www.linkedin.com/in/rennerocha
>   +55 19 8154-9345
>
> --
> 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: Displaying images

2010-08-20 Thread Ivan
Do you write your own context processors?

If yes, you need to add 'django.core.context_processors.media' in
TEMPLATE_CONTEXT_PROCESSORS manually.

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.media',
)

Cheers,
Ivan



On Fri, Aug 20, 2010 at 4:07 AM, Greg Pelly  wrote:
> Are your settings properly set up? Can you confirm that you are able to
> print settings.MEDIA_URL in your view?  MEDIA_URL defaults to the empty
> string, so that seems like the problem.  Then, pass in the request context
> as I described previously.
> From http://docs.djangoproject.com/en/dev/ref/templates/api/
> If TEMPLATE_CONTEXT_PROCESSORS contains this processor, every RequestContext
> will contain a variable MEDIA_URL, providing the value of the MEDIA_URL
> setting.
>
> Greg
>
> On Thu, Aug 19, 2010 at 10:54 AM, Bradley Hintze
>  wrote:
>>
>> Greg, that didn't do it :(
>> Thanks though :)
>>
>> On Thu, Aug 19, 2010 at 1:43 PM, Greg Pelly  wrote:
>> > try this:
>> > def math_form(request):
>> >   return render_to_response('form.html',
>> > {}, context_instance=RequestContext(request))
>> >
>> > greg
>> > On Thu, Aug 19, 2010 at 10:35 AM, Bradley Hintze
>> >  wrote:
>> >>
>> >> I am sorry. I am using render to response.
>> >>
>> >>  #view.py
>> >>
>> >> def math_form(request):
>> >>    return render_to_response('form.html')
>> >>
>> >> #base.html
>> >>
>> >> 
>> >> 
>> >> 
>> >>    {% block title %}{% endblock %}
>> >> 
>> >> 
>> >> 
>> >>    {% block header %}{% endblock %}
>> >>    Please enter two numbers to add them.
>> >>    {% block content %}{% endblock %}
>> >>    {% block footer %}
>> >>    
>> >>    Thanks for visiting my site.
>> >>    {% endblock %}
>> >> 
>> >>
>> >> On Thu, Aug 19, 2010 at 1:11 PM, Javier Guerra Giraldez
>> >>  wrote:
>> >> > On Thu, Aug 19, 2010 at 12:03 PM, Bradley Hintze
>> >> >  wrote:
>> >> >> So do I create 'my_data_dictionary'? and whats in there?
>> >> >
>> >> > are you using render_to_response()?  can't comment on your code if
>> >> > you
>> >> > don't show it
>> >> >
>> >> > --
>> >> > Javier
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups "Django users" group.
>> >> > To post to this group, send email to django-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.
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Bradley J. Hintze
>> >> Graduate Student
>> >> Duke University
>> >> School of Medicine
>> >> 801-712-8799
>> >>
>> >> --
>> >> 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.
>> >>
>> >
>> >
>> >
>> > --
>> > Greg Pelly
>> > CEO / CTO, Munchly Inc.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-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.
>> >
>>
>>
>>
>> --
>> Bradley J. Hintze
>> Graduate Student
>> Duke University
>> School of Medicine
>> 801-712-8799
>>
>> --
>> 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.
>>
>
>
>
> --
> Greg Pelly
> CEO / CTO, Munchly Inc.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.



Conneting Sybase ASE using pyodbc in Django

2010-09-08 Thread Ivan
I wonder any one is conneting Sybase ASE using pyodbc in Django? Any
wrapper available for that? Any solution?

Currently there are:
- sqlany-django (http://code.google.com/p/sqlany-django/) for Sybase
SQL Anywhere and not Sybase ASE
- django-pyodbc (http://code.google.com/p/django-pyodbc/) for MS SQL
Server through pyodbc

Thanks.

Ivan

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



Problem importing model after inspectdb

2010-09-23 Thread Ivan
Hi all,
I'm trying to build a Django project by working through the handbook
but I'm having some problems accessing the database by referencing the
model I've created from it (by inspectdb). When attemping to do some
"Basic Data Access" (Chapter 5) I can't import the models I've made
(from [app name].models import [model name]), with the console
erroring 'ImportError: cannot import name [model name]'. I checked the
models.py inspectdb made with 'python manage.py validate' and 'python
manage.py syncdb' exits with 'No fixtures found'. I would appreciate
any help I can get. Thanks

Here is my models.py from my app:
http://pastebin.ca/1947921

And here is my settings.py
http://pastebin.ca/1947922

-- 
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: Recommend a book

2010-09-23 Thread Ivan
Personally, I like hand on. "Practical Django Projects" is
recommended. http://apress.com/book/view/9781590599969



On Fri, Sep 24, 2010 at 12:38 PM, Tim Johnson  wrote:
> Thank you -
>  Shawn Milochik and Tran Cao Thai. :) thus far.
>  I'll check back in the morning.
>  cheers
> --
> Tim
> tim at johnsons-web.com or akwebsoft.com
> http://www.akwebsoft.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.
>
>

-- 
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 admin site and debug

2011-05-04 Thread Ivan
Try to replace your patern '^admin/' this '^admin/$', or swap
( r'^admin/', include( admin.site.urls ) )
and ( r'', include( 'role.company.urls' ) )

> my urlconf look like this
>
> from django.conf.urls.defaults import patterns, include
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns( '',
>     ( r'^admin/', include( admin.site.urls ) ),
>     ( r'', include( 'role.company.urls' ) ),
>  )
>
> and in the role.company.urls i dont put anything about debug or url
> that can override the admin ones

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



Easy way to serialize objects

2008-11-07 Thread Ivan Tarradellas

Hi all,

With Django, what is the easy and best way to serialize/deserialize
objects that are no Django objects?

django.core.serializers only works with Django objects. But what
happens if we have other object type?

How to serialize this:

class MyClass(object):
a = 'a'
b = 'b'



xml = serialization.serialize("xml",MyClass())

Tnxs

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



Re: Easy way to serialize objects

2008-11-10 Thread Ivan Tarradellas

Tnxs a lot Russ,

Then I will take a look on the state-of-the-art of this libraries. ;-)

On 8 nov, 05:22, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote:
> On Sat, Nov 8, 2008 at 1:35 AM,IvanTarradellas<[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > With Django, what is the easy and best way to serialize/deserialize
> > objects that are no Django objects?
>
> > django.core.serializers only works with Django objects. But what
> > happens if we have other object type?
>
> The short answer is "you have to build the serializer yourself".
> Django doesn't provide any mechanism for serializing arbitrary Python
> objects.
>
> The long answer depends on the serializer you want to use. Django's
> model serialization module builds on a number of other libraries
> (Python's builtin XML handling, simpleJSON, YAML, etc). These
> libraries handle the logic for how to serialize python primitive types
> (integer, list, etc). The Django serialization module describes how to
> decompose a django model instance into a series of primitives.
>
> If you want to serialize your own arbitrary object, you will need to
> come up with a similar set of rules, and wrap it around the base
> serialization libraries.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Bug in Admin or in my model ?

2008-11-15 Thread Ivan Mincik

Hi,
I have a problem when adding record by Django Admin and I am not sure where I 
have to look for it. Is this some problem in Django Admin or it can be solved 
by some 
configuration in model ?
I use  Foreign Key in table where I want to add record. Foreign Key is the 
field containing some non ASCII characters. See: 
http://gista.sk/dl/bugs/django/add_record_in_admin.png
I want to add record to "Metadata" which uses ForeignKey from "Vrstva".

*** When I submit, I get this error (nothing else printed):
Screenshot is here: 
http://gista.sk/dl/bugs/django/add_record_in_admin_submit.png

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in 
HandlerDispatch
result = object(req)

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

  File "/var/lib/python-support/python2.4/django/core/handlers/modpython.py", 
line 195, in __call__
response = self.get_response(request)

  File "/var/lib/python-support/python2.4/django/core/handlers/base.py", line 
128, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)

  File "/var/lib/python-support/python2.4/django/core/handlers/base.py", line 
148, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)

  File "/var/lib/python-support/python2.4/django/views/debug.py", line 39, in 
technical_500_response
html = reporter.get_traceback_html()

  File "/var/lib/python-support/python2.4/django/views/debug.py", line 95, in 
get_traceback_html
c = Context({

  File "/var/lib/python-support/python2.4/django/utils/encoding.py", line 35, 
in smart_unicode
return force_unicode(s, encoding, strings_only, errors)

  File "/var/lib/python-support/python2.4/django/utils/encoding.py", line 70, 
in force_unicode
raise DjangoUnicodeDecodeError(s, *e.args)

DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: 
ordinal not in range(128). You passed in 


*** Snippets from my model:
Full models.py is here: http://gista.sk/dl/bugs/django/models.py

class Metadata(models.Model):
vrstva = models.ForeignKey(Vrstva)
nazov = models.CharField(u"Názov stĺpca", max_length=100)
dlhy_nazov = models.CharField(u"Dlhý názov stĺpca", max_length=200)
hodnota = models.CharField(u"Formátovanie hodnoty", max_length=512, 
default="%s")
externa_databaza = models.ForeignKey(Externa_databaza, blank=True, 
null=True)
sql = models.TextField(u"SQL dopyt", blank=True)

def __unicode__(self):
return "%s %s" % (self.vrstva,self.nazov)

class Meta:
ordering = ["vrstva", "nazov"]
verbose_name_plural = u"metadata"

class Vrstva(Vrstvy_zaklad):
kategoria = models.ForeignKey(Kategoria, verbose_name=u"Kategória")
sql_atrib = models.TextField(u"Atributový SQL", blank=True)
tabulka = models.CharField(u"Tabuľka", max_length=200, blank=True, 
help_text=u"Tabuľka v ktorej sú gid a geom pre danú vrstvu")
transparent = models.BooleanField(u"Transparent")
zoom_level = models.IntegerField(u"Zoom level", default=1, 
help_text=u"Zoom level ktory sa použije pri zoomovaní na objekt pri 
vyhľadávaní")
sql_hladanie = models.TextField(u"Vyhľadávací SQL", blank=True)

class Meta:
ordering = ['kategoria','poradie']
verbose_name_plural = u"vrstvy"

*** My environment details:
OS: Debian Etch with python 2.4
Django version: 1.0, also tested on new 1.0.1 with same results
Database: PostgreSQL 8.1

*** It looks like the bug #3924 which should be allready closed. 

Can anybody give me some hint where to look for the solution ?

Thanks a lot
-- 
Ivan

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



Re: Bug in Admin or in my model ?

2008-11-15 Thread Ivan Mincik

On Saturday 15 November 2008 17:34, Luke Seelenbinder wrote:
> 
> You need to specify your encoding in your models file.
> Like: # -*- coding: iso-8859-15 -*-
> Look at http://
> evanjones.ca/python-utf8.html The sixth section of the page
> explains.
thanks for answer, but the first line in my models.py is # -*- coding: utf-8 
-*-. Please see : http://gista.sk/dl/bugs/django/models.py

> 
> Regards
> Luke
> 
> On Nov 15, 11:09 am, Ivan Mincik <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I have a problem when adding record by Django Admin and I am not sure where 
> > I have to look for it. Is this some problem in Django Admin or it can be 
> > solved by some
> > configuration in model ?
> > I use  Foreign Key in table where I want to add record. Foreign Key is the 
> > field containing some non ASCII characters. 
> > See:http://gista.sk/dl/bugs/django/add_record_in_admin.png
> > I want to add record to "Metadata" which uses ForeignKey from "Vrstva".
> >
> > *** When I submit, I get this error (nothing else printed):
> > Screenshot is 
> > here:http://gista.sk/dl/bugs/django/add_record_in_admin_submit.png
> >
> > Mod_python error: "PythonHandler django.core.handlers.modpython"
> >
> > Traceback (most recent call last):
> >
> >   File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, 
> > in HandlerDispatch
> >     result = object(req)
> >
> >   File 
> > "/var/lib/python-support/python2.4/django/core/handlers/modpython.py", line 
> > 222, in handler
> >     return ModPythonHandler()(req)
> >
> >   File 
> > "/var/lib/python-support/python2.4/django/core/handlers/modpython.py", line 
> > 195, in __call__
> >     response = self.get_response(request)
> >
> >   File "/var/lib/python-support/python2.4/django/core/handlers/base.py", 
> > line 128, in get_response
> >     return self.handle_uncaught_exception(request, resolver, exc_info)
> >
> >   File "/var/lib/python-support/python2.4/django/core/handlers/base.py", 
> > line 148, in handle_uncaught_exception
> >     return debug.technical_500_response(request, *exc_info)
> >
> >   File "/var/lib/python-support/python2.4/django/views/debug.py", line 39, 
> > in technical_500_response
> >     html = reporter.get_traceback_html()
> >
> >   File "/var/lib/python-support/python2.4/django/views/debug.py", line 95, 
> > in get_traceback_html
> >     c = Context({
> >
> >   File "/var/lib/python-support/python2.4/django/utils/encoding.py", line 
> > 35, in smart_unicode
> >     return force_unicode(s, encoding, strings_only, errors)
> >
> >   File "/var/lib/python-support/python2.4/django/utils/encoding.py", line 
> > 70, in force_unicode
> >     raise DjangoUnicodeDecodeError(s, *e.args)
> >
> > DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 
> > 1: ordinal not in range(128). You passed in
> >
> > *** Snippets from my model:
> > Full models.py is here:http://gista.sk/dl/bugs/django/models.py
> >
> > class Metadata(models.Model):
> >         vrstva = models.ForeignKey(Vrstva)
> >         nazov = models.CharField(u"Názov stĺpca", max_length=100)
> >         dlhy_nazov = models.CharField(u"Dlhý názov stĺpca", max_length=200)
> >         hodnota = models.CharField(u"Formátovanie hodnoty", max_length=512, 
> > default="%s")
> >         externa_databaza = models.ForeignKey(Externa_databaza, blank=True, 
> > null=True)
> >         sql = models.TextField(u"SQL dopyt", blank=True)
> >
> >         def __unicode__(self):
> >                 return "%s %s" % (self.vrstva,self.nazov)
> >
> >         class Meta:
> >                 ordering = ["vrstva", "nazov"]
> >                 verbose_name_plural = u"metadata"
> >
> > class Vrstva(Vrstvy_zaklad):
> >         kategoria = models.ForeignKey(Kategoria, verbose_name=u"Kategória")
> >         sql_atrib = models.TextField(u"Atributový SQL", blank=True)
> >         tabulka = models.CharField(u"Tabuľka", max_length=200, blank=True, 
> > help_text=u"Tabuľka v ktorej sú gid a geom pre danú vrstvu")
> >         transparent = models.BooleanField(u"Transparent")
> >         zoom_level = models.IntegerField(u"Zoom level", default=1, 
> > help_text=u"Zoom level ktor

Re: Bug in Admin or in my model ?

2008-11-15 Thread Ivan Mincik

On Saturday 15 November 2008 18:57, Karen Tracey wrote:
> There's a bug both in your models and in Django, I think.  Your __unicode__
> method for class Metadata:
> 
>def __unicode__(self):
> >return "%s %s" % (self.vrstva,self.nazov)
> >
> 
> needs to be:
> 
>def __unicode__(self):
> >
>return u"%s %s" % (self.vrstva,self.nazov)
Karen, really thanks a lot for perfect guess. Problem solved.
> 
> 
> The bug in Django is that the attempt to report that your existing
> __unicode__ method generated an error generated yet another error, and I
> haven't quite figured that one out yet.  But if you want to make progress
> you can just fix your __unicode__ method.
What to do with this? Do I have to fill some bug report ?
> 
> Karen
> 
> > 
> 

Ivan

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



Re: Subtle Memory Leak Finally Found! (DEBUG is off)

2008-11-18 Thread Ivan Sagalaev

7timesTom wrote:
> cars = Car.objects.filter(...) #upto 2000 items
> msg =... len(cars) # can you see the massive memory use here?

This is actually well documented: 
http://docs.djangoproject.com/en/dev/ref/models/querysets/#when-querysets-are-evaluated

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



Re: dynamic method calling

2008-11-22 Thread Ivan Sagalaev

Chris wrote:
> try:
> push = getattr(self, 'get_%s_content' % self.name)
> except AttributeError:
> raise "Method does not exist"
> if callable(push):
> push(**argv)

There are a couple of problems with this code.

1. It's more readable to call hasattr than to catch an exception from 
getattr:

if hasattr(self, 'get_%s_content' % self.name):
 raise Exception('Method does not exists')
if callable(push):
 push(**argv)

2. Raising another exception instead of the standard AttributeError 
looks suspicious. Why are you doing it?

3. Exceptions should be instances of class Exception, not strings.

4. The code silently does nothing when attribute is here but is not 
callable.

Of all these, points 1 and 3 are certainly worth addressing but for 2 
and 4 you may have valid reasons which I don't know :-)

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



Re: dynamic method calling

2008-11-22 Thread Ivan Sagalaev

Ivan Sagalaev wrote:
> if hasattr(self, 'get_%s_content' % self.name):
>  raise Exception('Method does not exists')

Typo: there should be `if not hasattr`, obviously.

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



Re: Best IDE for Django and python?

2008-11-26 Thread Ivan Mincik

Komodo Edit 5 couldn't run at Debian Etch. Has anybody some older version ? (4)
Ivan


On Wednesday 26 November 2008 17:50, vivek wrote:
> 
> I also use komodo ide :
>   - It can be used with other dynamic languages like php, so if you
> sometimes need to do something in languages other than python, it can
> come in handy.
>   - They have excellent licensing policy
> 
> but i doubt there is any "best" ide to everyone's need.  Most of
> choices suggested here are either free or free to try, so you can try
> them first.
> 
> > How do you develop your django projects, and where do you go when you
> > need to find documentation?
> 
> now for your second question:
> 
> http://docs.djangoproject.com/
> http://www.djangobook.com/
> 
> both are excellent resources for django documentation.
> > 
> 

-- 
Mgr. Ivan Minčík
Gista s.r.o
tel:. 0907 639 570
email: [EMAIL PROTECTED]
http://www.gista.sk, http://demo.gisplan.sk

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



Re: Generic Views and ModelAdmin: too much code?

2008-08-19 Thread Ivan Sagalaev

fabio natali wrote:
> This is the urls.py I created: http://dpaste.com/72138/
> It doesn't work though: I get a
> KeyError at /manufacturer
> u'manufacturer'
> when accessing http://localhost:8000/manufacturer
> (manufacturer being one of my model)

KeyError says that it can't find a key 'manufacturer' in dict 
model_classes. This leads me to think that model_classes is empty. It 
can be because my example is creating it by listing you module "models":

 ... for i in dir(models) ...

and I don't see where this "models" is imported. I was a bit sloppy when 
I was writing it and have it omitted. So you should import it. It's simply

 import models

if it's in the same directory as urls.py.

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



Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev

fabio natali wrote:
>>  import models
> 
> I added the line
> 
>   import arteak.management.models

It's not the same thing :-). This line won't load the name "models" into 
your local environment. If you want import from some path this should be:

 from arteak.management import models

> TypeError at /
> 'str' object is not callable

Can you provide full traceback? It's pretty hard to guess where this 
happens.

> Anyway I don't want to steal your time any longer. I really hoped
> saving some lines in urls.py could be easier. I'd probably better to
> write a short bash script to generate a urls.py file from my models.py
> with all the proper generic views entries for each model.

Well... The choice is yours. However I'd suggest to spend some time 
getting yourself more familiar with Python because Django is just Python 
in many ways.

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



Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev

fabio natali wrote:
> That's right! So here comes my current urls.py:
> 
> http://dpaste.com/72638/
> 
> then the traceback I get at http://localhost:8000/:
> 
> http://dpaste.com/72639/

Oy! I've found it :-). It has nothing to do with model_view decorator or 
anything that we're talking here about. It's in urls.py, on line 30:

 (r'^$', 'current_datetime')

You pass a string instead of a function. Django tries to import this 
name, fails and tries to call it as a function. Then you get this error 
because strings are not callable.

> and finally the traceback I get at http://localhost:8000/manufacturer/:
> 
> http://dpaste.com/72637/

Ok... I've finally managed to actually check what I has "invented" and 
it seems I was on crack... Sorry for the confusion. I've messed up 
building model_classes dict in two places but it doesn't matter because 
it can be done simpler.

 from django.db.models import get_model

 def model_view(func):
 def wrapper(request, *args, **kwargs):
 model = get_model('arteak', kwargs.pop('model'))
 kwargs['queryset'] = model.objects.all()
 return func(request, *args, **kwargs)
 return wrapper

It happens that Django already has a registry of all models and 
get_model can, well, get a model from it by an app_name ('arteak') and a 
model_name which is passed in kwargs right out of urlconf.

And model_classes code can be just thrown away.

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



Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev

fabio natali wrote:
> For the sake of clarity, my django project is named arteak, the models
> we are using belong to an app called "management".

Ah! Then there should of course be get_model('management', 
kwargs.pop('model')). I thought 'arteak' was the name of the app. This 
is why it returns None instead of a model right now.

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



Re: Slovkian speakers? Help wanted with #8709

2008-08-31 Thread Ivan Sagalaev

Frantisek Malina wrote:
> Sadly, I am not aware of any current Slovak Django users.
> E.g. First 50 results on http://google.sk/search?hl=sk&lr=lang_sk&q=django
> won't return a single blog-post about Django web framework in Slovak.

May be contact one of those: http://djangopeople.net/sk/ ?

Gábor Farkas, for one, is a well-known Django person.

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



Re: ANNOUNCE: Django 1.0 released

2008-09-04 Thread Ivan Sagalaev

dankelley wrote:
> In other words, should I (or typical users) download the official 1.0
> version, or will it still be advised to track the development version?

Nothing can stop you from using trunk :-)

I'm not a core developer so don't take it as an official advice. But I 
do think that living on the edge in the case of Django is most rewarding.

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



Re: DJANGO 1.0 : How to avoid converting to entities

2008-09-20 Thread Ivan Sagalaev

tsmets wrote:
> OK !
> I found it : http://code.djangoproject.com/wiki/AutoEscaping
> 
> {% autoescape off %}
> {{ body }}
> {% endautoescape %}

Or just {{ body|safe }}.

Better yet, the thing that creates colorizedCode should mark it as 
"safe" (i.e. not requiring escaping) in this fashion:

 from django.utils.safestring import mark_safe
 def colorize():
 # ...
 return mark_safe(result)

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



Re: DJANGO 1.0 : How to avoid converting to entities

2008-09-21 Thread Ivan Sagalaev

Malcolm Tredinnick wrote:
>> Better yet, the thing that creates colorizedCode should mark it as 
>> "safe" (i.e. not requiring escaping) in this fashion:
>>
>>  from django.utils.safestring import mark_safe
>>  def colorize():
>>  # ...
>>  return mark_safe(result)
> 
> Although if you ever write anything like that you are also responsible
> for escaping the existing code.

Good point, thanks. I've took a liberty to suppose that if it's about 
"colorizing" then it's probably some tool that generates HTML from a 
language source and probably is indeed safe.

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



Re: Custom upload handlers: Potential multi threading, session, etc issues. Take a look!

2008-10-20 Thread Ivan Sagalaev

truebosko wrote:
> What I found though, is that the view that is being called from JS
> will finally have access to the session variable after the upload is
> complete

Looks like you're doing it with development server. It's single-process 
and can't handle and upload and another view simultaneously. It should 
work as you expect in production environment where web servers can 
handle multiple requests at once.

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



reportlab - filename of generated PDF

2009-01-25 Thread Ivan Mincik

Dear django users,
we have a problem with filename of resulting PDF generated by reportlab and 
then downloaded by browser.  

Generated PDF is OK, but filename is incorrect. It is allways something like 
"randomstring.pdf.part". (for example sa34sdfasdf.pdf.part)


in the "view.py" there are these lines: 
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'filename=gisplan.pdf'

Please, can anybody see where can be the problem ?


Ivan

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



Re: reportlab - filename of generated PDF

2009-01-26 Thread Ivan Mincik

On Monday 26 January 2009, Vinay Sajip wrote:
> 
> On Jan 26, 7:59 am, Ivan Mincik  wrote:
> > Dear django users,
> > we have a problem with filename of resulting PDF generated by reportlab and 
> > then downloaded by browser.
> >
> > Generated PDF is OK, but filename is incorrect. It is allways something 
> > like "randomstring.pdf.part". (for example sa34sdfasdf.pdf.part)
> >
> > in the "view.py" there are these lines:
> > response = HttpResponse(mimetype='application/pdf')
> > response['Content-Disposition'] = 'filename=gisplan.pdf'
> >
> > Please, can anybody see where can be the problem ?
> 
> It looks like a temporary filename generated by whatever is
> downloading the file. For example, Firefox, while downloading, would
> name the file "gisplan.pdf.part" and rename it to "gisplan.pdf" after
> the download completed. If the downloader completed the download
> (accounting for the OK PDF file) but failed to rename it, you might
> get the result which you observed.
> 
> I use a slightly different content-disposition, indicating explicitly
> that it's an attachment:
> 
> response['Content-Disposition'] = 'attachment; filename=gisplan.pdf'
> 
> With this approach, everything works as expected for me.
Thanks, 
it is working now.

> 
> Regards,
> 
> Vinay Sajip
> > 
> 



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



Django and chat

2009-07-02 Thread Ivan Uemlianin

Dear All

I am looking into using or developing a chat application for Django,
for use in a social networking website based on the Pinax Django
"distribution".

I have searched for django-based chat applications and found very
little.  Below I list briefly what I've found.  Please could anyone
let me know if I've missed any significant projects.

There seem to be two very different kinds of technology being used in
these projects.  Some of the projects (eg django-chat) use the "same
old" approach of repeatedly polling the server at regular intervals
that lightweight chat apps in other languages use; some of the
projects use the comet approach (eg with orbited).

Is it worth using/developing a chat app using the old-fashioned
approach?  Is comet better for all circumstances?

My instinct is to try and get django-chat on its feet: stable and
documented.  If it turns out that approach is not up to my needs, I'll
turn to something using comet.

Projects I've found:

* django-chat
  http://code.google.com/p/django-chat/
  little documentation, but seems to work (with a strange intermittent
bug)

* evserver
  http://code.google.com/p/evserver/
  http://popcnt.org/2008/01/django-evserver-asynchronous-server-for.html
  http://popcnt.org/2007/12/asynchronous-django-responses-comet-yes.html
  evserver is

* Various projects based on Orbited
  http://orbited.org/
  - Orbited tutorials (http://orbited.org/wiki/Tutorials/)
  - willowchat (http://willowchat.org/)
  - Django, Comet and IRC client (http://www.rkblog.rk.edu.pl/w/p/
django-comet-and-irc-client/)
  includes a simple chat application:
http://evserver.googlecode.com/svn/trunk/evserver/examples/django_chat/

* django-jchat
  http://code.google.com/p/django-jchat/
  description, no documentation

* djangochat
  http://github.com/dmm/djangochat/tree/master
  "Django-based jabber client app"
  no documentation

Thanks and best wishes

Ivan


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



Re: Django and chat

2009-07-02 Thread Ivan Uemlianin

Xiong

Thanks for your comment.  Good questions.

I envisage a social networking website, based on Django.  The website
will provide a chat facility for users who are logged in: multi-user
chatrooms and private chat (I has been thinking of 1-to-1 as a special
case of multi-user).  Django-integration because certain chat
functions might have to access Django-centric information (eg
different types of user displayed differently; perhaps a django
moderation module).

If there is a standard embeddable thingamajig, that may well be the
way to go.  Can you recommend any that would fit the above usage?

Best

Ivan

> Are you looking for a multi-user chatroom, or private chat?  I'm
> guessing you want the first, but you included a jabber client in there
> as well, which, to my knowledge, only supports 1-to-1 conversations.
>
> The approach I've seen for most sites is to have a web interface to an
> irc room, so that you can chat without having an irc client, or with
> one, if you prefer.  I know that Rizon just announced an embeddable
> client for their network, and a quick google finds all sorts of
> different embeddable clients.  What specifically do you need Django-
> integration for, as opposed to a standard java/javascript embeddable
> thingamajig?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Bad DateTime for LANGUAGE_CODE = 'sk'

2009-08-11 Thread Ivan Mincik

On Tue, Aug 11, 2009 at 10:09 AM, gentlestone wrote:
>
> My settings:
>
> DEFAULT_CHARSET = "utf-8"
> TIME_ZONE = 'Europe/Bratislava'
> LANGUAGE_CODE = 'sk'
> USE_I18N = True
>
> DateTime fields are displayed in the admin page incorrectly. If I
> change the language code for 'en' or 'cz', the display format is ok.
> It is propably a bug. How can I fix it?

Yes, I can confirm this behavior.


> >
>

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



Customized django Group model

2009-11-04 Thread Ivan Poluyanov

Hello Django Users!
I wish customize standart Group model to add some fields (is_region,
is_managers).

how i can do this? true way:)

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



django with mod_wsgi on centos

2010-05-08 Thread Ivan Uemlianin

Dear All

I know this is strictly speaking off topic, so please forgive me.  I 
have asked at the mod_wsgi list.


On an Ubuntu machine I have a working django site, using nginx, apache 
and mod_wsgi.  Now I am having to install the site on a CentOS machine.  
Everything is working, apart form one thing: apache is returning 403 
permission denied when I try to access the wsgi script.


I have carefully followed the mod_wsgi installation and configuration 
instructions, and scoured the blogs, forums, and wikis of the web.  I 
have tried many things, but nothing will shift that 403. 

Below is a summary of the install and config steps I took and the fixes 
I've tried.  Can anyone suggest anything I've missed?


Can anyone suggest to me which permissions I need to change and to 
what?  Presumably read/write permissions to some file or directory but 
which one(s)?


Please let me know if you need more information.

Can anyone help? Unfortunately, I think we have to stick with CentOS.

With apologies, thanks and best wishes

Ivan

* What I did

As CentOS uses python 2.4, I installed python 2.6 into /opt.  I compiled 
from source using the following configure:


   ./configure --prefix=/opt --enable-ipv6 --with-threads --enable-shared

I made the libpython so available

$ cd /opt/lib/python2.6/config
$ ln -s ../../libpython2.6.so .

$ cat >> /etc/ld.so.conf.d/opt-python2.6.conf
/opt/lib
^D
$ ldconfig

$ cp /etc/ld.so.conf.d/opt-python2.6.conf /etc/ld.so.conf.d/python2.6.conf
(added later; just in case)

When compiling mod_wsgi from source I used the following configure:

   ./configure --with-python=/opt/bin/python

The resulting mod_wsgi.so is about 395k and is loading the python so:

# ls -l mod_wsgi.so
-rwxr-xr-x 1 root 385009 Apr 29 11:44 mod_wsgi.so
# ldd mod_wsgi.so
   libpython2.6.so.1.0 => /opt/lib/libpython2.6.so.1.0 
(0x2b249eec)

   libpthread.so.0 => /lib64/libpthread.so.0 (0x2b249f26f000)
   libdl.so.2 => /lib64/libdl.so.2 (0x2b249f48a000)
   libutil.so.1 => /lib64/libutil.so.1 (0x2b249f68f000)
   libm.so.6 => /lib64/libm.so.6 (0x2b249f892000)
   libc.so.6 => /lib64/libc.so.6 (0x2b249fb15000)
   /lib64/ld-linux-x86-64.so.2 (0x003dd100)

The django app and its django_wsgi.py wgi script are outside of document 
root.  django_wsgi.py has permissions 755, as does its containing directory.


Here are some relevant apache configs I'm using:

NameVirtualHost *:8080
Listen 127.0.0.1:8080

LoadModule  wsgi_module  modules/mod_wsgi.so
AddHandler wsgi-script  .wsgi
WSGISocketPrefix  run/wsgi

WSGIPythonHome  /home/path/to/py26/sys/prefix


   # ...
   WSGIScriptAlias  /  /path/to/django/app/apache/django_wsgi.py

   
   Order deny,allow
   Allow from all
   



The error in apache's error logs is just:

[error] [client 127.0.0.1] (13)Permission denied: access to / denied

And it's the same error with LogLevel set to info.

I have tried disabling selinux: no effect.
I have tried switching the CentOS machine off and on again: no effect.
I have tried the example wsgi script in the mod_wsgi wiki quick 
configuration page: still a 403.
I have not tried daemon mode: sounds good but doesn't look like it would 
address my current problem.





--
====
Ivan A. Uemlianin
Speech Technology Research and Development

   i...@llaisdy.com
www.llaisdy.com
llaisdy.wordpress.com
www.linkedin.com/in/ivanuemlianin

   "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
(Schiller, Beethoven)


--
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 with mod_wsgi on centos

2010-05-10 Thread Ivan Uemlianin
Dear Kenneth

Thanks for your suggestion.

I tried

$ chmod -R a+x mysite

(where mysite is the django site directory)

and stopped and started apache, but no effect.

I'm finding nginx a lot easier to work with than apache, especially
CentOS' apache.  My plan now is to get rid of apache altogether and
have nginx talk to django directly via fastcgi (e.g., [1]) (will also
give me an excuse to try out git instead of svn).  If you don't hear
back from me in a day or two, it worked.

With thanks and best wishes

Ivan

[1]  http://code.djangoproject.com/wiki/ServerArrangements#nginx


On May 8, 4:26 pm, Kenneth Gonsalves  wrote:
> On Saturday 08 May 2010 20:32:51 Ivan Uemlianin wrote:
>
> > Can anyone suggest to me which permissions I need to change and to
> > what?  Presumably read/write permissions to some file or directory but
> > which one(s)?
>
> I do not know whether this will help, but I have seen permission denied errors
> in mandriva and fedora when the relevant directories/files are not executable
> by all. Maybe a chmod a+x would help.
> --
> Regards
> Kenneth Gonsalves
> Senior Associate
> NRC-FOSS at AU-KBC
>
> --
> 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.



Re: django with mod_wsgi on centos

2010-05-10 Thread Ivan Uemlianin
Dear All

The nginx/fastcgi set up is now working (there's an easy-to-follow
howto on the django advent site [1]).

Embarrasingly I may have stumbled upon what was getting me 403s with
mod_wsgi, and it's nothing to do with apache or mod_wsgi.  After
setting up nginx with fastcgi I got the same 403.  Although the
"mysite" directory and everything under it had permissive permissions,
the user's home directory was 700:

/home/siteuser/mysite/775
/home/siteuser/   700

I changed the latter to 775 to and everything went smoothly.  I didn't
test it but apache/mod_wsgi will probably work too now.  Doh!

@Tom thanks for your suggestion.  When I used to use apache (LOL) I
would generally have the django app outside of DocumentRoot.  I think
changing permissions as above would fix things.  Otherwise I don't see
why an apache config set up that works on ubuntu would raise 403s on
centos (just checked: on the ubuntu machine /home/siteuser/ was 775).

Best wishes

Ivan

[1]  http://djangoadvent.com/1.2/deploying-django-site-using-fastcgi/

On May 10, 10:25 am, Tom Evans  wrote:
> On Mon, May 10, 2010 at 9:39 AM, Ivan Uemlianin  wrote:
> > Dear Kenneth
>
> > Thanks for your suggestion.
>
> > I tried
>
> >    $ chmod -R a+x mysite
>
> > (where mysite is the django site directory)
>
> > and stopped and started apache, but no effect.
>
> > I'm finding nginx a lot easier to work with than apache, especially
> > CentOS' apache.  My plan now is to get rid of apache altogether and
> > have nginx talk to django directly via fastcgi (e.g., [1]) (will also
> > give me an excuse to try out git instead of svn).  If you don't hear
> > back from me in a day or two, it worked.
>
> > With thanks and best wishes
>
> > Ivan
>
> > [1]  http://code.djangoproject.com/wiki/ServerArrangements#nginx
>
> Good luck with setting up your pure nginx configuration. Your apache
> configuration did not work because you had not granted apache access
> to the required on disk folders.
>
> You didn't mention this in your configuration, but you must allow
> access to your DocumentRoot in your vhost:
>
> 
>   ServerName foo
>   DocumentRoot /path/to/foo/htdocs
>   
>     Order allow,deny
>     Allow from all
>   
>   WSGIScriptAlias /app/ /path/to/foo/run/app.wsgi
> 
>
> 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 
> 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.



Re: django with mod_wsgi on centos

2010-05-10 Thread Ivan Uemlianin
@Graham see my reply this morning to your post on the modwsgi list:

http://groups.google.com/group/modwsgi/browse_thread/thread/a157d0eba50b826a

@Sam I didn't change the home directory permissions on either machine:
they seem to have different default settings (775 on ubuntu, 700 on
centos).

-- 
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: One to One chat like Facebook?

2010-05-17 Thread Ivan Uemlianin
Dear Anand

Frederico Caceres' app [1,2] is worth a look, but note that it uses
old-style repeated polling of the server.

Alex Clemesha has written an exciting piece on developing real-time
web apps with Django, Orbited and Twisted [3].  His demo application,
hotdot [4], includes a real-time chat application.

His blog also mentions Speeqe [5], which is a chat application
integrating Django and ejabberd, the erlang xmpp server.

Let us know how you get on.

Best wishes

Ivan

[1]  
http://pythonhaven.wordpress.com/2009/07/13/django-powered-ajax-chat-%E2%80%93-part-2/
[2]  
http://llaisdy.wordpress.com/2009/10/13/adding-a-django-application-to-pinax/
[3]  
http://www.clemesha.org/blog/2009/dec/17/realtime-web-apps-python-django-orbited-twisted/
[4]  http://clemesha.org/projects/hotdot/
[5]  http://code.stanziq.com/speeqe


On May 16, 11:13 am, Anand Agarwal  wrote:
> Hi All
>
> Is there any chat application in django similar to facebook chat?
>
> Regards
> Anand
> Got an Idea? BootStrap <http://bootstraptoday.com>it Today!!
>
> --
> 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.



Custom Django Admin translations

2010-05-18 Thread Ivan Mincik
Hi,
I would like to ask, what is the best way to change some of the
translation messages in Django Admin to custom ones. Is there any good
way, how to override system translations of Admin in some projects
where I need it ?

Thanks
Ivan

-- 
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: Chat application in Django

2010-09-01 Thread Ivan Uemlianin
Dear Shamail

As well as the resources already mentioned, I mention a few on this
comment on a similar thread in May:


http://groups.google.com/group/django-users/browse_thread/thread/6032003efcf2c2df/0575d5b54ecd5254#0575d5b54ecd5254

Hotdot (django, orbited and twisted) is good for realtime chat, and
easy to set up.  Whether Twisted is a pro or a com I leave up to you.

Speeqe is a hybrid system with django collaborating with an ejabberd
server for the realtime content.  In the long run this is probably
more robust (however, I'm afraid I haven't got round to testing it
myself).

Do let us know how you got on.

Best wishes

Ivan

On Sep 1, 3:05 pm, yves_s  wrote:
> I also looking for realtime messaging for django and found this two
> links.
>
> http://www.clemesha.org/blog/realtime-web-apps-python-django-orbited-...
>
> http://bitshaq.com/2010/07/30/a-simple-experiment-with-hookbox/
>
> yves

-- 
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: Chat application in Django

2010-09-04 Thread Ivan Uemlianin
Dear Shamail

It depends on your host.  Serving real-time content over the web
requires a web server that can do server push (e.g., Twisted, Tornado,
ejabberd, etc.).  If your host will let you install your own web
server, you're fine.

If your host insists on apache, ... I think server push is possible
with apache, ...  If you're sharing web server resources, your hosts
might not be too friendly about your doing server push.

If you can't run these systems with your current host, try them out on
your own machine while you're looking for a new host;)

Best wishes

Ivan


On Sep 3, 3:02 pm, Shamail Tayyab  wrote:
> Hi Ivan,
>
>   This looks promising, could you also throw some light on how hosting
> friendly this set up will be?
>
> Thanks
>
> On Fri, Sep 3, 2010 at 7:13 PM, Salman (shaq) Haq  
> wrote:
>
>
>
> > Hi guys,
>
> > I am the author of a 'A simple experiment with Hookbox' (see below).
>
> > Just wanted chime in and say that Hookbox is under development right
> > now
> > but it is looking very promising. A few people have deployed chat
> > applications
> > for high traffic websites using it already. The simplicity of Hookbox
> > is a major strength.
>
> > Hotdot is based on Orbited, which is also a framework by the author of
> > Hookbox.
>
> > A new feature coming up in Hookbox is the 'private message api' which
> > allows
> > messages to be passed from one client to another client rather simply.
> > I've been following
> > the mailing and people have already started posting demo code using
> > this feature.
>
> > Hope this helps.
>
> > Best,
> > Shaq
>
> > On Sep 1, 10:05 am, yves_s  wrote:
> >> I also looking for realtime messaging for django and found this two
> >> links.
>
> >>http://www.clemesha.org/blog/realtime-web-apps-python-django-orbited-...
>
> >>http://bitshaq.com/2010/07/30/a-simple-experiment-with-hookbox/
>
> >> yves
>
> > --
> > 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.
>
> --
> Shamail Tayyab
> Blog:http://shamail.in/blog

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



Where is csrf middleware for Django 1.1.1?

2010-01-26 Thread Ivan Uemlianin
Dear All

I am trying to locate the csrf middleware.  I have Django 1.1.1 but it
doesn't seem to have the module as documented [1]:

$ python manage.py shell
>>> import django
>>> django.VERSION
(1, 1, 1, 'final', 0)
>>> import django.contrib.csrf.middleware.CsrfMiddleware
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named CsrfMiddleware
>>> import django.contrib.csrf.middleware.CsrfViewMiddleware
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named CsrfViewMiddleware
>>> import django.contrib.csrf.middleware.CsrfResponseMiddleware
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named CsrfResponseMiddleware
>>> import django.contrib.csrf.middleware
>>>

Please can anyone help me resolve this problem?

Best wishes

Ivan


[1] csrf for 1.1
http://docs.djangoproject.com/en/1.1/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.



Creating sample users for testing

2010-03-22 Thread Ivan Uemlianin
Dear All

I'd like to create a bunch of sample users for testing a django
website.  I was going down the road of using an initial_data fixture,
but there seem to be a couple of problems with this:

- Can I supply partial data in initial_data, i.e. only auth.user info
(at the moment, username and password, and it seems to require last
login)?  When I do this, syncdb persists in asking me for an admin
user (even when the previously given admin user still works).

- How should I specify the password field in the fixture?  dumpdata
outputs a hash.  Do I need to write some script to generate hashes
from given passwords?

I'm now thinking a fixture might not be the right way to go: it might
be better to have a little script to add users once syncdb is done.
As well as allowing me to provide plain text passwords, I could easily
add site-specific attributes when I need them (dave.favourite_colour =
'orange'; bob.online = True, etc).

Is that second method just reinventing the fixture, or is it more
appropriate here?

Thanks and best wishes

Ivan

-- 
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: Creating sample users for testing

2010-03-23 Thread Ivan Uemlianin
Dear Ian

That's great!  Exactly my use case.  Thanks very much for your help.

Best wishes

Ivan

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



How to set a prompt for a choiceField?

2010-03-23 Thread Ivan Uemlianin
Dear All

I have a choiceField in one of my forms, and I'd like to have it
rendered displaying a prompt.  I think the html would be something
like this:


Please choose a colour:
Red
Green
Blue


This would display a drop-down menu showing "Please choose a colour:".

The form field would be something like this:

colours = (('r','Red'),('g','Green'),('b','Blue))
# ...
fave_colour = forms.ChoiceField(choices=colours)

The problem is, this displays one of the choices.  I'd much prefer a
prompt (in fact for our application, displaying one of the choices, as
if it were a kind of 'default', is not at /all/ appropriate).

I've tried

fave_colour = forms.ChoiceField(label="Please choose a colour:"
choices=colours)

and

fave_colour = forms.ChoiceField(initial="Please choose a colour:"
choices=colours)

and I've scoured the net for clues, but found nothing which works.

Please can anyone here help me work out how to do this with
django.forms?

With thanks and best wishes

Ivan

-- 
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 to set a prompt for a choiceField?

2010-03-23 Thread Ivan Uemlianin
Very sorry everybody: I googled around tons, but I didn't search this
group! LOL.  I'll know next time.

Adding an "invalid" choice to a ChoiceField?
http://groups.google.com/group/django-users/browse_thread/thread/dd6d8eb11f915c94/77aa6fbea94af4c4?lnk=gst&q=choicefield#77aa6fbea94af4c4

This works:

 colours = (('','Please choose a colour:'),('r','Red'),
('g','Green'),('b','Blue))
 # ...
 fave_colour = forms.ChoiceField(choices=colours)

Django's automagical form validation means the form cannot be
submitted without choosing a colour, and somehow (because empty string
always sorts before anything else?) the 'invalid' choice is displayed
by default and can act as a prompt.

Thanks (for the facility), apologies and best wishes

Ivan


On Mar 23, 2:56 pm, Ivan Uemlianin  wrote:
> Dear All
>
> I have a choiceField in one of my forms, and I'd like to have it
> rendered displaying a prompt.  I think the html would be something
> like this:
>
>     
>         Please choose a colour:
>         Red
>         Green
>         Blue
>     
>
> This would display a drop-down menu showing "Please choose a colour:".
>
> The form field would be something like this:
>
>     colours = (('r','Red'),('g','Green'),('b','Blue))
>     # ...
>     fave_colour = forms.ChoiceField(choices=colours)
>
> The problem is, this displays one of the choices.  I'd much prefer a
> prompt (in fact for our application, displaying one of the choices, as
> if it were a kind of 'default', is not at /all/ appropriate).
>
> I've tried
>
>     fave_colour = forms.ChoiceField(label="Please choose a colour:"
>                                     choices=colours)
>
> and
>
>     fave_colour = forms.ChoiceField(initial="Please choose a colour:"
>                                     choices=colours)
>
> and I've scoured the net for clues, but found nothing which works.
>
> Please can anyone here help me work out how to do this with
> django.forms?
>
> With thanks and best wishes
>
> Ivan

-- 
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: Creating sample users for testing

2010-03-24 Thread Ivan Uemlianin
Dear Dave

Thanks, that does look useful.  Seeing Ian's solution I was wondering
if I could manage.py in some way.

Best wishes

Ivan

On Mar 23, 4:55 pm, Dave Murphy  wrote:
> On Mon, Mar 22, 2010 at 12:26 PM, Ivan Uemlianin  wrote:
>
> > I'm now thinking a fixture might not be the right way to go: it might
> > be better to have a little script to add users once syncdb is done.
> > As well as allowing me to provide plain text passwords, I could easily
> > add site-specific attributes when I need them (dave.favourite_colour =
> > 'orange'; bob.online = True, etc).
>
> > Is that second method just reinventing the fixture, or is it more
> > appropriate here?
>
> It depends if you're going to be doing this more than once. If it's only
> once, then maybe a fixture is good enough. If you're going to be doing this
> more than once, and tweaking things over time then there's nothing wrong
> with a custom script. I chose the latter for my recent version of this
> dilemma, and I'm quite happy with it.
>
> You might be interested in custom management commands:
>
>  *http://docs.djangoproject.com/en/1.1/howto/custom-management-commands...
>
> --
> Dave Murphyhttp://schwuk.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.



django-simplepages "stable"?

2010-03-26 Thread Ivan Uemlianin
Dear All

I need a basic CMS and django-simplepages looks like it should fit the
bill.  I notice it hasn't had any changes since Aug 2008, or issues
posted since Feb 2009.  Does this mean it's "stable" or "broken"?  Is
anyone using it?

I've noticed an error in simplepages/models.py:

 5from django import forms
  ...
35class HTMLTextField(forms.TextField):
  ...

django.forms has no TextField.  I'm thinking of changing it to
forms.CharField.

Does anyone have (recent) experience of using simplepages?  Is it
bascially usable, or is it full of holes?

Thanks and best wishes

Ivan

-- 
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: doesNotExist

2010-04-03 Thread ivan marchesini
Hi Daniel
many thanks...
that help me a lot..
now it works..  ;-)

ivan

> 
> That method should have gone in the TipoIndagine model.
> --
> DR.
> 


-- 
Ti prego di cercare di non inviarmi files .dwg, .doc, .xls, .ppt.
Preferisco formati liberi.
Please try to avoid to send me .dwg, .doc, .xls, .ppt files.
I prefer free formats.
http://it.wikipedia.org/wiki/Formato_aperto
http://en.wikipedia.org/wiki/Open_format

Ivan Marchesini
Perugia (Italy)
Socio fondatore GFOSS "Geospatial Free and Open Source Software" 
http://www.gfoss.it
e-mail: marches...@unipg.it
ivan.marches...@gmail.com
fax (home): +39(0)5782830887
jabber: geoiva...@jabber.org
skype: geoivan73


signature.asc
Description: Questa è una parte del messaggio firmata digitalmente


Re: Mysql sleeping queries

2007-06-21 Thread Ivan Sagalaev

Malcolm Tredinnick wrote:
> One other thing that I forgot in my earlier email: it's not actually
> clear why the database connections get "lost" in the current
> implementation. We close the connection too early, but when the template
> rendering needs to access the database, it just opens a new one (that is
> why everybody is seeing more opens than closes). However, the next time
> that thread or process is used, Django should be reusing the same
> connection, since it will still be open and we check for an existing
> connection before opening a new one.

In case of threads the old thread's connection can't be reused because 
it is stored in thread.local() and a new thread is new thread. This 
ad-hoc 'pooling' actually never worked AFAIR... And I suspect that at 
least under Apache every new request results in a new Python thread both 
with prefork and worker mpms.

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



Re: Mysql sleeping queries

2007-06-21 Thread Ivan Sagalaev

Malcolm Tredinnick wrote:
> Thanks, Ilya. I'd gotten that far, too. Unfortunately, though, it isn't
> quite that easy. Well, it is that easy for mod_python, however for WSGI
> compliance, we can't do that (since the WSGI handler returns an
> iterable).

But a WSGI server calls "close()" on the iterator after iteration and we 
support this in HttpResponse. Why not send "signals.request_finished" there?

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



Re: Mysql sleeping queries

2007-06-21 Thread Ivan Sagalaev

Malcolm Tredinnick wrote:
> Perhaps read the remainder of the thread? :-)

Sorry, I was too impatient this time :-)

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



Re: Per-domain ROOT_URLCONF and TEMPLATE_DIRS

2007-06-30 Thread Ivan Sagalaev

Vladimir Pouzanov wrote:
> Hi all,
> 
> I have two sites that run nearly identical django instances. I wonder
> if it's possible to somehow set per-domain ROOT_URLCONF and
> TEMPLATE_DIRS to serve both sites from one django process.

Why not just have two settings files? If you have common settings you 
can keep them in one file and then import everything from it in each 
setting file:

 from common_settings import *

 # Specific TEMPLATE_DIRS
 TEMPLATE_DIRS = (
 ...
 )

 # Specific urlconf
 ROOT_URLCONF = ...


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



Re: Per-domain ROOT_URLCONF and TEMPLATE_DIRS

2007-06-30 Thread Ivan Sagalaev

Jeremy Dunck wrote:
> Two settings files being used by a single process?
> 
> How would that work?

Oh... I missed the bit about a single process. But now I wonder why 
require this? One server can happily serve two sites either from 
separate mod_python handlers or separate FastCGI servers.

Vladimir, why do you need a single process?

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



Re: Random character in rendered HTML

2007-07-24 Thread Ivan Sagalaev

brutimus wrote:
> {% block content %}
> 
> {% include "whatever.html" %}
> {% endblock %}

This is most certainly a BOM -- Byte Order Mark of a UTF-8 charset that 
your text editor has added at the beginning of the 'whatever.html'. It's 
a part of UTF-8 and those symbols are normally not seen when they are at 
the beginning of the string. However here this string is included in the 
middle of another and symbols are visible.

It looks like a bug in Django, it should strip BOM when loading utf-8 
templates... For now you may try to work around it by trying to set up 
you editor to not save a BOM (if it can do this).

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



Re: XML output

2007-08-11 Thread Ivan Sagalaev

Alex Nikolaenkov wrote:
> Hello guys,
> I like just about everything in django, but at this point of me reading django
> book I can't imagine the way of xmlizing django.

There are serializers in Django: 
http://www.djangoproject.com/documentation/serialization/

> Is there a way to use XSLT templates instead of standard django template 
> language?

It could look something like this (not tested of course :-) ):

 from django.core import serializers
 from models import MyModel

 def my_view(request):
   object_list = MyModel.objects.all()
   xml = serializers.serialize('xml', object_list)
   return HttpResponse(xml, mimetype='application/xml')

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



Re: Don't Repeat Yourself!

2007-08-11 Thread Ivan Sagalaev

sago wrote:
> The feed approach for routing urls is everything that django's url
> system was designed not to be: it imposes a hierarchical structure on
> the url, distributes the configuration over multiple representations,
> and could be avoided by having a feed view that behaves more like
> generic views:
> 
> 
> 
> Am I wrong to feel this way?

Can't say about wrong or not but I certainly felt the same way when I 
first used the syndication framework. Back then I decided not to worry 
too much about it but, yes, it would be nicer to have urlconfs behaving 
like they should in this field also.


So it's basically just mine +1 :-)

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



Re: unicode characters garbled on dumpdata / loaddata using postgres

2007-08-22 Thread Ivan Sagalaev

Wiley wrote:
> I was wondering if anyone else had trouble or a workaround for dumping
> and loading data with mixed character sets using a postgres backend.
> My data has quite a few Chinese characters, they run from my normal
> installation fine, but when i dump and reload the data, it's all
> corrupted.  Any hints here?

Are you using latest trunk builds? There were still a couple of problems 
with serialization in 0.96 release that were fixed on trunk by switching 
Django to unicode [1]. Now all should work fine.

[1]: 
http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist

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



Re: @url tag - getting rid of urlpatterns

2007-08-29 Thread Ivan Sagalaev

Ilya Semenov wrote:
> === apps/app1/views/__init__.py ===
> @url(r'^index/$')
> def index(request):
>   ...
> 
> @url(r'^news/$')
> def news(request):

While the decorator looks nice it creates in my opinion at least as many 
problems as it solves.

1. You can apply decorators only to custom views, not to generic views. 
And as generic views are commonly used one still should keep a separate 
urls.py for them.

2. One of the best things (again, in my opinion) of urls.py is that it 
shows whole user interface of an app in one place. You loose this 
feature with decorators scattered all over views.

BTW, do you know that you can use function objects instead of their 
names in url definition? So this:

 urlpatterns = patterns(__name__,
 (r'^index/$', 'index'),

becomes just:

 urlpatterns = patterns('',
 (r'^index/$', index),

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



Re: @url tag - getting rid of urlpatterns

2007-08-30 Thread Ivan Sagalaev

Ilya Semenov wrote:
> Second, I think the use of generic views is over-estimated. Generic
> views do not even support access restrictions (@user_passes_test) and
> thus are most of the time proxied via custom one-line views.

Actually they support decoration perfectly well, right in urls.py:

 from django.views.generic.list_detail import object_detail
 from some_decorators import decorator

 urlpatterns = patterns('',
 (r'...', decorator(object_detail), { ... }),
 )

Though I agree that generic views require some time get used to...

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



Re: django multi application, multi database, need to sync..

2008-01-17 Thread Ivan Illarionov

On 17 янв, 05:58, otonk <[EMAIL PROTECTED]> wrote:
> hi, i am currently designing two or more django application, one
> application act as the master application, contains all the data, the
> other application has partial function of the master application. The
> master database belongs to the master application, other database has
> a partial data from the master database. The reason we have such
> design is these application is separated geographically and the
> connection may not be always available. The problem with this design
> is how to move partial data from master db to other db, the sync
> process is triggered by user. I need an way to sync the data. I know
> this is doable but I am confused with the implementation. Any solution
> is appreciated. Thank you.

Create the sync script using the Python DB API directly (no Django
ORM). And then trigger it either automatically with the cron job or
manually, by wrapping that script inside django view. You may want to
add `modified` DateTimeField to all your Django models and store the
last sync date/time somewhere. So the sync script should only SELECT
records from master database where 'modified' is greater than last
sync date and INSERT/UPDATE it into other database.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django multi application, multi database, need to sync..

2008-01-18 Thread Ivan Illarionov

And it's also important to not really delete records from database.
Use the 'delete' boolean field to mark unneeded records.

On 18 янв, 06:18, otonk <[EMAIL PROTECTED]> wrote:
> > Create the sync script using the Python DB API directly (no Django
> > ORM). And then trigger it either automatically with the cron job or
> > manually, by wrapping that script inside django view. You may want to
> > add `modified` DateTimeField to all your Django models and store the
> > last sync date/time somewhere. So the sync script should only SELECT
> > records from master database where 'modified' is greater than last
> > sync date and INSERT/UPDATE it into other database.
>
> cool thanks Ivan..
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django multilingual

2008-01-26 Thread Ivan Illarionov

Piotr, having django-multilingual features in the core won't make them
any better. Complex models and use-cases will still need custom/manual
solutions. It will add unneeded overhead to single-language sites and
may even break the sites that use explicit custom solutions (like
mine).

I am developing several 2 language projects with Django and I don't
use django-multilingual - I do all multilingual tasks manually - and
some code is hardcoded/optimized for my Russian/English needs - no
general-purpose solution will ever 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django multilingual

2008-01-27 Thread Ivan Illarionov

Models that need flexibility have `lang` and `is_translation_of`
fields. Views (or custom managers) filter the output based on `lang`
and add the link to other language if translation exists. Some models
just have two separate text fields for each language and views (or
custom managers) display the text from either one or another. Some
content appears only in one language and is hardcoded into views/
templates. My multilingual projects deal only with two languages:
Russian and English - and don't have the goal to support more. I try
to customize each language version of the site to reflect both
cultural and local/international differences - any automagic solution
will fail to do that.

On 27 янв, 15:28, maco <[EMAIL PROTECTED]> wrote:
> Can you share the logic behind the models and views you use. Don't
> need to go into details, just the philosophy behind it, 
> eg.http://orestis.gr/en/blog/2007/05/14/international-part3/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error Message Best Practice Question

2008-01-27 Thread Ivan Sagalaev

[EMAIL PROTECTED] wrote:
> This seems kind of hacky, but it really seems like it makes sense to
> show this as a form error. The only other way I could think to solve
> this was to pass the request to the model and then check the above in
> the clean method, however this seems just as bad as it breaks the
> separation between the view and the model. Does anyone have a
> different suggestion as to how to do this cleanly?

It's really better to have this check in clean_number method of the form 
since it's effectively a field's error. Your form declaration would look 
like this:

 class CreditCardForm(ModelForm):
 class Meta:
 model = CreditCard

 def __init__(self, user, *args, **kwargs)
 super(CreditCardForm, self).__init__(*args, **kwargs)
 self.user = user

 def clean_number(self):
 if CreditCard.objects.filter(
number=self.cleaned_data['number'],
user=self.user):
 raise ValidationError('Duplicate Credit Card')
 return self.cleaned_data['number']

Note that form's __init__ accepts a user object that is required for 
this check. This will separate form logic from web request. In a view 
you instantiate the form like this:

 form = CreditCardForm(request.user, request.POST)

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



Re: Best practice for implementing multilingual content in template

2008-01-28 Thread Ivan Illarionov

IMO code_berzerker's approach is the best for complex models. But in
many cases that don't require a lot of flexibility it can be better to
use simpler approach with text fields for each language and function/
property to get the right field from templates. I  even wrote the
metaclass to make this DRY.

http://pastebin.com/m715ba882

You might need to edit the LANGUAGES tuple for your needs and add
__metaclass__ = MultilingualModelBase in the beginning of your
multilingual model classes. Properties will be automatically created.
If your model has `title_en` and `title_sv` this metaclass will create
`title` property that will get the right filed based on
settings.LANGUAGE_CODE.

Hope this helps.

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



Re: Best practice for implementing multilingual content in template

2008-01-28 Thread Ivan Illarionov

Made some corrections:
http://pastebin.com/d6337d211

On Jan 28, 10:45 pm, Ivan Illarionov <[EMAIL PROTECTED]>
wrote:
> IMO code_berzerker's approach is the best for complex models. But in
> many cases that don't require a lot of flexibility it can be better to
> use simpler approach with text fields for each language and function/
> property to get the right field from templates. I  even wrote the
> metaclass to make this DRY.
>
> http://pastebin.com/m715ba882
>
> You might need to edit the LANGUAGES tuple for your needs and add
> __metaclass__ = MultilingualModelBase in the beginning of your
> multilingual model classes. Properties will be automatically created.
> If your model has `title_en` and `title_sv` this metaclass will create
> `title` property that will get the right filed based on
> settings.LANGUAGE_CODE.
>
> Hope this helps.
>
> --Ivan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Question

2008-01-29 Thread Ivan Illarionov

> Fortnately, Python makes this very easy with the built-in
> property() call:
>
>   class MyModel(Model):
> surname = CharField(...)
> forenames = CharField(...)
> def _get_name(self):
>   return self.forenames + ' ' + self.surname
> name = property(fget=_get_name)

Python (2.4+) makes it even easier with decorator:
class MyModel(Model):
surname = CharField(...)
forenames = CharField(...)
@property
def name(self):
return 'self.forenames + ' ' + self.surname
or, better:
   @property
   def name(self):
return '%s %s' % (self.forenames, self.surname)

or one-liner (not very good):
name = property(lambda self: '%s %s' % (self.forenames, self.surname))


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



1.3x-3x Model Instantiation Optimization

2008-01-29 Thread Ivan Illarionov

After discussion on Django developers group about
Model.__init__(*args) deprecation I found the way to dramatically
optimize instantiation of Django models. Here is a code: 
http://pastebin.com/m8e7e365

You may add this code to your Django model class and then instead of
obj = YourModelClass(title='Title', ,
pub_date=datetime.datetime.now() )
use
row = (None, 'Title',..., datetime.datetime.now())
obj = YourModelClass.fromtuple(row) # 1.3x faster then before
or
obj = YourModelClass.fromtuple(row, False) # 3x faster then before
only if you don't need pre_init and post_init signals!

The number of tuple items should be exactly the same that number of
fields.

And, be careful, the code is experimental, untested and relies on deep
black magic of object.__new__(class) which creates the instance
without calling __init__
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

I had A LOT of similar problems when I need to work with cyrillic. I
can easily replay your problem. Fortunately I'm on localized Windows
machine.
So:
>>> path = r'C:\Documents and Settings\vanilla'
>>> os.path.isdir(path)
True
>>> os.listdir(path)[-1]
'\xd8\xe0\xe1\xeb\xee\xed\xfb'
>>> a = os.listdir(path)[-1]
>>> a
'\xd8\xe0\xe1\xeb\xee\xed\xfb'
>>> a.decode('utf-8')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1:
invalid dat
a

Here it is! Extremely difficult to diagnose problem!

And let's fix it:
>>> import sys
>>> a.decode(sys.getfilesystemencoding())
u'\u0428\u0430\u0431\u043b\u043e\u043d\u044b'
>>> b = a.decode(sys.getfilesystemencoding())
>>> print b
Шаблоны
>>> c = b.encode('utf-8')

Fixed

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



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

It looks that you have encoding problem. You have wrong characters
somewhere. The solution is to find the text that causes problems and
create custom encode and/or decode function that fixes this.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

> Our database is utf8 we explicitly convert ignoring errors to utf8
> before passing to textile. Also it's not 1 page that poops it's every
> site pooping at once.
That means that the problem is inside something that shows on every
page.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

You have this in your log:

func

  
  ignore_failures

  False

Maybe try to change this to True. And double check that everything is
converted with 'ignore'.

Another option: store the textiled xhtml in database.

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



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

You pass unicode value to textile.textile. I was able to repeat your
error by doing the same: textile.textile breaks with similar error
when it recieves a unicode string. It can be fixed by encoding your
value as utf-8 before passing to textile.textile.

Your error log has:
return textile.textile(value, encoding=settings.DEFAULT_CHARSET,
output=settings.DEFAULT_CHARSET)

But current Django trunk has:
return mark_safe(force_unicode(textile.textile(smart_str(value),
encoding='utf-8', output='utf-8')))

So you need to update your django/contrib/markup/templatetags/
markup.py and problem should dessapear.

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



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

Your problem was solved here:
http://code.djangoproject.com/changeset/5609/django/trunk/django/contrib/markup/templatetags/markup.py

You may have other problems if you mix trunk with 0.96. Many bugs are
solved in trunk - the best strategy is to update everything.

Hope, this helps.
-- Ivan

On Jan 30, 8:25 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote:
> You pass unicode value to textile.textile. I was able to repeat your
> error by doing the same: textile.textile breaks with similar error
> when it recieves a unicode string. It can be fixed by encoding your
> value as utf-8 before passing to textile.textile.
>
> Your error log has:
> return textile.textile(value, encoding=settings.DEFAULT_CHARSET,
> output=settings.DEFAULT_CHARSET)
>
> But current Django trunk has:
> return mark_safe(force_unicode(textile.textile(smart_str(value),
> encoding='utf-8', output='utf-8')))
>
> So you need to update your django/contrib/markup/templatetags/
> markup.py and problem should dessapear.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 1.3x-3x Model Instantiation Optimization

2008-01-30 Thread Ivan Illarionov

> Hm, a code running fast is really good but this solution seems to be really
> experimental and hard-to-use, as well as making code kinda unreadable. It
> would be great if it's implemented in next django releases to make django
> fast :). Is it possible to do it?

It depends on Django developers. I propose this to be included in core
Model class as alternative method, because they want to disable
instantiation from positional args.

But they also want to keep their API as clean as possible. Two methods
of doing one thing violates Python philosophy. And this is a good
point - features like these are not oriented for all Django users -
they need more skill and Python knowledge to be used effectively. It's
not for Django core - it's for 3rd party Django extensions and for
advanced Django customization/optimization by Django  :)

> And exactly in the same order they appear in instance._meta.fields...
Yes. Tuple instantiation can be very handy and fast - but requires
more care and testing. And disabling of Model.__init__ signals should
be even more careful - they are extremely slow and rarely used - but
some code may depend on them, so you need to double check that they
are not used anywhere.

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



Re: We're having an extremely difficult to diagnose problem:

2008-01-30 Thread Ivan Illarionov

The problem here is not about wrong encoding of strings - it's all
about unicode/string relationship and from-unicode-to-string/from-
string-to-unicode problem.

I really think that it will be fixed if you replace
return textile.textile(value, encoding=settings.DEFAULT_CHARSET,
output=settings.DEFAULT_CHARSET)

with, at least:
return textile.textile(value.encode(settings.DEFAULT_CHARSET),
encoding=settings.DEFAULT_CHARSET,
output=settings.DEFAULT_CHARSET)

or, better:
return textile.textile(smart_str(value), encoding='utf-8',
output='utf-8')

in django/contrib/markup/templatetags/markup.py


On 30 янв, 18:51, Noah <[EMAIL PROTECTED]> wrote:
> Our default encoding is UTF-8 and that problem would manifest more
> often and not take out the whole server.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: We're having an extremely difficult to diagnose problem:

2008-01-30 Thread Ivan Illarionov

If you don't want to rely on Django's smart_str, you can do following:
if isinstance(value, unicode):
value = value.encode('utf-8', 'ignore')
return textile.textile(value, encoding=settings.DEFAULT_CHARSET,
output=settings.DEFAULT_CHARSET)

textile.textile() certainly breaks with your error if given unicode
object. Anyone can repeat it. The problem probably doesn't manifest
more often because textile.textile() could get strings in most cases
and only in few cases it gets unicode - and then your server breaks.

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



Re: How to know if an object is being created in the save() method?

2008-01-30 Thread Ivan Illarionov

There is 'post_save' signal with 'created' parameter. But,
unfortunately, this feature is undocumented...


On Jan 31, 6:44 am, Julien <[EMAIL PROTECTED]> wrote:
> Hello there,
>
> Does the title says it all? When overriding the save method of an
> object, I'd like to know if that object is being created or updated.
>
> How I do it so far is:
>
> def save(self):
> if self.pk:
> ...=> being created
> else:
> ...=> being updated
>
> I vaguely remember seeing a parameter for the save method which would
> do that, but I can't find it. Any thoughts?
>
> Thanks!
>
> Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to know if an object is being created in the save() method?

2008-01-30 Thread Ivan Illarionov

Example of post_save with 'created' flag is in Django tests:
http://code.djangoproject.com/browser/django/trunk/tests/modeltests/signals/models.py
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Any way to know if a value has changed before saving?

2008-01-31 Thread Ivan Illarionov

> def save(self):
> if self.stuff !=
> magic_function_that_tells_what_is_in_database_for('stuff')
> do_this()
> super(A, self).save()

This 'magic function' is
self.__class__.objects.get(id=self.id).stuff

if self.stuff != self.__class__.objects.get(id=self.id).stuff:
do_this()



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



Re: how to speed up objects saving

2008-02-01 Thread Ivan Illarionov

You have two options:
1. Execute raw SQL 'INSERT' queries
2. Override the Model.save() or create new save_fast() method in your
Model class. The main speed eaters in Model.save() are
dispatcher.send() calls - so if you copy/paste the content of save
method from Django code without  dispatcher.send() lines you'll get a
reasonable speed increase.

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



Re: how to speed up objects saving

2008-02-01 Thread Ivan Illarionov


> I'll try to redefine save methods in all the objects to see how much time it
> saves

You may want to redefine the __init__ methods as well (it's called
when you create your objects before save), it adds overhead of two
more signals that are probably unused and can be removed for speed.

You can try comment out all dispatcher.send() lines of __init__ and
__save__ methods of Model class in /django/db/models/base.py and save
the file as base2.py in the same place inside your Django package and
say something like `from django.db.models.base2 import Model as
MyModel' and replace model.Model with MyModel in class definitions.

I know it's hackish, but it's easier and it works. :)

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



Re: Flash and Django

2008-02-01 Thread Ivan Illarionov

http://djangoamf.sourceforge.jp/index.php?DjangoAMF_en

On 1 фев, 18:33, "Ronaldo Z. Afonso" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm new in Django and Web development and I just want to know if it's
> possible to have a flash script showing elements that was retrieve from
> a data base by django?
> Any link or documentation would be appreciated.
> Thanks.
>
> Ronaldo.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best practices for creating Manager methods?

2008-02-24 Thread Ivan Illarionov

> def create_user(self, username, email, password=None):
> def make_random_password(self, length=10,
> allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'):
>
> These two methods seem to involve situations where they need to act on
> a model, but the object instance hasn't been created yet.  Should
> managers always be used for this?
Dave, these methods are methods of "UserManger" which is a Manager.
The Model that uses this Manager is called "User" and is a little
deeper in the code.
It looks that you misunderstood the code.

> Have people placed similar functionality within the model classes
> directly?  I suppose it depends on whether you need the functionality
> in absence of an object instance...
There was a discussion about this rescently. Classmethods and
staticmethods will work, as well as plain module-level functions, but
a Manager is a preferred way in Django.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread Ivan Sagalaev

fizban wrote:
> On 12 Apr, 12:54, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>> It sounds like you're using markdown 1.7. We haven't yet incorporated
>> the patch necessary to handle markdown 1.7 along with the earlier
>> versions. That will go in soon, though -- there's already a ticket in Trac 
>> for it.
> 
> Ok, that sounds cool (the pending fix, not the backwards incompatible
> changes); thank you for the reply

BTW, there is [python-markdown2][1] that doesn't have problems with 
neither unicode, nor byte strings in utf-8.

[1]: http://code.google.com/p/python-markdown2/

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



Re: Feel free to test queryset-refactor branch

2008-04-13 Thread Ivan Illarionov

Glad to hear that queryset-refactor is almost ready.

Currently, I noticed that there are few SQL portability issues and few
old queryset API issues (eg in admin). I already filed #6956 and
#6957.  I do some heavy testing of this branch and I will report
anything that goes wrong.

Regards,
--
Ivan

On Apr 13, 3:23 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> We're getting pretty close to merging queryset-refactor into trunk and
> would like to do this as soon as practical. There are still a couple of
> enhancements to add (#5420, mostly), one bug to fix (#5937) and some
> internal tweaking to do, but all the main stuff is ready to be used.
>
> So if anybody wants to test it out, go ahead. Read the wiki page[1] if
> you've got code that does any slightly unusual stuff, but for existing
> code that works on trunk, there shouldn't be any real changes required.
>
> [1]http://code.djangoproject.com/wiki/QuerysetRefactorBranch
>
> File any bug reports in Trac against the queryset-refactor
> "version" (please do NOT put the qs-rf keyword on the ticket; I'm using
> that for other purposes). Bug reports that are regressions from existing
> functionality are more interesting and important at the moment than
> feature enhancements to the new features, since the latter case can be
> dealt with at our leisure (they're not features that people are already
> relying upon).
>
> If you see any different results testing against the branch compared to
> trunk, it would be interesting to know about them. Reduce it to a small
> example before opening a ticket, wherever possible. Please don't make me
> wade through dozens of lines of code just to get to one query that is
> relevant. Bear in mind, though, that the difference could be because a
> bug existed in trunk and the branch is now giving the correct result. So
> make sure your test case is valid (even I got bitten by that in a
> project I wrote).
>
> Regards,
> Malcolm
>
> --
> The sooner you fall behind, the more time you'll have to catch 
> up.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi DB question

2008-04-17 Thread Ivan Sagalaev

shabda wrote:
>> You could use SQLAlchemy to access your forum database, as long as you
>> don't need it in the admin.
> 
> As, I just need to access the other DB in one place, I think this is
> the way to go here.

Come on guys! If you just need to create a record in a DB you certainly 
don't need *any* framework for it. It's a Python world, you can just 
write stuff here, not wait for any vendor to supply a framework for 
every possible movement.

This is as simple as:

 db = MySQLdb.connect(host='..', user='..', passwd='..')
 cursor = db.cursor()
 cursor.execute('insert into .. ')

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



Re: Trouble installing PIL

2008-05-23 Thread Ivan Illarionov

There is one common problem with PIL: if you tried to install it
*before* you install JPEG and other libraries, it won't recompile C
extensions with newer headers and libraries.

The solution is to rebuild PIL with -f switch:
python setup.py build_ext -f
(sudo) python setup.py install

Hope this helps.

Ivan

On 19 май, 03:22, Austin Govella <[EMAIL PROTECTED]> wrote:
> I used MacPorts to install jpeg (libjpeg), freetype, zlib, and then
> Python Imaging Library.
>
> When I validate, I get the "no PIL" error.
>
> Error: One or more models did not validate:
> imagetest.filetest: "image": To use ImageFields, you need to install
> the Python Imaging Library. Get it athttp://www.pythonware.com/products/pil/
> .
> imagetest.imagetest: "image": To use ImageFields, you need to install
> the Python Imaging Library. Get it athttp://www.pythonware.com/products/pil/
> .
>
> Any tips on where the problem might be?
>
> (This is my nth attempt. I was using Fink to install libjpeg and zlib,
> but when I installed PIL from source, it could never find libjpeg or
> zlib... :-(   Any tips or links on installing on osx 10.4 greatly
> appreciated.)
>
> Thanks,
> --
> Austin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ImportError: No module named _md5

2008-06-26 Thread Grunev Ivan

Hello

You need to install md5 module at first.

On Thu, 2008-06-26 at 22:28 -0700, [EMAIL PROTECTED] wrote:
> Hello,
> 
> I'm trying to install MySQL-python-1.2.2 and don't know how to resolve
> tis error:
> 
> jason-neridas-macbook:~ jasonnerida$ cd /Users/jasonnerida/Downloads/
> MySQL-python-1.2.2
> jason-neridas-macbook:MySQL-python-1.2.2 jasonnerida$ python setup.py
> build
> Traceback (most recent call last):
>   File "setup.py", line 5, in 
> import ez_setup; ez_setup.use_setuptools()
>   File "/Users/jasonnerida/Downloads/MySQL-python-1.2.2/ez_setup.py",
> line 83, in use_setuptools
> egg = download_setuptools(version, download_base, to_dir,
> download_delay)
>   File "/Users/jasonnerida/Downloads/MySQL-python-1.2.2/ez_setup.py",
> line 111, in download_setuptools
> import urllib2, shutil
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> lib/python2.5/urllib2.py", line 91, in 
> import hashlib
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> lib/python2.5/hashlib.py", line 133, in 
> md5 = __get_builtin_constructor('md5')
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> lib/python2.5/hashlib.py", line 60, in __get_builtin_constructor
> import _md5
> ImportError: No module named _md5
> 
> Thanks for any assistance,
> 
> Jason
> > 
-- 
With best regards,
Project Manager  
Ivan Grunev
Email: [EMAIL PROTECTED]  
Work Phone: +7(383)330-6626 ext 104
MSN: [EMAIL PROTECTED]  
YM: [EMAIL PROTECTED]  
Skype: ivan.grunev  
Sibers Group Ltd. (HireRussians)
http://sibers.com/ (http://hirerussinas.ru)


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



Re: {% url %} syntax in templates

2007-02-18 Thread Ivan Sagalaev

omat * gezgin.com wrote:
> And url pattern that matches the view is
> (r'^photo/(?P[-\w]+)/(?P\d+)/$',
> 'artist.views.artist_photo'),
> 
> Images are displaying fine but the links does not appear. (i.e. {% url
> artist.views.artist_photo slug=artist.slug,id=photo.id %} does not
> render anything.
> 
> Do you have any idea what is wrong with my syntax?

The syntax is correct, I just got it working on my machine. Things to check:

- Does your template's context actually contain an object 'artist' with 
a non-empty slug? Non-empty because your url pattern expects it this way.

- Is photo.is is a number?

- What is the first parameter in your patterns() that contains this 
pattern? It it's not empty then the actual view name will be 
concatenated after that prefix.

- Is this urlconf file included in the root urlconf? E.g. does your 
project find a URL like /photo/something/1/ ?

> Also I think this syntax works only if the view is defined as a string
> in the urls.py. Is this true?

No, it works with callable views just fine.

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



Re: unicode in filters

2007-02-19 Thread Ivan Sagalaev

Dirk Eschler wrote:
> you can try to add this as first line in your file:
> 
> # -*- coding: utf-8 -*-

And after this there's no need to write u'ç'.encode('utf-8') but is 
enough to write just 'ç'.

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



Re: installation-wide fixed language

2007-02-26 Thread Ivan Sagalaev

omat * gezgin.com wrote:
> Yes, but I want the application to be internationalized. I want only
> one of the installations to have only one translation.

I had this problem on my site. I don't know if it's a bug or not but I 
managed to make it work by choosing English as a default language and 
Russian (in my case) as a translation. As I understand, with gettext you 
can't have exactly one language because it has separate concepts of a 
default language and translations.


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



Re: Persistent connections

2007-02-27 Thread Ivan Sagalaev

[EMAIL PROTECTED] wrote:
> Is this truly the case? I thought Django used a persistent db
> connection.

No, Django closes connections upon each request. There were some 
discussions about it in the early days and some consensus was along the 
lines that a simple ad-hoc solutions like "just don't close connections" 
wouldn't suffice and it's better for the user to use solid external 
tools. pgpool is an example of such a tool for Postgres and there is 
also SQLRelay that works for many DBs.

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



Re: select_related() and null=True

2007-03-06 Thread Ivan Sagalaev

Ilya Semenov wrote:
> What different approach could I choose? I'm writing real-life model -
> a Ticket can either have a User (who resolved it), or not (if the
> ticket has not been yet resolved). Listing all resolved Tickets with
> corresponding Users is a simple real-life task, too.

Indeed... However Django does not implement it as of now. It would be 
fine if you create (or just find) a ticket on this issue in Django Trac 
(http://code.djangoproject.com/). Note, though, that the code dealing 
with query construction is undergoing a heavy refactoring so it may take 
a while to implement this behavior.

> How do I find a different approach? The only solution which comes to
> my mind is to create a "special" User with id=0, and make all None
> references point to it instead, but this seems very unnatural and
> hackish to me.

I'd suggest to do just this (not exactly with some special id but with 
some special username). This is, in fact, one of the classic 
refactorings from M. Fauler's book -- "Introduce NULL object". In short, 
having an object that acts as "nobody", "nothing", "not initialised" etc 
is more convenient than having the field just NULL because then there 
are far less places where you should do NULL checks.

For example (simplified) you can set username to "nobody" and in a 
template write:

 {{ ticket.user }}

instead of:

 {% if ticket.user %}{{ ticket.user }}{% else %}nobody{% 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: getting raw SQL queries

2007-03-09 Thread Ivan Sagalaev

Iapain wrote:
> Hello,
> 
> I am writing a SQL logviewer for sql queries fired by django. If I use
> below code then i get an empty list of dictionary.
> 
> from django.db import conneciton
> from django.conf import settings
> debug = settings.DEBUG #btw its always True, because i set it to true
> in my settings.py
> settings.DEBUG = True
> print str(connection.queries)

Where is this code located? A common error is to place such logs in a 
view before rendering a response while many queries happen during 
response generation from templates.

Your best bet is to put this logic in a response middleware and place it 
  last.

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



Re: BooleanField won't update

2007-03-13 Thread Ivan Sagalaev

[EMAIL PROTECTED] wrote:
> def update_snip(request):
> u = User.objects.get(id=request.session['userid'])
> snip = Snippet.objects.filter(id=snippet_id,user=u)
> snip[0].active = 0
> snip[0].save()
> print "Active = %s" % snip[0].active
> 
> This NEVER works. What am I doing wrong?

This is because 'snip' is not a list but a queryset and 'snip[0]' is 
implemented in a way to just add 'LIMIT 1' to the query. And this query 
is executed each time when you try to access an attribute of 'snip[0]' 
thus giving you new fresh copy of the object from database:

 snip[0].active = 0 # get a snip, set active = 0
 snip[0].save() # get a snip from db again and save it

This is why 'active' is never saved.

Assign 'snip[0]' to a variable and it will work as expected.

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



Re: {% url %} problem

2007-03-13 Thread Ivan Sagalaev

akonsu wrote:
> i think the reason is two entries in the urlpatterns with the same
> view. is this a bug?

Well, not exactly a bug but a limitation of "reverse" function that {% 
url %} uses to do actual resolving. Incidentally there is a thread in 
django-developers[1] about solving a similar issue.

But in your case I believe you can just collapse both url patterns into 
one since they point to the same view:

 urlpatterns = patterns('',
   (r'^(\w+)?/?$', 'path.to.myview'),
 )

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



Re: {% url %} problem

2007-03-13 Thread Ivan Sagalaev

akonsu wrote:
> thank you Ivan,
> 
> the problem with collapsing is that the 'name' parameter in my view
> does not get the default value then if the url is empty.

Oh... Indeed :-( Then may be just checking the value inside the function 
is your best bet for this case.

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



  1   2   3   4   5   6   >