Re: Model Forms

2009-08-27 Thread Siddharth Godbole
Yup It worked! I saved the form with excluded foreign key with commit=False.
Then set the proper instance to foreign key and then saved. It worked just
fine.

Thanks for the help :)

On Thu, Aug 27, 2009 at 10:47 PM, Shawn Milochik wrote:

>
> There are different options, depending on whether the instance of B is
> a required part of A's model.
>
> 1. You can add an "exclude" section to your ModelForm of A. Validate
> BForm, validate AForm, then take the resulting instance of A and set
> it's 'b' attribute to the resulting instance of BForm.save().
>
> 2. Validate BForm first. Then, before AForm.is_valid(), you set
> AForm.data['B'] manually, to B.pk, then validate A.
>
> Maybe there's a more elegant way, but those will work.
>
> 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-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: QuerySet without result_cache?

2009-08-27 Thread Alex Gaynor

On Thu, Aug 27, 2009 at 5:56 PM, Sam Tregar wrote:
> On Thu, Aug 27, 2009 at 5:47 PM, Alex Gaynor  wrote:
>>
>> Instead of iterating over the QuerySet itself, use
>> QuerySet.iterator(), this will avoid populating the result cache.
>
> Thanks, works great!  This would make a good addition to the manual section
> that describes how the QuerySet cache system works.  Maybe I'll see about a
> patch.
>
> -sam
>
>
> >
>

Note that the iterator() method is documented in the QuerySet
documentation: 
http://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Re: Django test suite does not discover test method "test_string_regex"

2009-08-27 Thread Karen Tracey
On Thu, Aug 27, 2009 at 2:21 PM, Gregor Müllegger wrote:

>
> Hi,
>
> i have an issue with the standard test runner of django. If i try to
> run the testsuite of an app everything gets executed in the right
> fashion. While all executed tests pass without errors, the test method
> "test_string_regex" is not evaluated! If i rename the method to any
> athor name like "test_string_regex2", "test_string__regex" or
> "test__string_regex" it is discovered by the test suite.
> I also can execute the single test with the "python manage.py test
> applabel.TestCaseName.test_string_regex".
>
> This seams very scary to me.
> Is this a bug in the django testrunner?
>

Unlikely.  More likely there is something in your test suite causing this.
How are you determining that this method is not running when you run the
full suite?  Are you sure you don't have multiple test_string_regex methods
defined in this TestCase?

FWIW, I just tried adding a method with that name to a test suite I have and
it runs fine.

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-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: invalid template tag

2009-08-27 Thread Javier Guerra

On Thu, Aug 27, 2009 at 2:03 PM, nixon66 wrote:
> register.filter(uscurrency)

should be

register.filter ('uscurrency', uscurrency)

-- 
Javier

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



Table with search results and returning to previous page.

2009-08-27 Thread Viacheslav Chumushuk
Hello.

I have project design question. Imaging that we have page with simple search
form at the top and search results at the bottom of the same page. And every
row of result table has a link to another page (edit/view this founded
item). After user clicking this link he goes to another page (for example
edit product), then he presses a button (say save or cancel) and returns to
the previous page with results. How to make user see exactly the same page,
with the same data in search form and the seame searching results?
Almost all projects have similar functionality, isn't it. I want to discuss
how to do it in the best way, how different people do it.
I see only the one variant, -- with flash data which is stored into session.

And can you recommend some reference to documentation/code about this kind
of flash storing. Because I was googled and found only some simple flash to
use in views, just to show messages, but not to transfer data between pages.
Thanks.

Best regards, Viacheslav.

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



Django test suite does not discover test method "test_string_regex"

2009-08-27 Thread Gregor Müllegger

Hi,

i have an issue with the standard test runner of django. If i try to
run the testsuite of an app everything gets executed in the right
fashion. While all executed tests pass without errors, the test method
"test_string_regex" is not evaluated! If i rename the method to any
athor name like "test_string_regex2", "test_string__regex" or
"test__string_regex" it is discovered by the test suite.
I also can execute the single test with the "python manage.py test
applabel.TestCaseName.test_string_regex".

This seams very scary to me.
Is this a bug in the django testrunner?

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



Integrating external tools into Django

2009-08-27 Thread Jenny

Hello ppl,

may somebody help me?
I need to integrate widgets like iCalender or a chat into Django.
How do I do it correctly?
Thx!

Jenny

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



django-tinymce problem on server

2009-08-27 Thread Sonal Breed

Hi all,

I have django-tinymce spellchecker working perfectly on my local
machine which is Ububtu.
But as soon as, I deploy it on a web host (CentOS), it gives me
problems. Specifically, when I click the specllchecker button,
following errors are logged:

Traceback (most recent call last):

 File "/home/mygoplanner/webapps/mygostaging/lib/python2.5/django/core/
handlers/base.py", line 86, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/home/mygoplanner/webapps/mygostaging/mygo/tinymce/views.py",
line 69, in spell_check
   return HttpResponse(simplejson.dumps(output),

UnboundLocalError: local variable 'output' referenced before
assignment


,
POST:,
COOKIES:{'__utma':
'171779938.132725263310057000.1249582915.1251233797.1251394837.30',
 '__utmb': '171779938.17.10.1251394837',
 '__utmc': '171779938',
 '__utmz': '171779938.1249582915.1.1.utmcsr=(direct)|utmccn=(direct)|
utmcmd=(none)',
 'sessionid': '3160e3bb9a31ae72f39cc0b5a0e5e695'},
META:{'AUTH_TYPE': 'Basic',
 'CONTENT_LENGTH': 0L,
 'CONTENT_TYPE': None,
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8',
 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
 'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
 'HTTP_AUTHORIZATION': 'Basic YWRtaW5pc3RyYXRvcjpteWcwcDE0bm4zcg==',
 'HTTP_CACHE_CONTROL': 'no-cache',
 'HTTP_CONNECTION': 'close',
 'HTTP_CONTENT_LENGTH': '64',

At first, I thought it was because the enchant and pyenchant
istallation issue. I then installed the enchant library and pyenchant
package on server manually. So import enchant works perfectly in
python interactive window. Also I was told by the web host support
people to include
SetEnv PYENCHANT_LIBRARY_PATH /home/mygoplanner/lib/libenchant.so

in httpd.conf . So done that as well. But still I am getting above
error and looks like it is coming from code. So if it is working
locally, why does it fail on server??

Thanks for any help guys, pleeaase...


Thanks in advance,

Sincerely,
Sonal.
--~--~-~--~~~---~--~~
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: QuerySet without result_cache?

2009-08-27 Thread Sam Tregar
On Thu, Aug 27, 2009 at 5:47 PM, Alex Gaynor  wrote:

>
> Instead of iterating over the QuerySet itself, use
> QuerySet.iterator(), this will avoid populating the result cache.
>

Thanks, works great!  This would make a good addition to the manual section
that describes how the QuerySet cache system works.  Maybe I'll see about a
patch.

-sam

--~--~-~--~~~---~--~~
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: Dynaically fields to a formwizard form

2009-08-27 Thread dingue fever

Thanks. I will check out your suggestions.

On Aug 26, 6:07 am, Peter Bengtsson  wrote:
> You can add and modify fields on a form in the form's __init__
> function.
>
> class MyForm(forms.Form):
>     country = forms.ChoiceField()
>     def __init__(self, *args, **kwargs):
>          super(MyForm, self).__init__(*args, **kwargs)
>         self.fields['country'].choices = \
>           [(c.iso_code, c.name) for c in get_all_choices()]
>
> Perhaps you'll need to do it in the view.
> You can create the form instance both before you bind it with
> something like request.POST or if you do it later.
> E.g.
> def my_view(request):
>     form = MyForm()
>     form.fields['country'].choices = get_my_country_choices
> (request.user)
>     if request.method == "POST":
>         # bind the form
>         form.is_bound = True
>         form.data = request.POST
>         if form.is_valid():
>     return render(request, 'my_template.html', locals())
>
>             cool!
> On Aug 25, 7:16 am, dingue fever  wrote:
>
> > Hi,
>
> > Is it possible to dynamically add fields to a formwizard form. I have
> > been able to add the fields I want but if the form fails validation
> > the new dynamic fields disappear when the form re-renders. Is it
> > possible to override this so that I can validate and return the new
> > fields if the validation fails?
>
> > Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model Forms

2009-08-27 Thread Shawn Milochik

There are different options, depending on whether the instance of B is  
a required part of A's model.

1. You can add an "exclude" section to your ModelForm of A. Validate  
BForm, validate AForm, then take the resulting instance of A and set  
it's 'b' attribute to the resulting instance of BForm.save().

2. Validate BForm first. Then, before AForm.is_valid(), you set  
AForm.data['B'] manually, to B.pk, then validate A.

Maybe there's a more elegant way, but those will work.

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-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: invalid template tag

2009-08-27 Thread nixon66

Still getting the same errors.

On Aug 27, 7:10 pm, Javier Guerra  wrote:
> On Thu, Aug 27, 2009 at 2:03 PM, nixon66 wrote:
> > register.filter(uscurrency)
>
> should be
>
> register.filter ('uscurrency', uscurrency)
>
> --
> Javier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: invalid template tag

2009-08-27 Thread nixon66

The file is mytag.py and the directory is now called templatetags

On Aug 27, 4:42 pm, Daniel Roseman  wrote:
> On Aug 27, 8:03 pm, nixon66  wrote:
>
> > I've just created a template tag as described in the documents, but
> > keep getting errors.
>
> > In an installed app I created a directory called Templatetags. I
> > created a blank __init__.py file and a file called mytag.
>
> Is the file called just 'mytag' or (as it should be) 'mytag.py'? Is
> the directory called 'Templatetags' rather than
> 'templatetags' (assuming you're on Linux, where case is significant in
> filenames)?
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many-to-many column admin interface

2009-08-27 Thread Sven Richter
I found this thread:
http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
on Stackoverflow, but when i try the suggested TabularInline thing i get the
error:

 has no ForeignKey to


Greetings
Sven



On Thu, Aug 27, 2009 at 5:03 PM, Thomas Guettler  wrote:

>
> Hi,
>
> I had the same question some time ago and found no answer,
> but maybe you try harder.
>
> Sven Richter schrieb:
> > Hi,
> >
> > i have a new problem with my many-to-many field.
> >
> > I have two models A and B.
> > A(models.model):
> >   b = models.ManyToManyField('app.B')
> >
> > Now when i edit A in the admin interface everything is ok, i can select
> all
> > B instances A belongs to.
> >
> > What i need now is to be able to do the same thing from B's admin
> interface.
> > When i edit B i want to select all instances of A B belongs to.
> >
> > Is there a way to achieve that?
>
> --
> Thomas Guettler, http://www.thomas-guettler.de/
> E-Mail : guettli (*)
> thomas-guettler + 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-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: invalid template tag

2009-08-27 Thread nixon66

Made the changes and still getting the same error.


On Aug 27, 3:11 pm, Javier Guerra  wrote:
> i only see a couple of minimal typos, could be your problem:
>
> > In an installed app I created a directory called Templatetags. I
>
> should be 'templatetags', no capitalization.
>
> > created a blank __init__.py file and a file called mytag. Mytag has a
> > function
>
> > from django import template
>
> > register template.Library()
>
> should be 'register = template.Library()'
>
> --
> Javier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: QuerySet without result_cache?

2009-08-27 Thread Alex Gaynor

On Thu, Aug 27, 2009 at 5:34 PM, Sam Tregar wrote:
> Hey all.  So, I figured out how to run my QuerySet through MySQLdb's
> SSCursor!  Woo!
>
> Bad news: it's still using a ton of memory.  As far as I can tell it's being
> used by QuerySet's internal _result_cache which is holding all the rows
> retrieved by the query.  Is there any way to turn this cache off?  Looking
> at the code leads me to think no, but I thought I'd ask.
>
> -sam
>
>
> >
>

Instead of iterating over the QuerySet itself, use
QuerySet.iterator(), this will avoid populating the result cache.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Re: Django scalability with files

2009-08-27 Thread Rafael Ferreira
The queue idea is a good one, and you can use Gearman to do that really
easily. Another, even simpler, way to handle this is to use some kind of
shared NFS mount for the storage. All things being equal, scaling a filer or
SAN will be much easier than scaling your DB, specially if - like most
similar cases I've seen in the past - most of you db becomes blob data.

On Thu, Aug 27, 2009 at 8:32 AM, David De La Harpe Golden <
david.delaharpe.gol...@ichec.ie> wrote:

>
> Lewis Taylor wrote:
>
> > Is there a better solution django offers, and why are
> > blobs not supported. ideally i would have the image stored in DB and
> > that way there would never be sync issues.
> >
>
> FWIW (which given you're concerned about scaling mightn't be all that
> much), it's fairly straightforward to stash small to middling sized*
> binary stuff naively to a database rather than fs without even writing a
> full custom file storage backend: just base64 encode it to text (using a
> postgres bytea would be preferable, but BinaryField or whatever isn't in
> Django yet, so my get_internal_type returns "TextField").
>
> e.g. (...not efficient (watch it slurp the whole thing into memory),
> some might say pretty dumb):
> http://python.pastebin.com/d1c577e71
>
> * postgres text and bytea go up to 1GB IIRC.
>
>
>
>
> >
>

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



QuerySet without result_cache?

2009-08-27 Thread Sam Tregar
Hey all.  So, I figured out how to run my QuerySet through MySQLdb's
SSCursor!  Woo!

Bad news: it's still using a ton of memory.  As far as I can tell it's being
used by QuerySet's internal _result_cache which is holding all the rows
retrieved by the query.  Is there any way to turn this cache off?  Looking
at the code leads me to think no, but I thought I'd ask.

-sam

--~--~-~--~~~---~--~~
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: pyfacebook, No module named facebook.djangofb...

2009-08-27 Thread Mike Ramirez
On Thursday 27 August 2009 08:36:25 am garagefan wrote:
> i've taken the project directly from github and attempted to run
> python setup.py install and get the same error:
>
> running install
> error: invalid Python installation: unable to open /usr/lib/python2.5/
> config/Makefile (No such file or directory)
>
try: yum provides /usr/lib/python2.5/config/Makefile

you'll get something like this:

[r...@sylia httpd]# yum provides /usr/lib/python2.5/config/Makefile



0 packages excluded due to repository protections   
 
Importing additional filelist information   
 
python-devel-2.5.1-26.fc9.i386 : The libraries and header files needed for 
Python development. 
  
Repo: updates-newkey
 
Matched from:   
 
Filename: /usr/lib/python2.5/config/Makefile
 



python-devel-2.5.1-25.fc9.i386 : The libraries and header files needed for 
Python development.
Repo: fedora
Matched from:
Filename: /usr/lib/python2.5/config/Makefile



python-devel-2.5.1-26.fc9.i386 : The libraries and header files needed for 
Python development.
Repo: installed
Matched from:
Other   : Provides-match: /usr/lib/python2.5/config/Makefile


> i assume then, i need to install Makefile? I've attempted to try yum
> install Makefile to no success
>

Makefile isn't a program, it's a file that the program make uses to build 
software.  Software developers usually create this for you (similar to a 
setup.py), what it really wants is the one from the python install. You 
should really read the error messages more carefully and look at your tools 
deeper. 

Mike

-- 
Tout choses sont dites deja, mais comme personne n'ecoute, il faut
toujours recommencer.
-- A. Gide

[ All things have already been said, but since no one listens, one
  must always start again. ]


signature.asc
Description: This is a digitally signed message part.


Re: show user and date in change_list

2009-08-27 Thread Alex Gaynor

On Thu, Aug 27, 2009 at 12:18 PM, Sandra Django wrote:
> Hi, I want display in change_list view, user who added an object and date. I
> did that:
> - models.py ---
>>
>> class One(models.Model):
>>     ..
>> def user(self):
>>     return self.user.username
>>
>> def date(self):
>>     return self.date
>
>
>>
>> -- admin.py ---
>> class OneAdmin(admin.ModelAdmin):
>>     list_display = ['name', 'user', 'date']
>
>
>>
>> But both functions returns (None). Why I can do it?
>>
>>
>
>
> >
>

You can't have methods with the same names as fields on your models,
since this would mean an object having two attributes by the same
name.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



show user and date in change_list

2009-08-27 Thread Sandra Django
Hi, I want display in change_list view, user who added an object and date. I
did that:
- models.py ---
>
> class One(models.Model):
> ..
> def user(self):
> return self.user.username
>
> def date(self):
> return self.date



> -- admin.py ---
> class OneAdmin(admin.ModelAdmin):
> list_display = ['name', 'user', 'date']



> But both functions returns (None). Why I can do 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-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: invalid template tag

2009-08-27 Thread Daniel Roseman

On Aug 27, 8:03 pm, nixon66  wrote:
> I've just created a template tag as described in the documents, but
> keep getting errors.
>
> In an installed app I created a directory called Templatetags. I
> created a blank __init__.py file and a file called mytag.

Is the file called just 'mytag' or (as it should be) 'mytag.py'? Is
the directory called 'Templatetags' rather than
'templatetags' (assuming you're on Linux, where case is significant in
filenames)?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Related ownership for items that dont' exist yet?

2009-08-27 Thread Streamweaver

Sorry if I'm getting a little far out here.

I have two models, a parent and a child with a FK relationship (See
the code below for example) and I have a method in each called
is_owner.  For the child it checks to see if a user passed is the
objects owner OR if that user passes the parents is_owner method.

I use this in a decorator that I use in views to give permission for
updating or deleting based on checking permissions OR if they pass the
objects is_owner check.

My problem is with new child objects.  How would I check for new child
objects if the parent is an owner so they can get the proper Form to
create it?



class Project(models.Model):
owner = models.ForeignKey(User)

def is_owner(self, user):
if user == self.owner:
return True
return False


class Release(models.Model):
project_fk = models.ForeignKey(Project)
owner = models.ForeignKey(User)

def is_owner(self, user):
if user == self.owner:
return True
if self.project_fk.is_owner(user):
return True
return False
--~--~-~--~~~---~--~~
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: invalid template tag

2009-08-27 Thread Javier Guerra

i only see a couple of minimal typos, could be your problem:

> In an installed app I created a directory called Templatetags. I

should be 'templatetags', no capitalization.

> created a blank __init__.py file and a file called mytag. Mytag has a
> function
>
> from django import template
>
> register template.Library()

should be 'register = template.Library()'

-- 
Javier

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



Re: How to check which form was submitted?

2009-08-27 Thread Maksymus007

On Thu, Aug 27, 2009 at 5:00 PM, Thomas Guettler wrote:
>
>
>
> Maksymus007 schrieb:
>> On Thu, Aug 27, 2009 at 1:22 PM, David Zhou wrote:
>>> On Thu, Aug 27, 2009 at 7:09 AM, Maksymus007 wrote:
 I've got two different form on the same page, under the same URL.
 When I send one of them, the second one gets validated too.
 I set prefixes but no change.

 Is there any way to distinguish between two forms, choosing one that
 have been submited?
>>> Prefixes are for using the same form multiple times on a page,
>>> avoiding name collisions.
>>>
>>> Post the part of your view that handles your forms.
>>>
>>> -- dz
>>>
>>
>> Nothing special
>>
>>     if request.method == 'POST':
>>         form = RegisterForm(request.POST)
>>         if form.is_valid():
>>              pass
>>
>> And second one is handled by middleware, in similar way
>
> You handle forms in a middleware? Why? Middleware code gets
> executed for every http request ...
>
>  Thomas
>

Yes I know, but thats happen only if user has no session and all pages
are restricted to logged users.

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



invalid template tag

2009-08-27 Thread nixon66

I've just created a template tag as described in the documents, but
keep getting errors.

In an installed app I created a directory called Templatetags. I
created a blank __init__.py file and a file called mytag. Mytag has a
function

from django import template

register template.Library()

def uscurrency(c):
   try:
   if c > 0:
   return '$%.2f'% c
   else:
   return '-$%.2f' % (-1*c)
   except TypeError:
   return c
register.filter(uscurrency)



In my template I have {% load mytag %}

Yet I get this error:
'mytag' is not a valid tag library: Could not load template library
from django.templatetags.mytag, No module named mytag

Suggestions as to what I'm 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-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
-~--~~~~--~~--~--~---



What do you use for a shopping cart (in an existing app?)

2009-08-27 Thread ristretto.rb

Hello,

I would like to add shopping cart features to a current web
application.  Has anyone solved this type of problem?  What did you
do?  Roll your own features (add to cart, view cart, payment, etc)?
Use Satchmo?  Use something else?

Thanks
Gene

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



How to control which DB connection and cursor a queryset will use

2009-08-27 Thread Sam Tregar
I'm trying to get a queryset to issue its query over a different DB
connection, using a different cursor class.  Does anyone know if that's
possible and if so how it might be done?  In psuedo-code:

  # setup a new db connection:
  db = db_connect(cursorclass=AlternateCursor)

  # setup a generic queryset
  qset = blah.objects.all()

  # tell qset to use the new connection:
  qset.use_db(db)

  # and then apply some filters
  qset = qset.filter(...)

  # and execute the query:
  for object in qset:
 ...

-sam

--~--~-~--~~~---~--~~
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: pyfacebook, No module named facebook.djangofb...

2009-08-27 Thread garagefan

doh, forgot that i never installed python-devel, der... everything
works now, nothing to see here... no novice server users here >_>

On Aug 27, 11:36 am, garagefan  wrote:
> i've taken the project directly from github and attempted to run
> python setup.py install and get the same error:
>
> running install
> error: invalid Python installation: unable to open /usr/lib/python2.5/
> config/Makefile (No such file or directory)
>
> i assume then, i need to install Makefile? I've attempted to try yum
> install Makefile to no success
>
> On Aug 26, 10:06 pm, Matias  wrote:
>
>
>
> > Where did you get the files?
> > if you go to the pyfacebook at 
> > googlehttp://code.google.com/p/pyfacebook/theprojectis now hosted in
> > github.
> > So if you downloaded from google it may be outdated.
> > The installation is much more simpler than what the tutorial says, so i
> > recommend to download fromhttp://github.com/sciyoshi/pyfacebook/tree/master
>
> > HTH,
>
> > Matias.
>
> > On Wed, Aug 26, 2009 at 9:58 PM, garagefan  wrote:
>
> > > steps followed here:
>
> > >http://wiki.developers.facebook.com/index.php/PythonPyFacebookTutorial
>
> > > page with error is here:
>
> > >http://kennethdavid.net/fbapp/fbsample/
>
> > > obviously, python.conf is setup correctly to call the correct settings
> > > file. facebook is a link (ln -s) to /pyfacebook/facebook, as per
> > > instructions. facebook IS in the site-packages directory, same as
> > > django
>
> > > settings as per instructions:
>
> > > MIDDLEWARE_CLASSES = (
> > >    'django.middleware.common.CommonMiddleware',
> > >    'django.contrib.sessions.middleware.SessionMiddleware',
> > >    'django.contrib.auth.middleware.AuthenticationMiddleware',
> > >    'facebook.djangofb.FacebookMiddleware',
> > > )
>
> > > svn for pyfacebook ishttp://pyfacebook.googlecode.com/svn/trunk/if
> > > anyone wants to check out the files that come in the folders...r
> > > you can check them out here
> > >http://github.com/sciyoshi/pyfacebook/tree/master
>
> > > running python setup.py install in pyfacebook ends up being an error
> > > looking for config/Makefile saying that it does not exist, infact... i
> > > do not have a config dir in python2.5
>
> > > any help would be appreciated
>
> > --
> > :wq
--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-27 Thread Thomas Guettler

Hi,

I had the same question some time ago and found no answer,
but maybe you try harder.

Sven Richter schrieb:
> Hi,
> 
> i have a new problem with my many-to-many field.
> 
> I have two models A and B.
> A(models.model):
>   b = models.ManyToManyField('app.B')
> 
> Now when i edit A in the admin interface everything is ok, i can select all
> B instances A belongs to.
> 
> What i need now is to be able to do the same thing from B's admin interface.
> When i edit B i want to select all instances of A B belongs to.
> 
> Is there a way to achieve that?

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + 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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django scalability with files

2009-08-27 Thread David De La Harpe Golden

Lewis Taylor wrote:

> Is there a better solution django offers, and why are
> blobs not supported. ideally i would have the image stored in DB and
> that way there would never be sync issues.
> 

FWIW (which given you're concerned about scaling mightn't be all that
much), it's fairly straightforward to stash small to middling sized*
binary stuff naively to a database rather than fs without even writing a
full custom file storage backend: just base64 encode it to text (using a
postgres bytea would be preferable, but BinaryField or whatever isn't in
Django yet, so my get_internal_type returns "TextField").

e.g. (...not efficient (watch it slurp the whole thing into memory),
some might say pretty dumb):
http://python.pastebin.com/d1c577e71

* postgres text and bytea go up to 1GB IIRC.




--~--~-~--~~~---~--~~
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: Generating slugs

2009-08-27 Thread Michael
On Thu, Aug 27, 2009 at 11:02 AM, RubenK  wrote:

>
> Thanks for the help! It worked! How would I go about hiding the field?
>

I think you would have to go all the way and put the form on the model
admin, which really isn't difficult. Follow this:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-adminand
just overwrite the slug field and make the widget a hiddeninput. Docs
here: http://docs.djangoproject.com/en/dev/ref/forms/fields/#widget

--~--~-~--~~~---~--~~
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: How to check which form was submitted?

2009-08-27 Thread Thomas Guettler



Maksymus007 schrieb:
> On Thu, Aug 27, 2009 at 1:22 PM, David Zhou wrote:
>> On Thu, Aug 27, 2009 at 7:09 AM, Maksymus007 wrote:
>>> I've got two different form on the same page, under the same URL.
>>> When I send one of them, the second one gets validated too.
>>> I set prefixes but no change.
>>>
>>> Is there any way to distinguish between two forms, choosing one that
>>> have been submited?
>> Prefixes are for using the same form multiple times on a page,
>> avoiding name collisions.
>>
>> Post the part of your view that handles your forms.
>>
>> -- dz
>>
> 
> Nothing special
> 
> if request.method == 'POST':
> form = RegisterForm(request.POST)
> if form.is_valid():
>  pass
> 
> And second one is handled by middleware, in similar way

You handle forms in a middleware? Why? Middleware code gets
executed for every http request ...

 Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + 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-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: pyfacebook, No module named facebook.djangofb...

2009-08-27 Thread garagefan

i've taken the project directly from github and attempted to run
python setup.py install and get the same error:

running install
error: invalid Python installation: unable to open /usr/lib/python2.5/
config/Makefile (No such file or directory)

i assume then, i need to install Makefile? I've attempted to try yum
install Makefile to no success


On Aug 26, 10:06 pm, Matias  wrote:
> Where did you get the files?
> if you go to the pyfacebook at 
> googlehttp://code.google.com/p/pyfacebook/theproject is now hosted in
> github.
> So if you downloaded from google it may be outdated.
> The installation is much more simpler than what the tutorial says, so i
> recommend to download fromhttp://github.com/sciyoshi/pyfacebook/tree/master
>
> HTH,
>
> Matias.
>
>
>
>
>
> On Wed, Aug 26, 2009 at 9:58 PM, garagefan  wrote:
>
> > steps followed here:
>
> >http://wiki.developers.facebook.com/index.php/PythonPyFacebookTutorial
>
> > page with error is here:
>
> >http://kennethdavid.net/fbapp/fbsample/
>
> > obviously, python.conf is setup correctly to call the correct settings
> > file. facebook is a link (ln -s) to /pyfacebook/facebook, as per
> > instructions. facebook IS in the site-packages directory, same as
> > django
>
> > settings as per instructions:
>
> > MIDDLEWARE_CLASSES = (
> >    'django.middleware.common.CommonMiddleware',
> >    'django.contrib.sessions.middleware.SessionMiddleware',
> >    'django.contrib.auth.middleware.AuthenticationMiddleware',
> >    'facebook.djangofb.FacebookMiddleware',
> > )
>
> > svn for pyfacebook ishttp://pyfacebook.googlecode.com/svn/trunk/if
> > anyone wants to check out the files that come in the folders...r
> > you can check them out here
> >http://github.com/sciyoshi/pyfacebook/tree/master
>
> > running python setup.py install in pyfacebook ends up being an error
> > looking for config/Makefile saying that it does not exist, infact... i
> > do not have a config dir in python2.5
>
> > any help would be appreciated
>
> --
> :wq
--~--~-~--~~~---~--~~
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: Generating slugs

2009-08-27 Thread RubenK

Thanks for the help! It worked! How would I go about hiding the field?

On Aug 27, 4:28 pm, Michael  wrote:
> On Thu, Aug 27, 2009 at 9:55 AM, RubenK  wrote:
>
> > I've setup my 'prepopulate_fields' so that it should automatically
> > enter a slug in the admin site, however when I click the 'add' link
> > it gives me the following error:
>
> > "Key 'slug' not found in Form"
>
> > I've triple checked all my models and database tables and everything
> > seems to be in order so I'm sort of stuck now!
> > These are my files:
>
> >http://dpaste.com/hold/86096/- models.py
> >http://dpaste.com/hold/86098/- admin.py
>
> > Could anyone please assist me?
>
> prepopulate_from is just a javascript feature of the admin, so the
> javascript needs a field to populate to. If you want to generate a
> slug on save and not worry about adding the field to the admin, you
> should subclass the save method on the model. I also think you could
> make the slug field hidden by adding the attribute in the field.
>
> Just add slug into the fields in the model admin and it will work for you,
>
> Michael
--~--~-~--~~~---~--~~
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 building data structure for Archive page

2009-08-27 Thread Gijs Nijholt

That's exactly what I needed. Thanks a lot.

--
Gijs


On Aug 27, 4:31 pm, David Zhou  wrote:
> On Thu, Aug 27, 2009 at 10:10 AM, gnijholt wrote:
> > Or is there a better way to generate a full archive page (per year,
> > per month)?
>
> You'll need to test this, but you should be able to do that with {%
> ifchanged %}:
>
> #view:
> posts = Posts.objects.order_by('-pub_date')
>
> #template
>
> {% for post in posts %}
>     {% ifchanged post.pub_date.year %}
>         {{post.pub_date.year}}
>     {% endifchanged %}
>     {% ifchanged post.pub_date.month %}
>         {{post.pub_date.month}}
>     {% endifchanged %}
>     {{ post.title }}
> {% endfor %}
>
> -- dz
--~--~-~--~~~---~--~~
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: Model Theory 101 - Video Sharing App

2009-08-27 Thread Bill Freeman
Look at django-oembed.  A CharField will serve for every (supported)
provider.

On Wed, Aug 26, 2009 at 8:17 PM, thornomad  wrote:

>
> Hi - need some suggestions.
>
> I am trying to put together an app that allows users to submit links
> to videos at popular video sharing sites (e.g., youtube, vimeo, etc)
> -- the links get submitted, data about the video (title, description,
> play count, etc) is collected from the respective site and populates
> model fields, and the video entry is queued for review.
>
> Caveats: I would like to keep the original "synced" data in its own
> field and the "approved" data (as edited) in separate field.  I
> imagine that the data first gets brought into the "edit" field, admin
> may make changes and save, but the "originating" data will remain
> separate and continue to be updated (synced).
>
> This means I need at least
>
> I am stuck, though, on the most appropriate/logical approach to this
> app.  Some approaches I've considered.
>
> [1] My first thought is to create base model "Video" (with the main
> fields) and then create child models like YoutubeVideo and VimeoVideo
> and BlipVideo ... when the user submits a url, would do a regex on it
> in the view, and send it through the appropriate child class.  I could
> then grab the base Video model in my views (not having to distinguish
> the type of video) and use a "leaf" technique (eg,
> http://www.djangosnippets.org/snippets/1031/) to run the child's
> "sync" or "update" command.  CONS: seems tacky and not easy to build
> on.  The leaf technique isn't working when I override the save()
> function in leaf models.
>
> [2] Perhaps create only a single model and then create separate
> classes/functions to handle the the syncing of data based on the
> URLField data ... so, perhaps when Video.update() is called, it would
> run the logic then to see what kind of url it has, and how to update
> it.  CONS: I thought maybe I could just create a ForeignKey field to a
> non-model group of classes with common functions (update, sync,
> etc) ... but I am not sure how, or if, I can do that.
>
> [3] Outsourcing.
>
> Hope this makes sense and folks have some feedback about how they
> might approach this.  I would like this to be easily expandable -- for
> example, add YouTube and Vimeo support to start, and easily add other
> sites without having to "hack" it.
>
> I know this is a huge question, but am interested in your "Design
> Approach" thoughts ...
>
> Thanks,
> Damon
> >
>

--~--~-~--~~~---~--~~
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: Generating slugs

2009-08-27 Thread Daniel Roseman

On Aug 27, 2:55 pm, RubenK  wrote:
> I've setup my 'prepopulate_fields' so that it should automatically
> enter a slug in the admin site, however when I click the 'add' link
> it gives me the following error:
>
> "Key 'slug' not found in Form"
>
> I've triple checked all my models and database tables and everything
> seems to be in order so I'm sort of stuck now!
> These are my files:
>
> http://dpaste.com/hold/86096/- models.pyhttp://dpaste.com/hold/86098/- 
> admin.py
>
> Could anyone please assist me?

You're explicitly restricting the fields you display on the form, via
the fieldsets attribute - but slug isn't one of the fields you
display. Prepopulating fields is done via javascript on the form
itself, so the fields have to be present.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem building data structure for Archive page

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 10:10 AM, gnijholt wrote:
> Or is there a better way to generate a full archive page (per year,
> per month)?

You'll need to test this, but you should be able to do that with {%
ifchanged %}:

#view:
posts = Posts.objects.order_by('-pub_date')

#template

{% for post in posts %}
{% ifchanged post.pub_date.year %}
{{post.pub_date.year}}
{% endifchanged %}
{% ifchanged post.pub_date.month %}
{{post.pub_date.month}}
{% endifchanged %}
{{ post.title }}
{% endfor %}

-- dz

--~--~-~--~~~---~--~~
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: Generating slugs

2009-08-27 Thread Michael
On Thu, Aug 27, 2009 at 9:55 AM, RubenK  wrote:

>
> I've setup my 'prepopulate_fields' so that it should automatically
> enter a slug in the admin site, however when I click the 'add' link
> it gives me the following error:
>
> "Key 'slug' not found in Form"
>
> I've triple checked all my models and database tables and everything
> seems to be in order so I'm sort of stuck now!
> These are my files:
>
> http://dpaste.com/hold/86096/ - models.py
> http://dpaste.com/hold/86098/ - admin.py
>
> Could anyone please assist me?
>

prepopulate_from is just a javascript feature of the admin, so the
javascript needs a field to populate to. If you want to generate a
slug on save and not worry about adding the field to the admin, you
should subclass the save method on the model. I also think you could
make the slug field hidden by adding the attribute in the field.

Just add slug into the fields in the model admin and it will work for you,

Michael

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



Generating slugs

2009-08-27 Thread RubenK

I've setup my 'prepopulate_fields' so that it should automatically
enter a slug in the admin site, however when I click the 'add' link
it gives me the following error:

"Key 'slug' not found in Form"

I've triple checked all my models and database tables and everything
seems to be in order so I'm sort of stuck now!
These are my files:

http://dpaste.com/hold/86096/ - models.py
http://dpaste.com/hold/86098/ - admin.py

Could anyone please assist me?

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



Problem building data structure for Archive page

2009-08-27 Thread gnijholt

Hello Django-users,

Actually it's more of a basic Python problem than a Django problem.
I'll try to be brief:

In the view, I'm looping through my posts as such:
---
def archive(request):
years = Post.objects.dates('pub_date', 'year')
for year in years:
print year.year
months = Post.objects.filter(pub_date__year=year.year).dates
('pub_date', 'month')
for month in months:
print month.month

return render_to_ etcetera
---

I don't know how I can dynamically create a list/array/dict/tuple
through which I can loop in the template like this:
---
{% for y in years %}
{{ y.year }}
{% for m in y.months %}
{{ m.month }}
{% for post in m.post.all %}
{{ post.title }}
{% if not forloop.last %},{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
---

Or is there a better way to generate a full archive page (per year,
per month)?

Thanks,
Gijs
--~--~-~--~~~---~--~~
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: template tag response None. but why?

2009-08-27 Thread Bill Freeman
I don't know what else is wrong but:

On Wed, Aug 26, 2009 at 8:15 PM, MIL  wrote:

>bits = token.contents.split()


should probably be:

bits = token.split_contents()

and render must return a string whether or not there is an
ObjectDoesNotExist exception, so, maybe:

   def render(self, context):
   try:
   context[self.varname] =
Blog.objects.get(user=self.user)
   except ObjectDoesNotExist:
   context[self.varname] = None   # Or whatever you want
to get if the user doesn't exist
   # Or, if the variable was previously set to the no
such user value, use "pass".
   return ""


Another issue, if I understand another thread correctly, is that the
variable assignment will go away when you return (the dictionary stack will
be popped).  Or this might only apply from one file to another (extends,
include).  I'm not sure of that.  The tag that I wrote has a matching end
tag, so the stuff between gets rendered before my render returns, and the
variable that I set is available there.

Bill

--~--~-~--~~~---~--~~
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: get an object's model name

2009-08-27 Thread MIL

Thanks, both of you :o)

I tried using it directly in my template like
{{object.__class__.__name__}}
But that didnt work.

So I did it by adding this to my models:

def get_model_name(self):
return self.__class__.__name__


And it works

Thanks again :o)

On 27 Aug., 13:29, David Zhou  wrote:
> On Thu, Aug 27, 2009 at 7:08 AM, Léon Dignòn wrote:
>
>  from django.contrib.auth.models import User
>  u = User.objects.get(id=1)
>  u
> > 
>  print u
> > leon
>  type(u)
> > 
>
> Alternatively:
>
> >>> u.__class__.__name__
>
> 'User'
>
> -- dz
--~--~-~--~~~---~--~~
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: How to check which form was submitted?

2009-08-27 Thread Michael
On Thu, Aug 27, 2009 at 7:58 AM, Maksymus007  wrote:

>
> On Thu, Aug 27, 2009 at 1:41 PM, David Zhou wrote:
> >
> > On Thu, Aug 27, 2009 at 7:33 AM, Maksymus007
> wrote:
> >>
> >> On Thu, Aug 27, 2009 at 1:22 PM, David Zhou wrote:
> >>> Post the part of your view that handles your forms.
> >>
> >> Nothing special
> >>
> >>if request.method == 'POST':
> >>form = RegisterForm(request.POST)
> >>if form.is_valid():
> >> pass
> >>
> >> And second one is handled by middleware, in similar way
> >
> > Put in a hidden inputs in your fields to distinguish the two.  For
> example:
> >
> > if request.method == 'POST' and '_hiddenname' in request.POST:
> > ...
> >
> > -- dz
> >
>
> Thats what I did :)
> Sad there is no special option to add to form or was_post(), but thanks
> anyway;
>

Add a name to your submit button:


then you can just use if request.POST.has_key('_submit_name')

That works, you already have to add the submit button, so no real extra
work.

--~--~-~--~~~---~--~~
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: How to check which form was submitted?

2009-08-27 Thread Maksymus007

On Thu, Aug 27, 2009 at 1:41 PM, David Zhou wrote:
>
> On Thu, Aug 27, 2009 at 7:33 AM, Maksymus007 wrote:
>>
>> On Thu, Aug 27, 2009 at 1:22 PM, David Zhou wrote:
>>> Post the part of your view that handles your forms.
>>
>> Nothing special
>>
>>    if request.method == 'POST':
>>        form = RegisterForm(request.POST)
>>        if form.is_valid():
>>             pass
>>
>> And second one is handled by middleware, in similar way
>
> Put in a hidden inputs in your fields to distinguish the two.  For example:
>
> if request.method == 'POST' and '_hiddenname' in request.POST:
>     ...
>
> -- dz
>

Thats what I did :)
Sad there is no special option to add to form or was_post(), but thanks anyway;

--~--~-~--~~~---~--~~
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: redirect in django

2009-08-27 Thread ankit rai
thanks i got the solution

On Thu, Aug 27, 2009 at 4:28 PM, Matthias Kestenholz <
matthias.kestenh...@gmail.com> wrote:

>
> On Thu, Aug 27, 2009 at 12:38 PM, ankit rai wrote:
> > Nobody knows the answer to this question i think so
> >
>
> Did you really expect an answer within an hour of sending the email to
> the list? A little bit of patience would really be in order here.
>
> If you need answers _fast_, IRC would be a better medium. There's no
> guarentee you'll get help either way, though.
>
>
> > On Thu, Aug 27, 2009 at 2:59 PM, ankit  wrote:
> >>
> >> I am new to django.I having to app in my admin.Know I want to know
> >> that how can i redirect user to one app listpage if clicks save on
> >> second app.say from app2 to app1
> >>
>
> You can do this by overriding the ModelAdmin response_change or
> response_add method (or both, depending on your needs) you are
> registering your model with.
>
> Something like this:
>
> class MyModelAdmin(admin.ModelAdmin):
>def response_change(self, ...):
>...
>
> admin.site.register(MyModel, MyModelAdmin)
>
>
> I've never seen the need to do such a thing up to now, but this code
> snippet should be enough to get you started.
>
>
>
> Matthias
>
>
>
> --
> FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/
>
> >
>

--~--~-~--~~~---~--~~
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: How to check which form was submitted?

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 7:33 AM, Maksymus007 wrote:
>
> On Thu, Aug 27, 2009 at 1:22 PM, David Zhou wrote:
>> Post the part of your view that handles your forms.
>
> Nothing special
>
>    if request.method == 'POST':
>        form = RegisterForm(request.POST)
>        if form.is_valid():
>             pass
>
> And second one is handled by middleware, in similar way

Put in a hidden inputs in your fields to distinguish the two.  For example:

if request.method == 'POST' and '_hiddenname' in request.POST:
 ...

-- dz

--~--~-~--~~~---~--~~
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: How to check which form was submitted?

2009-08-27 Thread Maksymus007

On Thu, Aug 27, 2009 at 1:22 PM, David Zhou wrote:
>
> On Thu, Aug 27, 2009 at 7:09 AM, Maksymus007 wrote:
>>
>> I've got two different form on the same page, under the same URL.
>> When I send one of them, the second one gets validated too.
>> I set prefixes but no change.
>>
>> Is there any way to distinguish between two forms, choosing one that
>> have been submited?
>
> Prefixes are for using the same form multiple times on a page,
> avoiding name collisions.
>
> Post the part of your view that handles your forms.
>
> -- dz
>

Nothing special

if request.method == 'POST':
form = RegisterForm(request.POST)
if form.is_valid():
 pass

And second one is handled by middleware, in similar way

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



Re: redirect in django

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 6:58 AM, Matthias
Kestenholz wrote:
>
>> On Thu, Aug 27, 2009 at 2:59 PM, ankit  wrote:
>>>
>>> I am new to django.I having to app in my admin.Know I want to know
>>> that how can i redirect user to one app listpage if clicks save on
>>> second app.say from app2 to app1
>>>
>
> You can do this by overriding the ModelAdmin response_change or
> response_add method (or both, depending on your needs) you are
> registering your model with.

The easiest way I can think of is to capture the response, and check
that.  For example:

class MyModelAdmin(admin.ModelAdmin):
   def response_change(self, *args, **kwargs):
  response = super(MyModelAdmin, self).response_change(*args, **kwargs)
  if 'Location' in response and response['Location'] == "../":
 #generate your own HttpResponseRedirect
  else:
 return response

Really though, jumping around the admin like that is potentially
really confusing.

-- dz

--~--~-~--~~~---~--~~
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: get an object's model name

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 7:08 AM, Léon Dignòn wrote:
>
 from django.contrib.auth.models import User
 u = User.objects.get(id=1)
 u
> 
 print u
> leon
 type(u)
> 

Alternatively:

>>> u.__class__.__name__
'User'

-- dz

--~--~-~--~~~---~--~~
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: How to check which form was submitted?

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 7:09 AM, Maksymus007 wrote:
>
> I've got two different form on the same page, under the same URL.
> When I send one of them, the second one gets validated too.
> I set prefixes but no change.
>
> Is there any way to distinguish between two forms, choosing one that
> have been submited?

Prefixes are for using the same form multiple times on a page,
avoiding name collisions.

Post the part of your view that handles your forms.

-- dz

--~--~-~--~~~---~--~~
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: get an object's model name

2009-08-27 Thread Léon Dignòn

Hello,

simply use type()

>>> from django.contrib.auth.models import User
>>> u = User.objects.get(id=1)
>>> u

>>> print u
leon
>>> type(u)


-ld


On Aug 27, 11:59 am, MIL  wrote:
> Hello :o)
>
> I would like to know how to get the model name of an object.
>
> sort of like object.get_model_name or something like that
>
> Is there a way to that.
>
> I tried altering my model something like this, but it doesnt work:
>
>         def get_model_name(self):
>                 return '%s'%(class)
>
> Thanks :o)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to check which form was submitted?

2009-08-27 Thread Maksymus007

I've got two different form on the same page, under the same URL.
When I send one of them, the second one gets validated too.
I set prefixes but no change.

Is there any way to distinguish between two forms, choosing one that
have been submited?

--~--~-~--~~~---~--~~
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: redirect in django

2009-08-27 Thread Matthias Kestenholz

On Thu, Aug 27, 2009 at 12:38 PM, ankit rai wrote:
> Nobody knows the answer to this question i think so
>

Did you really expect an answer within an hour of sending the email to
the list? A little bit of patience would really be in order here.

If you need answers _fast_, IRC would be a better medium. There's no
guarentee you'll get help either way, though.


> On Thu, Aug 27, 2009 at 2:59 PM, ankit  wrote:
>>
>> I am new to django.I having to app in my admin.Know I want to know
>> that how can i redirect user to one app listpage if clicks save on
>> second app.say from app2 to app1
>>

You can do this by overriding the ModelAdmin response_change or
response_add method (or both, depending on your needs) you are
registering your model with.

Something like this:

class MyModelAdmin(admin.ModelAdmin):
def response_change(self, ...):
...

admin.site.register(MyModel, MyModelAdmin)


I've never seen the need to do such a thing up to now, but this code
snippet should be enough to get you started.



Matthias



-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

--~--~-~--~~~---~--~~
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: redirect in django

2009-08-27 Thread ankit rai
Nobody knows the answer to this question i think so

On Thu, Aug 27, 2009 at 2:59 PM, ankit  wrote:

>
> Hello,
>
>
> I am new to django.I having to app in my admin.Know I want to know
> that how can i redirect user to one app listpage if clicks save on
> second app.say from app2 to app1
>
>
> >
>

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



Re: Django scalability with files

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 6:13 AM, Lewis
Taylor wrote:
>
> I have an imagefield that i want to create a thumbnail for on approval
> of the image. The problem is (setup is 2 django instances, load
> balancer and DB) if the image is stored on one machine it's not the
> cleanest solution to have to get the image from the other server and

We ran into a similar issue in a past project, and if you have
scalability concerns, setting up a proper queue system is pretty much
the only practical method we thought of.  For every image uploaded,
add a new task to the queue detailing where the image is located. Then
have a separate image processing service running somewhere, ping the
queue for new tasks, and sync the processed image to your static
server(s).

If you really want to store uploaded images directly to the database
in blobs, look into writing a custom storage backend:

http://docs.djangoproject.com/en/dev/howto/custom-file-storage/

That will lessen syncing issues without needing a task queue, but will
make your db server work harder.

-- dz

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



Model Forms

2009-08-27 Thread Sid

I have 2 models say A and B, B has A has a foreign key reference to A.
There is a model form created for mode B called as BForm. Now If i
create instance of BForm and display it in a page, foreign key field
appears as a drop down choice box in the form. Instead of this if i
set instance of B to BForm before displaying it, it shows all
validation errors also.

I want to do something like this - pass unbound BForm to display, when
i get response, create form from request.POST and instance of B.
However if i do this and then check if form is valid, it shows me
error. Can someone please guide me on how I can correct this? I don't
want to display the multiple choice dropdown in form display, but can
i display it like hidden input variable or something?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django scalability with files

2009-08-27 Thread Lewis Taylor

Question:

I have an imagefield that i want to create a thumbnail for on approval
of the image. The problem is (setup is 2 django instances, load
balancer and DB) if the image is stored on one machine it's not the
cleanest solution to have to get the image from the other server and
process it. Is there a better solution django offers, and why are
blobs not supported. ideally i would have the image stored in DB and
that way there would never be sync issues.

Thanks

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



get an object's model name

2009-08-27 Thread MIL

Hello :o)

I would like to know how to get the model name of an object.

sort of like object.get_model_name or something like that

Is there a way to that.

I tried altering my model something like this, but it doesnt work:

def get_model_name(self):
return '%s'%(class)


Thanks :o)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



redirect in django

2009-08-27 Thread ankit

Hello,


I am new to django.I having to app in my admin.Know I want to know
that how can i redirect user to one app listpage if clicks save on
second app.say from app2 to app1


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



Many-to-many column admin interface

2009-08-27 Thread Sven Richter
Hi,

i have a new problem with my many-to-many field.

I have two models A and B.
A(models.model):
  b = models.ManyToManyField('app.B')

Now when i edit A in the admin interface everything is ok, i can select all
B instances A belongs to.

What i need now is to be able to do the same thing from B's admin interface.
When i edit B i want to select all instances of A B belongs to.

Is there a way to achieve that?


Greetings
Sven

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



Filter

2009-08-27 Thread Güngör Basa
Hi.I have a problem with my filter. I want to filter date and time but
filter is not working.I am sending my models.py

from django.db import models
from datetime import datetime
from datetime import date
from datetime import time
class Randevu(models.Model):
def __unicode__(self):
Randevu.objects.all()
fil=Randevu.objects.filter(date=self.date)
fil2=fil.filter(time=self.time)

if fil2!=None:
print"Error"

return u'%s %s' % (self.name, self.surname)



choice = (
('08:00', ('08')),
('09:00', ('09')),
('10:00', ('10')),
('11:00', ('11')),
('13:00', ('13')),
('14:00', ('14')),
('15:00', ('15')),
('16:00', ('16')),
)

name = models.CharField(max_length=30,verbose_name="Name")
surname = models.CharField(max_length=30,verbose_name="Surname")
date = models.DateField(verbose_name="Date")
time = models.TimeField(choices = choice,verbose_name="Time")
subject = models.TextField(verbose_name="Subject")
email = models.EmailField(verbose_name="Electronic Address")


#Daybreakers
# Create your models here.

--~--~-~--~~~---~--~~
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: Forms for views

2009-08-27 Thread gentlestone

Thanks, it looks like a good very light example, how to build such a
framework. What is good I am thinking in a good way, just no adequate
framework exists yet.

On 26. Aug, 18:14 h., Daniel Roseman  wrote:
> On Aug 26, 4:14 pm, gentlestone  wrote:
>
>
>
> > I'm looking for a support for viewing models in templates.
>
> > Forms is a nice support but it is made for editing objects, not for
> > viewing objects. I found some attemps on the internet, like using
> > forms with ReadOnlyWidgets, but I thing it is not the way.
>
> > Forms are great, because a template-designer can use the general
> > as_table() and don't have to know too much about the model. And also
> > the dependency between the model and templates are isolated via Forms.
> > And also it is good when a template-designer can iterate through form
> > fields or directly use fileds like form.theField attribute.
>
> > Unfortunately there is no such support for viewing model instances in
> > templates. Yes of course, there is a possibility use the "dot" like
> > instance.theAttribute in the template, but this means strong template
> > dependency on models and also the template designer can't use _meta
> > informations like verbose names and so. Yes, I can make for my models
> > some methods like constructTemplateDictionaryForXyView, feed the
> > dictionary with model attributes and models opts, but what I am
> > looking for are support classes like Form and ModelForm for
> > constructing dictionares for HTML rendering from models metamodels.
>
> > I am ready to write such support for myself, but it is a long task and
> > propably i am thinking in wrong way, because nobody has written it yet.
>
> You might want to look at django.contrib.databrowse - it sounds like
> it does what you want. 
> See:http://docs.djangoproject.com/en/dev/ref/contrib/databrowse/
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: print PDF on windows

2009-08-27 Thread mettwoch

Apache is running under a system account. A quick test of running
Apache under my user account enabled printing indeed. I'll follow your
suggestion and create a dedicated user with restricted rights to run
Apache under.

Thanks so much for your help

Marc

On Aug 27, 2:42 am, Sam Lai  wrote:
> 2009/8/27 mettwoch :
>
>
>
> > I'm now using Foxit Reader. Thanks for the tip. The following works
> > perfectly in the Django shell and prints the document in
> > attachment.file.path to the specified network printer:
>
> > p = Popen (['C:\\Program Files\\Foxit Software\\Foxit Reader\\Foxit
> > Reader.exe',
> >        '/t',
> >        attachment.file.path,
> >        'SM03\\HPCOMPTOIR0'])
>
> > The same code works silently in a Apache / mod_wsgi context but does
> > not produce any result on the printer. Do You have any ideas?
>
> Could be a permissions issue - what user is apache running under?
>
> Also, you might want to try enabling the 'allow service to interact
> with desktop' option to see if that works. If it does, you might have
> to look at another solution or somehow impersonating another user to
> do the printing as there are security risks associated with this
> option.
>
>
>
> > Marc
>
> > On Aug 26, 1:46 am, Sam Lai  wrote:
> >> Use python to call a PDF reader via the command line -
>
> >>http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm
>
> >>http://foxit.vo.llnwd.net/o28/pub/foxit/manual/enu/FoxitReader30_Manu...
> >> (see the Command Line section)
>
> >> Depending on the complexity of your PDFs, I'd recommend using Foxit
> >> instead; Adobe Reader on windows isn't the most stable especially when
> >> it comes to open many PDFs - you might have to manually manage
> >> instances to make sure it doesn't eat up all your memory. Foxit Reader
> >> however doesn't render all PDFs perfectly, or at least the same way
> >> that Adobe Reader does. YMMV though.
>
> >> 2009/8/26 mettwoch :
>
> >> > How do the Django people handle printing directly on Windows? I
> >> > remembered abouthttp://timgolden.me.uk/python/win32_how_do_i/print.html,
> >> > but unfortunately his method for PDFs only print on the default
> >> > printer. I need the server to produce the PDF, save it (works already)
> >> > and send it to a specific shared printer on the network. The printer
> >> > should be determined from a table that holds 'host' - 'printer' pairs
> >> > e.g. ('PC01', '\\PC01\PR01'). The host ('PC01') determined from the
> >> > http request allows to choose the right printer ('\\PC01\PR01') from
> >> > that table.
>
> >> > Printing should be executed directly when the user has submitted the
> >> > request. Any solution that pops up the document locally in a PDFReader
> >> > and where the user has to hit the print button is not viable.
>
> >> > Kindly Yours
> >> > Marc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django + Godaddy

2009-08-27 Thread Nanopino

I just got off the phone with godaddy for the last time. I've canceled
my hosting with them as they are reluctant to install python-sqlite2.
Something as simple as database libraries that can be yum installed
and they wouldn't budge. They really wanted me to switch to VPS with
them. It took me 2 weeks to get django up and running and when i tried
to build something with it is when i found out i couldn't hook it up
to a database because pysqlite or the mysql libraries aren't
installed. Tried to install pysqlite from source in my local directory
just like I did with django, using --prefix but pysqlite needs gcc to
compile some portions of the code and gcc is unavailable in their
jailed ssh. ARG, so angry!

Justin's correct save yourself the headache, unfortunately my head's
already throbbing.

On Aug 26, 10:45 pm, Justin Lilly  wrote:
> On 26 Aug 2009 03:58:58-0700, Nanopino wrote:
>
>
>
>
>
> > i've actually have semi success in getting django to work on godaddy.
> > It displays the "Congratulations on your first Django-powered page."
> > You will have to be signed up for the linux shared hosting Deluxe or
> > higher plan in order for fastcgi to be enabled. I can show you how to
> > get it up and running but the only problem is that once it is up and
> > running you can't do anything with it because the pysqlite2 and python
> > bindings for mysql aren't installed making django useless. I'm trying
> > to see if godaddy tech support will "yum install python-sqlite2" but i
> > really doubt it. They keep trying to upsell me to a VPS. I've been at
> > them for 2 weeks now... :-/
>
> > On Aug 25, 10:02 am, Andrés Martín - martyn
> >  wrote:
> > > Hi django Users.
>
> > > I need to know if somebody has used Django on godaddy Host service ?
>
> > > If yes, is easy to configure ? what recomended to me in that case ?
>
> > > Thank you!
>
> > > Regards
> > > --
> > > Andrés Martín Ochoa;
>
> Save yourself a headache and ditch godaddy. They're fantastic for domain
> purchasing, but leave you wanting when it comes to hosting. Especially
> for something like Django. I might suggesthttp://webfaction.com/as a
> reasonable alternative. Trust me in that any amount you may have prepaid
> for godaddy hosting will be worth nothing when compared to the amount of
> frustration you will face trying to get something setup on a host that
> isn't accomodating.
>
>  -justin
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
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: unicode problem?

2009-08-27 Thread andreas schmid

take a look at that discussion:
http://groups.google.com/group/django-users/browse_thread/thread/1de89cdee99b1086

lerner wrote:
> def output(request):
> response = HttpResponse(mimetype='text/csv')
> response['Content-Disposition'] = 'attachment; filename=%s' %
> 'address.csv'
> t = loader.get_template('csv.html')
> #objs = Address.objects.get_list()
> objs = Address.objects.all()
> d = []
> for o in objs:
> d.append((o.name, o.gender, o.telphone, o.mobile, o.room))
> c = Context({
> 'data': d,
> })
> response.write(t.render(c))
> return response
> -
> I define a funtion to write some chinese into a csv type file,
> but i I get this file and open it  in windows, it will appear messy
> code.
> I know this file is encoded in utf-8 default,  but I find the
> response.write module
> have no encoding method, because django just has utf-8 encoding.
> how to write it encoding "Gb2312" or "GBK" or some others chinese
> encoding.
>
> >
>
>   


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