content template loads at bottom of base template instead of top

2010-03-17 Thread timdude
Hiya all,

My lovely django app is letting me down (or I'm letting it down). I am
using a base template with a content template extending this base.
Half of the time and on random pages, the content template loads at
the bottom of the page/base template.

Anyone know what's going on?

Cheers,
Tim

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



Upload image file, resize using PIL, then save into ImageField - what to save to ImageField?

2010-03-17 Thread robinne
I can save an uploaded image to a FileField like this (where
"ProductFile" is a model) and "TempFile" is an ImageField:

uploadedfile = request.FILES['uploadfile']
ProductFile.objects.create(FileName=UploadDate=datetime.datetime.now(),
TempFile=uploadedfile)

But, how do I manipulate the image size and then save to this model? I
am working with PIL, but I can't save a PIL Image to a ImageField. Can
I save the file to disk using PIL and then pass in the file path and
name to the model? If so, what is the syntax for saving the ImageFile
when you are no longer working with the original uploadedfile object?

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



Re: UserCreationForm : is clean_username necessary?

2010-03-17 Thread Karen Tracey
On Wed, Mar 17, 2010 at 9:41 PM, Peyman  wrote:

>  In django.contrib.auth.UserCreationForm, there is clean_username
> that checks if the username already exist in the db. This should not
> be necessary because this form is a ModelForm and the associated model
> User has unique=True.
>  Am I wrong?
>

I think you are right. The original appearance of the code that is now in
that clean_username method was quite a while ago, back in 2006:

http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/forms.py?rev=3520#L8

When added, the check was part of a custom form manipulator. Manipulators
were before my time but just from looking at it I get the impression there
was no way to take the automatically created manipulator for a model and
tweak it to only display a subset of the fields, add entry of two password
fields instead of the one in the model, etc. So this form was added as a
custom manipulator, and it needed to do the username unique validation
itself since it wasn't building off of the basic add manipulator for the
auth User object.

Then manipulators got replaced by newforms (which became forms) and model
forms, and model forms did unique validation (eventually -- they may not
have when this particular form was converted to newforms), and could be
customized in ways the old manipulators could not, so this custom form's
manual unique validation eventually became unnecessary. But nobody
noticed...until now.

Karen

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



Email address in registration form

2010-03-17 Thread Wiiboy
Hi guys,
I'm using a combination of the UserCreationForm and my own ModelForm
of my Profile model to create a registration form.  I want to get
users' email addresses, however, that seems to be a field in
contrib.auth.User, so it should be in UserCreationForm.  I don't know
whether to
a. Add to the UserCreationForm, and add an email_address field or
b. Add the email_address field to my custom form, and retrieve it and
save it to the contrib.auth.User model after the form is submitted.

Any ideas

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



Re: django buildout trouble

2010-03-17 Thread John Griessen

Kevin Teague wrote:

I'm looking into why buildout would leave the pythonpath incomplete
and think it is just a buildout.cfg problem.  The same site structure worked
in a non-buildout form.



Yes, this sounds like a simple library path problem. Did you provide a
setup.py for your cottagematic_com app so that Buildout could find it?

No.

Did you declare a dependency on cottagematic_com in the package list
for your buildout config?

No.
Neither of those are mentioned in any Django docs.  Can a Django
project dir be considered a separate app and packaged as such?
Is that compatible with django?


It can be difficult to get Django set-up with Buildout, since the
Django tutorial doesn't follow Python packaging conventions yet.

Is django on a roadmap to do that?

 In a

pinch, you could try just exporting your packages location onto
PYTHONPATH, e.g.:

export PYTHONPATH=/home/john/WEBprojects/cottagematic_bld/

(or where ever your python source tree lives)


It can't hurt much to try that...

There are some buildout django examples on the web, but very specific and
no explanation of buildout.  I'll look into generating a setup.py and ask
on the django user list about that.

John

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



UserCreationForm : is clean_username necessary?

2010-03-17 Thread Peyman
Hi all,

  In django.contrib.auth.UserCreationForm, there is clean_username
that checks if the username already exist in the db. This should not
be necessary because this form is a ModelForm and the associated model
User has unique=True.
  Am I wrong?

Thanks
-- Peyman

-- 
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: More tutorials and recipes?

2010-03-17 Thread Continuation
Check out the online Django book:

http://www.djangobook.com/

It's somewhat outdated but it covers all the basics.

On Mar 17, 5:48 am, ALJ  wrote:
> I've done the tutorial. This is great. It's practical. You can see how
> things fit together. But the application is quite simple.
>
> I've read the documentation. This tells you how the bits work. But
> it's quite detailed.
>
> What I am looking for is something that goes beyond the tutorials to
> bridge the gap to the detail of the modules. Are there any?

-- 
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: passing more information with formsets

2010-03-17 Thread Alastair Campbell
On Wed, Mar 17, 2010 at 7:02 PM, Dennis Kaarsemaker
 wrote:
> In the view function, you could add an attribute (say, instance :-)) to
> each form in the formset. That to me is a better way than doing weird
> magic in a template.

You're probably right, but I couldn't work that out for formsets:
http://dpaste.com/172317/

Is there a standard programming pattern for matching up two loops?
(I'm not a programmer by trade.)

>> Also, is there a danger to using form.something.data? It isn't in the
>> docs, but I found it as a possible way of matching the form against
>> the object values.

I've put in a hidden field for that (for now), it's only used for
display, it isn't used by any subsequent view, so hopefully doesn't
cause any problems.

Thanks,

-Alastair

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



Re: django buildout trouble

2010-03-17 Thread Kevin Teague

>
> I think it is a path problem, since the /polls/ part of the running site
> can't find views and the /admin part can't find views.
>
> I'm looking into why buildout would leave the pythonpath incomplete
> and think it is just a buildout.cfg problem.  The same site structure worked
> in a non-buildout form.
>

Yes, this sounds like a simple library path problem. Did you provide a
setup.py for your cottagematic_com app so that Buildout could find it?
Did you declare a dependency on cottagematic_com in the package list
for your buildout config?

It can be difficult to get Django set-up with Buildout, since the
Django tutorial doesn't follow Python packaging conventions yet. In a
pinch, you could try just exporting your packages location onto
PYTHONPATH, e.g.:

export PYTHONPATH=/home/john/WEBprojects/cottagematic_bld/

(or where ever your python source tree lives)

-- 
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: Conflict between django csrf and credit card clearing?

2010-03-17 Thread Joakim Hove
Hello Peter,

thank you very much for your answer. The exception did the job :-)

Joakim

-- 
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: dev server cannot access javascript files in template

2010-03-17 Thread Igor Ganapolsky
I should add that I still have the problem...

On Mar 17, 6:24 pm, Igor Ganapolsky  wrote:
> I have since then moved my javascript file to a site_media/scripts
> directory.  My project structure looks like this:
> webservice/
>  |-- first/
>     -- site_media/
>        -- scripts/
>     -- templates/
>   -- urlss/
>
> What I have done is:
> 1) In urls.py I added (r'^site_media/(?P.*)$',
> 'django.views.static.serve',{'document_root': 'first/site_media/
> scripts', 'show_indexes': True})
> 2) In my view I have a render_to_response('TopicTree.html',
> {'site_media':'first/site_media/scripts/'},
> context_instance=RequestContext(request))
> 3) In my TopicTree.html template I have a 
>
> On Mar 17, 6:04 pm, Daniel Roseman  wrote:
>
> > On Mar 17, 9:30 pm, Igor Ganapolsky  wrote:
>
> > > Hi,
> > > I am running a django dev server.  I have a template where I'm calling
> > > a javascript function from a an external .js file (residing in the
> > > same directory as the template).  However, I get the following error:
> > > "ReferenceError: al is not defined".  Nevertheless, when I just open
> > > this html page without the django dev server, the function al() works
> > > fine.
> > > I am puzzled by this.  Does anybody have an idea?
>
> > > Thanks
>
> > Why is your javascript file in the same directory as the template? How
> > have you configured your server to serve static assets?
> > --
> > DR.

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



Re: dev server cannot access javascript files in template

2010-03-17 Thread Igor Ganapolsky
I have since then moved my javascript file to a site_media/scripts
directory.  My project structure looks like this:
webservice/
 |-- first/
-- site_media/
   -- scripts/
-- templates/
  -- urlss/

What I have done is:
1) In urls.py I added (r'^site_media/(?P.*)$',
'django.views.static.serve',{'document_root': 'first/site_media/
scripts', 'show_indexes': True})
2) In my view I have a render_to_response('TopicTree.html',
{'site_media':'first/site_media/scripts/'},
context_instance=RequestContext(request))
3) In my TopicTree.html template I have a 

On Mar 17, 6:04 pm, Daniel Roseman  wrote:
> On Mar 17, 9:30 pm, Igor Ganapolsky  wrote:
>
> > Hi,
> > I am running a django dev server.  I have a template where I'm calling
> > a javascript function from a an external .js file (residing in the
> > same directory as the template).  However, I get the following error:
> > "ReferenceError: al is not defined".  Nevertheless, when I just open
> > this html page without the django dev server, the function al() works
> > fine.
> > I am puzzled by this.  Does anybody have an idea?
>
> > Thanks
>
> Why is your javascript file in the same directory as the template? How
> have you configured your server to serve static assets?
> --
> DR.

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



Re: admin delete action

2010-03-17 Thread Karen Tracey
On Wed, Mar 17, 2010 at 6:14 PM, SlafS  wrote:

> Is there a ticket already for this ?


Yes. http://code.djangoproject.com/ticket/12962

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



admin delete action

2010-03-17 Thread SlafS
Hi there!

Anyone else can't delete objects on admin change list with newest
Django (12801)?

When the list has list_editable fields it raises Validation Error

Is there a ticket already for this ?

Regards

---
stack:


Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/v/slafs/
Django Version: 1.2 beta 1 SVN-12801
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'v']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in wrapper
  240. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "/usr/lib/python2.5/site-packages/django/utils/decorators.py" in
_wrapped_view
  74. response = view_func(request, *args,
**kwargs)
File "/usr/lib/python2.5/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
in inner
  194. return view(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/utils/decorators.py" in
_wrapper
  21. return decorator(bound_func)(*args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/utils/decorators.py" in
_wrapped_view
  74. response = view_func(request, *args,
**kwargs)
File "/usr/lib/python2.5/site-packages/django/utils/decorators.py" in
bound_func
  17. return func(self, *args2, **kwargs2)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in changelist_view
  996. formset = cl.formset = FormSet(request.POST,
request.FILES, queryset=cl.result_list)
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
__init__
  408. super(BaseModelFormSet, self).__init__(**defaults)
File "/usr/lib/python2.5/site-packages/django/forms/formsets.py" in
__init__
  47. self._construct_forms()
File "/usr/lib/python2.5/site-packages/django/forms/formsets.py" in
_construct_forms
  91. for i in xrange(self.total_form_count()):
File "/usr/lib/python2.5/site-packages/django/forms/formsets.py" in
total_form_count
  70. return
self.management_form.cleaned_data[TOTAL_FORM_COUNT]
File "/usr/lib/python2.5/site-packages/django/forms/formsets.py" in
_management_form
  57. raise ValidationError('ManagementForm data is
missing or has been tampered with')

Exception Type: ValidationError at /admin/v/slafs/
Exception Value: [u'ManagementForm data is missing or has been
tampered with']

-- 
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: dev server cannot access javascript files in template

2010-03-17 Thread Daniel Roseman
On Mar 17, 9:30 pm, Igor Ganapolsky  wrote:
> Hi,
> I am running a django dev server.  I have a template where I'm calling
> a javascript function from a an external .js file (residing in the
> same directory as the template).  However, I get the following error:
> "ReferenceError: al is not defined".  Nevertheless, when I just open
> this html page without the django dev server, the function al() works
> fine.
> I am puzzled by this.  Does anybody have an idea?
>
> Thanks

Why is your javascript file in the same directory as the template? How
have you configured your server to serve static assets?
--
DR.

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



dev server cannot access javascript files in template

2010-03-17 Thread Igor Ganapolsky
Hi,
I am running a django dev server.  I have a template where I'm calling
a javascript function from a an external .js file (residing in the
same directory as the template).  However, I get the following error:
"ReferenceError: al is not defined".  Nevertheless, when I just open
this html page without the django dev server, the function al() works
fine.
I am puzzled by this.  Does anybody have an idea?

Thanks

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



Re: Conflict between django csrf and credit card clearing?

2010-03-17 Thread pjrhar...@gmail.com
On Mar 17, 7:37 pm, Joakim Hove  wrote:
> Summary of redirections:
>
>       Form at my site --> DIBS --> simple view at my site.
>
> Any tips?
>
> Joakim

My best guess is that the user must be getting posted back to that
address when they click a button on the external website.

You can probably just add an exception:

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

Peter

-- 
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: More tutorials and recipes?

2010-03-17 Thread ALJ
Thanks Alastair ... I'll check it out.

On Mar 17, 12:57 pm, Alastair Campbell  wrote:
> > On Mar 17, 11:23 am, Jirka Vejrazka  wrote:
> >> > What I am looking for is something that goes beyond the tutorials to
> >> > bridge the gap to the detail of the modules. Are there any?
>
> I found the best next step was the "Practical Django Projects" 
> book:http://apress.com/book/view/1430219386
>
> (I need to get the 2nd Ed though). The first edition was really good
> at taking your through practical projects, and helping you learn the
> django way. I assume the 2nd edition just brings it upto date.
>
> Kind regards,
>
> -Alastair

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



Re: Using a many-to-many through with users

2010-03-17 Thread Charlie L
I guess I should have made this more clear what my question was:

Anybody know how to fix the WHERE clause?  Is there a better way to
achieve this functionality?

On Mar 17, 3:44 pm, Charlie L  wrote:
> I'm running into some trouble adding a custom many-to-many field to
> the User model.
>
> http://dpaste.com/173041/
>
> I am modelling social relationships, and to do this I have a
> relationship model with 2 foreign keys to users, a 'from_user' and a
> 'to_user' -- in essence, this looks like a Many-to-many table between
> users and can probably act like one.
>
> So what I'm trying to do is, mimicking django's
> ManyRelatedObjectsDescriptor, create a RelatedManager dynamically that
> will access the relationship table.
>
> It's almost working right, except for the last part of the WHERE query
> that's being generated:
>
> In [5]: co = User.objects.get(username='coleifer')
>
> In [6]: co.relationships.all()
> Out[6]: []
>
> In [8]: connection.queries.pop()
> Out[8]:
> SELECT "auth_user"."id", etc, etc
> FROM "auth_user"
> INNER JOIN "relationships_relationship"
>   ON ("auth_user"."id" = "relationships_relationship"."from_user_id")
> WHERE "relationships_relationship"."id" = 69327
> LIMIT 21
>
> the where should read "relationships_relationshpi"."to_user_id" =
> 69327

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



Using a many-to-many through with users

2010-03-17 Thread Charlie L
I'm running into some trouble adding a custom many-to-many field to
the User model.

http://dpaste.com/173041/

I am modelling social relationships, and to do this I have a
relationship model with 2 foreign keys to users, a 'from_user' and a
'to_user' -- in essence, this looks like a Many-to-many table between
users and can probably act like one.

So what I'm trying to do is, mimicking django's
ManyRelatedObjectsDescriptor, create a RelatedManager dynamically that
will access the relationship table.

It's almost working right, except for the last part of the WHERE query
that's being generated:

In [5]: co = User.objects.get(username='coleifer')

In [6]: co.relationships.all()
Out[6]: []

In [8]: connection.queries.pop()
Out[8]:
SELECT "auth_user"."id", etc, etc
FROM "auth_user"
INNER JOIN "relationships_relationship"
  ON ("auth_user"."id" = "relationships_relationship"."from_user_id")
WHERE "relationships_relationship"."id" = 69327
LIMIT 21


the where should read "relationships_relationshpi"."to_user_id" =
69327

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



Conflict between django csrf and credit card clearing?

2010-03-17 Thread Joakim Hove
Hello,

I am using Django to write a sort of web-shop site. For reading
credit
card information, and reserving the money we use a third part company
called DIBS. The flow of the application is roughly like this:

1. The customer peeks around at our site and selects product(s) to
buy.

2. When the customer is ready to commit she is redirected to the site
of
the third party. The URL redirecting there contains some
information
about the purchase, i.e. the amount, an order id in our system
and
so on.
In addition the url contains three extra URLs which the DIBS
system
will redirect to, depending on the outcome of the transaction.

3. When a transaction has completed successfully DIBS will redirect
the
customer to a URL like this on my site:

http://what.ever/DIBS/accept/d/

The url mapping of this is just to a simple view function
displaying a
"Thank you for your purchase blablabla" text. Now this page is not
rendered, instead I get 403 and CSRF verification failure.
Now the view I would like to render in this case is not a form, so
I do
not really understand how the csrf macinery of Django comes into
play?

Summary of redirections:

  Form at my site --> DIBS --> simple view at my site.

Any tips?


Joakim



-- 
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: ProgrammingError: relation "project_webproject" does not exist

2010-03-17 Thread neridaj
I restarted my server and the images now display. I don't understand
why I need to do that for the images to show up.

On Mar 17, 12:30 pm, neridaj  wrote:
> Hello,
>
> I've been working on a portfolio website that includes an app called
> projects. Within this app are the models WebProject and ScreenShot for
> project info and related screenshots for display on the portfolio
> page. Everything has been working fine up until now, when I try to add
> another project. I'm able to add the project and related screenshots
> without error but the images for the new project are not being found
> when the page is displayed, while the two previous projects display
> fine.
>
> When I view the postgresql db tables all the info is there, however,
> when I query the tables from within the django interactive shell I'm
> getting errors when I try to do a simple select. I tried running
> syncdb but that didn't help. I don't have a ton of data in the db yet
> so I've been considering dumping the tables but what if this happens a
> year down the road, any ideas?
>
> >>> wp = WebProject.objects.get(id=1)
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py",
> line 120, in get
>     return self.get_query_set().get(*args, **kwargs)
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
> line 300, in get
>     num = len(clone)
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
> line 81, in __len__
>     self._result_cache = list(self.iterator())
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
> line 238, in iterator
>     for row in self.query.results_iter():
>   File "/usr/lib/python2.6/dist-packages/django/db/models/sql/
> query.py", line 287, in results_iter
>     for rows in self.execute_sql(MULTI):
>   File "/usr/lib/python2.6/dist-packages/django/db/models/sql/
> query.py", line 2369, in execute_sql
>     cursor.execute(sql, params)
>   File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py",
> line 19, in execute
>     return self.cursor.execute(sql, params)
> ProgrammingError: relation "project_webproject" does not exist
>
> or...
>
> >>> e = Entry.objects.get(id=1)
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py",
> line 120, in get
>     return self.get_query_set().get(*args, **kwargs)
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
> line 300, in get
>     num = len(clone)
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
> line 81, in __len__
>     self._result_cache = list(self.iterator())
>   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
> line 238, in iterator
>     for row in self.query.results_iter():
>   File "/usr/lib/python2.6/dist-packages/django/db/models/sql/
> query.py", line 287, in results_iter
>     for rows in self.execute_sql(MULTI):
>   File "/usr/lib/python2.6/dist-packages/django/db/models/sql/
> query.py", line 2369, in execute_sql
>     cursor.execute(sql, params)
>   File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py",
> line 19, in execute
>     return self.cursor.execute(sql, params)
> InternalError: current transaction is aborted, commands ignored until
> end of transaction block

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



ProgrammingError: relation "project_webproject" does not exist

2010-03-17 Thread neridaj
Hello,

I've been working on a portfolio website that includes an app called
projects. Within this app are the models WebProject and ScreenShot for
project info and related screenshots for display on the portfolio
page. Everything has been working fine up until now, when I try to add
another project. I'm able to add the project and related screenshots
without error but the images for the new project are not being found
when the page is displayed, while the two previous projects display
fine.

When I view the postgresql db tables all the info is there, however,
when I query the tables from within the django interactive shell I'm
getting errors when I try to do a simple select. I tried running
syncdb but that didn't help. I don't have a ton of data in the db yet
so I've been considering dumping the tables but what if this happens a
year down the road, any ideas?

>>> wp = WebProject.objects.get(id=1)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py",
line 120, in get
return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
line 300, in get
num = len(clone)
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
line 81, in __len__
self._result_cache = list(self.iterator())
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
line 238, in iterator
for row in self.query.results_iter():
  File "/usr/lib/python2.6/dist-packages/django/db/models/sql/
query.py", line 287, in results_iter
for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.6/dist-packages/django/db/models/sql/
query.py", line 2369, in execute_sql
cursor.execute(sql, params)
  File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
ProgrammingError: relation "project_webproject" does not exist

or...

>>> e = Entry.objects.get(id=1)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py",
line 120, in get
return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
line 300, in get
num = len(clone)
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
line 81, in __len__
self._result_cache = list(self.iterator())
  File "/usr/lib/python2.6/dist-packages/django/db/models/query.py",
line 238, in iterator
for row in self.query.results_iter():
  File "/usr/lib/python2.6/dist-packages/django/db/models/sql/
query.py", line 287, in results_iter
for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.6/dist-packages/django/db/models/sql/
query.py", line 2369, in execute_sql
cursor.execute(sql, params)
  File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
InternalError: current transaction is aborted, commands ignored until
end of transaction block

-- 
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: passing more information with formsets

2010-03-17 Thread Dennis Kaarsemaker
On wo, 2010-03-17 at 09:34 +, Alastair Campbell wrote:
> On Tue, Mar 16, 2010 at 7:46 PM, Dennis Kaarsemaker wrote:
> > Each ModelForm has an instance attribute, so you can use
> > {{ form.instance.whatever }}
> 
> Hi Dennis,
> 
> Unfortunately it is not a model form. The form creates an "entry",
> which is de-normalised data taken from the person (member) details and
> the event details.
> 
> The closest I've gotten so far is to use something like this in the
> formset loop:
> {% for member in members %}
> {% ifequal member.sail_number form.sail_number.data %}
> {{ member.name}}
> {% endifequal %}
> {% endfor %}
> 
> Unfortunately not all members have sail numbers, so I'll try passing
> initial data for member.id through to the form as a better match.
> 
> Unless there's a better way to do it?

In the view function, you could add an attribute (say, instance :-)) to
each form in the formset. That to me is a better way than doing weird
magic in a template.

> Also, is there a danger to using form.something.data? It isn't in the
> docs, but I found it as a possible way of matching the form against
> the object values.

Maybe you can run into user input creepiness, such as someone overriding
the field in the post request and being able to see data from other
objects. Not sure how realistic that is.

-- 
Dennis K.

The universe tends towards maximum irony. Don't push it.

-- 
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: Many to Many...so many queries

2010-03-17 Thread TheIvIaxx
I made a mistake in my model definitions above.  The Term field on
Image is a ManyToMany() not ForeignKey().

Anyhow I did look into value_list, however it didn't add much, if any,
performance gain.  But the select_related did!  That was exactly what
I needed.  Thanks Bruno for the tip.


On Mar 17, 1:38 am, bruno desthuilliers
 wrote:
> On Mar 17, 4:24 am, TheIvIaxx  wrote:
>
>
>
>
>
> > Hello all, i have a question about a certain query i have.  Here is my
> > model setup:
>
> > class Term():
> >     term = CharField()
>
> > class Image():
> >     image = FileField()
> >     terms = ForeignKey(Term)
>
> > These have been abbreviated for simiplicity, ut you get the gist of
> > it.  Anyhow i have to query for a few hundred Image objects, then get
> > a list of Term objects for each of these.  Really i just need the IDs
> > of the Terms.  Currently i have my query like this:
>
> > images = Image.objects.all()
>
> you can use 'select_related' here - it'll use a join to prefetch
> related Term objects:
>
> images = Image.objects.select_related('terms').all()
>
>
>
> > responseImages = []
> > for i in images:
> >     terms = [term.id for term in n.terms.all()]
> >     responseObjects.append({'image': n, 'terms': terms})
>
> I guess this is not your real code !-)
>
> I don't know what this 'responseObjects' is - , but if you use Django
> templates, you just don't need all this above code. Just pass 'images'
> in the template's context and you'll be fine:
>
> 
> {% for image in images %}
>    
>       {{ image.title }}
>      
>         {% for term in image.terms.all %}
>             {{ term.id }}
>         {% endfor %}
>         
>    
> {% endfor %}
> 
>
> 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.



Re: Python unicode issues when running in django environment

2010-03-17 Thread Karen Tracey
On Wed, Mar 17, 2010 at 1:08 PM, Tom Evans  wrote:

> Hmm, still a bit confused why it doesn't exhibit the issue under a
> regular python 2.5 shell if it is a python 2.5 issue. Something
> definitely 'tweaks' the environment going through the django shell
> rather than the python shell. Must only be triggered in certain edge
> cases, I suppose.
>

I don't remember the details exactly, but I believe it's a bug for input
read by code.interact(). manage.py shell calls code.interact() to present
the interpreter shell, and what you enter at the shell is processed as input
by code.interact(). The Python shell invoked directly via the python
executable does not use code.interact(), so you see the problem when running
under python manage.py shell, but not the plain Python shell.



> However, that does explain the failing tests. I am initiating one side
> of the RPC from the shell, for testing, like so:
>
> >>> checkBounceUser('10.0.0.1', {'X-Hi': u'£' }, sp=settings.SSO_ID)
>
> which then prints out the extracted arguments in the console of the
> other server:
> name: X-Hi  value: £
> repr(name): u'X-Hi'  repr(value): u'\xc2\xa3'
>
> If I give it an explicit unicode codepoint, there isn't the parsing bug,
> and so:
>
> >>> checkBounceUser('10.0.0.1', {'X-Hi': u'\xa3' }, sp=settings.SSO_ID)
> name: X-Hi  value: £
> repr(name): u'X-Hi'  repr(value): u'\xa3'
>

Another workaround is to avoid using manage.py shell; instead use the plain
python shell with  DJANGO_SETTINGS_MODULE set in the environment.

Karen

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



Re: Python unicode issues when running in django environment

2010-03-17 Thread Tom Evans
On Wed, Mar 17, 2010 at 4:33 PM, Karen Tracey  wrote:
> On Wed, Mar 17, 2010 at 12:14 PM, Tom Evans 
> wrote:
>>
>> Any pointers?
>
> http://bugs.python.org/issue1288615
>
> It's fixed in current Python 2.6, I believe.
>
> However, this is a shell-only issue, so I'm not sure it will explain your
> original problem.
>
> Karen
>

Hmm, still a bit confused why it doesn't exhibit the issue under a
regular python 2.5 shell if it is a python 2.5 issue. Something
definitely 'tweaks' the environment going through the django shell
rather than the python shell. Must only be triggered in certain edge
cases, I suppose.

However, that does explain the failing tests. I am initiating one side
of the RPC from the shell, for testing, like so:

>>> checkBounceUser('10.0.0.1', {'X-Hi': u'£' }, sp=settings.SSO_ID)

which then prints out the extracted arguments in the console of the
other server:
name: X-Hi  value: £
repr(name): u'X-Hi'  repr(value): u'\xc2\xa3'

If I give it an explicit unicode codepoint, there isn't the parsing bug, and so:

>>> checkBounceUser('10.0.0.1', {'X-Hi': u'\xa3' }, sp=settings.SSO_ID)
name: X-Hi  value: £
repr(name): u'X-Hi'  repr(value): u'\xa3'

As always, garbage in => garbage out, so that explains why nothing I
was doing helped!

Thanks for the pointers Karen!

Cheers

Tom

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



Re: Python unicode issues when running in django environment

2010-03-17 Thread Karen Tracey
On Wed, Mar 17, 2010 at 12:14 PM, Tom Evans wrote:

> Any pointers?


http://bugs.python.org/issue1288615

It's fixed in current Python 2.6, I believe.

However, this is a shell-only issue, so I'm not sure it will explain your
original problem.

Karen

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



Python unicode issues when running in django environment

2010-03-17 Thread Tom Evans
Hi all

I have a weird problem with unicode conversion whilst running in the
django environment. I'm not convinced django is the cause, but
hopefully someone will have seen something like this and can point me
in the right direction..

The original code was an XML-RPC call from one django server to
another, and the problem occurred when attempting to extract the
parameters from the utf-8 encoded XML, but fortunately I can reproduce
it much more simply. The basic process is that a unicode string is
encoded to a utf-8 bytestring, and put into an XML document. It is
then extracted from the XML by the other server and then
re-interpreted as a unicode string, which should look like this:

> $ python
Python 2.5.2 (r252:60911, Apr 25 2008, 17:25:09)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7
Type "help", "copyright", "credits" or "license" for more information.
>>> u'£'
u'\xa3'
>>> u'£'.encode('utf-8')
'\xc2\xa3'
>>> unicode(u'£'.encode('utf-8'), 'utf-8')
u'\xa3'
>>> print unicode(val.encode('utf-8'), 'utf-8')
£

As you can see, exactly as expected. However, when running under
'manage.py shell', the behaviour is quite different:

Python 2.5.2 (r252:60911, Apr 25 2008, 17:25:09)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> u'£'
u'\xc2\xa3'
>>> u'£'.encode('utf-8')
'\xc3\x82\xc2\xa3'
>>> unicode(u'£'.encode('utf-8'), 'utf-8')
u'\xc2\xa3'
>>> print unicode(u'£'.encode('utf-8'), 'utf-8')
£

Any pointers?

Cheers

Tom

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



Re: Hostmonster shared hosting and django tinymce

2010-03-17 Thread Bobby Roberts
hey i've uploaded the ckeditor folder to my /static/admin/js
directory.   I'm trying to get the text areas to use it but i'm not
having any luck so I don't think i'm putting code in the right place.
can you help?




On Mar 17, 9:18 am, chris hendrix  wrote:
> ok thanks for pointing me in the right direction.  doesn't sound too hard.
>
> On Wed, Mar 17, 2010 at 8:59 AM, Omer Barlas  wrote:
> > tchendrix @ 17-03-2010 14:31:
>
> >  do you by chance have instructions on how to get that installed with
> >> django so it works properly? They don't say anything in their install
> >> docs about what javascript to call.
>
> > you don't install it over django. put the javascript files in your /media
> > folder, and load the javascript in your template, that's it. If you can't
> > solve it, I can give you a step-by-step in an available time.
>
> > regards.
>
> > --
> > Omer Barlas
> > omer.bar...@gmail.com
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Multiple Primary Keys

2010-03-17 Thread Ramiro Morales
On Wed, Mar 17, 2010 at 12:21 PM, ojayred  wrote:
> Hello Users,
>
> I am new to using Django and so far, I like it. I have installed
> Django and want to use it with a pre-existing database. Several tables
> have multiple primary keys. How do I create the multiple primary keys
> in the model? I did use the inspectdb command to help me create the
> model because some tables have more than 25 columns.

Unfortunately it isn't supported. See:

http://docs.djangoproject.com/en/1.1/faq/models/#do-django-models-support-multiple-column-primary-keys

-- 
Ramiro Morales  |  http://rmorales.net

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



Re: mr.developer and buildout (newbie questions)

2010-03-17 Thread John Griessen

Bill Freeman wrote:

I'm of two minds as to what you are asking.


Thanks very much for the time writing back about my problem.


1.  For components that don't have a version specification, buildout
*normally) checks
to see if there is a newer version available, and, if there is
installs it in place of the
existing version (doesn't necessarily delete the files for the old
version, just removes
it from your python path).


2.  If you are editing the stuff that buildout downloaded, yes, that
can get trashed. 


I'm not even able to recreate that problem I thought I had.
I have read and will reread what you wrote though, since
I will be using git VCS on my apps.  What I think is still wrong is
about buildout, mentioned in the post subject line
Re: django buildout trouble

I'd like to find ways to confirm what mr.developer and buildout are doing.
The docs are not complete enough to tell fully.

Should the output of bin/develop list show the django-mptt
that I asked buildout to get from svn just because it is a
checkout?  I'm not going to touch it.

bin/develop list only returns
django-mptt

Nothing about my django project, which I am going to touch...
Seems like mr.develop only helps keep track of changes to
published eggs.  I see no way yet to make an egg of the
non-boilerplate part of django apps, so mr.developer is
only used by me so far to get buildout to use the svn HEAD
of django-mptt.

Thanks,

John Griessen

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



Re: django buildout trouble

2010-03-17 Thread John Griessen

andreas schmid wrote:

did you run ./bin/django syncdb?

Yes.

did you edit the cottagematic_com.urls to get the admin working?

I edited, but it does not work.


ViewDoesNotExist: Could not import
cottagematic_com.django.contrib.auth.views.
this one looks strange to me because cottagematic_com is your project
dir (right?) and django is located in cottagematic_bld/parts/django. did
you customize some admin views?

Yes, my example for this is the django tutorial polls directory,
which has admin.


p.s. about the versioning we were speaking yestereday, you should commit
also the cottagematic_bld/cottagematic_com folder to the versioning repo.


Yes, did that.


My pythonpath has/home/john/WEBprojects/cottagematic_bld/parts/django
but no path to templates or the django app cottagematic_com


I think it is a path problem, since the /polls/ part of the running site
can't find views and the /admin part can't find views.

I'm looking into why buildout would leave the pythonpath incomplete
and think it is just a buildout.cfg problem.  The same site structure worked
in a non-buildout form.

John

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



Multiple Primary Keys

2010-03-17 Thread ojayred
Hello Users,

I am new to using Django and so far, I like it. I have installed
Django and want to use it with a pre-existing database. Several tables
have multiple primary keys. How do I create the multiple primary keys
in the model? I did use the inspectdb command to help me create the
model because some tables have more than 25 columns.  Also, can I run
an SQL module (*.sql file) from Django? Or any suggestions on how to
do so. Thank you for your input.

-- 
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 leaves opened connections

2010-03-17 Thread cleg
I'm using Django ORM with Postgres. After any operations with models
(e.g. simple select) in postgres appears new opened connection in
 state.

I've tried all possible transaction manipulations, I've tried calling

connection.close()
manually. All useless. And sooner or later, I'm recieveing "FATAL:
connection limit exceeded for non-superusers" message.

What can I've made 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=en.



Re: mr.developer

2010-03-17 Thread Bill Freeman
I'm of two minds as to what you are asking.

1.  For components that don't have a version sepcification, buildout
*normally) checks
to see if there is a newer version available, and, if there is
installs it in place of the
existing version (doesn't necessarily delete the files for the old
version, just removes
it from your python path).

You can avoid this by using the -N command line swtich.  (That capital
N, small n is the
default behavior.)  I use this a lot.  In the land of plone
developemnt I wind up needing
to re-run buildout fairly often, but don't want my downloaded stuff upgraded.

You can still upgrade a single package by deleting (or moving) it's
egg (or other installed
footprint) and running buildout -N.  It will see that it doesn't have
a package for the
requirement, and install one.

Note that specifying a new version number for a component is not
enough to get it changed
if you use -N.  -N says "If I have some version of a requirement
already, use it".  But if you
delete a newer version of apackage, you can use version specifiers to
go back to an older
version, for example.

I'm not absolutely sure how this interacts with stuff pulled from a
version control system, rather
than from pypi or wherever as a tarball or egg.


2.  If you are editing the stuff that buildout downloaded, yes, that
can get trashed.  Eggs
won't get downloaded until there is a newer version available, but
that becomes a time bomb.

If you are doing a serious fork, then you want to look at development
eggs.  That's typically
placed in a subdirectory in egg format of the src subdirectory of the
directory containing
buildout.cfg.  You list the egg name in your buildout:eggs value, and
the relative path to
the egg in the buildout:develop value.  For example:

[buildout]

eggs =
  your
  other
  eggs
  your_development_egg

develop =
  src/your_development_egg

What all this does is make buildout include
src/your_development_egg/your_deveolpment_egg
(remember, this is egg format) in your path, but it makes no
assumptions about being able to get
versions of your project from somewhere.  (setup.py of your egg
probably gets run, but you
can probably no-op it.  There are probably some paster scripts that
will make you an empty egg
structure - the ones for plone probably run a little deeper than you
want, unless you need to
take advantage of namespace packages.)  So you check the code out into
the directory that gets
added to the path, and go to town.  buildout won't run a svn update
there, for example.

2a.  Another, less savory, but more convenient approach that I have
sometimes taken is to add
a file in an automatically downloaded egg (or equivalet) to my top
level (directory with buildout.cfg)
mercurial repository, about which buildout (at least so far) knows
nothing.  It might also live in
a svn repository (I have that situation exactly), which works fine, so
long as you add a regexp
pattern to .hgignore to exclude the .svn directories (and likewise,
make svn ignore the .hg and
.hgignore files at the top level, if the svn checkout is rooted at or
above the same directory).

Then just make sure that your changed files are checked into mercurial
before running buildout,
and you can revert them afterwards.

Bill

On Tue, Mar 16, 2010 at 3:32 PM, John Griessen  wrote:
> If you run buildout it checks out what you made changes to -- wiping the
> changes.
> Am I supposed to be using any particular version control with buildout?  It
> seems
> to mention many kinds.
>
> So, my buildout.cfg looks like:
>
>  [buildout]
> eggs-directory = /home/john/buildout/eggs
> extensions = mr.developer
> sources = sources
> auto-checkout = django-mptt
>
> parts =
>    django
>
> eggs =
>    mock
>    django-notification
>    django-page-cms
>    django-haystack
>
> [sources]
> django-mptt = svn http://django-mptt.googlecode.com/svn/trunk/
> path=django-mptt
>
> [django]
> recipe = djangorecipe
> version = 1.1.1
> settings = development
> urls =
>
>
>  http://code.google.com/p/django-messages/source/browse/#svn/branches/messages-0.4.x
>
> wsgi = true
> eggs = ${buildout:eggs}
> project = cottagematic_com
>
>
> Should my project go under sources?
> Should I start using svn or git on my project dirs and add and commit?
>  (trying this next)
>
> thanks,
>
> John
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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

Re: Modifying admin to filter choices

2010-03-17 Thread derek
On Mar 16, 8:35 pm, Nick  wrote:
> I am working on a project that has a portion of the admin with three
> different "choices" options.  The section of the model that this
> thread is concerned with looks like this:
>
> Department_Choices = (
> ('Advertising', 'Advertisinf'),
> ('NIC', 'NIC'),
> ('Production', 'Production'),
> )
>
> Department_Groups = ( #Advertising has three groups, NIC has 5,
> Produciton has 5
> ('Auto Sales', 'Auto Sales'),
> ('Print Production', 'Print Production'),
> )
>
> Subgroups = ( #some groups have sub-groups (ex. Auto Sales has print
> and online subgroups)
> ('Online', 'Online'),
> ('Print', 'Print'),
> )
>
> # model
>
> department = models.Charfield(choices=Department_Choices)
> group = models.CharField(choices=Department_Goups)
> subgroup - models.CharField(choices=Subgroups)
>
> I would like to have something in place that filters the groups and
> subgroups based on the department. So, if I choose Advertising in
> departments it brings up applicable groups, if I bring up Auto in
> groups it brings up applicable subgroups.
>
> Does Django have a built in way of handling this, do I need to modify
> the admin template? Do I need to forget about entering this in the
> admin and create a form with a bunch of AJAX involved?

Suggest you use AJAX - e.g. see:
http://code.google.com/p/django-ajax-filtered-fields/
or
http://www.nerdydork.com/dynamic-filtered-drop-down-choice-fields-with-django.html

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



Re: Django With Google App Engine

2010-03-17 Thread Waldemar Kornewald
On Mar 17, 4:27 am, TheIvIaxx  wrote:
> it works pretty well, however i couldn't get m2m to work.  i guess
> that doesnt translate well to BigTable

It's not yet supported (it depends on JOIN emulation), but we will
eventually add it. Currently (and for the next few months), we have
lots of other stuff on our plates, so if anyone wants to help please
join and we'll get you started:
http://groups.google.com/group/django-non-relational

ATM, you can model m2m relations via ListField (in
djangotoolbox.fields) pretty much like you would with App Engine's own
models. The project is here:
http://bitbucket.org/wkornewald/djangotoolbox/

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.



Re: how to run a given project

2010-03-17 Thread hk
it was exactly that thanks :D!

On Mar 17, 2:39 am, Jeremy Sandell  wrote:
> On Mar 16, 4:58 am, hk  wrote:
>
> > hi
>
> > Ive just started experiencing DJango i am an undergrad student i was
> > given a Django project on which to extend functionality but after
> > installing all the necessary apps for it but  i cant seem to run it
> > i get "Database wit does not exist " (wit is the database for this
> > proj but i dont if i should make it in postrgres or ??,i tries making
> > it and then i got other errors)
> > im working in Linux
>
> > im sure there is a simple way and that im just overcomplicating things
> > What can i do to run this project?
>
> > kind regards
> > hk
>
> Hi,
>
>     Is PostGIS already set up on that server? If so, verify that the
> table was created from the template_postgis template.
>
>    Just a wild guess. Hope it helps.  :D
>
> Jeremy

-- 
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: Hostmonster shared hosting and django tinymce

2010-03-17 Thread chris hendrix
ok thanks for pointing me in the right direction.  doesn't sound too hard.



On Wed, Mar 17, 2010 at 8:59 AM, Omer Barlas  wrote:

> tchendrix @ 17-03-2010 14:31:
>
>  do you by chance have instructions on how to get that installed with
>> django so it works properly? They don't say anything in their install
>> docs about what javascript to call.
>>
>
> you don't install it over django. put the javascript files in your /media
> folder, and load the javascript in your template, that's it. If you can't
> solve it, I can give you a step-by-step in an available time.
>
> regards.
>
>
> --
> Omer Barlas
> omer.bar...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: What validation tests are applied to ImageField?

2010-03-17 Thread thanos
DJango's ImageFields uses the PIL verify to check the image.

trial_image = Image.open(file)
trial_image.verify()


See: http://www.pythonware.com/library/pil/handbook/image.htm


On Mar 15, 10:56 pm, john2095  wrote:
> The documentation states about the ImageField
>
> "Like FileField, but validates that the uploaded object is a valid
> image. Has two extra optional arguments:"
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#imagefield
>
> I went cruising the source to try and work out what tests are
> implemented to define "a valid image" but didn't get much
> satisfaction. There seemed to be a fair bit of talk about dimensions
> but nothing about much else.  I was thinking/hoping to find something
> which inspected the binary stream to ensure the .jpg/.gif/.png/.bmp
> fit its applicable formats.
>
> Question is "What is the definition of a 'valid image'" in this
> context?"
> and, optionally, where is the source code for that?
>
> t.i.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: Hostmonster shared hosting and django tinymce

2010-03-17 Thread Omer Barlas

tchendrix @ 17-03-2010 14:31:

do you by chance have instructions on how to get that installed with
django so it works properly? They don't say anything in their install
docs about what javascript to call.


you don't install it over django. put the javascript files in your /media 
folder, and load the javascript in your template, that's it. If you can't 
solve it, I can give you a step-by-step in an available time.


regards.

--
Omer Barlas
omer.bar...@gmail.com

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



Re: What validation tests are applied to ImageField?

2010-03-17 Thread Karen Tracey
On Wed, Mar 17, 2010 at 1:51 AM, john2095  wrote:

> Maybe I should post this on the developers list?
>

No. The topic for django-developers is the development of Django itself.
Questions about the use of Django are off-topic and will be directed
elsewhere.

Validation of image fields is done at the form field level, see:

http://code.djangoproject.com/browser/django/trunk/django/forms/fields.py#L459

Karen

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



Re: What validation tests are applied to ImageField?

2010-03-17 Thread pjrhar...@gmail.com
> What constitutes a 'valid' image?
> The documentation states "ImageField... Like FileField, but validates
> that the uploaded object is a valid image."

I haven't read through the code, but the error must be caught
somewhere because I just tested it out.

Trying to upload in the admin a random file with a png extension
throws a ValidationError:

"Upload a valid image. The file you uploaded was either not an image
or a corrupted image."

My guess is just that if PIL can open it, its an image, if not, it
throws the error.

Peter

-- 
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: Hostmonster shared hosting and django tinymce

2010-03-17 Thread tchendrix
do you by chance have instructions on how to get that installed with 
django so it works properly?  They don't say anything in their install 
docs about what javascript to call.


Omer Barlas wrote:

Bobby Roberts @ 17-03-2010 06:15:

anyone get this working?  I've followed the instructions in the
install docs for django-tiny and still have the ole ugly text box up
there.


why do you rely on django-tiny? use ckeditor, it's very simple to 
deploy, just add the js code to your  and apply 
class="ckeditor" to your textareas.




--
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: Hostmonster shared hosting and django tinymce

2010-03-17 Thread tchendrix

i'll check it out



Omer Barlas wrote:

Bobby Roberts @ 17-03-2010 06:15:

anyone get this working?  I've followed the instructions in the
install docs for django-tiny and still have the ole ugly text box up
there.


why do you rely on django-tiny? use ckeditor, it's very simple to 
deploy, just add the js code to your  and apply 
class="ckeditor" to your textareas.




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



No required field indication in TabularInline

2010-03-17 Thread Dirk Eschler
Hello,

in StackedInline the label of a required field gets the class required. In 
TabularInline (and GenericTabularInline) however, the corresponding table head 
cell gets no class, so there is no indication if a field is required or not. 
You have to save to know what fields are required. Is this just a missing 
feature or am i missing something?

Best Regards,
Dirk Eschler

-- 
Dirk Eschler 
http://www.krusader.org

-- 
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: More tutorials and recipes?

2010-03-17 Thread Alastair Campbell
> On Mar 17, 11:23 am, Jirka Vejrazka  wrote:
>> > What I am looking for is something that goes beyond the tutorials to
>> > bridge the gap to the detail of the modules. Are there any?

I found the best next step was the "Practical Django Projects" book:
http://apress.com/book/view/1430219386

(I need to get the 2nd Ed though). The first edition was really good
at taking your through practical projects, and helping you learn the
django way. I assume the 2nd edition just brings it upto date.

Kind regards,

-Alastair

-- 
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: More tutorials and recipes?

2010-03-17 Thread ALJ
Hi Jirka,

Cheers for that. I like the cookbook (http://code.djangoproject.com/
wiki/CookBook)

ALJ

On Mar 17, 11:23 am, Jirka Vejrazka  wrote:
> > What I am looking for is something that goes beyond the tutorials to
> > bridge the gap to the detail of the modules. Are there any?
>
>   Hi,
>
>   how about checking out some existing applications to learn how those
> work? Many of them are small enough to get the useful tips and tricks
> from them in 10 minutes (per app ;-)
>
>  http://code.djangoproject.com/wiki/DjangoResources
>
>   HTH
>
>     Jirka

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



Re: How to check if I installed Django well?

2010-03-17 Thread Archidjango
Alright! Works fine now!!

Thanks a lot!!! :-)

On Mar 16, 12:43 pm, Daniel Roseman  wrote:
> On Mar 16, 9:49 am, Archidjango  wrote:
>
>
>
>
>
> > Hey all,
>
> > I'm a fresh Python/Django user and I'm experiencing a couple of
> > problems to check if Django is correctly installed on my machine. Well
> > I guess it's not honestly.
>
> > I used Windows XP and untarred Django 1.1.1 directly on my C: drive.
>
> > When I try to import django in IDLE, this is what I get:
>
> > >>> import django
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >     import django
> > ImportError: No module named django
>
> > 
>
> > Basically, I think it's downloaded and untarred but not installed
> > well.
>
> > I tried to follow the instructions on the django website, but I'm not
> > sure to understand well what is meant by the following:
>
> > tar xzvf Django-1.1.1.tar.gz
> > cd Django-1.1.1
> > sudo python setup.py install
>
> > Could anyone help me please? I'm really a beginner in programmation
> > (as you probably have guessed), so don't be scared to oversimplify ;-)
>
> > Thanks a lot in advance!
>
> Those are the instructions for Linux/Unix systems. You're on Windows.
> The documentation states:
> "If you're using Windows, start up a command shell with administrator
> privileges and run the command 'setup.py 
> install'."http://docs.djangoproject.com/en/1.1/topics/install/#installing-offic...
> --
> DR.- Hide quoted text -
>
> - Show quoted text -

-- 
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: More tutorials and recipes?

2010-03-17 Thread Jirka Vejrazka
> What I am looking for is something that goes beyond the tutorials to
> bridge the gap to the detail of the modules. Are there any?

  Hi,

  how about checking out some existing applications to learn how those
work? Many of them are small enough to get the useful tips and tricks
from them in 10 minutes (per app ;-)

  http://code.djangoproject.com/wiki/DjangoResources

  HTH

Jirka

-- 
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 tutorials and recipes?

2010-03-17 Thread ALJ
I've done the tutorial. This is great. It's practical. You can see how
things fit together. But the application is quite simple.

I've read the documentation. This tells you how the bits work. But
it's quite detailed.

What I am looking for is something that goes beyond the tutorials to
bridge the gap to the detail of the modules. Are there any?

-- 
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: passing more information with formsets

2010-03-17 Thread Alastair Campbell
On Tue, Mar 16, 2010 at 7:46 PM, Dennis Kaarsemaker wrote:
> Each ModelForm has an instance attribute, so you can use
> {{ form.instance.whatever }}

Hi Dennis,

Unfortunately it is not a model form. The form creates an "entry",
which is de-normalised data taken from the person (member) details and
the event details.

The closest I've gotten so far is to use something like this in the
formset loop:
{% for member in members %}
{% ifequal member.sail_number form.sail_number.data %}
{{ member.name}}
{% endifequal %}
{% endfor %}

Unfortunately not all members have sail numbers, so I'll try passing
initial data for member.id through to the form as a better match.

Unless there's a better way to do it?

Also, is there a danger to using form.something.data? It isn't in the
docs, but I found it as a possible way of matching the form against
the object values.

Kind regards,

-Alastair

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



Re: django-weave needs contribution...

2010-03-17 Thread Jens Diemer

Am 07.03.2010 20:15, schrieb Jens:

I started http://code.google.com/p/django-weave/ a Django reuseable
Application witch implements a Firefox weave server.

The Project is in planning/pre-alpha state.

If anyone has interest to help, please contact me!


Bookmark sync works now, since:
http://code.google.com/p/django-weave/source/detail?r=41


--
Mfg.

Jens Diemer



http://www.jensdiemer.de

--
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: A bit of a modeling question

2010-03-17 Thread ALJ
Hi,

Thanks. I can't see the wood for the trees at the moment.

Neil

On Mar 17, 2:57 am, aditya  wrote:
> ALJ,
> In that case, I think you need multiple models, without inheritance...
>
> Aditya
>
> On Mar 16, 1:48 pm, ALJ  wrote:
>
> > Hi aditya,
>
> > I wasn't aware of the editable parameter (which means I've learnt
> > something) but I still don't think it will help me.
>
> > The user will create an 'invoice' for want of a better word, that will
> > be made up of lots of different entries. Some of these are fixed
> > (description and unit price) and therefore selected from a list of
> > options, some are classified (description) but can enter a unit price,
> > and some are unclassified so they will need to enter free text
> > description and unit cost. Eg
>
> > Type, Description, unit price, units
> > Fixed, Commission on Product XXX, £20, [12]
> > Fixed, Commission on Product YYY, £18, [4]
> > Fixed, Inconvenience allowance, £30, [2]
> > Classified, Parking fees, [£10], [1]
> > Classified, Hotel, [£100], [2]
> > Unclassified, [Emergency Courier we didn't think we'd need], [£50],
> > [1]
>
> > [] = user entered,
>
> > > How will the model be used? It looks to me like what you're after is
> > > the 'editable' parameter, as in something like:
> > > class Unclassified(models.Model):
> > >   name = models.CharField(max_length=50)
> > >   cost = models.DecimalField(max_digits=5,decimal_places=2)
>
> > > class Classified(Unclassified):
> > >   name =
> > > models.CharField(default="Hotels",editable=False,max_length=50)
>
> > > class Fixed(Unclassified):
> > >   name = models.Charfield(editable=False,max_length=50)
> > >   cost =
> > > models.DecimalField(max_digits=5,decimal_places=2,editable=False)
>
> > > On Mar 16, 9:36 am, ALJ  wrote:
>
> > > > Hi Preston,
>
> > > > Sorry, I don't get it.
>
> > > > The certainly do have the same fields, but sometimes the fields are
> > > > derived from a linked table, or are a foreign key or sometimes text.
> > > > So I don't understand how having the interface adapt to what the
> > > > current type is would work.
>
> > > > ALJ
>
> > > > On Mar 16, 3:04 pm, Preston Holmes  wrote:
>
> > > > > On Mar 16, 3:21 am, ALJ  wrote:
>
> > > > > > This is a bit of a modeling question that I am struggling to get my
> > > > > > head around. How would you model this scenario?
>
> > > > > > I have to record expenses that are of 3 different types.
>
> > > > > > 1. Fixed - The name of the expense and unit amount are fixed. For
> > > > > > example, "inconvenience allowance" of £30 per day.
> > > > > > 2. Classified - The name of the expense is fixed, but the actual 
> > > > > > unit
> > > > > > amount isn't. For example "Hotel expenses". The actual unit amount
> > > > > > will depend on the hotel they stay at. They'll need to enter that
> > > > > > themselves.
> > > > > > 3. Unclassified - The name of the expense and the amount is 
> > > > > > arbitrary.
> > > > > > So they may have an expense we haven't thought of before but it 
> > > > > > needs
> > > > > > to go in.
>
> > > > > > Of course I'll need to create a summary that tots up the total
> > > > > > expenses for the particular event.
>
> > > > > whether you subclass a base model, or simply have a "type" field on
> > > > > your expense object is going to depend on the details and nuance of
> > > > > the rest of your business logic in your app.  I would only say that
> > > > > simple is better unless you have a reason or need for the complexity.
>
> > > > > Given that the fields between them are identical, I would probably
> > > > > just use a "type" choice field and have the interface adapt as needed.
>
> > > > > -Preston
>
> > > > > > Would the best way of doing this be:
>
> > > > > > a) Have a base model and then build on that for the 3 different
> > > > > > scenarios?
> > > > > > b) Have three different tables and then do a union on them?
>
> > > > > > Just for interest ... this is where I got so far, but am now stumped
>
> > > > > > class CostType(models.Model):
> > > > > >     name = models.CharField("Name", max_length=30) 'e.g. commission,
> > > > > > subsistence ...
>
> > > > > > class CostItem(models.Model):
> > > > > >     name = models.CharField("Name", max_length=50) 'e.g. product x,
> > > > > > inconvenience allowance, ...
> > > > > >     cost_type = models.ForeignKey(CostType, verbose_name="Type")
>
> > > > > > class Rate(models.Model):
> > > > > >     cost_item = models.ForeignKey(CostItem, verbose_name="Item")
> > > > > >     valid_from = models.DateField("From")
> > > > > >     valid_till = models.DateField("Till")
> > > > > >     unit_amount = models.DecimalField("Price Per Unit", 
> > > > > > max_digits=5,
> > > > > > decimal_places=2)
>
> > > > > > 'Costs with a fixed description and unit amount
> > > > > > class FixedCostList(models.Model):
> > > > > >     markettingevent= 

Send e-mail with large files from form attached

2010-03-17 Thread tezro
Hello everyone. I need some help or advice.

I've got a form with 20 ImageFields - such a form for sending photos
to the site admin as a request for a new user. Well, Django certainly
handles and uploads the, that's OK. But when it comes to sending all
the files as an attachment - I got stuck.

Here's a simple example of how I tried to do that:

from django.core.mail import EmailMessage

email = EmailMessage()
for (k, v) in request.FILES.items():
email.attach(v.name, v.read())


Small files are read nicely. But when someone "clever" fills out all
the form files (all the twenty) with images each one at least 10 Mb -
Django consumes so much memory... so I'm not in knowledge to handle
that.

Please, guide me how to handle big files from a form and send them
without memory leaks. Thanks ahead.

-- 
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: Many to Many...so many queries

2010-03-17 Thread bruno desthuilliers
On Mar 17, 4:37 am, TheIvIaxx  wrote:
> i suppose i could, but that will be a last resort :)  What about
> dropping down to raw SQL just to get the IDs:
>
> SELECT term_id FROM image_term WHERE image_id = %i
>
> or is that discouraged?  Can it be done with the ORM?

You'd have the exact same result using the ORM:

   ids = image.terms.values_list('id', flat=True)

but this won't solve the real problem of doing images.count() queries
- which is what select_related is for.

-- 
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: Many to Many...so many queries

2010-03-17 Thread bruno desthuilliers
On Mar 17, 4:24 am, TheIvIaxx  wrote:
> Hello all, i have a question about a certain query i have.  Here is my
> model setup:
>
> class Term():
>     term = CharField()
>
> class Image():
>     image = FileField()
>     terms = ForeignKey(Term)
>
> These have been abbreviated for simiplicity, ut you get the gist of
> it.  Anyhow i have to query for a few hundred Image objects, then get
> a list of Term objects for each of these.  Really i just need the IDs
> of the Terms.  Currently i have my query like this:
>
> images = Image.objects.all()

you can use 'select_related' here - it'll use a join to prefetch
related Term objects:

images = Image.objects.select_related('terms').all()

>
> responseImages = []
> for i in images:
>     terms = [term.id for term in n.terms.all()]
>     responseObjects.append({'image': n, 'terms': terms})

I guess this is not your real code !-)



I don't know what this 'responseObjects' is - , but if you use Django
templates, you just don't need all this above code. Just pass 'images'
in the template's context and you'll be fine:


{% for image in images %}
   
  {{ image.title }}
 
{% for term in image.terms.all %}
{{ term.id }}
{% endfor %}

   
{% endfor %}



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.



Re: Hostmonster shared hosting and django tinymce

2010-03-17 Thread Omer Barlas

Bobby Roberts @ 17-03-2010 06:15:

anyone get this working?  I've followed the instructions in the
install docs for django-tiny and still have the ole ugly text box up
there.


why do you rely on django-tiny? use ckeditor, it's very simple to deploy, 
just add the js code to your  and apply class="ckeditor" to 
your textareas.


--
Omer Barlas
omer.bar...@gmail.com

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



Re: django buildout trouble

2010-03-17 Thread andreas schmid
did you run ./bin/django syncdb?
did you edit the cottagematic_com.urls to get the admin working?

ViewDoesNotExist: Could not import
cottagematic_com.django.contrib.auth.views.
this one looks strange to me because cottagematic_com is your project
dir (right?) and django is located in cottagematic_bld/parts/django. did
you customize some admin views?

p.s. about the versioning we were speaking yestereday, you should commit
also the cottagematic_bld/cottagematic_com folder to the versioning repo.

John Griessen wrote:
> I've tested a buildout of django with mysql database and used
> bin/django runserver to get the django internal server going with
> no errors on starting.
>
> When I try browsing to  http://127.0.0.1:8000/ I get a the debug version
> of a 404 page, which is OK for the copy of the tutorial polls app
> that is all this project has for now.  The when I try
> http://127.0.0.1:8000/polls I get:
>
> No module named polls.urls
> and for:
> http://127.0.0.1:8000/admin/  I get:
>
> ViewDoesNotExist: Could not import
> cottagematic_com.django.contrib.auth.views.
> Exception Location: 
> /home/john/WEBprojects/cottagematic_bld/parts/django/django/template/debug.py
> in render_node, line 81
>
> Here is part of my settings file:
>
> MIDDLEWARE_CLASSES = (
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.middleware.doc.XViewMiddleware',
> )
>
> ROOT_URLCONF = 'cottagematic_com.urls'
>
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.admin',
> )
>
> TEMPLATE_LOADERS = (
> 'django.template.loaders.filesystem.load_template_source',
> 'django.template.loaders.app_directories.load_template_source',
> )
>
> TEMPLATE_DIRS = (
> os.path.join(os.path.dirname(__file__), "templates"),
> "/home/john/djangotemplates"
>
> )
>
>
> My pythonpath has/home/john/WEBprojects/cottagematic_bld/parts/django
> but no path to templates or the django app cottagematic_com
>
> Any ideas why not?
>
> thanks,  John
>

-- 
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: What validation tests are applied to ImageField?

2010-03-17 Thread Kenneth Gonsalves
On Wednesday 17 Mar 2010 11:21:45 am john2095 wrote:
> Maybe I should post this on the developers list? Would that upset
> them?
> 

most of them read this list
-- 
regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS
http://certificate.nrcfoss.au-kbc.org.in

-- 
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: Form validation changes since 1.1.1? (Autocomplete errors)

2010-03-17 Thread john2095
There has been some change between 1.1 and trunk regarding questions
whether to enforce defaults at the form or the model level.  Might be
relevant, or provide a clue:
http://stackoverflow.com/questions/1436327/does-model-charfieldblankfalse-work-with-save

On Mar 17, 12:11 pm, Karen Tracey  wrote:
> Yeah but, if it worked previously under 1.1, it ought not be broken by
> updating to 1.2.
>
> Sounds like under 1.1 required=False on the form field overrode blank=False
> on the model field, whereas with the current trunk required=False on the
> form field is being ignored in favor of blank=False on the model field.
>
> It's probably worth opening a ticket; I don't recall hearing this reported
> before.
>
> Karen

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