Django not enforcing blank=False on a model

2013-07-29 Thread Knight Samar
Hi,

I have a model

> from django.db import models
>
> class Organization(models.Model):
> name = models.CharField(max_length=100,
> blank = False,  #mandatory
> help_text = "Name of your Organization",
> verbose_name = '',
> unique = True,
> primary_key = True,
> )
>
>
and a piece of code

> from organization.models import Organization
> o = Organization.objects.create() 
> o.save() 


which works *without raising an IntegrityError!* And the following also 
works just the same!

> from organization.models import Organization
> o = Organization() 

o.save() 


I am using SQLite3(SQLite 3.7.9 2011-11-01 00:52:41 
c7c6050ef060877ebe77b41d959e9df13f8c9b5e) as the database backend and it 
shows the following as the schema:

CREATE TABLE "organization_organization" ( "name" varchar(100) NOT NULL 
> PRIMARY KEY ); 

 
Even if SQLite3 was buggy, shouldn't Django itself enforce the constraint 
on ORM layer ?

I have deleted .pyc files and also the .sqlite3 file before testing again. 
I am using Django 1.5.1

What am I missing ? Why is Django *NOT* enforcing blank=False ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: invalid literal for int() with base 10

2012-10-22 Thread Nathan Knight
Just so you know, it is bad practice to use "import * " when importing 
modules in python.
With many modules being used, you can run into conflicting definitions. 
Plus, it increases overhead - potentially an exponential decrease in 
performance! 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rIiEjKPOpX8J.
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: Management form in Model Formsets

2012-07-01 Thread Knight Samar

Thanks Thomas! I checked the script and tried to follow it.

It seems that for Django 1.2, *not* modifying the form-TOTAL_FORMS, 
form-INITIAL_FORMS and form-MAX_NUM_FORMS works properly!! 

Regards,
Samar

On Sunday, 1 July 2012 22:12:37 UTC+5:30, Thomas Orozco wrote:
>
> You might want to check this snippet out: djangosnippets.org/snippets/1389
> */*
> Le 1 juil. 2012 06:27, "Knight Samar" <knightsa...@gmail.com> a écrit :
>
>> Hi,
>>
>> I am using Django 1.2 and developing using Model formsets. Using 
>> JavaScript, I am allowing the user to dynamically "Add another" formset on 
>> the template, but I can't figure out what exactly I have to modify in the 
>> management forms, for all the formsets to be successfully saved.
>>
>> The documentation points out to three properties in the management form - 
>> form-TOTAL_FORMS, form-INITIAL_FORMS and form-MAX_NUM_FORMS. But I don't 
>> understand, which properties I have to exactly modify and how, when a new 
>> formset is being added dynamically using JavaScript ?
>>
>> Thanks :)
>>
>> Regards,
>> Samar
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/Ecs6EVDku_YJ.
>> 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.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/0MFh_Lo5aDEJ.
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.



Management form in Model Formsets

2012-06-30 Thread Knight Samar
Hi,

I am using Django 1.2 and developing using Model formsets. Using 
JavaScript, I am allowing the user to dynamically "Add another" formset on 
the template, but I can't figure out what exactly I have to modify in the 
management forms, for all the formsets to be successfully saved.

The documentation points out to three properties in the management form - 
form-TOTAL_FORMS, form-INITIAL_FORMS and form-MAX_NUM_FORMS. But I don't 
understand, which properties I have to exactly modify and how, when a new 
formset is being added dynamically using JavaScript ?

Thanks :)

Regards,
Samar

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Ecs6EVDku_YJ.
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.



Getting children of an ABC

2012-01-01 Thread Knight Samar
I am using Django 1.3.1 and I have the following piece of models:

class masterData(models.Model):
uid = models.CharField(max_length=20,primary_key=True)

class Meta:
abstract = True;

class Type1(masterData):
 pass;

class Type2(masterData):
 pass;

Now, I am trying to get a list of all child classes of masterData. I
have tried:

masterData.__subclasses__()

The very interesting thing that I found about the above is that it
works flawlessly in *python manage.py shell* and does NOT work at all
when running the webserver!

So how do I get the models derived from an Abstract Base Class model ?

Regards,
Samar

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



Documentation error?

2011-03-14 Thread Adam Knight
On the description for django.contrib.auth.views.login at
http://docs.djangoproject.com/en/1.2/topics/auth/#django.contrib.auth.views.loginthe
documentation says:

If you are using alternate authentication (see Other authentication sources)
> you can pass a custom authentication form to the login view via the
> authentication_form parameter. This form must accept a request keyword
> argument in its __init__ method, and provide a get_user method which returns
> the authenticated user object (this method is only ever called after
> successful form validation).


Note the phrase "This form must accept a request keyword argument in its
__init__ method".  When I do this as it literally states and expect a
"request" keyword argument, I don't get a request.  When I looked at
django.contrib.auth.views.login on line 31 I see that it's actually setting
the keyword argument "data" instead.

Did I miss something or is this a bug I should file?

(Yes, expecting the "data" keyword works perfectly, but it's not in the
documentation that I can see.)
-- 
Adam

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



load auth data with natural keys

2010-08-17 Thread knight
Hi,

I am using django 1.2.1. I dumped the auth data with natural keys (--
natural), but when I try to load them I get the following error:

Installing xml fixture 'auth' from absolute path.
Problem installing fixture 'auth.xml': Traceback (most recent call
last):
  File "/var/peertv/peergw/.env/lib/python2.5/site-packages/django/
core/management/commands/loaddata.py", line 165, in handle
for obj in objects:
  File "/var/peertv/peergw/.env/lib/python2.5/site-packages/django/
core/serializers/xml_serializer.py", line 158, in next
return self._handle_object(node)
  File "/var/peertv/peergw/.env/lib/python2.5/site-packages/django/
core/serializers/xml_serializer.py", line 198, in _handle_object
data[field.attname] = self._handle_fk_field_node(field_node,
field)
  File "/var/peertv/peergw/.env/lib/python2.5/site-packages/django/
core/serializers/xml_serializer.py", line 222, in
_handle_fk_field_node
obj =
field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value)
  File "/var/peertv/peergw/.env/lib/python2.5/site-packages/django/
contrib/contenttypes/models.py", line 15, in get_by_natural_key
ct = self.get(app_label=app_label, model=model)
  File "/var/peertv/peergw/.env/lib/python2.5/site-packages/django/db/
models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
  File "/var/peertv/peergw/.env/lib/python2.5/site-packages/django/db/
models/query.py", line 341, in get
% self.model._meta.object_name)
DoesNotExist: ContentType matching query does not exist.

What am I doing wrong?

Thanks, Alex A.

-- 
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: moving to django 1.2.1

2010-07-29 Thread knight
Thank you all for the links and advises.
It really helps me.

Regards, Alex A.

On Jul 29, 10:32 am, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> On Wed, Jul 28, 2010 at 9:29 PM, Massimiliano Ravelli
>
> <massimiliano.rave...@gmail.com> wrote:
> > On Jul 28, 3:13 pm, knight <alexar...@gmail.com> wrote:
> >> What are the minimal changes that I need to make in order to work with
> >> 1.2.1?
>
> > Did you have a look 
> > athttp://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> > ?
>
> As it says at the top of that wiki page, that page documents the
> backwards incompatible changes that were made in the leadup to Django
> 1.0.
>
> If you want migration notes for Django 1.1 or 1.2, you should consult
> the relevant release notes:
>
> [1]http://docs.djangoproject.com/en/dev/releases/1.1/
> [2]http://docs.djangoproject.com/en/dev/releases/1.2/
>
> Yours,
> Russ Magee %-)

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



Re: moving to django 1.2.1

2010-07-28 Thread knight
Does anybody knows a good post or blog about the changes including
csrf?

On Jul 28, 4:33 pm, Maksymus007 <maksymus...@gmail.com> wrote:
> On Wed, Jul 28, 2010 at 3:29 PM, Massimiliano Ravelli
>
> <massimiliano.rave...@gmail.com> wrote:
> > On Jul 28, 3:13 pm, knight <alexar...@gmail.com> wrote:
> >> What are the minimal changes that I need to make in order to work with
> >> 1.2.1?
>
> > Did you have a look 
> > athttp://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> > ?
>
> This link in worth nothing.
> The same all the sentences link '1.1 and 1.2 are compatible'.
> They are not.
>
> I have quite big application written in 1.1 - still can't fully run it on 1.2.
> As I discovered: forms fields set to be blank=True and null=True when
> left blank on 1.1 get null value as expected, on 1.2 the get empty
> string - which crashes if database has constraints.

-- 
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: moving to django 1.2.1

2010-07-28 Thread knight
Is anybody knows a good post or blog about these thing including csrf
changes?

On Jul 28, 4:33 pm, Maksymus007 <maksymus...@gmail.com> wrote:
> On Wed, Jul 28, 2010 at 3:29 PM, Massimiliano Ravelli
>
> <massimiliano.rave...@gmail.com> wrote:
> > On Jul 28, 3:13 pm, knight <alexar...@gmail.com> wrote:
> >> What are the minimal changes that I need to make in order to work with
> >> 1.2.1?
>
> > Did you have a look 
> > athttp://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> > ?
>
> This link in worth nothing.
> The same all the sentences link '1.1 and 1.2 are compatible'.
> They are not.
>
> I have quite big application written in 1.1 - still can't fully run it on 1.2.
> As I discovered: forms fields set to be blank=True and null=True when
> left blank on 1.1 get null value as expected, on 1.2 the get empty
> string - which crashes if database has constraints.

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



moving to django 1.2.1

2010-07-28 Thread knight
Hi,

I have pretty big django app running on django 1.0.2 and I want to
move it to django 1.2.1 since I want to use multiple databases.
What are the minimal changes that I need to make in order to work with
1.2.1?
I mean, what should I do regarding csrf and so on...
Is there a good place to read other than django documentation?

Thanks, Arshavski Alexander.

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



fabric ssh connect problem

2010-05-31 Thread knight
Hi,

I'm trying to deploy a django app with fabric and get the following
error:

Alexs-MacBook:fabric alex$ fab config:instance=peergw deploy -H  -
u  -p 
[192.168.2.93] run: cat /etc/issue
Traceback (most recent call last):
  File "build/bdist.macosx-10.6-universal/egg/fabric/main.py", line
419, in main
  File "/Users/alex/Rabota/server/mx30/scripts/fabric/fab/
commands.py", line 37, in deploy
checkup()
  File "/Users/alex/Rabota/server/mx30/scripts/fabric/fab/
commands.py", line 140, in checkup
if not 'Ubuntu' in run('cat /etc/issue'):
  File "build/bdist.macosx-10.6-universal/egg/fabric/network.py", line
382, in host_prompting_wrapper
  File "build/bdist.macosx-10.6-universal/egg/fabric/operations.py",
line 414, in run
  File "build/bdist.macosx-10.6-universal/egg/fabric/network.py", line
65, in __getitem__
  File "build/bdist.macosx-10.6-universal/egg/fabric/network.py", line
140, in connect
  File "build/bdist.macosx-10.6-universal/egg/paramiko/client.py",
line 149, in load_system_host_keys
  File "build/bdist.macosx-10.6-universal/egg/paramiko/hostkeys.py",
line 154, in load
  File "build/bdist.macosx-10.6-universal/egg/paramiko/hostkeys.py",
line 66, in from_line
  File "build/bdist.macosx-10.6-universal/egg/paramiko/rsakey.py",
line 61, in __init__
paramiko.SSHException: Invalid key
Alexs-MacBook:fabric alex$

I can't connect to the server via ssh. What can be my problem?

Regards, Arshavski Alexander.

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



uploading file in 2 steps

2010-05-31 Thread knight
Hi,

I want to upload a file in 2 steps.
First I want to upload it and show the errors and on the second step I
want actually to save the file data in the database.
So I made a simple form and my problem is how to pass the same file to
the form on the second step.
I mean how to insert request.FILES data in the same form again. Or
maybe there is a better way?

Thanks,
Arshavski Alexander.

-- 
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: forms question in django 1.1

2010-04-28 Thread knight
Thanks a lot. That's the problem.
As always, my stupid mistake.

On Apr 28, 6:12 pm, Bill Freeman <ke1g...@gmail.com> wrote:
> I do notice that you have 'player_option' in the fields tuple, while
> there is no such model field, but instead a field named 'player_options'
> (plural).  If that's actually in the source, I'd fix it before looking any
> harder.
>
>
>
>
>
> On Wed, Apr 28, 2010 at 10:32 AM, knight <alexar...@gmail.com> wrote:
> > I have the following form:
>
> > class ModuleItemForm2(forms.ModelForm):
> >    class Meta:
> >        model = Module_item
> >        fields = ('title', 'media', 'thumb', 'desc', 'default',
> > 'player_option')
>
> > The model is:
>
> > class Module_item(models.Model):
> >    title = models.CharField(max_length=100)
> >    layout = models.CharField(max_length=5, choices=LAYOUTS_CHOICE)
> >    media = models.CharField(help_text='Media url', max_length=500,
> > blank=True, null=True)
> >    conserv = models.ForeignKey(Conserv, help_text= 'Redirect to
> > Conserv', blank=True, null=True)
> >    conserve_section = models.CharField(max_length=100, help_text=
> > 'Section within the redirected Conserv', blank=True, null=True)
> >    parent = models.ForeignKey('self', help_text='Upper menu.',
> > blank=True, null=True)
> >    module = models.ForeignKey(Module, blank=True, null=True)
> >    thumb = models.FileField(upload_to='sms/module_items/thumbs',
> > blank=True, null=True)
> >    desc = models.CharField(max_length=500, blank=True, null=True)
> >    auto_play = models.IntegerField(help_text='Auto start play
> > (miliseconds)', blank=True, null=True)
> >    order = models.IntegerField(help_text='Display order', blank=True,
> > null=True)
> >    depth = models.IntegerField(help_text='The layout depth',
> > blank=True, null=True)
> >    flow_replace = models.IntegerField(blank=True, null=True)
> >    default = models.IntegerField(help_text='The selected sub item
> > (Note: Starting from 0)', blank=True, null=True)
> >    player_options = models.CharField(max_length=1000, null=True,
> > blank=True)
>
> > In my view I build form:
>
> > module_item_form2 = ModuleItemForm2()
> > print module_item_form2
>
> > And I get the following error on the print line:
>
> > 'NoneType' object has no attribute 'label'
>
> > It works fine with django 1.0.2. I see the error only in django 1.1.
>
> > Do you have an idea what am I doing wrong?
>
> > Regards, Arshavski Alexander.
>
> > --
> > 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 
> 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.



forms question in django 1.1

2010-04-28 Thread knight
I have the following form:

class ModuleItemForm2(forms.ModelForm):
class Meta:
model = Module_item
fields = ('title', 'media', 'thumb', 'desc', 'default',
'player_option')

The model is:

class Module_item(models.Model):
title = models.CharField(max_length=100)
layout = models.CharField(max_length=5, choices=LAYOUTS_CHOICE)
media = models.CharField(help_text='Media url', max_length=500,
blank=True, null=True)
conserv = models.ForeignKey(Conserv, help_text= 'Redirect to
Conserv', blank=True, null=True)
conserve_section = models.CharField(max_length=100, help_text=
'Section within the redirected Conserv', blank=True, null=True)
parent = models.ForeignKey('self', help_text='Upper menu.',
blank=True, null=True)
module = models.ForeignKey(Module, blank=True, null=True)
thumb = models.FileField(upload_to='sms/module_items/thumbs',
blank=True, null=True)
desc = models.CharField(max_length=500, blank=True, null=True)
auto_play = models.IntegerField(help_text='Auto start play
(miliseconds)', blank=True, null=True)
order = models.IntegerField(help_text='Display order', blank=True,
null=True)
depth = models.IntegerField(help_text='The layout depth',
blank=True, null=True)
flow_replace = models.IntegerField(blank=True, null=True)
default = models.IntegerField(help_text='The selected sub item
(Note: Starting from 0)', blank=True, null=True)
player_options = models.CharField(max_length=1000, null=True,
blank=True)

In my view I build form:

module_item_form2 = ModuleItemForm2()
print module_item_form2

And I get the following error on the print line:

'NoneType' object has no attribute 'label'

It works fine with django 1.0.2. I see the error only in django 1.1.

Do you have an idea what am I doing wrong?

Regards, Arshavski Alexander.

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



twitter login button

2010-04-15 Thread knight
HI

I have a django application running on app engine and I want to add a
twitter login to my application.
Do you have a good links how to do that. I already registered my app
in twitter.
Just don't know how to do login/logout buttons.

Thanks, Arshavski Alexander

-- 
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: search and filtering in app engine

2010-04-06 Thread knight
Thanks.

On Apr 2, 4:22 pm, Waldemar Kornewald <wkornew...@gmail.com> wrote:
> On Apr 2, 12:26 pm, knight <alexar...@gmail.com> wrote:
>
> > 1.) I get error: "'Query' object has no attribute 'all'" on line 59 in
> > views.
> > As I understand it's something to do with the fact that GAE queryset
> > is different from django queryset.
> > How can I fix that?
>
> You've mixed two different model APIs. Your models seem to be written
> in Django's API, but your views seem to use App Engine's model API. If
> you want to use Django's API you should rewrite your views according
> to Django's API and take a look at the djangoappengine backend for
> Django-nonrel:http://www.allbuttonspressed.com/projects/djangoappengine
> If you want to use App Engine's model API instead you should rewrite
> your models and read the App Engine documentation.
>
> > 2.) If I have 'search' in my request.GET I also fall on line 54 in my
> > views.
> > This is because I can't search by Q object in GAE, I guess.
> > How can I fix that?
>
> You can't use your search function on App Engine. There is no
> "icontains" query equivalent on App Engine. Instead, you should take a
> look at nonrel-search which works with 
> Django-nonrel:http://www.allbuttonspressed.com/blog/django/2010/03/Nonrel-search-re...
>
> Bye,
> Waldemar Kornewald

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



search and filtering in app engine

2010-04-02 Thread knight
Hi,

I'm trying to add filter and search to my site.
It's exactly the same code as in another working django project. The
difference is that this time I do it with app engine.

my views: http://slexy.org/view/s21GMw2sh1
my forms: http://slexy.org/view/s21XX8bquM
my search function: http://slexy.org/view/s2NOalh2uC

I have 2 problems:

1.) I get error: "'Query' object has no attribute 'all'" on line 59 in
views.
As I understand it's something to do with the fact that GAE queryset
is different from django queryset.
How can I fix that?

2.) If I have 'search' in my request.GET I also fall on line 54 in my
views.
This is because I can't search by Q object in GAE, I guess.
How can I fix that?

Thanks, Alex A.

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



more than 1 foreign key

2010-03-09 Thread knight
I have the following models: http://slexy.org/view/s20T8yOiKZ.
When I try to click add button for worlds in admin page it shows me
the following error:
 has more than 1 ForeignKey
to .
I think it's something to do with inline.
What can it be?

Regards, Arshavski Alexander.

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



anonymous user

2010-02-19 Thread knight
How can I just enable anonymous user in Django?
I mean, what is the minimum I should do to be logged in as anonymous
first time I go to my site?

Regards, Arshavski Alexnder.

-- 
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: moving to Django 1.1 problem

2010-02-15 Thread knight
Thanks,

You are great. It also solves my problem. :)

On Feb 15, 3:32 pm, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On Feb 15, 1:30 pm, knight <alexar...@gmail.com> wrote:
>
> Don't know if it has anything to do with your problem, but there's an
> error in your form:
>
>
>
> > My form:
>
> > class UploadImageForm(ModelForm):
> >     class Meta:
> >         model = ImageUpload
> >         fields = ('thumb')
>
> Python gotcha here: what defines a tuple is the comma, not the parens.
> You want:
>
>          fields = ('thumb', ) # required trailing comma
>
> HTH

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



moving to Django 1.1 problem

2010-02-15 Thread knight
Hi,

I'm trying to move from django 1.0.2 to 1.1 and I am getting the
following error in one of my templates:

Request Method: GET
Request URL:http://localhost:8000/conserv/media_assets/vod/
Exception Type: TemplateSyntaxError
Exception Value:Caught an exception while rendering: 'NoneType'
object has no attribute 'label'
Exception Location: /opt/local/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/site-packages/django/template/debug.py in
render_node, line 81
Python Executable:  /opt/local/Library/Frameworks/Python.framework/
Versions/2.6/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.6.2

The error is on the line with the "for" tag.
My template:

{% for field in upload_image_form %}


{{field.name}}


{{field}}


{% endfor %}

My form:

class UploadImageForm(ModelForm):
class Meta:
model = ImageUpload
fields = ('thumb')

My model:

class ImageUpload(models.Model):
thumb = models.FileField(upload_to='thumbs', blank=True,
null=True)


Does anyone know how can I solve it?

Thanks,
Arshavski Alexander.

-- 
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: test fixtures

2010-02-02 Thread knight
Hi,
Thanks for the reply.
Checked both things and it's fine.
I mean, I can load the fixtures with loaddata and I'm importing from
django.test.
Any other ideas?

On Feb 1, 4:28 pm, Russell Keith-Magee <freakboy3...@gmail.com> wrote:
> On Mon, Feb 1, 2010 at 10:01 PM, knight <alexar...@gmail.com> wrote:
> > Hi,
>
> > I want to use some fixtures in my tests.
> > I have cms_sample app and a fixtures folder inside with
> > cms_sample_data.xml
>
> > I use the following in my test.py:
>
> > class Funtionality(TestCase):
> >    fixtures = ['cms_sample_data']
>
> There are two likely causes. Firstly, are you importing:
>
> from unittest import TestCase
>
> or
>
> from django.test import TestCase
>
> ? If you are importing from unittest, you don't get any of Django's
> fixture support.
>
> Secondly, are you sure that your fixture exists and is formatted
> correctly? If your fixture has errors in it, you may not see any test
> data. Try running ./manage.py loaddata cms_sample_data and see what
> happens.
>
> Yours,
> Russ Magee %-)

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



Re: postgres exception

2010-02-01 Thread knight
Thanks. I solved the problem. I added transaction.rollback() to one of
the exceptions. Thanks

On Feb 1, 2:27 pm, Shawn Milochik  wrote:
> Do you have any messages coming from prior to that? The error you're 
> receiving comes when something else has blown up with your database 
> transaction, and then your code tries to execute something else against the 
> database while your transaction is already 'broken.' So, the problem is 
> probably not with that print statement, but with whatever was tried against 
> the database before that.
>
> Shawn

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



test fixtures

2010-02-01 Thread knight
Hi,

I want to use some fixtures in my tests.
I have cms_sample app and a fixtures folder inside with
cms_sample_data.xml

I use the following in my test.py:

class Funtionality(TestCase):
fixtures = ['cms_sample_data']

But the fixtures are not loaded. What am I missing?

Thanks, Arshavski Alexander.

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



postgres exception

2010-02-01 Thread knight
I have django application and I'm using postgres.
I try to execute the bollowing line in one of my tests:

print BillingUser.objects.all()

and I get the following error: "current transaction is aborted,
commands ignored until end of transaction block."
My postresql log is here: http://slexy.org/view/s2t3wxNWsd.

How can I fix that?
Thanks, Arshavski Alexander.

-- 
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: no attribute 'save_m2m'

2010-01-18 Thread Adam Knight
Ensure it's the save() method on the FORM and not the MODEL. :)

On Mon, Jan 18, 2010 at 12:23 PM, GoSantoni  wrote:
> Hi Nek4life,
>
> Unfortunately that didn't work.
>
> TypeError at /blog/new/
> save() got an unexpected keyword argument 'commit'
> Request Method: POST
> Request URL:    http://localhost:8000/blog/new/
> Exception Type: TypeError
> Exception Value:
> save() got an unexpected keyword argument 'commit'
>
> On Jan 18, 4:21 pm, nek4life  wrote:
>> On Jan 18, 10:01 am, GoSantoni  wrote:
>>
>>
>>
>>
>>
>> > Hi
>>
>> > Trying to use save_m2m as described 
>> > herehttp://docs.djangoproject.com/en/1.0/topics/forms/modelforms/#the-sav...
>> > Though in run into an attrribute error 'Post' object has no attribute
>> > 'save_m2m'
>>
>> > *** Model ***
>> > class Post(models.Model):
>> >     id                     = models.AutoField(primary_key=True)
>> >     imagepost       = models.ManyToManyField(Image, verbose_name=_
>> > ('media'))
>>
>> >     def save(self, force_insert=False, force_update=False):
>> >         self.updated_at = datetime.now()
>> >         super(Post, self).save(force_insert, force_update)
>>
>> > *** View ***
>> > def new(request, form_class=BlogForm, template_name="blog/new.html"):
>> >     if request.method == "POST":
>> >         if request.POST["action"] == "create":
>> >             blog_form = form_class(request.user, request.POST)
>> >             if blog_form.is_valid():
>> >                 blog = blog_form.save(commit=False)
>> >                 blog.author = request.user
>> >                 if getattr(settings, 'BEHIND_PROXY', False):
>> >                     blog.creator_ip = request.META
>> > ["HTTP_X_FORWARDED_FOR"]
>> >                 else:
>> >                     blog.creator_ip = request.META['REMOTE_ADDR']
>> >                 blog.save()
>> >                 blog.save_m2m()
>> >                 request.user.message_set.create(message=_
>> > ("Successfully saved post '%s'") % blog.item)
>> >                 if notification:
>> >                     if blog.status == 2: # published
>> >                         if friends: # @@@ might be worth having a
>> > shortcut for sending to all friends
>> >                             notification.send((x['friend'] for x in
>> > Friendship.objects.friends_for_user(blog.author)), "blog_friend_post",
>> > {"post": blog})
>>
>> >                 return HttpResponseRedirect(reverse
>> > ("blog_list_yours"))
>> >         else:
>> >             blog_form = form_class()
>> >     else:
>> >         blog_form = form_class(request.user)
>>
>> >     return render_to_response(template_name, {
>> >         "blog_form": blog_form,
>>
>> >     }, context_instance=RequestContext(request))
>>
>> > Question 1:
>> > So far i found these 2 posts using map and instances in the view. Is
>> > that the way to solve 
>> > this?http://stackoverflow.com/questions/1477319/how-to-get-the-django-curr...
>>
>> > Question 2:
>> > Does the def save() in the model need alteration? Or addition of a def
>> > save_m2m() ? Change gives a 'super' object has no attribute 'save_m2m'
>>
>> > Thanks
>>
>> From the link you provided.
>>
>> "[..] To work around this problem, every time you save a form using
>> commit=False, Django adds a save_m2m() method to your ModelForm
>> subclass."
>>
>> Try adding blog.save(commit=False) instead of just blog.save()
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>



-- 
Adam
-- 
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 running xp problem

2009-12-03 Thread knight
I have OSX machine running django app with appengine launcher and a
wirtual machine with windows XP running the same app.
The problem is that I have 2 XP machines where I get: "No module named
urls". What can be the problem? Maybe some system variables?
The code is exactly the same.

Regards, Arshavski Alexander.

--

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.




mod_wsgi configure problem

2009-12-01 Thread knight
Hi,

I need my django app to listen to port 80 and port .

I have 2 servers. One is listening to both ports and one is not
listening to .
The first one's apache conf is:

Listen 
WSGIRestrictStdout Off
WSGIPassAuthorization On
LoadModule wsgi_module modules/mod-wsgi.so
WSGIScriptAlias /peergw /home/user/mx30/django.wsgi


Order deny,allow
allow from all


Alias /media/ "/var/www/media/"
Alias /peergw/site_media/ "/var/www/site_media/"


Order deny,allow
Allow from all


WSGIScriptAlias /peergw_test /home/user/test/mx30/django.wsgi
Alias /peergw_test/site_media/ "/var/www/site_media_test/"



The second one is (The one that doesn't listen to ):

Listen 
WSGIRestrictStdout Off
WSGIPassAuthorization On
LoadModule wsgi_module modules/mod-wsgi.so
WSGIScriptAlias /peergw /home/reeptv/mx30/django.wsgi


Order deny,allow
allow from all


Alias /media/ "/var/www/media/"
Alias /peergw/site_media/ "/var/www/site_media/"


Order deny,allow
Allow from all



The main difference are the last 2 lines. Does anybody has an idea how
can I make the last one listen to  and 80?

Regards,
Arshavski Alexander.

--

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.




App engine launcher on windows problem

2009-11-29 Thread knight
I'm trying to install app engine with django 1.1 on windows.

When launching the app engine I'm getting the following error:
http://slexy.org/view/s21oLrbkHh
The steps I do are:
1.) Create new app via launcher
2.) Copy my code (Which is empty django project)

My main.py code: http://slexy.org/view/s21oxoNqVv
I'm falling on line: "import django.db" which I can do successfully
from cmd. Do you have an idea what I'm doing wrong?

Regards, Arshavski Alexander.

--

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: Multiple level aggregate

2009-11-18 Thread Adam Knight
On Nov 16, 2009, at 12:12 PM, despy wrote:

> Hi,
> 
> I'm trying to get my head around a complex aggregate query and I could
> do with some help. Say I have the following models
> 
> StockMarket
> |
> Stock
> |
> StockPrice
> 
> If StockPrice has price and date fields, and one price entry for every
> day for every stock how would I write a query to get the average price
> for a given stockmarket for the last six months?


http://docs.djangoproject.com/en/dev/topics/db/aggregation/#generating-aggregates-over-a-queryset

prices = StockPrice.objects.filter(stock__market=SomeMarket,  ... and so on
avg = prices.aggregate(Avg('price'))

Or something like that.  Basically, you approach it from the other end.  You 
want the market's aggregate, but the answer to that is an average of StockPrice 
objects, so you search for them with the conditions you want and then apply the 
aggregate operation to that.

Adam Knight
codepoetry - http://www.codepoetry.net/products/



--

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




Re: Redirect problems

2009-11-18 Thread Adam Knight
On Nov 18, 2009, at 6:06 AM, Zeynel wrote:

> I've been trying to redirect
> 
> /admin/ to /admin/wkw1/lawyer
> 
> The suggestions from my previous post 
> http://groups.google.com/group/django-users/msg/67c4594a4083bd45
> did not work.
> 
> I read the redirect section in the documents as suggested
> 
> http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-simple-redirect-to
> 
> and tried this urls.py
> 
> from django.conf.urls.defaults import *
> from django.contrib import admin
> admin.autodiscover()
> 
> urlpatterns = patterns('',
>(r'^wkw1/$', 'sw1.wkw1.views.index'),
> #(r'^admin/', include(admin.site.urls)),
> )
> 
> urlpatterns += patterns('django.views.generic.simple',
>   ('^admin/$', 'redirect_to', {'url': '/admin/wkw1/lawyer/'}),
>   )
> 
> but this too results in a server error.
> 
> Any suggestions?
> 
> Thanks.

Order matters.


urlpatterns = patterns('',
   (r'^wkw1/$', 'sw1.wkw1.views.index'),
)

urlpatterns += patterns('django.views.generic.simple',
  ('^admin/$', 'redirect_to', {'url': '/admin/wkw1/lawyer/'}),
)

urlpatterns += patterns('',
   (r'^admin/', include(admin.site.urls)),
)


Adam Knight
codepoetry - http://www.codepoetry.net/products/

--

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




Drupal migration

2009-11-17 Thread Adam Knight
Has anyone migrated a Drupal 6 site before?  I have all the nodes, comments, 
and URLs coming across but now that I start on the taxonomy bits I'm running 
into some problems with how they did their tables versus what would have been 
sane (lack of a primary key column and, instead, a joint unique column in 
termnode).

So, has anyone done a migration before (that included taxonomy) and have some 
code (preferably some models) laying around that I could poke around with?

(Work so far: 
http://bitbucket.org/codepoet/sitepoet/src/tip/sitepoet/drupal_support/management/commands/convertdrupal.py)

Adam Knight
codepoetry - http://www.codepoetry.net/products/



--

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




Re: How to use subqueries in django

2009-11-17 Thread Adam Knight
On Nov 17, 2009, at 7:49 AM, Radhikavk wrote:

> 
> hi,
> 
> how to use search criteria using OR and AND in queries
> user can search room by no,room_type, block etc i need the combination 
> 
> 
> Please can you refer the tutorial

http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

Adam Knight
codepoetry - http://www.codepoetry.net/products/




--

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




Re: Help with manage.py syncdb

2009-11-17 Thread Adam Knight
What everyone else said.  But, also, Snow Leopard made Python complicated.  It 
ships with 2.4, 2.5, and 2.6.  There's an easy_install for each version.  If 
you easy_install the MySQLdb module without specifying which easy_install 
you're using, it will use whatever the default version of Python is (defaults 
to 2.6 unless you changed it).  The backtrace indicates you're using Py 2.6, so 
you should be okay, unless you ran easy_install-2.5 to install the MySQL 
module, in which case the wrong version of Python received the module, in which 
case 2.6 won't find it.

Yay, something to make it more complicated!  Woo!

More: 
http://stackoverflow.com/questions/1380281/set-snow-leopard-to-use-python-2-5-rather-than-2-6

Adam Knight
codepoetry - http://www.codepoetry.net/products/


On Nov 16, 2009, at 11:40 PM, jd_python wrote:

> What am I possibly doing wrong?

--

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




Re: wsgi config

2009-11-11 Thread knight

Hi,

Thanks for the reply.It helps for the admin media.
But my site_media (static files) still don't work.
Do you have another idea what my problem is?

Thanks, Arshavski Alexander.

On Nov 11, 12:31 am, Angel Cruz <mrangelc...@gmail.com> wrote:
> Maybe the backslash is a problem.
>
> Here is how my media alias looks like:
>
> Alias /media/ "C:/Program Files/Apache Software
> Foundation/Apache2.2/htdocs/django/media/"
>  Foundation/Apache2.2/htdocs/django/media/">
> Order allow,deny
> Allow from all
> 
>
>
>
> On Sun, Nov 8, 2009 at 11:37 PM, knight <alexar...@gmail.com> wrote:
>
> > Hi. I have a problem with configuring my django site with mod_wsgi.
> > My httpd.conf is:
>
> > LoadModule wsgi_module modules/mod-wsgi.so
> > WSGIScriptAlias /peergw C:/mxhw/mx30/django.wsgi
>
> > 
> >        Order deny,allow
> >        allow from all
> > 
>
> > Alias /media/ "C:\Program Files\Apache Software Foundation
> > \Apache2.2\htdocs\media"
> > Alias /peergw/site_media/ "C:\Program Files\Apache Software Foundation
> > \Apache2.2\htdocs\site_media"
>
> >  > \Apache2.2\htdocs">
> > Order deny,allow
> > Allow from all
> > 
>
> > I want my site to run on /peergw since I have many instances on the
> > server and each one running with the different prefix.
> > Everything works fine except all the images - I can't see static media
> > files both in admin and my site.
> > When I go to "/site_media//image" and not "/peergw/site_media//
> > image", I do see the image.
> > What am I doing wrong?
> > By the way, I'm running on Vista, but I have the same problem on XP.
>
> > Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



wsgi config

2009-11-08 Thread knight

Hi. I have a problem with configuring my django site with mod_wsgi.
My httpd.conf is:


LoadModule wsgi_module modules/mod-wsgi.so
WSGIScriptAlias /peergw C:/mxhw/mx30/django.wsgi


Order deny,allow
allow from all


Alias /media/ "C:\Program Files\Apache Software Foundation
\Apache2.2\htdocs\media"
Alias /peergw/site_media/ "C:\Program Files\Apache Software Foundation
\Apache2.2\htdocs\site_media"


Order deny,allow
Allow from all



I want my site to run on /peergw since I have many instances on the
server and each one running with the different prefix.
Everything works fine except all the images - I can't see static media
files both in admin and my site.
When I go to "/site_media//image" and not "/peergw/site_media//
image", I do see the image.
What am I doing wrong?
By the way, I'm running on Vista, but I have the same problem on XP.

Thanks, Arshavski Alexander.



--~--~-~--~~~---~--~~
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: extends tag in template

2009-10-20 Thread knight

Thanks for the reply.
It doesn't matter where I put {{ MEDIA_URL }}.
I get the error in any case

On Oct 20, 11:09 am, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 20 oct, 09:56, knight <alexar...@gmail.com> wrote:
>
> > Hi,
>
> > I have override 2 admin templates: index.html and base_site.html.
> > The first line of index.html is: {% extends "admin/base_site.html" %}
> > Everything works fine, but if I insert {{ MEDIA_URL }} in
> > base_site.html, I get the following error when going to my admin page:
>
> > TemplateSyntaxError at /admin/
> >  must be the first tag in the
> > template.
>
> > Is anybody have an idea why can't I put {{ MEDIA_URL }} in
> > base_site.html?
>
> You failed to specify _where_ you inserted {{ MEDIAL_URL }}. What is
> clear is that you cannot put _anything_ before a {% extends XXX %}
> tag.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



extends tag in template

2009-10-20 Thread knight

Hi,

I have override 2 admin templates: index.html and base_site.html.
The first line of index.html is: {% extends "admin/base_site.html" %}
Everything works fine, but if I insert {{ MEDIA_URL }} in
base_site.html, I get the following error when going to my admin page:

TemplateSyntaxError at /admin/
 must be the first tag in the
template.

Is anybody have an idea why can't I put {{ MEDIA_URL }} in
base_site.html?

Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Disable apache directory browsing

2009-09-23 Thread knight

Hi,

I have installed django app with wsgi. I see that by default I have
directory browsing enabled in my static files and I want to turn it
off.
My httpd.conf:

LoadModule python_module modules/mod-wsgi.so

WSGIScriptAlias /peergw /home/alex/mx30/django.wsgi

Alias /media/ /var/www/media/
Alias /peergw/site_media/ /var/www/site_media/

How can I turn off directory browsing from /peergw/site_media? (It's
my static files)
I tried "Options -Indexes", but without luck.

Thanks in advance, Alex Arshavski
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



turning login off in admin

2009-09-01 Thread knight

Hi,

I want to turn off the login when going to the admin page url.
I want to enter to admin pages as anonymous/no user and require login
only in 2 specific urls.
How can I turn off the login request in the beginning?

Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



apache write permissions

2009-08-04 Thread knight

Hi,

I have a django project with the following apache configuration:

LoadModule python_module modules/mod_python.so

SetHandler python-program
PythonPath "['/home/alex'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mx30.settings
PythonOption django.root /peergw
PythonDebug Off

Alias "/peergw/site_media" "/var/www/site_media"

SetHandler None

Alias "/media" "/var/www/media"

SetHandler None

Listen 


I have added backup and restore buttons on admin page. They use
dumpdata and loaddata.
Backup data should save the backup in /home/alex/mx30/backups
directory.
I succeed to backup the data with django development server but can
not do it with apache.
Can anyone give me a suggestion how to give apache write permissions
to my /home/alex/mx30/backups directory?
Tried to give all permission to directory and change owner to www-data
and it didn't help.

Thanks, Arshavski Alexander.






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



encoding question

2009-06-24 Thread knight

Hi,

I have html page with inline editing. (I have text, that when I click
on it, it changes to edit box, and I can change the text)
I do it with some java scripts. (http://www.yvoschaap.com/index.php/
weblog/ajax_inline_instant_update_text_20/)
The problem is that I should save the text that I change in the
database of my django application and what I get after text change is
unicode.
I mean, something like: %u05D9%u05D2.

Maybe someone has an idea how can I save the hebrew letters, for
example, correctly in the 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



apache maximum users config

2009-05-13 Thread knight

Hi,

I have a django application running on apache2 with default
httpd.conf.
Is anybody knows a simple way to configure apache2 (httpd.conf) for
the best performance.
I mean allow maximum amount of simultaneous users?

Thanks, Alex A.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



apache maximum users config

2009-05-13 Thread knight

Hi,

I have a django application running on apache2 with default
httpd.conf.
Is anybody knows a simple way to configure apache2 (httpd.conf) for
the best performance.
I mean allow maximum amount of simultaneous users?

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



python version

2009-04-05 Thread knight

Hi,

I have 2 servers with my django app:
The first one has python2.5 as default python and the second don't (It
has python2.5 installed together with the older version).
I want to run dumpdata from my application and I have the following
problem:
If I call: "python manage.py dumpdata" the second server won't work.
If I call: "python2.5 manage.py dumpdata" the first server won't
work.
I mean, I will get the following error:

Traceback (most recent call last):
  File "manage.py", line 2, in 
from django.core.management import execute_manager
ImportError: No module named django.core.management

How can I find the right python version to call? Maybe I can take it
from PYTHONPATH? If yes, where can I find it?

Thanks, Alex A.

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



Could not import settings

2009-03-31 Thread knight

Hi,

I'm trying to install my django application on CentOS 5 and I'm
getting the following error:

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

My httpd.conf looks as follows:

Listen 80

SetHandler python-program
PythonPath "['/home/peertv', '/home/peertv/mx30', '/usr/lib/
python2.5'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mx30.settings
PythonOption django.root /peergw
PythonDebug On
PythonInterpreter mx30


I can do python settings.py, so I don't have spelling errors.
I can import settings from shell.
I have all the permissions to mx30 directory where the settings are
located.
I tried all the things in the similar threads here.

Can you please give me the directions where else I can look for a
solution?

Thanks, Arshavski 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-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
-~--~~~~--~~--~--~---



Languages problem

2009-03-24 Thread knight

Hi,

I have the following class in my models.py:

class MainCategory(models.Model):
title = models.CharField(max_length=50)
value = models.DecimalField(default=0, max_digits=5,
decimal_places=3)
secid = models.SlugField(max_length=1000, editable=False)
def save(self):
if not self.pk:
self.secid = slugify(self.title).replace("-", "_")
if MainCategory.objects.filter(secid = self.secid):
super(MainCategory, self).save()
self.secid = "%s__%s" %(self.secid, self.pk)
return super(MainCategory, self).save()
def __unicode__(self):
return self.title

I have the following problem:
If I create new object with title on Russian or Arabic or any other
language, I see it in admin with the empty string instead of it's
title.
My database is postgres and its utf-8.
I guess it's something to do with unicode but I can't understand what
exactly.
Do you have any ideas?

Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



import settings problem

2009-03-09 Thread knight

Hi,

I am trying to install django application on CentOS 5 and I'm getting
this error, when I go to the admin page:

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

my httpd.conf looks like this:

LoadModule python_module modules/mod_python.so

SetHandler python-program
PythonPath "['/home/reeptv1'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mx30.settings
PythonOption django.root /peergw
PythonDebug On


I can import settings.py and django from python shell,
I can run the server with django-admin.py, after setting
DJANGO_SETTINGS_MODULE and PYTHONPATH.

Does anybody have an idea what I can do?
Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



admin templates problem

2009-03-01 Thread knight

Hi,

I have a django application where I override the main admin page
(index.html in template/admin)
I use apache, I have a link to admin media folder and I have a
following problem:

In my admin pages I see the admin templates on all the pages except
the one I overrided (index.html).
Is anyone know what can be the problem?

Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



checking if db is empty

2009-02-25 Thread knight

Hi,

I'm using postgres database in my Django application.
Is there a way to check if the database is empty from my models.py? (I
mean before the first syncdb)

Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



default value for foreign key

2009-02-23 Thread knight

Hi,

I have models.py like this:

class Media_biz(models.Model):
---
default = models.BooleanField("Default", blank=True, null=True)
---

def get_default_Media_biz():
if Media_biz.objects.filter(default=True).count() != 0:
return Media_biz.objects.filter(default=True)[0]
else:
return None

class Metadata(models.Model):
---
media_biz = models.ForeignKey('Media_biz',
default=get_default_Media_biz)
---

What I want is to set the default value of Media_biz in Metadata. The
problem is:
When I create a new database and run syncdb, I get:
psycopg2.ProgrammingError: relation "cms_sample_media_biz" does not
exist

How can I check that the Media_biz table exist in the database?

Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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: default value for foreign key and CharField

2009-02-09 Thread knight

Thanks,

My Media_biz is edited inline in another class. So I have:
class MetadataInline(admin.StackedInline) and
class MetadataAdmin(admin.ModelAdmin)

Can you tell what method I should override and in which class in order
to set the initial value while editing inline?

Regards, Alex Arshavski.

On Feb 5, 11:21 pm, Rajesh Dhawan  wrote:
> > > > I have the following classes in my models.py:
>
> > > > class Default(models.Model):
> > > >     name = models.CharField(max_length=50, choices =
> > > > (('rental_period', 'rental_period'), ('currency', 'currency')),
> > > > unique=True)
> > > >     value = models.CharField(max_length=50)
>
> > > > class Media_biz(models.Model):
> > > >     name = models.CharField(max_length=50)
> > > >     currency = models.ForeignKey(Currency)
> > > >     rental_period = models.CharField(max_length=5, blank=True,
> > > > null=True)
>
> > > > What I want is:
> > > > When I add new Media_biz in my admin page, I want to check if there is
> > > > a Default object with the name "currency" or "rental_period" and take
> > > > it's value as default.
>
> > > You want to take its value as default for what field of Media_biz? And
> > > if you have two Default instances (one for currency and another for
> > > rental_period), which one provides the default value?
> > Each Default instance provide default value for one of the fields:
> > I want to take the default value of rental_period to rental_period and
> > default value of currency to currency.
> > The value of the currency should be the name of Currency object for
> > foreign key.
>
> You can override your Media_biz admin model's get_form method and
> inject your initial values. It would be something like this:
>
> def get_form(self, request, obj=None, **kwargs):
>     form = super(YourMedia_bizAdmin, self).get_form(request, obj,
> **kwargs)
>     try:
>         currency_default = Default.objects.get(name='currency')
>         currency = Currency.objects.get(name=currency_default.value)
>         form.fields['currency'].initial = currency.pk
>     except Default.DoesNotExist:
>         pass
>     try:
>         rental_default = Default.objects.get(name='rental_period')
>         form.fields['rental_period'].initial = rental_default.value
>     except Default.DoesNotExist:
>         pass
>     return form
>
> -RD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: default value for foreign key and CharField

2009-02-05 Thread knight

Hi,
Thanks for the fast reply.
Each Default instance provide default value for one of the fields:
I want to take the default value of rental_period to rental_period and
default value of currency to currency.
The value of the currency should be the name of Currency object for
foreign key.

Thanks, Alex A.

On Feb 5, 10:59 pm, Rajesh Dhawan <rajesh.dha...@gmail.com> wrote:
> On Feb 5, 10:59 am, knight <alexar...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I have the following classes in my models.py:
>
> > class Default(models.Model):
> >     name = models.CharField(max_length=50, choices =
> > (('rental_period', 'rental_period'), ('currency', 'currency')),
> > unique=True)
> >     value = models.CharField(max_length=50)
>
> > class Media_biz(models.Model):
> >     name = models.CharField(max_length=50)
> >     currency = models.ForeignKey(Currency)
> >     rental_period = models.CharField(max_length=5, blank=True,
> > null=True)
>
> > What I want is:
> > When I add new Media_biz in my admin page, I want to check if there is
> > a Default object with the name "currency" or "rental_period" and take
> > it's value as default.
>
> You want to take its value as default for what field of Media_biz? And
> if you have two Default instances (one for currency and another for
> rental_period), which one provides the default value?
>
> -RD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



default value for foreign key and CharField

2009-02-05 Thread knight

Hi,

I have the following classes in my models.py:

class Default(models.Model):
name = models.CharField(max_length=50, choices =
(('rental_period', 'rental_period'), ('currency', 'currency')),
unique=True)
value = models.CharField(max_length=50)

class Media_biz(models.Model):
name = models.CharField(max_length=50)
currency = models.ForeignKey(Currency)
rental_period = models.CharField(max_length=5, blank=True,
null=True)

What I want is:
When I add new Media_biz in my admin page, I want to check if there is
a Default object with the name "currency" or "rental_period" and take
it's value as default.

I tried to use "default" field option for this, but I can't insert
logic that checks Default objects in models.py, because it fails on
syncdb if my db is empty.

Does anybody have a solution how can I do that?

Thanks,
Arshavski Alexander.
--~--~-~--~~~---~--~~
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: Changing default app url in development server

2009-02-04 Thread knight

Thank you all for the replies.
I will try the middleware solution and tell you how it's going. :)

It's nice to see that our group is big enough to get ~15 replies in 2
days.

Thanks,
Arshavski Alexander.

On Feb 5, 5:14 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> On Feb 5, 1:25 am, Adam Stein <a...@eng.mc.xerox.com> wrote:
>
> > I do something similiar where I have an extra item in the url.  To get
> > Apache and the Django server to match, I just add the extra part in
> > urls.py that I'm matching.  So instead of something like:
>
> > (r'^admin/(.*)', admin.site.root)
>
> > in Alex's case, it would be:
>
> > (r'^peergw/admin/(.*)', admin.site.root)
>
> > The same would go for any other match, just add the 'peergw' in front.
>
> > That way, the exact same URL can be used in both places.
>
> Which will then not work if you move to mod_wsgi or other WSGI hosting
> systems where SCRIPT_NAME is correctly set to be the mount point of
> the application. The django.root option is a mod_python specific hack
> to work around inadequacies in mod_python. It would not be wise to
> rely on mod_python broken behaviour of urls.py working how it does for
> you if django.root not set.
>
> Graham
>
>
>
> > On Wed, 2009-02-04 at 15:11 +0100, Ales Zoulek wrote:
> > > As I undrestood it is that it's infact *used* on Apache.
> > > That's why the django project is on "/peergw" - Apache, but "/" - dev 
> > > server.
>
> > > And Alex wants to simulate this behaviour on dev server side.
>
> > > Or am I wrong?
>
> > > A.
>
> > > On Wed, Feb 4, 2009 at 3:02 PM, Karen Tracey <kmtra...@gmail.com> wrote:
> > > > On Wed, Feb 4, 2009 at 4:46 AM, Ales Zoulek <ales.zou...@gmail.com> 
> > > > wrote:
>
> > > >> That's not as easy as it seams, quick fix/hack would be middleware
> > > >> that strips out /pergw from the url. That middleware would be used
> > > >> only for dev server, not for apache.
>
> > > > What about simply using the django.root PythonOption when running under
> > > > Apache:
>
> > > >http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#basi...
>
> > > > Its entire reason for being is, I believe, to handle situations like 
> > > > this.
>
> > > > Karen
>
> > > >> A.
>
> > > >> On Wed, Feb 4, 2009 at 9:39 AM, knight <alexar...@gmail.com> wrote:
>
> > > >> > My production version is running on different computer with apache
> > > >> > installed on http:///peergw
> > > >> > and development version on my computer is running on http:// > > >> > with port>.
> > > >> > I want them both to run on http:///peergw.
> > > >> > The port has no difference.
>
> > > >> > Thanks, Alex A.
>
> > > >> > On Feb 4, 9:58 am, Ian Lewis <ianmle...@gmail.com> wrote:
> > > >> >> What are you trying to do? If your development appserver is 
> > > >> >> conflicting
> > > >> >> with
> > > >> >> a locally installed apache then why not just use a different port?
>
> > > >> >> python manage.py runserver 8001
>
> > > >> >> 2009/2/4 knight <alexar...@gmail.com>
>
> > > >> >> > Hi,
>
> > > >> >> > My question is:
>
> > > >> >> > Is there a way to change my default app url in development server
> > > >> >> > fromhttp://localhost:8000tohttp://localhost:8000/peergw.
>
> > > >> >> > If it's a problem, maybe someone have a good reference for
> > > >> >> > configuring
> > > >> >> > apache server on MAC.
>
> > > >> >> > Regards,
> > > >> >> > Arshavski Alexander.
>
> > > >> >> --
> > > >> >> ===
> > > >> >> 株式会社ビープラウド  イアン・ルイス
> > > >> >> 〒150-0012
> > > >> >> 東京都渋谷区広尾1-11-2アイオス広尾ビル604
> > > >> >> email: ianmle...@beproud.jp
> > > >> >> TEL:03-5795-2707
> > > >> >> FAX:03-5795-2708http://www.beproud.jp/
> > > >> >> ===
>
> > > >> --
> > > >> --
> > > >> Ales Zoulek
> > > >> +420 604 332 515
> > > >> Jabber: a...@jabber.cz
> > > >> ICQ: 82647256
> > > >> --
>
> > --
> > Adam Stein @ Xerox Corporation       Email: a...@eng.mc.xerox.com
>
> > Disclaimer: Any/All views expressed
> > here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]
>
>
--~--~-~--~~~---~--~~
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: Overriding admin template: index.html

2009-02-04 Thread knight

My problem is that I want to pass additional variables to index.html.
So I thought I can do it if I add these variables to view that renders
index.html.

Regards, Alex A.

On Feb 4, 10:55 am, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> On Wednesday 04 Feb 2009 2:05:37 pm knight wrote:
>
> > Thanks for the fast reply.
> > I read this but I still cannot find the view that renders index.html.
>
> well, according to this link, you do not need the view in order to override
> index.html of admin.
>
> --
> regards
> KGhttp://lawgon.livejournal.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Changing default app url in development server

2009-02-04 Thread knight

My production version is running on different computer with apache
installed on http:///peergw
and development version on my computer is running on http://.
I want them both to run on http:///peergw.
The port has no difference.

Thanks, Alex A.

On Feb 4, 9:58 am, Ian Lewis <ianmle...@gmail.com> wrote:
> What are you trying to do? If your development appserver is conflicting with
> a locally installed apache then why not just use a different port?
>
> python manage.py runserver 8001
>
> 2009/2/4 knight <alexar...@gmail.com>
>
>
>
> > Hi,
>
> > My question is:
>
> > Is there a way to change my default app url in development server
> > fromhttp://localhost:8000tohttp://localhost:8000/peergw.
>
> > If it's a problem, maybe someone have a good reference for configuring
> > apache server on MAC.
>
> > Regards,
> > Arshavski Alexander.
>
> --
> ===
> 株式会社ビープラウド  イアン・ルイス
> 〒150-0012
> 東京都渋谷区広尾1-11-2アイオス広尾ビル604
> email: ianmle...@beproud.jp
> TEL:03-5795-2707
> FAX:03-5795-2708http://www.beproud.jp/
> ===
--~--~-~--~~~---~--~~
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: Overriding admin template: index.html

2009-02-04 Thread knight

Hi,

Thanks for the fast reply.
I read this but I still cannot find the view that renders index.html.

Regards,
Arshavski Alexander

On Feb 4, 9:52 am, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> On Wednesday 04 Feb 2009 1:18:53 pm knight wrote:
>
> > I want to override admin template: index.html.
> > I have found the template but not the view that renders it.
> > Maybe someone know how django rendering index.html template and where
> > I can find the view?
>
> does this 
> help?http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad...
>
> --
> regards
> KGhttp://lawgon.livejournal.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Overriding admin template: index.html

2009-02-03 Thread knight

Hi,

I want to override admin template: index.html.
I have found the template but not the view that renders it.
Maybe someone know how django rendering index.html template and where
I can find the view?

Thanks,
Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Changing default app url in development server

2009-02-03 Thread knight

Hi,

My question is:

Is there a way to change my default app url in development server
from http://localhost:8000 to http://localhost:8000/peergw.

If it's a problem, maybe someone have a good reference for configuring
apache server on MAC.

Regards,
Arshavski Alexander.
--~--~-~--~~~---~--~~
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: admin sorting in ManyToMany fields

2009-01-28 Thread knight

Hi,

You can do it by adding:

class Meta:
ordering = ['name']

to you Name class.
Regards, Alex A.

On Dec 24 2008, 9:17 am, "Aaron Lee"  wrote:
> Hi I have a ManyToMany field names in my class and I would like to show the
> names in sorted order (according to 'name') in the admin interface when I
> edit a Person. Right now it's showing by the pk order of Name. What's the
> right way to override this order? Thanks
> class Name(models.Model):
>   name = models.CharField()
>
> class Person(models.Model):
>   code = models.CharField()
>   names = models.ManyToManyField(Name)
>
> class PersonAdmin(admin.ModelAdmin):
>   list_display = ('code',)
>   ordering = ('code',)
>
> admin.site.register(Person, PersonAdmin)
>
> -Aaron
--~--~-~--~~~---~--~~
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: ManyToMany problem

2009-01-09 Thread knight

Thanks, Meir.

On Jan 7, 11:24 am, mksoft <m...@mksoft.co.il> wrote:
> Hi Alex,
>
> On Jan 4, 12:27 pm, knight <alexar...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I have the following problem:
> > I have models.py with the following class:
>
> > class Section(Feed):
> >     parent = models.ManyToManyField('self', blank=True, null=True)
> >     depth = models.IntegerField(editable=False)
> >     def save(self):
> >         self.depth = 1
> >         if self.parent:
> >             self.depth = self.parent.depth + 1
> >         return super(Section, self).save()
> >     def __unicode__(self):
> >         return "Section_%s" %(self.title)
>
> Looks like the problem is trying to access the m2m property before the
> instance is saved
> for the 1st time - no id means ManyToMany relations will fail. In
> `save` you're
> trying to access `parent` (should be called `parents` IMO, plural)
> which is m2m
> and trigger the error.
>
> * You'll need to check if you have an id, if not, save it once to get
> it. After that, calculate and
>   save again (blah).
>
> * You can't access `parent` like that, m2m behaves like a list,  so
> you'll have to check members
>   of that list - which is not clear how is going to be achieved. If
> different parents have different levels
>   which one will you use ?
>
> * Another problem: If parent's level is changed, the children won't be
> updated, potential mess
>
> * Last thing: Treading this path might lead to recursion (item with
> parents which have the
>   item in their parent, or up the tree, as well), you might wanna
> rethink this setup.
>
>
>
> > and admin.py with the following classes:
>
> > class SectionInline(admin.TabularInline):
> >     model = Section
> >     extra = 2
> >     verbose_name_plural = "Sub Sections"
>
> > class SectionAdmin(admin.ModelAdmin):
> >     inlines = [
> >         SectionInline, ItemInline
> >     ]
>
> > When I try to save new Section from the admin page, I get the
> > following error:
>
> > 'Section' instance needs to have a primary key value before a many-to-
> > many relationship can be used.
>
> > There are 2 things that I don't understand:
>
> > 1.) Why am I getting this error, if my ManyToMany relation is optional
> > 2.) I tried many things including defining id of the Section with
> > AutoField but still without luck.
>
> > Does anyone have an idea what is my problem/mistake here?
>
> > Thanks, Arshavski Alexander.
>
> Cheers
> --
> Meir Kriheli
--~--~-~--~~~---~--~~
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: Filtering parents by child attributes

2009-01-04 Thread knight

Try something like:

students = Student.objects.all()
absences = Absences.objects.all()
for absence in absences:
students.remove(absence.fk)

Maybe I'm wrong somewhere in the syntax, but the idea should be clear.

Regards, Alex A.

On Jan 2, 6:57 pm, Mathieu Steele  wrote:
> Here is an example of the data model for the type of filter I would
> like to do:
>
> class Student
>        name
>
> class Absence
>        foreign key Student
>        date
>
> Is there a way to filter Students with no absences?
>
> something like Student.objects.filter(absence_set__count=0)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Templates dir exception

2009-01-04 Thread knight

I think you can try accessing books/publisher_list.html instead of
just publisher_list.html
This should solve the problem, if I understand it correctly.

Regards, Alex A.

On Jan 4, 11:11 am, HB  wrote:
> Hey,
> My Django project has the  following structure:
> +++
> djcode
>        # Django files (urls.py ...)
>        templates (for storing template pages)
>        books
>             # books application files (models.py ...)
>             publisher_list.html
> +++
> Here is a snippet from settings.py
> TEMPLATE_DIRS = (
>     os.path.join(os.path.dirname(__file__), 'templates'),
> )
>
> But when I'm trying to access publisher_list.html , I got this
> exception:
> /media/sda4/Projects/djcode/djdrive/templates/books/
> publisher_list.html
> TemplateDoesNotExist
>
> I tried to add books folder to TEMPATES_DIRS, but I got the same
> exception:
> /media/sda4/Projects/djcode/djdrive/books/books/publisher_list.html
> TemplateDoesNotExist
>
> Any ideas?
> #Platform Django 1.0.2
> Thanks for 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ManyToMany problem

2009-01-04 Thread knight

Hi,

I have the following problem:
I have models.py with the following class:

class Section(Feed):
parent = models.ManyToManyField('self', blank=True, null=True)
depth = models.IntegerField(editable=False)
def save(self):
self.depth = 1
if self.parent:
self.depth = self.parent.depth + 1
return super(Section, self).save()
def __unicode__(self):
return "Section_%s" %(self.title)

and admin.py with the following classes:

class SectionInline(admin.TabularInline):
model = Section
extra = 2
verbose_name_plural = "Sub Sections"

class SectionAdmin(admin.ModelAdmin):
inlines = [
SectionInline, ItemInline
]


When I try to save new Section from the admin page, I get the
following error:

'Section' instance needs to have a primary key value before a many-to-
many relationship can be used.

There are 2 things that I don't understand:

1.) Why am I getting this error, if my ManyToMany relation is optional
2.) I tried many things including defining id of the Section with
AutoField but still without luck.

Does anyone have an idea what is my problem/mistake here?

Thanks, Arshavski Alexander.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



double logging in unittest

2008-12-18 Thread knight

Hi,

I have unittests in my django applications and I have a strange
behavior:
When I run the tests, I am getting each print-out to log from my
application twice.
I am using the standard python logging libraries.
Does anyone know this issue?

Thanks,
Arshavski Alexander.
--~--~-~--~~~---~--~~
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: Problem with loading fixture xml to Postgres database

2008-01-17 Thread knight

I'm not sure, but I think it's a problem with the psycopg backend
under Python 2.3.5.
When I loaded fixtures with Python 2.3.5 I got no errors and the
fixtures haven't been loaded.
When I loaded fixtures with Python 2.5 I got an error and when I fixed
it the fixtures were loaded.
I used the same fixtures data.
I'm sorry, but I don't have Python 2.3.5 environment anymore, so I can
not check it.

Regards, Alex Arshavski.

On Jan 17, 12:42 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Jan 16, 2008 10:47 PM, knight <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have figured out what theproblemis.
> > I was using python 2.3.5. And with this python version, Django says
> > that X entities were imported, but none is really imported.
> > And after installing python 2.5, I got the error message on missing
> > dependencies.
>
> This is interesting - I wasn't aware of any differences that might
> exist with the Python 2.3.5 backend.
>
> Is this aproblemwith the psycopg backend under Python 2.3.5? Does it
> undergo dependency failures in a different way to the Python 2.5
> backend?
>
> If you run the Django system tests (the runtests.py script in the test
> directory of a Django checkout) using Python 2.3.5, do you get any
> failures?
>
> 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
-~--~~~~--~~--~--~---



Re: Problem with loading fixture xml to Postgres database

2008-01-16 Thread knight

I have figured out what the problem is.
I was using python 2.3.5. And with this python version, Django says
that X entities were imported, but none is really imported.
And after installing python 2.5, I got the error message on missing
dependencies.

Thanks for you replies,
Regards, Alex Arshavski.

On Jan 15, 9:09 am, knight <[EMAIL PROTECTED]> wrote:
> If I put the objects in my fixture in the right order, I can see them
> in the database after they are loaded.
> Do you have any other suggestions?
>
> Regards,
> Alex.
>
> On Jan 15, 12:40 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
> > On Jan 14, 2008 11:46 PM, knight <[EMAIL PROTECTED]> wrote:
>
> > > I have a large fixture initial_data.xml and I'm trying to syncdb on
> > > new Postgres database, & though it says it imported 764 objects, I see
> > > none in the db.
>
> > As another reply suggests - if your fixture loading operation is
> > returning 'imported 764 objects', they are being loaded, its just a
> > matter of where.
>
> > > After a little investigation, I think it is related to dependencies
> > > between classes (foreign keys), which aren't handled in the right
> > > order.
>
> > Unlikely. We have a fairly extensive test suite for fixture loading,
> > and we explicitly test for potential order dependency issues.
>
> > > I'm using Python 2.3.5, Postgres 8.1.2 & Django dev version.
> > > Is this a known issue? Is it related to Postgres or its DB API?
>
> > To the best of my knowledge, there are no fixture loading problems
> > with the Postgres backend. Postgres is probably the most reliable of
> > the backends for fixture loading. That doesn't mean there _isn't_ a
> > bug - just that it would be the backend that is least likely to have
> > one.
>
> > 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
-~--~~~~--~~--~--~---



Re: Problem with loading fixture xml to Postgres database

2008-01-16 Thread knight

I have figured out what the problem is.
I was using python 2.3.5. And with this python version, Django says
that X entities were imported, but none is really imported.
And after installing python 2.5, I got the error message on missing
dependencies.

Thanks for you replies,
Regards, Alex Arshavski.

On Jan 15, 9:09 am, knight <[EMAIL PROTECTED]> wrote:
> If I put the objects in my fixture in the right order, I can see them
> in the database after they are loaded.
> Do you have any other suggestions?
>
> Regards,
> Alex.
>
> On Jan 15, 12:40 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
> > On Jan 14, 2008 11:46 PM, knight <[EMAIL PROTECTED]> wrote:
>
> > > I have a large fixture initial_data.xml and I'm trying to syncdb on
> > > new Postgres database, & though it says it imported 764 objects, I see
> > > none in the db.
>
> > As another reply suggests - if your fixture loading operation is
> > returning 'imported 764 objects', they are being loaded, its just a
> > matter of where.
>
> > > After a little investigation, I think it is related to dependencies
> > > between classes (foreign keys), which aren't handled in the right
> > > order.
>
> > Unlikely. We have a fairly extensive test suite for fixture loading,
> > and we explicitly test for potential order dependency issues.
>
> > > I'm using Python 2.3.5, Postgres 8.1.2 & Django dev version.
> > > Is this a known issue? Is it related to Postgres or its DB API?
>
> > To the best of my knowledge, there are no fixture loading problems
> > with the Postgres backend. Postgres is probably the most reliable of
> > the backends for fixture loading. That doesn't mean there _isn't_ a
> > bug - just that it would be the backend that is least likely to have
> > one.
>
> > 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
-~--~~~~--~~--~--~---



Re: Problem with loading fixture xml to Postgres database

2008-01-14 Thread knight

If I put the objects in my fixture in the right order, I can see them
in the database after they are loaded.
Do you have any other suggestions?

Regards,
Alex.

On Jan 15, 12:40 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Jan 14, 2008 11:46 PM, knight <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have a large fixture initial_data.xml and I'm trying to syncdb on
> > new Postgres database, & though it says it imported 764 objects, I see
> > none in the db.
>
> As another reply suggests - if your fixture loading operation is
> returning 'imported 764 objects', they are being loaded, its just a
> matter of where.
>
> > After a little investigation, I think it is related to dependencies
> > between classes (foreign keys), which aren't handled in the right
> > order.
>
> Unlikely. We have a fairly extensive test suite for fixture loading,
> and we explicitly test for potential order dependency issues.
>
> > I'm using Python 2.3.5, Postgres 8.1.2 & Django dev version.
> > Is this a known issue? Is it related to Postgres or its DB API?
>
> To the best of my knowledge, there are no fixture loading problems
> with the Postgres backend. Postgres is probably the most reliable of
> the backends for fixture loading. That doesn't mean there _isn't_ a
> bug - just that it would be the backend that is least likely to have
> one.
>
> 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
-~--~~~~--~~--~--~---



Problem with loading fixture xml to Postgres database

2008-01-14 Thread knight

Hi,

I have a large fixture initial_data.xml and I'm trying to syncdb on
new Postgres database, & though it says it imported 764 objects, I see
none in the db.
After a little investigation, I think it is related to dependencies
between classes (foreign keys), which aren't handled in the right
order.
I'm using Python 2.3.5, Postgres 8.1.2 & Django dev version.
The fixture was generated from a database of the same type and
version

Is this a known issue? Is it related to Postgres or its DB API?
I need urgent help, and any idea/direction would be highly
appreciated!

Thanks in advance,
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-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
-~--~~~~--~~--~--~---



Problem with loading fixture xml to Postgres database

2008-01-14 Thread knight

Hi,

I have a large fixture initial_data.xml and I'm trying to syncdb on
new Postgres database, & though it says it imported 764 objects, I see
none in the db.
After a little investigation, I think it is related to dependencies
between classes (foreign keys), which aren't handled in the right
order.
I'm using Python 2.3.5, Postgres 8.1.2 & Django dev version.
Is this a known issue? Is it related to Postgres or its DB API?

Thanks in advance,
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-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: Curious error with Free Comments

2006-11-16 Thread Sir Knight

No, I neve touched any of those

I guess it has to do with the fact that I do not have article.id
property.

What did I do wrong in models this time around

Ramdas


--~--~-~--~~~---~--~~
 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: Will Complex URLs Slow Things Down?

2006-05-26 Thread Cameron Kenneth Knight

3. "(?i)pattern" matches "PATTERN"


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