Re: Working with outside data sources

2010-02-18 Thread Rishabh Manocha
On Fri, Feb 19, 2010 at 11:23 AM, Michael Lissner <
mliss...@michaeljaylissner.com> wrote:

>  Thanks for the reply.
>
> My teammate that writing the scrapers is a java guy, and he's planning to
> use that rather than django/python. I haven't looked at the kinds of
> databases that django creates, but do you think that will cause any
> problems?
>
> If not, I think we'll proceed with plan B, below.
>

I don't think it should be a problem, as long as you guys can come to a
consensus about how your tables will be defined and named (I made the table
naming mistake early on - django expects certain table names names for
models you have defined in your models.py files - of-course you can override
that by setting db_table in the Meta class for said model) . Also, if he
plans on serializing any data, make sure he does so in something like JSON
or XML so that you can have access to it via Python.

Also, have you taken a look at the inspectdb management command - it might
go a long way in helping you get your models.py files setup - see
http://docs.djangoproject.com/en/dev/ref/django-admin/#inspectdb


>
> Michael lissnermliss...@michaeljaylissner.com
> 909-576-4123
>
>
> Rishabh Manocha wrote on 02/18/2010 07:16 PM:
>
>
>
> On Fri, Feb 19, 2010 at 10:04 AM, mjlissner <mjliss...@gmail.com> wrote:
>
>> I'm using django for a final project in my masters program at UC
>> Berkeley, and I'm trying to sort out exactly how the database works. I
>> would spend a bunch of time figuring this out myself, but I am working
>> in a team, and my teammates need this info asap.
>>
>> My teammates are making scrapers that pull information from
>> various .gov websites, and then dump that information into a mysql
>> database.
>>
>> It's my job to use django to make queries on that database, and to
>> build a web front end to it.
>>
>> We've developed a data model for the database, but my question is
>> what's the best way to interface between the data they're dumping in,
>> and django? I have two thoughts about this...both of which are
>> probably wrong:
>> 1. They can build a separate database, and I can pull from it using
>> custom sql queries within my django code; or
>> 2. I can use django models to flesh out the database, and then they
>> can dump into the tables that were created by the syncdb command.
>>
>> Can people opine as to what the best way to do this might be, or what
>> kinds of problems we can anticipate if we do the above?
>>
>> --
>> 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<django-users%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
> I've done something similar with my project. I setup up my database tabels
> such that they work with both my scraping code as well as my django code. To
> insert data from my scraping code, I used sqlalchemy (though, you can just
> as easily use django's ORM for this - this method would probably be better
> in the longer run 'cause you can define your models in one place and just
> include them in both your scraping code as well as your django site) and
> then just accessed that data from my django site accessing the same database
> (no replication, parsing etc.). This method has worked out quiet well for
> me, so far.
>
> --
>
> Best,
>
> R
>  --
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 

Best,

R

-- 
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: Working with outside data sources

2010-02-18 Thread Rishabh Manocha
On Fri, Feb 19, 2010 at 10:04 AM, mjlissner  wrote:

> I'm using django for a final project in my masters program at UC
> Berkeley, and I'm trying to sort out exactly how the database works. I
> would spend a bunch of time figuring this out myself, but I am working
> in a team, and my teammates need this info asap.
>
> My teammates are making scrapers that pull information from
> various .gov websites, and then dump that information into a mysql
> database.
>
> It's my job to use django to make queries on that database, and to
> build a web front end to it.
>
> We've developed a data model for the database, but my question is
> what's the best way to interface between the data they're dumping in,
> and django? I have two thoughts about this...both of which are
> probably wrong:
> 1. They can build a separate database, and I can pull from it using
> custom sql queries within my django code; or
> 2. I can use django models to flesh out the database, and then they
> can dump into the tables that were created by the syncdb command.
>
> Can people opine as to what the best way to do this might be, or what
> kinds of problems we can anticipate if we do the above?
>
> --
> 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.
>
>
I've done something similar with my project. I setup up my database tabels
such that they work with both my scraping code as well as my django code. To
insert data from my scraping code, I used sqlalchemy (though, you can just
as easily use django's ORM for this - this method would probably be better
in the longer run 'cause you can define your models in one place and just
include them in both your scraping code as well as your django site) and
then just accessed that data from my django site accessing the same database
(no replication, parsing etc.). This method has worked out quiet well for
me, so far.

-- 

Best,

R

-- 
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-debug-toolbar and 404's

2010-02-12 Thread Rishabh Manocha
On Fri, Feb 12, 2010 at 10:41 PM, Rob Hudson <r...@cogit8.org> wrote:

> Can you test it by disabling the debug toolbar middleware?  I've
> duplicated your exact settings as much as I can and it's working for
> me.  If disabling the middleware makes the admin appear, then it would
> seem something in the toolbar is causing the problem.
>
> And you are right... those settings you refer to are optional.
>
> Thanks,
> Rob
>
> On Feb 11, 10:57 pm, Rishabh Manocha <rmano...@gmail.com> wrote:
> > Mike,
> >
> > Thanks for replying. Reading through the django-debug-toolbar docs, those
> > settings are all optional, so I just figured I don't need to set them for
> > the default debug-toolbar functionality. I'll give it a shot though, just
> to
> > make sure.
> >
> > Anybody else have any ideas??
> >
> > --
> >
> > Best,
> >
> > R
>
> --
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
Rob,

Disabling the debug toolbar middleware does make the admin appear.

I have now fixed my problem though. It seems it had something to do with
creating a symlink in my site-packages folder to the debug_toolbar folder in
my git checkout. Running 'setup.py install' fixed my issues - everything
shows up fine using the same settings.

Thanks for the help.

-- 

Best,

R

-- 
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-debug-toolbar and 404's

2010-02-11 Thread Rishabh Manocha
On Thu, Feb 11, 2010 at 11:56 AM, Mike Dewhirst <mi...@dewhirst.com.au>wrote:

> Rishab
>
> Maybe you haven't included any toolbar panels?
>
> Here is an example ...
>
> if TOOLBAR:
>DEBUG_TOOLBAR_CONFIG = {
>'INTERCEPT_REDIRECTS': TOOLBAR_REDIRECTS,
>'SHOW_TOOLBAR_CALLBACK': None,
>}
>
>DEBUG_TOOLBAR_PANELS = (
>#'debug_toolbar.panels.version.VersionDebugPanel',
>#'debug_toolbar.panels.timer.TimerDebugPanel',
>'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
>'debug_toolbar.panels.headers.HeaderDebugPanel',
>'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
>'debug_toolbar.panels.template.TemplateDebugPanel',
>'debug_toolbar.panels.sql.SQLDebugPanel',
>'debug_toolbar.panels.logger.LoggingPanel',
>)
>
>MIDDLEWARE_CLASSES += (
>'debug_toolbar.middleware.DebugToolbarMiddleware',
>)
>
>INSTALLED_APPS += (
>'debug_toolbar',
>)
>
> Mike
>
>
> On 11/02/2010 2:07pm, Rishabh Manocha wrote:
>
>> Hey Guys,
>>
>> I know I must be doing something stupid here, but for the life of me, I
>> can't seem to be able to get django-debug-toolbar to work - I keep
>> getting a 404 error whenever I visit http://localhost:8000/admin/ (see
>> [1]). I've followed the Installation instructions at
>> http://github.com/robhudson/django-debug-toolbar. Here are the relevant
>> sections of my settings.py:
>>
>> ...
>> MIDDLEWARE_CLASSES = (
>> 'django.middleware.common.CommonMiddleware',
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'django.middleware.csrf.CsrfViewMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> 'debug_toolbar.middleware.DebugToolbarMiddleware',
>> )
>>
>> ROOT_URLCONF = 'testproject.urls'
>> ...
>> INSTALLED_APPS = (
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.sites',
>> 'django.contrib.messages',
>> 'django.contrib.admin',
>> 'testapp',
>> 'debug_toolbar',
>> )
>>
>> INTERNAL_IPS = ('127.0.0.1', )
>>
>> and my testproject.urls.py <http://testproject.urls.py>:
>>
>>
>> from django.conf.urls.defaults import *
>>
>> # Uncomment the next two lines to enable the admin:
>> from django.contrib import admin
>> admin.autodiscover()
>>
>> urlpatterns = patterns('',
>> # Example:
>> # (r'^testproject/', include('testproject.foo.urls')),
>>
>> # Uncomment the admin/doc line below and add
>> 'django.contrib.admindocs'
>> # to INSTALLED_APPS to enable admin documentation:
>> # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>> # Uncomment the next line to enable the admin:
>> (r'^admin/', include(admin.site.urls)),
>> )
>>
>> This is running against 'Django version 1.2 beta 1', python 2.5.and the
>> latest checkout of django-debug-toolbar from github (if it matters, I've
>> symlinked the debug_toolbar folder into my site-packages).
>>
>> I'd really appreciate pointers as to what I'm doing wrong here.
>>
>> --
>>
>> Best,
>>
>> R
>>
>> [1] - http://i.imgur.com/5GkiQ.png
>>
>> --
>> 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<django-users%2bunsubscr...@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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
Mike,

Thanks for replying. Reading through the django-debug-toolbar docs, those
settings are all optional, so I just figured I don't need to set them for
the default debug-toolbar functionality. I'll give it a shot though, just to
make sure.

Anybody else have any ideas??

-- 

Best,

R

-- 
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-debug-toolbar and 404's

2010-02-10 Thread Rishabh Manocha
Hey Guys,

I know I must be doing something stupid here, but for the life of me, I
can't seem to be able to get django-debug-toolbar to work - I keep getting a
404 error whenever I visit http://localhost:8000/admin/ (see [1]). I've
followed the Installation instructions at
http://github.com/robhudson/django-debug-toolbar. Here are the relevant
sections of my settings.py:

...
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

ROOT_URLCONF = 'testproject.urls'
...
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'testapp',
'debug_toolbar',
)

INTERNAL_IPS = ('127.0.0.1', )

and my testproject.urls.py:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^testproject/', include('testproject.foo.urls')),

# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)

This is running against 'Django version 1.2 beta 1', python 2.5.and the
latest checkout of django-debug-toolbar from github (if it matters, I've
symlinked the debug_toolbar folder into my site-packages).

I'd really appreciate pointers as to what I'm doing wrong here.

-- 

Best,

R

[1] - http://i.imgur.com/5GkiQ.png

-- 
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: ModelAdmin.get_readonly_fields with ForeignKey's

2010-02-06 Thread Rishabh Manocha
On Sat, Feb 6, 2010 at 10:35 PM, Karen Tracey <kmtra...@gmail.com> wrote:

> On Sat, Feb 6, 2010 at 6:16 AM, Rishabh Manocha <rmano...@gmail.com>wrote:
>
>> [snip]
>> While this works just fine, the one problem I'm having is that instead of
>> showing the title of the book (i.e. - calling Book.__unicode__), the admin
>> simply shows the primary key value of the Book.
>>
>>
> Sounds like:
>
> http://code.djangoproject.com/ticket/12654
>
> Which was fixed in r12366 just a few days ago. If you upgrade to the beta
> release the problem should be fixed.
>

Yep - that did the trick. Thanks.


>
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 

Best,

R

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



ModelAdmin.get_readonly_fields with ForeignKey's

2010-02-06 Thread Rishabh Manocha
Hi Guys,

I was trying to use the newly introduced ModelAdmin.get_readonly_fields
method to mark a OneToOne relation as read only - something along the lines
of:

models.py:
class Book(models.Model):
title = models.CharField(max_length = 50)
...

def __unicode__(self):
return '%s' % self.title

class BookInventory(models.Model):
...
book = models.OneToOneField(Book)

def __unicode__(self):
return '%s' % self.book

admin.py:
class BookInventoryAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj = None):
if obj is not None:
return ['book']
else:
return []

While this works just fine, the one problem I'm having is that instead of
showing the title of the book (i.e. - calling Book.__unicode__), the admin
simply shows the primary key value of the Book.

This issue was bug #342 in Django Trac - [1] - and was fixed in
changeset 11965 - [2].

Does anyone have any ideas about how to get the title of the book to show up
in the admin page for BookInventory, instead of it's primary key value?

Thanks in advance,

Rishabh

[1] - http://code.djangoproject.com/ticket/342
[2] - http://code.djangoproject.com/changeset/11965

-- 
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: Default Selection in ChoiceField

2010-02-01 Thread Rishabh Manocha
On Tue, Feb 2, 2010 at 8:56 AM, Sumanth  wrote:
> Hi all,
>
> I  have a basic form
>
> class AssumptionsForm(forms.Form):
>       writedownoper  = forms.ChoiceField( required=True, choices =
> [('1','1'),('2',2='),('3','3')])
>
> Now in my view after I create the form I want to set value 2 as
> default. How can I do it? Is there set default API that I can use.

There are two ways you can do this. If the initial choice for
'writedownoper' will always be '2', you can use pass an 'initial'
argument when declaring the field [1]:

writedownoper = forms.ChoiceField( required=True, choices =
[('1','1'),('2','2'),('3','3')], initial = '2')

However, if that value needs to be dynamic, you can do so when
instantiating the form in your view [2]:

writedownoper = forms.ChoiceField( required=True, choices =
[('1','1'),('2','2'),('3','3')])

views.py:

form = AssumptionsForm(initial = {'writedownopen' : '2'})




>
> Thanks in advance
> Sumanth
>
> --
> 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.
>
>



-- 

Best,

R

[1] - http://docs.djangoproject.com/en/dev/ref/forms/fields/#initial
[2] - http://docs.djangoproject.com/en/dev/ref/forms/api/#dynamic-initial-values

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



'Reverse' (??) InlineModelAdmin objects

2010-01-29 Thread Rishabh Manocha
Hey guys,
I've been trying to get InlineModelAdmin objects setup in my admin
app, but am unable to figure out how to do so correctly. Using the
same example as the one listed in the docs [1]:

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

class Book(models.Model):
   author = models.ForeignKey(Author)
   title = models.CharField(max_length=100)

What I would like to do is have the Author creation form show up in
with the Book creation form - so basically, my admin.py code would
look something like:

class AuthorInline(admin.TabularInline):
model = Author

class BookAdmin(admin.ModelAdmin):
...
inlines = [AuthorInline, ]

However, when I try this, I get an error:

Exception Value:  has no ForeignKey to
.

So, I was wondering if anyone knows how I could get an Author creation
form show up inline with on the 'Add Book' page.

Thanks.

--

Best,

R

[1] 
- http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

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



Re: newbie question on 'clean_' functions

2009-12-09 Thread Rishabh Manocha
On Thu, Dec 10, 2009 at 12:12 PM, Rishabh Manocha <rmano...@gmail.com> wrote:
> On Thu, Dec 10, 2009 at 11:21 AM, Kenneth McDonald
> <kenneth.m.mcdon...@sbcglobal.net> wrote:
>>
>>> And the code to create and validate the form is...?  That might help
>>> in figuring out what is wrong.
>>>
>> Sure. It's just:
>>
>>
>>
>> def buysell(request):
>>     form = BuySellForm()
>>     return render_to_response('buysellform.html', {'form': form})
>
> Here is the problem. As of now, `form` is an unbound form (see docs
> [1]). You need to do something like:
>
> form = BuySellForm(request.POST)
>
> This will trigger all the validation functions,

Correction here. You'll need to call `form.is_valid()` to trigger validation.

>  including clean_shares. You should rewrite your `buysell` view to be 
> something
> along the lines of:
>
> def buysell(request):
>    if request.method == "POST":
>        form = BuySellForm(request.POST)
>        if form.is_valid():
>            #do something...
>        else:
>            #return an error
>     else:
>         form = BuySellForm()
>         return render_to_response('buysellform.html', {'form': form})
>
> Also, unless you haven't posted all the code from BuySellForm's
> definition, clean_shares will throw an error because there is no field
> called `data` defined in the form.
>
> [1] - 
> http://docs.djangoproject.com/en/dev/ref/forms/api/#bound-and-unbound-forms
>
>>
>>
>>
>> in file 'buysell.py', and is referenced as http://.../buysell, as per
>> the urls.py file:
>>
>>
>>
>> from django.conf.urls.defaults import *
>> from mysite import buysell
>>
>> # Uncomment the next two lines to enable the admin:
>> # from django.contrib import admin
>> # admin.autodiscover()
>>
>> urlpatterns = patterns('',
>>     (r'^buysell/$', buysell.buysell),
>>     (r'^boughtsold/$', buysell.boughtsold),
>>
>>
>> and for good measure the HTML is:
>>
>>
>>
>> 
>> 
>> 
>>        Symbol:
>>        Shares:
>>        Price:
>>        
>>        
>> 
>> 
>> 
>>
>>
>> Thanks!
>> Ken
>>
>>
>> --
>>
>> 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.
>>
>>
>>
>
>
>
> --
>
> Best,
>
> R
>



-- 

Best,

R

--

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




Re: newbie question on 'clean_' functions

2009-12-09 Thread Rishabh Manocha
On Thu, Dec 10, 2009 at 11:21 AM, Kenneth McDonald
 wrote:
>
>> And the code to create and validate the form is...?  That might help
>> in figuring out what is wrong.
>>
> Sure. It's just:
>
>
>
> def buysell(request):
>     form = BuySellForm()
>     return render_to_response('buysellform.html', {'form': form})

Here is the problem. As of now, `form` is an unbound form (see docs
[1]). You need to do something like:

form = BuySellForm(request.POST)

This will trigger all the validation functions, including
clean_shares. You should rewrite your `buysell` view to be something
along the lines of:

def buysell(request):
if request.method == "POST":
form = BuySellForm(request.POST)
if form.is_valid():
#do something...
else:
#return an error
 else:
 form = BuySellForm()
         return render_to_response('buysellform.html', {'form': form})

Also, unless you haven't posted all the code from BuySellForm's
definition, clean_shares will throw an error because there is no field
called `data` defined in the form.

[1] - 
http://docs.djangoproject.com/en/dev/ref/forms/api/#bound-and-unbound-forms

>
>
>
> in file 'buysell.py', and is referenced as http://.../buysell, as per
> the urls.py file:
>
>
>
> from django.conf.urls.defaults import *
> from mysite import buysell
>
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
>
> urlpatterns = patterns('',
>     (r'^buysell/$', buysell.buysell),
>     (r'^boughtsold/$', buysell.boughtsold),
>
>
> and for good measure the HTML is:
>
>
>
> 
> 
> 
>        Symbol:
>        Shares:
>        Price:
>        
>        
> 
> 
> 
>
>
> Thanks!
> Ken
>
>
> --
>
> 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.
>
>
>



-- 

Best,

R

--

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 form to UPDATE a record?

2009-12-03 Thread Rishabh Manocha
On Thu, Dec 3, 2009 at 4:17 PM, Todd Blanchard  wrote:
> All the tutorials on forms discuss creating a new record.
>
> I've got a record in the database, I want to fetch it, plunk its values into 
> a form, let the user edit it and save it.
>
> I don't see how to conveniently put the model's values into the form.  It 
> seems the form wants a dictionary of values, so how to convert a model object 
> to a dict?
>
> -Todd Blanchard
>
> --
>
> 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.
>
>
>

Assuming you'd use a ModelForm[1] to update the records, all you need
to do is something like the following:

my_record = Record.objects.get(id = 1)
my_form = MyRecordModelForm(instance = my_record)

You will then have a form with the 'values' on the fields pre-set.
Users can then edit the form to their hearts content, submit it and
you can the process the form[2] as you would normally do with a
ModelForm.


[1] - http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
[2] - 
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

-- 

Best,

R

--

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 lookup tables which has ForeignKey relationship

2009-11-17 Thread Rishabh Manocha
On Tue, Nov 17, 2009 at 7:40 PM, guptha  wrote:

> hi group,
>
> class Parent(models.Model):
>user = models.ForeignKey(User,unique=True)
>school=models.ForeignKey(School)
>def __unicode__(self):
>   return self.user.username
>
> class Student(models.Model):
>user = models.ForeignKey(User,unique=True)
>school=models.ForeignKey(School)
>standard=models.ForeignKey(Standard)
>
>
> class StudentParent(models.Model):
>student=models.ForeignKey(Student)
>parent = models.ForeignKey(Parent)
>
>
> In template,with help of student object I tried to retrieve parent
> name like
>
> {{studentobj.studentparent__parent}}
>
> but this could not fetch me the result .please correct me.
>
> A simpler way could be to place the parent foreignkey in student
> table ,but for learning point of view i need to know why do I couldn't
> hook parent name with the above
> Thanks
> ganesh
>
> --
>
> 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=.
>
>
>
Ganesh,

Have a look at
http://docs.djangoproject.com/en/dev/ref/models/relations/#ref-models-relations.
You'll basically have to do something like this in your template:

{% for studentparent in studentobj.studentparent_set.all %}
{{ studentparent.parent }}
{% endfor %}

This makes sense because (presumably) each student would have two
StudentParent objects associated with it.

-- 

Best,

R

--

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




Re: need foreign key help quick

2009-11-08 Thread Rishabh Manocha
On Sun, Nov 8, 2009 at 9:41 PM, Bobby Roberts  wrote:

>
> anyone out there that can help me?
>
> On Nov 7, 8:39 pm, Bobby Roberts  wrote:
> > Hi.  I have never used foreign keys I need to start and I need
> > help.  I'm running python2.5 and django1.1.   I have an installation
> > of Satchmo running fine; however, I need to modify the Product table.
> > I need to tie fields from the Product module to fields in another
> > module outside of satchmo.
> >
> > here's the setup:
> >
> > I have Satchmo products  installed here:
> >
> > /django_apps/live/satchmo/products
> >
> > I have another module installed here
> >
> > /django_apps/live/elmago
> >
> > I'm trying to add a dropbox field in products that is related to the
> > PK field in one of my elmago classes as follows:
> >
> > BinderCountry = models.ForeignKey('elmago.CountryOfOrigin',
> > verbose_name=_('Binder Country'), blank=False, null=False, help_text=_
> > ("Please choose the country of origin for the binder."))
> >
> > The elmago.CountryOfOrigin class looks like this:
> >
> > class CountryOfOrigin (models.Model):
> > Id = models.AutoField(primary_key=True)
> > CountryName = models.CharField (max_length=250, blank=True,
> > db_index=True)
> > DateAdded = models.DateTimeField (auto_now_add=True,
> > blank=False, db_index=True)
> >
> > What am i doing wrong?  After restarting apache... i get the following
> > error:
> >
> > AttributeError at /admin/product/product/add/
> >
> > 'str' object has no attribute '_default_manager'
> >
> > Please help quickly!
> >
>


You'll need to give us a more complete Traceback, but perhaps define a
__unicode__ function in CountryOfOrigin...

-- 

Best,

R

--~--~-~--~~~---~--~~
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: Display a value from another table

2009-11-01 Thread Rishabh Manocha
On Mon, Nov 2, 2009 at 1:43 PM, Denis Bahati  wrote:

> Hi All,
> Am developing an application where by it links two tables author and book,
> the id of author is a foreign key to book table. How can i display the name
> of the author when am displaying the book list.
>
> >
>
I'm not sure how you the id of an author can be a ForeignKey to a Book. Can
you paste your models so that we can get a clearer picture. Assuming your
Book model looks something like the below:

class Book(models.Model):
...
author = models.ForeignKey(Author)

You would do:

>>> my_author = Author.objects.create('James Joyce')
>>> my_book = Book.objects.create(..., author = my_author)
>>> my_book.author


-- 

Best,

R

--~--~-~--~~~---~--~~
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: syncdb for INSTALLED_APPS throws errors

2009-10-29 Thread Rishabh Manocha
On Thu, Oct 29, 2009 at 2:47 PM, sridharpandu wrote:

>
> Hi,
>
> I ran the syncdb command to create the tables for INSTALLED_APPS. I
> get the errors as shown in the output below. Can someone tell me
> what's wrong. I am using a laptop that runs Django as well as the
> MySQL database .
>
> srid...@sridhar:~/finch/chennaicard$ python manage.py syncdb
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "/var/lib/python-support/python2.6/django/core/management/
> __init__.py", line 340, in execute_manager
>utility.execute()
>  File "/var/lib/python-support/python2.6/django/core/management/
> __init__.py", line 295, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/var/lib/python-support/python2.6/django/core/management/
> base.py", line 192, in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "/var/lib/python-support/python2.6/django/core/management/
> base.py", line 218, in execute
>self.validate()
>  File "/var/lib/python-support/python2.6/django/core/management/
> base.py", line 246, in validate
>num_errors = get_validation_errors(s, app)
>  File "/var/lib/python-support/python2.6/django/core/management/
> validation.py", line 22, in get_validation_errors
>from django.db import models, connection
>  File "/var/lib/python-support/python2.6/django/db/__init__.py", line
> 16, in 
>backend = __import__('%s%s.base' % (_import_path,
> settings.DATABASE_ENGINE), {}, {}, [''])
>  File "/var/lib/python-support/python2.6/django/db/backends/mysql/
> base.py", line 13, in 
>raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: No module named MySQLdb
>
>
> Best regards
>
> Sridhar Pandurangiah
>
> >
>
The problem is listed out at the end of the Traceback - "Error loading
MySQLdb module: No module named MySQLdb". You need to install the python
MySQL driver. You can get it at http://mysql-python.sourceforge.net/

-- 

Best,

R

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

2009-10-25 Thread Rishabh Manocha
On Mon, Oct 26, 2009 at 9:37 AM, Jeffrey Taggarty wrote:

>
> Hello,
>
> I have a web site which shows different content based on a location
> the visitor chooses. e.g: User enters in 55812 as the zip. I know what
> city and area lat/long. that is and give them their content pertinent
> to that area. My question is how can I store this in a cookie so that
> when they return they are not required to always enter their zip code?
>
> I see it as follows:
>
> 1) Set persistent cookie based on their area.
> 2) When they return read cookie, grab zipcode.
> 3) Return content based on the zip code in their cookie.
>
> I can't seem to find any solid information on setting a cookie. Any
> help is greatly appreciated.
>
> Thanks,
>
> Jeff
>
> >
>

Check out
http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponse.set_cookie
.
-- 

Best,

R

--~--~-~--~~~---~--~~
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: extending django-registration ( MixIn ModelForm and Form)

2009-06-01 Thread Rishabh Manocha
On Tue, Jun 2, 2009 at 9:10 AM, Marco Bazzani wrote:

>
> On Mon, Jun 1, 2009 at 23:19, V  wrote:
> >
> > On Jun 1, 6:50 pm, Marco Bazzani  wrote:
> >> I'm trying to extends django-registration app with some more fields in
> >> the moment of registration
> >> those fields are saved in a subclass of User
> >>
> >> for reference here are the form classes:
> http://bitbucket.org/ubernostrum/django-registration/src/tip/registra...
> >>
> >> ok here is my code
> >>
> >> #models.py
> >> class Customer(User):
> >> company =
>  models.CharField(_('Company'),max_length=200,blank=True)
> >> address =models.CharField(_('Address'),max_length=255)
> >> state_province =
> models.CharField(_('State/Province'),max_length=200)
> >> country =
> >> models.CharField(_('Country'),max_length=3,choices=COUNTRY_CHOICES)
> >> phone_number =   models.CharField(_('Phone Number'), max_length=20)
> >> fax_number = models.CharField(_('Fax Number'),
> max_length=20,blank=True)
> >> other_contacts = models.TextField(_('Other Contacts'),blank=True)
> >>
> >> objects = UserManager()
> >>
> >> #forms.py
> >> from registration.forms import RegistrationForm
> >> from django import forms
> >> from customers.models import Customer
> >> from classmaker import classmaker
> >>
> >> class ProfileForm(forms.ModelForm):
> >> class Meta:
> >> model = Customer
> >> fields = (
> >>   'state_province',
> >>   'country',
> >>   'phone_number',
> >>   'fax_number',
> >>   'other_contacts',
> >>)
> >>
> >> class RegistrationFormProfile(RegistrationForm, ProfileForm):
> >> __metaclass__ = classmaker()
> >>
> >> the classmaker was necessary to solve the metaclass conflict problem
> >> as described herehttp://www.djangosnippets.org/snippets/703/
> >>
> >> anyway everythings seams to be ok a part from the fact that only
> >> ProfileForm is displayed in the template
> >> even if I switch the order of the inheritance.
> >>
> >> I've also modified some django registration to use my Model instead of
> >> User ( but shouldn't be the origin of the problem)
> >>
> >> any clue ?
> >>
> >> cheers
> >> Marco
> >
> > I don't have any clues on your problem, except that I can't really
> > understand why do you extend the User model as you do, instead of
> > adding a profile model that has a OneToOneField to User
> >
> > this way you don't have to edit django-registration, and you can have
> > a fairly simple save method in your profile where you first create the
> > User, and then attach a profile to it. I would go this way.
> >
> > V
> > >
> >
>
> how do you collect additional user data during registration with your
> method ?
>
> >
>
You can define your own form class (which can inherit from one of the
existing form classes defined in the App) and define custom actions in it's
save method. See [1] for an example of a form I am using. You can then pass
the "register" view your own form using the "form_class" parameter as
explained in [2].

-- 

Best,

R

[1] - http://dpaste.com/50347/
[2] -
http://bitbucket.org/ubernostrum/django-registration/src/tip/docs/views.txt

--~--~-~--~~~---~--~~
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: Ajax and https

2009-04-30 Thread Rishabh Manocha
On Thu, Apr 30, 2009 at 4:10 PM, ruben.django wrote:

>
> Hi,
>
> i've got a template with a jquey ajax call. Before, the web service
> (Apache) always redirects to a http direction and the ajax call worked
> perfectly, but from now, it redirects to a secure https direction and
> the ajax call has stopped working. The browser shows me the next
> message:
>
> Security error: the content in https://mysite/foo/34 can't load data
> from http://mysite/foo/34.
>
> Can anybody help me?
>
> Thanks.
>
> >
>
I don't think this has anything to do with Django. Your problem is that
you're making an Ajax call from a https connection to a http connection (
https://mysite/foo/34 to http://mysite/foo/34). Fix this and your problems
should go away.

-- 

Best,

R

--~--~-~--~~~---~--~~
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: Design Question

2009-02-05 Thread Rishabh Manocha
On Fri, Feb 6, 2009 at 5:48 AM, mguthrie  wrote:

>
> Anybody?
>
> On Feb 3, 9:41 am, mguthrie  wrote:
> > I'm looking at creating an application that would use Django Auth for
> > managing users but once logged in the user will "belong" only to a
> > specific organization and can only work with data associated with that
> > organization.  I've looked at using the Django Sites contrib but I
> > would like something that is dynamically assigned and not specified in
> > the settings file like sites.
> >
> > What would be the best route to adding this functionality?  From what
> > I've looked at so far it might be best to create a Manager that would
> > handle the model end of things and filter based off of the
> > organization id.
> >
> > Any ideas would be welcome.  Also, is there a better way to do this
> > that wouldn't require having a separate DB for each organization?  I
> > would like each account to be assigned to an organization unless it's
> > a superuser account which would be able to oversee the entire
> > application.
> >
> > Thanks in advance.
> >
>
This is interesting. In the few minutes I spent thinking about it, I
couldn't come up with a very compelling solution, but maybe user profiles[1]
are what you are looking for.

-- 

Best,

R

[1] -
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-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
-~--~~~~--~~--~--~---



Re: Admin in Django

2008-11-25 Thread Rishabh Manocha
On Wed, Nov 26, 2008 at 10:00 AM, Praveen <[EMAIL PROTECTED]>wrote:

>
> Hi All, i am very new bie of Django, i have started work on before 3
> days.
> I am following DJango book. I am playing with 6 chapter "Using the
> admin interface"
> In my urls.py file i set the url for admin
>
> from django.conf.urls.defaults import *
> urlpatterns = patterns('',
>   # Example:
>   # (r'^blog/', include('blog.foo.urls')),
>   (r"^admin/", include("django.contrib.admin.urls")),
>   (r"^pro/book/$", "blog.blogapp.views.bookentry"),
> )
>
> but when i am running in browser http://127.0.0.1:8000/admin its
> giving me error
> File "/usr/lib/python2.4/site-packages/django/core/servers/
> basehttp.py", line 277, in run
>   self.result = application(self.environ, self.start_response)
>
>  File "/usr/lib/python2.4/site-packages/django/core/servers/
> basehttp.py", line 634, in __call__
>   return self.application(environ, start_response)
>
>  File "/usr/lib/python2.4/site-packages/django/core/handlers/
> wsgi.py", line 239, in __call__
>   response = self.get_response(request)
>
>  File "/usr/lib/python2.4/site-packages/django/core/handlers/
> base.py", line 67, in get_response
>   response = middleware_method(request)
>
>  File "/usr/lib/python2.4/site-packages/django/middleware/common.py",
> line 72, in process_request
>   urlresolvers.resolve("%s/" % request.path_info)
>
>  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
> line 244, in resolve
>   return get_resolver(urlconf).resolve(path)
>
>  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
> line 180, in resolve
>   sub_match = pattern.resolve(new_path)
>
>  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
> line 178, in resolve
>   for pattern in self.urlconf_module.urlpatterns:
>
>  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
> line 197, in _get_urlconf_module
>   self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])
>
> ImportError: No module named urls
>
> and when i checked manually in that directory there were no urls.py
> file
> in usr/lib/python2.4/site-packages/django/contrib/admin/
>
> how may i resolve that problem. i followed each and every steps of
> Django book
>
> Thanks
> >
> The Django Book is outdated (at-least the admin part, I have not looked at
others). There was a major refactor of the admin code before Django 1.0 was
released (this was after the book was written). To get the latest
documentation on how to use the admin site, see
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-admin.

-- 

Best,

R

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



Re: How to show only 2 decimal places in my view?

2008-11-25 Thread Rishabh Manocha
On Wed, Nov 26, 2008 at 9:59 AM, Greg <[EMAIL PROTECTED]> wrote:

>
> Hello,
> I have the following code:
>
> ///
>
> b = Choice.objects.filter(choice=a.collection.id)
>for cb in b:
>discount_price = cb.price.name * Decimal(str(.75))
>cb.price.name = discount_price
>assert False, cb.price.name
>
> ///
>
> Basically I'm just decreasing my price by 25%.  However, when I do
> this my new value contains 4 decimal places.  37.5000 or 135..
> What do I need to do to only show 2 decimal places.  I know how to do
> it in my template.  But I need to be able to do this in my view.
>
> Thanks
>
>
> >
>
This is more of a Python question, than a Django question. I do the
following to print out only 2 decimal places from a float:
>>> x = 35.
>>> print "%.2f" % x
35.00

You can use float() instead of print to get a float type back, but that is
probably not the most efficient way to do things.

-- 

Best,

R

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



Re: Django-Registration and NewForms Error

2008-10-08 Thread Rishabh Manocha
On Wed, Oct 8, 2008 at 5:07 PM, Chris <[EMAIL PROTECTED]> wrote:

>
> I installed django-registration via easy_install, and followed the
> directions for setting it up in my app, but when I go to /register, I
> get the error:
>
>  File "/usr/lib/python2.5/site-packages/django_registration-0.5-
> py2.5.egg/registration/views.py", line 12, in 
>
>  File "/usr/lib/python2.5/site-packages/django_registration-0.5-
> py2.5.egg/registration/forms.py", line 7, in 
>
> ImportError: cannot import name newforms
>
> Does anyone know what would cause this error? The line it's
> complaining about is "from django import forms", which if I try from
> the command line imports just fine.
>
> This is the urls.py I'm using:
>
> from django.conf.urls.defaults import *
> from django.views.generic.simple import direct_to_template
> from registration.views import activate
> from registration.views import register
>
> urlpatterns = patterns('',
>(r'^account/activate/(?P\w+)/$',
>activate,
>{'template': 'templates/account_activate.html'}
>),
>(r'^account/login/$',
>'django.contrib.auth.views.login',
>{'template_name': 'templates/account_login.html'},
>),
>(r'^account/logout/$',
>'django.contrib.auth.views.logout',
>{'template_name': 'templates/account_logout.html'},
>),
>(r'^account/password/change/$',
>'django.contrib.auth.views.password_change',
>{'template_name': 'templates/account_password_change.html'}
>),
>(r'^account/password/change/done/$',
>'django.contrib.auth.views.password_change_done',
>{'template_name': 'templates/
> account_password_change_done.html'}
>),
>(r'^account/password/reset/$',
>'django.contrib.auth.views.password_reset',
>{'template_name': 'templates/account_password_reset.html'}
>),
>(r'^account/password/reset/done/$',
>'django.contrib.auth.views.password_reset_done',
>{'template_name': 'templates/
> account_password_reset_done.html'}
>),
>(r'^account/profile/$',
>direct_to_template,
>{'template': 'templates/account_profile.html'}
>),
>(r'^account/register/$',
>register,
>{'template': 'templates/account_register.html'},
>   ),
>   (r'^account/register/complete/$',
>direct_to_template,
>{'template': 'templates/account_registration_complete.html'},
>   ),
> )
>
> >
>
The problem most probably is that the version of django-registration you
have installed via easy_install is not the latest version available - and
hence is probably doing an import like "from django import newforms as
forms" (or something like that) in forms.py. "newforms" was renamed to
"forms" at some point before the 1.0 release and so python is unable to
import "newforms". The latest version(in trunk) seems to have fixed this[1].

Uninstall the version you have installed via easy_install and grab the
latest tar from the official site -
http://code.google.com/p/django-registration/.

-- 

Best,

R

[1] -
http://code.google.com/p/django-registration/source/browse/trunk/registration/forms.py#7

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



Re: dictionary from object

2008-08-26 Thread Rishabh Manocha
On Wed, Aug 27, 2008 at 10:55 AM, Vance Dubberly <[EMAIL PROTECTED]>wrote:

>
> So I want to do something I'd think would be extremely common and simple.
>
> user = User.objects.get(pk=data['id'])
>
> I want a dictionary of the model attributes/values from user.
>
> user_dict = { 'first_name' : 'foo', ..
>
> Am I asking to much or reading to little?
>
>
> --
> To pretend, I actually do the thing: I have therefore only pretended to
> pretend.
>  - Jacques Derrida
>
> >
>
I think what you're looking for is
http://www.djangoproject.com/documentation/db-api/#values-fields.

-- 

Best,

R

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



Re: forms.ChoiceField()

2008-07-25 Thread Rishabh Manocha
In your form field definition, set empty_labal = None

This was somewhere in the docs, but am unable to find it in the 2 mins I
spent on the search.

Best,

R

On Fri, Jul 25, 2008 at 10:14 AM, JF Simon <[EMAIL PROTECTED]> wrote:

>
> hi !
>
> How to remove the first --- in a  from a
> forms.ChoiceField() ?
> Required is set to True and I set default to 1, but there's still this
> f***in item !!!
> Any idea ?
> >
>

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



Re: forms.ChoiceField()

2008-07-25 Thread Rishabh Manocha
That's "empty_label = None". Sorry for the typo

Best,

R

On Fri, Jul 25, 2008 at 3:07 PM, Rishabh Manocha <[EMAIL PROTECTED]> wrote:

> In your form field definition, set empty_labal = None
>
> This was somewhere in the docs, but am unable to find it in the 2 mins I
> spent on the search.
>
> Best,
>
> R
>
>
> On Fri, Jul 25, 2008 at 10:14 AM, JF Simon <[EMAIL PROTECTED]> wrote:
>
>>
>> hi !
>>
>> How to remove the first --- in a  from a
>> forms.ChoiceField() ?
>> Required is set to True and I set default to 1, but there's still this
>> f***in item !!!
>> Any idea ?
>> >>
>>
>

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



Re: i18n: How to the language on per-user basis

2008-07-18 Thread Rishabh Manocha
You could use "user profiles" which will allow you to store various user
specific preferences. See [1] to learn how to do this.

I am currently using profiles to identify users by the department they work
in and the last time they edited a form (this is different from last login).

Best,

R

[1] -
http://www.djangoproject.com/documentation/authentication/#storing-additional-information-about-users

On Thu, Jul 17, 2008 at 6:32 PM, Torsten Bronger <
[EMAIL PROTECTED]> wrote:

>
> Hallöchen!
>
> In my Web application, every user has to log in.  In an additional
> user database table, the prefered language of each user is given.
> But how do I activate it?
>
> I use django.contrib.auth.views.login for the login.  However, as
> far as I can see, I have to copy-and-paste this function and add a
> line to it which stors the language in the current session.  Am I
> right?
>
> Tschö,
> Torsten.
>
> --
> Torsten Bronger, aquisgrana, europa vetus
>   Jabber ID: [EMAIL PROTECTED]
>
>
> >
>

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



Re: Add filters to the Users List/Page in the admin app

2008-06-25 Thread Rishabh Manocha
Anybody got any ideas here?? I could really use some help with this problem.

Thanks,

Rishabh

On Tue, Jun 24, 2008 at 9:49 AM, Rishabh Manocha <[EMAIL PROTECTED]> wrote:

> Ok, so I need a bit more direction here. I've got newforms-admin setup and
> working as far as displaying the various FK relationships a user has on
> his/her page. However, I'm still not able to figure out how to display FK
> relationships in the list_filter page. Here is my setup (the UserTechSkill
> from above has not changed, except for the admin stuff):
>
> Note: I haven't copied and pasted here - don't have my work laptop with me
> right now - so there might be some typos, but the logic is the same.
>
> in models.py:
>
> from django.contrib.auth.admin import UserAdmin
>
> ...
>
> class MyUserAdmin(UserAdmin):
> inlines = [UserTechSkillsAdmin,...]
> list_filter = ('is_staff',)
>
> admin.site.unregister(User)
> admin.site.register(User,MyUserAdmin)
>
> Now what I would like to be able to do is be able to add a TechSkillsList
> filter to the list_filter tuple. I figure that since a user is related to
> the UserTechSkill class and a UserTechSkill class is related to the
> TechSkillsList class, there must be some way I can get a list of
> TechSkillsList in the User class (a list of TechSkillsList which includes
> skills chosen by all users, but not the ones that haven't been selected by
> anyone yet). Can someone point me in the right direction here??
>
> Best,
>
> Rishabh
>
> On Thu, Jun 12, 2008 at 7:00 PM, Rajesh Dhawan <[EMAIL PROTECTED]>
> wrote:
>
>>
>> Hi Rishabh,
>>
>> >
>> > Now, the django admin app provides (by default) a page where user
>> details
>> > are listed. I do not want to change that list. However, I would like to
>> add
>> > filters on that page (remove the superuser status and staff status
>> filters
>> > and add others like TechSkillsList etc.). I was wondering if this were
>> > possible, and if so, how. I am using a (somewhat out of date) trunk
>> checkout
>> > of the djago code. If this is not possible in the current admin, is it
>> > possible using newforms-admin??
>>
>> Yes, newsforms-admin will let you create an admin area for the
>> auth.User model using your own admin options (list filters, search,
>> etc.) It's worth switching to that branch and trying this out.
>>
>> http://code.djangoproject.com/wiki/NewformsAdminBranch
>> http://code.djangoproject.com/wiki/NewformsHOWTO
>>
>> -Rajesh D
>>
>>
>> >>
>>
>

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



Re: dynamic value of a ModelChoiceField

2008-06-23 Thread Rishabh Manocha
You're probably looking for
http://www.djangoproject.com/documentation/newforms/#initial

Best,

Rishabh

On Tue, Jun 24, 2008 at 9:04 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

>
> I probably need to be more specific..
>
> here's my model:
>
> class Recipe(modesl.Model):
>
>   recipetitle = models.CharField()
>   cooking_method = models.ForeignKey(CookingMethod)
>
> class CookingMethod(models.Model):
>
>   cookmethodname = models.CharField()
>
>
> forms.py
>
>  class RecipeForm(forms.Form):
>
>title = forms.CharField()
>cookmethod =
> forms.ModelChoiceField(queryset=CookingMethod.objects.all())
>
> views.py
>
>   def edit_recipe(request,recipe_id):
>
> if request.method == "POST":
>yadda yadda
>
>else:
>   recipe = Recipe.objects.get(id=recipe_id)
>   recipeform = RecipeForm()
>   recipeform.fields['title'] = recipe.recipetitle
>   recipeform.fields['cooking_method'] = recipe.cooking_method
>
>
> When a new recipe is created, all the different cooking methods
> correctly show up in the recipe form as a  html element
> (corresponding to the ModelChoice field in the form).
>
> However, when an existing recipe is being edited, the recipe title is
> retrieved correctly, but the corresponding recipe cooking method is
> not displayed in the  html element. instead, the one
> corresponding to the empty label (--) shows up.
>
> Any ideas ? I'm losing my mind over this.
>
> thanks in advance.
>
>
> On Jun 22, 11:15 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > In a form, I have a field defined asModelChoiceField
> >
> > class myForm(forms.Form)
> >   myfield = forms.ModelChoiceField(MyClass.objects.all())
> >  myfield2 = forms.CharField()
> >
> > My problem is that I cant seem to dynamically set the value that the
> > user selected for this field. When ever, user edits the record, this
> > select list always gets set to no value instead of the value that the
> > user had originally selected.
> >
> > the input text field has no problems in showing the saved data
> > correctly.
> >
> > am I missing something ?
> >
> > thnx,
> > -p
> >
>

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



Re: Add filters to the Users List/Page in the admin app

2008-06-23 Thread Rishabh Manocha
Ok, so I need a bit more direction here. I've got newforms-admin setup and
working as far as displaying the various FK relationships a user has on
his/her page. However, I'm still not able to figure out how to display FK
relationships in the list_filter page. Here is my setup (the UserTechSkill
from above has not changed, except for the admin stuff):

Note: I haven't copied and pasted here - don't have my work laptop with me
right now - so there might be some typos, but the logic is the same.

in models.py:

from django.contrib.auth.admin import UserAdmin

...

class MyUserAdmin(UserAdmin):
inlines = [UserTechSkillsAdmin,...]
list_filter = ('is_staff',)

admin.site.unregister(User)
admin.site.register(User,MyUserAdmin)

Now what I would like to be able to do is be able to add a TechSkillsList
filter to the list_filter tuple. I figure that since a user is related to
the UserTechSkill class and a UserTechSkill class is related to the
TechSkillsList class, there must be some way I can get a list of
TechSkillsList in the User class (a list of TechSkillsList which includes
skills chosen by all users, but not the ones that haven't been selected by
anyone yet). Can someone point me in the right direction here??

Best,

Rishabh

On Thu, Jun 12, 2008 at 7:00 PM, Rajesh Dhawan <[EMAIL PROTECTED]>
wrote:

>
> Hi Rishabh,
>
> >
> > Now, the django admin app provides (by default) a page where user details
> > are listed. I do not want to change that list. However, I would like to
> add
> > filters on that page (remove the superuser status and staff status
> filters
> > and add others like TechSkillsList etc.). I was wondering if this were
> > possible, and if so, how. I am using a (somewhat out of date) trunk
> checkout
> > of the djago code. If this is not possible in the current admin, is it
> > possible using newforms-admin??
>
> Yes, newsforms-admin will let you create an admin area for the
> auth.User model using your own admin options (list filters, search,
> etc.) It's worth switching to that branch and trying this out.
>
> http://code.djangoproject.com/wiki/NewformsAdminBranch
> http://code.djangoproject.com/wiki/NewformsHOWTO
>
> -Rajesh D
>
>
> >
>

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



Re: dynamically filling ChoiceField

2008-06-22 Thread Rishabh Manocha
Some more details would be good, but off the top of my head, something like
this might work:

def my_view(request):
   form = MyForm()
   form.fields['mychoice'].choices = ((1,'ABC'),(2,'XYZ'))

I havent' been able to test this out, so make sure you do before you using
it.

You can of-course do any amount of pre-processing before you apply that
tuple.

Best,

Rishabh

On Mon, Jun 23, 2008 at 8:25 AM, Calvin Dodge <[EMAIL PROTECTED]> wrote:

>
> I've been tearing out what little hair I have left trying to figure
> this out.
>
> How do I dynamically fill a ChoiceField by filtering on a value known
> to the URLView? Every "dynamic fill" example I've found assumes the
> form knows it all - I haven't seen anything which shows me how to pass
> that value from the view to the form.
>
> Help? Please?
>
> Calvin Dodge
> >
>

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



Re: Model - Only allow One

2008-06-16 Thread Rishabh Manocha
Why not just override the save method for the model and delete any instances
of it before calling super.save(). I'm not a 100% sure on this, but I do
think the admin interface calls the model save method whenever you edit
something from there.

So, something like this:

class About(models.Model):
  text = models.TextField()
  pub_date = models.DateTimeField(auto_now=True)

  def save(self):
 About.objects.all().delete()
 super(About, self).save()

Also see
http://www.djangoproject.com/documentation/model-api/#overriding-default-model-methods
Best,

Rishabh

On Tue, Jun 17, 2008 at 2:05 AM, Dan Lazewatsky <[EMAIL PROTECTED]> wrote:

>
> The way you described has the added advantage of effectively keeping a
> version history. However, if no one is ever going to use this history
> it's just a waste of space. There are two other options I can think of,
> one probably better than the other:
> 1. Django's cache framework
> (http://www.djangoproject.com/documentation/cache/) should help avoid
> some of the overhead of the DB calls.
> 2. Triggers - MySQL and Oracle (and probably others) support triggers
> which fire a certain event occurs. You could setup a trigger that fires
> when a new row is inserted into your about table that deletes all rows
> but the new one. In my experience, triggers are a pain to deal with, but
> it's an option.
>
> ocgstyles wrote:
> > The client wants certain parts of the site to be editable, I don't
> > particularly agree with the logic, simply because why take a DB hit
> > (although small) just to grab text from a database for an "About" page
> > when that text us USUALLY static.
> >
> > So thinking of this "About" page, maybe the client just tells a little
> > about the business etc, but maybe wants to update it occasionally.  I
> > implemented it as a "About" class in a "Section" module.  But with
> > that model, you can add multiple "About" texts.  One way I thought of
> > doing it was to grab the latest edited object like this:
> >
> > class About(models.Model):
> >text = models.TextField()
> >pub_date = models.DateTimeField(auto_now=True)
> >
> > Then just use:
> >
> > About.objects.order_by('-pub_date')
> >
> > to retrieve the latest edited version.  So having many versions isn't
> > a problem...
> >
> > Just wondered if there was a better way to handle this.
> >
> >
> > On Jun 14, 2:41 pm, bruno desthuilliers
> > <[EMAIL PROTECTED]> wrote:
> >
> >> On 14 juin, 15:53, ocgstyles <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >>> Is there a way create a restriction that will only allow one instance
> >>> of a model?
> >>>
> >> The closest you could get would be to define a model with a unique not
> >> editable field and override the save method to make this field a
> >> constant value. But that wont work for direct database access.
> >>
> >> Anyway, why would you want such a thing ?
> >>
> > >
>
> >
>

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



Re: Add filters to the Users List/Page in the admin app

2008-06-13 Thread Rishabh Manocha
This is what I was thinking, but I thought there was a glimmer of hope of
achieving this without moving over to newforms-admin. Is there absolutely no
way to do this using trunk??

I'll give newforms-admin a shot on my dev box over the weekend and see what
comes out of it. I will research this too, but are there any backwards
incompatible changes between the current trunk and the newforms-admin
branch?? I'm thinking the qs-rf merge maybe introduced some issues...

Thanks anyways,

R


On 6/12/08, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
>
> Hi Rishabh,
>
> >
> > Now, the django admin app provides (by default) a page where user details
> > are listed. I do not want to change that list. However, I would like to
> add
> > filters on that page (remove the superuser status and staff status
> filters
> > and add others like TechSkillsList etc.). I was wondering if this were
> > possible, and if so, how. I am using a (somewhat out of date) trunk
> checkout
> > of the djago code. If this is not possible in the current admin, is it
> > possible using newforms-admin??
>
> Yes, newsforms-admin will let you create an admin area for the
> auth.User model using your own admin options (list filters, search,
> etc.) It's worth switching to that branch and trying this out.
>
> http://code.djangoproject.com/wiki/NewformsAdminBranch
> http://code.djangoproject.com/wiki/NewformsHOWTO
>
> -Rajesh D
>
>
> >
>


-- 
Best,

Rishabh

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



Re: Custom validationrules for newforms?

2008-06-11 Thread Rishabh Manocha
http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validationis
probably what you're looking for.

Best,

Rishabh

On Wed, Jun 11, 2008 at 3:20 PM, mwebs <[EMAIL PROTECTED]> wrote:

>
> I want to add a custom validation rule for a newforms form.
> I could not figure out how to do this. Can someone give me an advice
> how to do this. thanks, toni
> >
>

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



Add filters to the Users List/Page in the admin app

2008-06-11 Thread Rishabh Manocha
Hey all,

I'm using django's in-built authentication mechanism for my app. Several of
my models are of the form:

class UserTechSkill(models.Model):
user = models.ForeignKey(User,edit_inline = models.TABULAR)
skill = models.ForeignKey(TechSkillsList,core=True)
prof_level = models.ForeignKey(ProficiencyLevel,core=True)
years = models.IntegerField("Years of Experience", max_length=2)

def __str__(self):
return u'%s' % ';'.join([str(self.skill),str(self.prof_level)])

TechSkillsList is a list that is updated via the admin app and displayed to
the user using a select multiple box (the user cannot alter the list of
TechSkills).

Now, the django admin app provides (by default) a page where user details
are listed. I do not want to change that list. However, I would like to add
filters on that page (remove the superuser status and staff status filters
and add others like TechSkillsList etc.). I was wondering if this were
possible, and if so, how. I am using a (somewhat out of date) trunk checkout
of the djago code. If this is not possible in the current admin, is it
possible using newforms-admin??

Many Thanks,

Rishabh

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



Re: use my own widgets when creating a form out of a model

2008-06-04 Thread Rishabh Manocha
What you want to do is perfectly doable. If (for example) you want the
street field to show up as a textarea with 40 columns in your form, you
would put something like this in your forms.py:

class PersonForm(ModelForm):
   street = forms.CharField(widget = forms.TextArea(attrs = {"cols":40}))
   class Meta:
   model = Person
   fields = ['name', 'notes', 'email', 'cellphone',
'officephone', 'skypename', 'street', 'number', 'suffix', 'zip',
'city', 'country', 'photo']

You can of-course do this with any field and use any widget for said field.

Best,

R

On Wed, Jun 4, 2008 at 6:49 PM, Wim Feijen <[EMAIL PROTECTED]> wrote:

>
> Hello people,
>
> Being able to work with Django is very helpful to me. However, I am
> unsure whether I can create a form out of a database model and then
> customize that form. Using widgets to increase the textarea to 40
> would be great! But after reading  the documentation I am convinced I
> cannot do that.
>
> One solution I can think of, is to loop over the fields in the form
> and start changing those? Is that possible? Then again, is that the
> proper way to do it?
>
> My models are below.
>
> Thanks for any help!
>
> Wim
>
> 
>
> class Person(models.Model):
>name = models.CharField(max_length=100)
>notes = models.CharField(max_length=100, blank=True)
>email = models.EmailField(max_length=100, blank=True)
>cellphone = models.CharField(max_length=100, blank=True)
>officephone = models.CharField(max_length=100, blank=True)
>chat = models.CharField(max_length=100, blank=True)
>skypename = models.CharField(max_length=100, blank=True)
>street = models.CharField(max_length=100, blank=True)
>number = models.CharField(max_length=100, blank=True)
>suffix = models.CharField(max_length=100, blank=True)
>zip = models.CharField(max_length=100, blank=True)
>city = models.CharField(max_length=100, blank=True)
>country = models.CharField(max_length=100, blank=True)
>photo = models.ImageField(upload_to='.', blank=True)
>company = models.ManyToManyField(Company)
>groups = models.ManyToManyField(Group)
>deleted = models.BooleanField(default=False)
>shared = models.ManyToManyField(User, related_name='shared')
>owner = models.ForeignKey(User)
>
>def __str__(self):
>return self.name
>
> class PersonForm(ModelForm):
>class Meta:
>model = Person
>fields = ['name', 'notes', 'email', 'cellphone',
> 'officephone', 'skypename', 'street', 'number', 'suffix', 'zip',
> 'city', 'country', 'photo']
>
> >
>

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



Re: Apache (and dev server) throws "connection reset" when accessing pages via IE 6

2008-05-23 Thread Rishabh Manocha
Graham,

Thanks for the reply (and pardon me for the delayed response). It ended up
being a proxy setting that I was missing (or at-least that's what it seems
like). I have fixed that, and no longer see the connection reset issues. I
will however, keep your tips above in store - it definitely seems like that
could be an issue if my app ever goes large.

Thanks for your help,

R

On Wed, May 21, 2008 at 5:42 AM, Graham Dumpleton <
[EMAIL PROTECTED]> wrote:

>
>
>
> On May 20, 10:53 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote:
> > Hey Guys,
> >
> > I have just deployed my code to my test server (from my laptop) and
> > setup apache/mod_python to serve the pages. Everything works just fine
> > when I work with Firefox, but whenever I access my pages using IE 6, I
> > keep getting the following errors in the apache error logs:
> >
> > [Tue May 20 17:59:43 2008] [notice] mod_python: (Re)importing module
> > 'django.core.handlers.modpython'
> > [Tue May 20 17:59:45 2008] [notice] mod_python: (Re)importing module
> > 'django.core.handlers.modpython'
> > [Tue May 20 17:59:45 2008] [notice] mod_python: (Re)importing module
> > 'django.core.handlers.modpython'
> > [Tue May 20 17:59:45 2008] [notice] mod_python: (Re)importing module
> > 'django.core.handlers.modpython'
> > [Tue May 20 17:59:45 2008] [info] [client 146.208.137.89]
> > (104)Connection reset by peer: core_output_filter: writing data to the
> > network
> > [Tue May 20 17:59:45 2008] [info] [client 146.208.137.89] (32)Broken
> > pipe: core_output_filter: writing data to the network
> >
> > This results in my forms being thrown off the tracks and I end up
> > getting weird form results (going by the data being saved to the DB).
> >
> > I am using apache 2.0 and mod_python 3.2:
> > httpd-2.2.3-6.el5
> > mod_python-3.2.8-3.1
> >
> > My apache configuration is:
> > 
> > SetHandler python-program
> > PythonHandler django.core.handlers.modpython
> > SetEnv DJANGO_SETTINGS_MODULE MyProject.settings
> > SetEnv PYTHON_EGG_CACHE /tmp/python-eggs
> > PythonDebug On
> > PythonPath "['/opt/proj'] + sys.path"
> > 
> >
> > I get a similar error using the dev server:
> >
> > Exception happened during processing of request from ('127.0.0.1', 2144)
> > Traceback (most recent call last):
> >   File "C:\Python25\lib\SocketServer.py", line 222, in handle_request
> > self.process_request(request, client_address)
> >   File "C:\Python25\lib\SocketServer.py", line 241, in process_request
> > self.finish_request(request, client_address)
> >   File "C:\Python25\lib\SocketServer.py", line 254, in finish_request
> > self.RequestHandlerClass(request, client_address, self)
> >   File "C:\Python25\Lib\site-packages\django\core\servers\basehttp.py",
> > line 554, in __init__
> > BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
> >   File "C:\Python25\lib\SocketServer.py", line 522, in __init__
> > self.handle()
> >   File "C:\Python25\Lib\site-packages\django\core\servers\basehttp.py",
> > line 594, in handle
> > self.raw_requestline = self.rfile.readline()
> >   File "C:\Python25\lib\socket.py", line 346, in readline
> > data = self._sock.recv(self._rbufsize)
> > error: (10054, 'Connection reset by peer')
> >
> > I read [1] where this guy had a similar problem but fixed it by
> > changing his proxy settings to make it such that going to localhost
> > does not take a route via the proxy. Trying the same thing did not
> > help in my case.
> >
> > I was hoping someone else would have run into this problem and could
> > suggest a solution.
> >
> > Many thanks,
> >
> > Rishabh
> >
> > [1] -
> http://groups.google.com/group/django-users/browse_thread/thread/bfb2...
>
> This indicates that the browser (or proxy) closed the connection
> before all response content had been sent. Use live headers extension
> for Firefox to capture the response headers and make sure the Content-
> Length is actually correct for the amount of data sent. Some browsers
> are more tolerant of incorrect content lengths on responses than
> others. If the browser is being more strict it may close connection
> immediately it sees content length read, but if you were wrongly
> sending more data than that, result would be truncated and would get
> this error on server side if running with 'info' for LogLevel. Note
> that by default LogLevel is 'warn' and you

Re: Really, realy strange MySQLdb problem, cycling through error messages.

2008-05-20 Thread Rishabh Manocha

There was a permission denied error 'cause if your webserver was
running under some user other than root (as it should be), it won't be
able to write to the root's home directory (as it shouldn't).

Assuming you are using Apache with mod_python, here is something you
could put in your httpd.conf:

SetEnv PYTHON_EGG_CACHE /tmp/python-eggs

Include this with the rest of your settings for the django app.

Best,

R

On Wed, May 21, 2008 at 3:04 AM, Rodrigo Culagovski
<[EMAIL PROTECTED]> wrote:
>
> For future reference: fixed, it stabilized to the 3rd error message. I
> added this to __init.py__ in the application's directory:
>
> import os
> os.environ['PYTHON_EGG_CACHE'] = '/tmp'
>
> Apparently there was some permission error on '/root/.python-eggs'
> >
>

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



Apache (and dev server) throws "connection reset" when accessing pages via IE 6

2008-05-20 Thread Rishabh Manocha

Hey Guys,

I have just deployed my code to my test server (from my laptop) and
setup apache/mod_python to serve the pages. Everything works just fine
when I work with Firefox, but whenever I access my pages using IE 6, I
keep getting the following errors in the apache error logs:

[Tue May 20 17:59:43 2008] [notice] mod_python: (Re)importing module
'django.core.handlers.modpython'
[Tue May 20 17:59:45 2008] [notice] mod_python: (Re)importing module
'django.core.handlers.modpython'
[Tue May 20 17:59:45 2008] [notice] mod_python: (Re)importing module
'django.core.handlers.modpython'
[Tue May 20 17:59:45 2008] [notice] mod_python: (Re)importing module
'django.core.handlers.modpython'
[Tue May 20 17:59:45 2008] [info] [client 146.208.137.89]
(104)Connection reset by peer: core_output_filter: writing data to the
network
[Tue May 20 17:59:45 2008] [info] [client 146.208.137.89] (32)Broken
pipe: core_output_filter: writing data to the network

This results in my forms being thrown off the tracks and I end up
getting weird form results (going by the data being saved to the DB).

I am using apache 2.0 and mod_python 3.2:
httpd-2.2.3-6.el5
mod_python-3.2.8-3.1

My apache configuration is:

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE MyProject.settings
SetEnv PYTHON_EGG_CACHE /tmp/python-eggs
PythonDebug On
PythonPath "['/opt/proj'] + sys.path"



I get a similar error using the dev server:

Exception happened during processing of request from ('127.0.0.1', 2144)
Traceback (most recent call last):
  File "C:\Python25\lib\SocketServer.py", line 222, in handle_request
self.process_request(request, client_address)
  File "C:\Python25\lib\SocketServer.py", line 241, in process_request
self.finish_request(request, client_address)
  File "C:\Python25\lib\SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "C:\Python25\Lib\site-packages\django\core\servers\basehttp.py",
line 554, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
  File "C:\Python25\lib\SocketServer.py", line 522, in __init__
self.handle()
  File "C:\Python25\Lib\site-packages\django\core\servers\basehttp.py",
line 594, in handle
self.raw_requestline = self.rfile.readline()
  File "C:\Python25\lib\socket.py", line 346, in readline
data = self._sock.recv(self._rbufsize)
error: (10054, 'Connection reset by peer')

I read [1] where this guy had a similar problem but fixed it by
changing his proxy settings to make it such that going to localhost
does not take a route via the proxy. Trying the same thing did not
help in my case.

I was hoping someone else would have run into this problem and could
suggest a solution.

Many thanks,

Rishabh

[1] - 
http://groups.google.com/group/django-users/browse_thread/thread/bfb25d10aa51ed2/3272996e2ea13fd3

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



Re: Adding database table to Selection Widget on newforms

2008-05-19 Thread Rishabh Manocha

Since the list of countries is coming from a model, why not use
ModelChoiceField [1]. So, your field will look something like:

Country = forms.ModelChoiceField(required=True,widget=forms.Select(attrs
= attrs_dict), queryset = Country.objects.all())

Best,

R

On Mon, May 19, 2008 at 10:02 AM, Jorge Romo <[EMAIL PROTECTED]> wrote:
>
> Hello again guys!
>
> I'm using django-registration and i wanna use django-countries with it
> so i can ask my new user for its country. But i don't know how to call
> it... this is my django-registration country code:
>
>   Country =  forms.CharField(widget=forms.Select(attrs=attrs_dict,
> choices=()), label=_(u'country'))
>
> Any help will be appreciated!
>
> Thanx!
> >
>

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



Re: get for errors as string and not as HTML

2008-04-30 Thread Rishabh Manocha

Did you take a look at
http://www.djangoproject.com/documentation/newforms/#customizing-the-error-list-format
 ??

You could just return the error message without wrapping it in any
div/span/ul etc.

R

On Tue, 2008-04-29 at 22:23 -0700, Mike Chambers wrote:
> Thanks.
> 
> This was the only way I could get the string:
> 
> {% for s in form.user_name.errors %}{{s}}{% endfor %}
> 
> I tried some of the list template filters (such as slice, but didnt 
> havent any luck with them).
> 
> Are there instances where more than one validation error would be 
> returned for a specific field?
> 
> Thanks again for the help...
> 
> mike chambers
> 
> 
> Ronny Haryanto wrote:
> > On Wed, Apr 30, 2008 at 12:03 PM, Mike Chambers <[EMAIL PROTECTED]> wrote:
> >>  
> >> Name
> >> {{ form.user_name }} {{ form.user_name.errors }}
> >>  
> > 
> >>  Is there any way to just get the raw error string?
> > 
> > You should be able to treat form.user_name.errors as a python list
> > (e.g. iterate with for, join, etc).
> > 
> > Ronny
> 
> > 


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



Re: Confused on a foriegnkey error

2008-04-26 Thread Rishabh Manocha

Excuse me for not writing back earlier - travelling isn't always easy.
I have however, figured out the cause of this problem and fixed it. I
believe it had to do with using ModelMultipleChoiceField instead of
ModelChoiceField. Thanks for clearing that up. I will also make a note
to be more precise with the snippets I put up in the future.

I still need some help with selecting multiple options, but since it
doesn't exactly fit under this topic, I'll post a new message up.

Thanks,

R

On Tue, Apr 22, 2008 at 9:41 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
>
> On Mon, Apr 21, 2008 at 12:06 PM, Rishabh Manocha <[EMAIL PROTECTED]>
> wrote:
>
>
> >
> > Thanks for writing back, Karen. I guess the snippets of code I
> > inserted were a little misleading. I have many other modelforms too,
> > which all have a user = ForeignKey(User) defined. Problem is that I
> > have to use multiple instances of these forms (for example, I need I
> > have a ModelForm called PrevoiusOrganisation. Each instance represents
> > one org, but I want the user to be able to enter multiple previous
> > organisations ) which all have to have their "user" set. An example
> > is:
> >
> > if request.POST:
> >new_user = UserDetailsForm(request.POST, request.FILES,
> instance=User())
> >prevorgforms = [PrevOrgsForm(request.POST,
> > prefix="prevorgs"+str(x), instance = PrevOrgs()) for x in range(0, 3)]
> >prevorgprojsforms = [PrevOrgProjsForm(request.POST,
> > prefix="prevorgprojs"+str(x), instance = PrevOrgProjs()) for x in
> > range(0, 4)]
> >if new_user.is_valid() and all([prevorgform.is_valid() for
> > prevorgform in prevorgforms]) and ...:
> >new_user_id = new_user.save()
> >set_user_id(prevorgforms,new_user_id)
> >set_user_id(prevorgprojsforms,new_user_id)
> >...
> >
> > def set_user_id(the_list, the_user_id):
> >for list_elem in the_list:
> >new_list_elem = list_elem.save(commit=False)
> >new_list_elem.user = the_user_id
> >new_list_elem.save()
> >
> > I have not had any issues with this function and my other modelforms,
> > so I don't think I'm doing something wrong here. I suspect something
> > is missing either during the Ajax call or later when I set the
> > queryset for each list on submission.
> >
> > Hope that clears up my problem a little bit more.
> >
>
> Well no, that didn't really clear things up.  You were asking about trouble
> saving a SkillListForm and now are posting about how set_user_id is called
> when you are doing things with a UserDetailsForm and some different
> organization forms with multiple instances, which is confusing since it
> seems entirely unrelated to the original problem.  I gather what you are
> trying to say, though, is that this same set_user_id function is called when
> you are doing the processing to save a SkillListForm?  If so I'm not sure
> why you didn't just post the code involved when saving a SkillListForm.
>
> Anyway, on closer inspection of the SkillListForm I do notice a problem: you
> override skill like so:
>
>
> skill = forms.ModelMultipleChoiceField(required = True, label = "Technical
> Skill",queryset = A.objects.none())
>
> This should be a ModelChoiceField, not a ModelMultipleChoiceField.  (Also
> the queryset should be tied to the B model, not A, since skill is a
> ForeignKey specifying a B model instance.)
>
> However, though this error would produce exactly the symptom you describe,
> I'm not entirely sure that is the cause of your problem because you say your
> form displays two drop-down boxes and a ModelMultipleChoiceField wouldn't
> have a drop-down widget, so I am not sure the code you posted really matches
> what you are running (there are also some typos in the ForeignKey
>  definitions, so it seems you re-typed vs. cut-and-pasted your code).
> People are much more likely to be able to provide useful help when you post
> exactly the code you are running.  If you feel it is too complicated by all
> means try to simplify it, but verify you still hit the problem with the
> simplified code.  Oftentimes in the process of simplifying you can identify
> what is causing the problem.
>
> Karen
>
>
>
> > Best,
> >
> > R
> >
> >
> >
> >
> >
> > On Mon, Apr 21, 2008 at 6:38 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
> > >
> > > On Mon, Apr 21, 2008 at 2:53 AM, Rishabh Manocha <[EMAIL PROTECTED]>
> wrote:
> > >
> > >
> > > >
> > > > Hey Guys,
> > > >
> > > > 

Re: sys.path on freebsd 6.2 HALP!

2008-04-24 Thread Rishabh Manocha

I'm having similar issues gettind mod_python to work with Apache on a  
windows box. I don't have my httpd.conf in front of me atm, but i'm  
basically seeing what zoggernaut is seeing :(

Best,

R
On 25-Apr-08, at 8:14 AM, zoggernaut wrote:

>
> FYI, I followed the instructions on the tutorial posted here:
> http://www.djangoproject.com/documentation/tutorial01
>
> Below is my settings.py Mod_python runs fine.
>  settings.py
> -
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
> ('Mark Hentov', '[EMAIL PROTECTED]'),
> )
>
> MANAGERS = ADMINS
> DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
> 'postgresql', 'my
> sql', 'sqlite3' or 'oracle'.
> DATABASE_NAME = '' # Or path to database file if using
> sqlite3.
> DATABASE_USER = '' # Not used with sqlite3.
> DATABASE_PASSWORD = '' # Not used with sqlite3.
> DATABASE_HOST = '' # Set to empty string for localhost.
> Not used wit
> h sqlite3.
> DATABASE_PORT = '' # Set to empty string for default. Not
> used with
> sqlite3.
> TIME_ZONE = 'America/EDT'
> LANGUAGE_CODE = 'en-us'
> SITE_ID = 1
> USE_I18N = True
> MEDIA_ROOT = '/home/frobnitz/frobnitz'
> MEDIA_URL = ''
> ADMIN_MEDIA_PREFIX = '/media/'
> SECRET_KEY = 'loL3rc4t'
> TEMPLATE_LOADERS = (
>'django.template.loaders.filesystem.load_template_source',
>'django.template.loaders.app_directories.load_template_source',
> # 'django.template.loaders.eggs.load_template_source',
> )
>
> MIDDLEWARE_CLASSES = (
>'django.middleware.common.CommonMiddleware',
>'django.contrib.sessions.middleware.SessionMiddleware',
>'django.contrib.auth.middleware.AuthenticationMiddleware',
>'django.middleware.doc.XViewMiddleware',
> )
>
> ROOT_URLCONF = 'frobnitz.urls'
>
> )
>
> INSTALLED_APPS = (
>'django.contrib.auth',
>   'django.contrib.contenttypes',
>'django.contrib.sessions',
>'django.contrib.sites',
>'frobnitz.polls',
>'django.contrib.admin',
> )
> - end settings.py
> 
>
> On Apr 24, 5:17 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>>> ImportError: Could not import settings 'frobnitz.settings' (Is it on
>>> sys.path? Does it have syntax errors?): No module named
>>> frobnitz.settings
>>
>> So as the error clearly asks you:
>>
>> 1. Does your frobnitz/settings.py have syntax errors?
>
> If I could see the errors, I would not be posting here.
>
>> 2. Is it in your PYTHONPATH? Your Apache conf for the application
>> should have a line like:
>>
>> PythonPath "['/path/to/project'] + sys.path"
>>
>> That goes in the  directive and should point to the
>> directory that's the parent of your frobnitz directory. See this for
>> details:
>
> The PARENT of the project dir! I had that wrong. Changing this has
> helped some but now I cannot connect to the sqlite db. Heh.
>
> Here are the python lines from httpd.conf. I include them despite the
> fact they
> have nothing to do with django not working when I use the built-in
> django development server i.e. "python manage.py runserver".
>
>  apache lines
> --
> LoadModule python_module libexec/apache22/mod_python.so
>
> 
>AddHandler mod_python .py
>PythonHandler mptest
>PythonDebug On
> 
>
> 
>  SetHandler mod_python
>  PythonHandler mod_python.testhandler
> 
>
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE frobnitz.settings
>#SetEnv DJANGO_SETTINGS_MODULE settings.py
>PythonDebug On
>PythonPath "['/usr/home/frobnitz'] + sys.path"
> 
>
>
>
> --~--~-~--~~~---~--~~
> 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-user


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



Re: How to use ImageField to save images to dynamic path

2008-04-22 Thread Rishabh Manocha

Yea, I don't think the method I described would work for directories
(or at-least I can't figure out how). It does, however, work if you
want to add something to a filename before saving it. The code I use
is:

request.FILES['resume']['filename'] = request.POST['empid'] + "_" +
request.FILES['resume']['filename']

Best,

R

On Tue, Apr 22, 2008 at 5:52 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>
>  How do you mean of changing request.FILES there itself?
>  I tried to add the directory to request.FILES but failed. Django
>  ignored the directory and savethe image to the MEDIA_ROOT not
>  MEDIA_ROOT/images.
>
>
>  class Thing(models.Model):
> photo = models.ImageField(
> upload_to='images/', blank=True, null=True)
>
>
> class ThingForm(ModelForm):
> class Meta:
> model = Thing
>
>  def thing_add(request):
> if request.method == 'POST':
> if 'photo' in request.FILES:
> request.FILES['photo']['filename'] =
>  ''.join(['test/',request.FILES['photo']['filename']])
> form = ThingForm(request.POST, request.FILES)
> if form.is_valid():
> form.save()
> else:
> form = ThingForm()
>
> return render_to_response('iuv.html', {'form': form})
>
>
>
>  On Apr 21, 3:19 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote:
>  > I don't know if this answers your specific question, but this is being
>  > worked on, apparently -http://code.djangoproject.com/ticket/5361.
>  >
>  > I had a similar requirement, where I wanted to dynamically append a
>  > model field to the filename before saving it. I ended up getting the
>  > model field's value from request.POST in the view, and changing
>  > request.FILES there itself.
>  >
>  > Best,
>  >
>  > R
>  >
>
> > On Sun, Apr 20, 2008 at 6:45 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>  >
>  > >  I defined such a model:
>  >
>  > >  class Thing(models.Model):
>  > > photo = models.ImageField(
>  > >upload_to='images/', blank=True, null=True)
>  >
>  > >  Here is the form for this model:
>  > >  class ThingForm(ModelForm):
>  > > class Meta:
>  > > model = Thing
>  >
>  > >  Now it could handle the image upload request and save images to
>  > >  MEDIA_ROOT/images/ directory.
>  >
>  > >  My question is how to change theupload_tovalue dynamicly in the
>
>
> > >  view. For example, I can get the user name in the view level, and I
>  > >  want to save the image to that user's directory, e.g. 'avatar/
>  > >  username/'.
>  >
>

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



Re: DateField widget, ModelForm and javascript

2008-04-21 Thread Rishabh Manocha

AFAIK that JS date picker is only available in the admin interface.
rendering a form as {{ my_form}} does not print that date picker
either.

I'd be interested in knowing how to get it to show up too (what JS/CSS
files need to be added, whether there is some setting we can use in
the python code itself or do we have to print out each field
independently and insert the appropriate code for the picker etc.).

Best,

R

On Mon, Apr 21, 2008 at 9:46 PM, Guillaume Lederrey
<[EMAIL PROTECTED]> wrote:
>
>  Hello !
>
>  I have a model that I try to edit with a ModelForm. This model has a
>  DateField property. I render the form in my template with a simple :
>
>  {{ form.as_p }}
>
>  I expected the DateField to be displayed as in the admin interface,
>  with a javascript date picker. But I only get a text field. The value
>  format is validated as a date format, so I expect the field is treated
>  as a DateField.
>
>  Is there a way to automagically get the javascript date picker, or is
>  it something I have to add manually ?
>
>  Thanks for your help !
>
>MrG
>
>  --
>  Jabber : [EMAIL PROTECTED]
>  Skype : Guillaume.Lederrey
>  Projects :
>  * http://rwanda.ledcom.ch/
>
>  >
>

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



Re: Widgets with an error class

2008-04-21 Thread Rishabh Manocha

http://www.djangoproject.com/documentation/newforms/#customizing-the-error-list-format

documentation ftw :)

On Mon, Apr 21, 2008 at 5:15 AM, J. Pablo Fernández <[EMAIL PROTECTED]> wrote:
>
>  No ideas on this?
>
>
>
>  On Apr 6, 2:38 am, J. Pablo Fernández <[EMAIL PROTECTED]> wrote:
>  > Hello,
>  >
>  > Is there some way to add a class="error" or wrap the inputs in a   > class="error"> when the field has a validationerror?
>  >
>  > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Confused on a foriegnkey error

2008-04-21 Thread Rishabh Manocha

Thanks for writing back, Karen. I guess the snippets of code I
inserted were a little misleading. I have many other modelforms too,
which all have a user = ForeignKey(User) defined. Problem is that I
have to use multiple instances of these forms (for example, I need I
have a ModelForm called PrevoiusOrganisation. Each instance represents
one org, but I want the user to be able to enter multiple previous
organisations ) which all have to have their "user" set. An example
is:

if request.POST:
new_user = UserDetailsForm(request.POST, request.FILES, instance=User())
prevorgforms = [PrevOrgsForm(request.POST,
prefix="prevorgs"+str(x), instance = PrevOrgs()) for x in range(0, 3)]
prevorgprojsforms = [PrevOrgProjsForm(request.POST,
prefix="prevorgprojs"+str(x), instance = PrevOrgProjs()) for x in
range(0, 4)]
if new_user.is_valid() and all([prevorgform.is_valid() for
prevorgform in prevorgforms]) and ...:
new_user_id = new_user.save()
set_user_id(prevorgforms,new_user_id)
set_user_id(prevorgprojsforms,new_user_id)
...

def set_user_id(the_list, the_user_id):
for list_elem in the_list:
new_list_elem = list_elem.save(commit=False)
new_list_elem.user = the_user_id
new_list_elem.save()

I have not had any issues with this function and my other modelforms,
so I don't think I'm doing something wrong here. I suspect something
is missing either during the Ajax call or later when I set the
queryset for each list on submission.

Hope that clears up my problem a little bit more.

Best,

R


On Mon, Apr 21, 2008 at 6:38 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
>
> On Mon, Apr 21, 2008 at 2:53 AM, Rishabh Manocha <[EMAIL PROTECTED]> wrote:
>
>
> >
> > Hey Guys,
> >
> > I have 4 models working something like this:
> >
> > class User(models.Model):
> >   name = models.CharField()
> >   email = models.EmailField()
> >   ...
> >
> > class A(models.Model):
> >   domainname = models.CharField()
> >
> > class B(models.Model):
> >   domain = models.ForigenKey(A)
> >   name = models.CharField()
> >
> > class C(models.Model):
> >   user = models.ForiegnKey(User)
> >   skill = models.ForeignKey(B)
> >   years = models.IntegerField()
> >
> > The reason class C exists is because A & B will be used as drop down
> > lists whose values only the admin should enter through the admin
> > interface. That bit is working ok.
> >
> > I use ModelForms to load the form for C (like this):
> >
> > class SkillListForm(forms.ModelForm):
> >domainname = forms.ModelChoiceField(required=True, label =
> > "Domain", widget = forms.Select({"onchange" : "javascript:
> > updateTechSkillsList(this);"}),queryset = A.objects.all())
> >skill = forms.ModelMultipleChoiceField(required = True, label =
> > "Technical Skill",queryset = A.objects.none())
> >
> >class Meta:
> > model = C
> > exclude = ("user",)
> >
> > The form, as you can see, produces two drop down lists. The second one
> > is blank to begin with, but the javascript function
> > (updateTechSkillsList) populates it based on the selection in the
> > first list. The JS function makes an Ajax call to a URL whose function
> > in views.py is:
> >
> > def populate_techskills(request):
> >if request.GET:
> >domain = get_object_or_404(A, pk=request.GET['domain_id'])
> >choices = domain.b_set.all()
> >choices_html = ""
> >for choice in choices:
> >choices_html += "%s" %
> > (choice.id, choice.name)
> >return HttpResponse(choices_html)
> >else:
> >return HttpResponseRedirect("/userform/")
> >
> > When the form is finally submitted, I reset the queryset for skills
> > after checking for request.POST so that the values populated by JS and
> > the values being held by the form instance are the same:
> > myform.fields['skill'].queryset = A.objects.get(pk =
> > request.POST["techskills-domainname"]).b_set.all()
> >
> > The form then validates ok (passes myform.is_valid()) however, when it
> > comes time to save it, I keep getting the following error:
> >
> > Traceback:
> > File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
> > get_response
> >  82. response = callback(request, *callback_args,
> > **callback_kwargs)
> > File "C:\Documents and
> >
> Settings\rmanocha\workspace\TechSkillsInventory\..\TechSkillsInve

Re: How to use ImageField to save images to dynamic path

2008-04-21 Thread Rishabh Manocha

I don't know if this answers your specific question, but this is being
worked on, apparently - http://code.djangoproject.com/ticket/5361.

I had a similar requirement, where I wanted to dynamically append a
model field to the filename before saving it. I ended up getting the
model field's value from request.POST in the view, and changing
request.FILES there itself.

Best,

R

On Sun, Apr 20, 2008 at 6:45 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>
>  I defined such a model:
>
>  class Thing(models.Model):
> photo = models.ImageField(
> upload_to='images/', blank=True, null=True)
>
>  Here is the form for this model:
>  class ThingForm(ModelForm):
> class Meta:
> model = Thing
>
>  Now it could handle the image upload request and save images to
>  MEDIA_ROOT/images/ directory.
>
>  My question is how to change the upload_to value dynamicly in the
>  view. For example, I can get the user name in the view level, and I
>  want to save the image to that user's directory, e.g. 'avatar/
>  username/'.
>
>  >
>

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



Confused on a foriegnkey error

2008-04-21 Thread Rishabh Manocha

Hey Guys,

I have 4 models working something like this:

class User(models.Model):
   name = models.CharField()
   email = models.EmailField()
   ...

class A(models.Model):
   domainname = models.CharField()

class B(models.Model):
   domain = models.ForigenKey(A)
   name = models.CharField()

class C(models.Model):
   user = models.ForiegnKey(User)
   skill = models.ForeignKey(B)
   years = models.IntegerField()

The reason class C exists is because A & B will be used as drop down
lists whose values only the admin should enter through the admin
interface. That bit is working ok.

I use ModelForms to load the form for C (like this):

class SkillListForm(forms.ModelForm):
domainname = forms.ModelChoiceField(required=True, label =
"Domain", widget = forms.Select({"onchange" : "javascript:
updateTechSkillsList(this);"}),queryset = A.objects.all())
skill = forms.ModelMultipleChoiceField(required = True, label =
"Technical Skill",queryset = A.objects.none())

class Meta:
 model = C
 exclude = ("user",)

The form, as you can see, produces two drop down lists. The second one
is blank to begin with, but the javascript function
(updateTechSkillsList) populates it based on the selection in the
first list. The JS function makes an Ajax call to a URL whose function
in views.py is:

def populate_techskills(request):
if request.GET:
domain = get_object_or_404(A, pk=request.GET['domain_id'])
choices = domain.b_set.all()
choices_html = ""
for choice in choices:
choices_html += "%s" %
(choice.id, choice.name)
return HttpResponse(choices_html)
else:
return HttpResponseRedirect("/userform/")

When the form is finally submitted, I reset the queryset for skills
after checking for request.POST so that the values populated by JS and
the values being held by the form instance are the same:
myform.fields['skill'].queryset = A.objects.get(pk =
request.POST["techskills-domainname"]).b_set.all()

The form then validates ok (passes myform.is_valid()) however, when it
comes time to save it, I keep getting the following error:

Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Documents and
Settings\rmanocha\workspace\TechSkillsInventory\..\TechSkillsInventory\users\views.py"
in index
  57.   set_user_id(techskillslistforms, new_user_id)
File "C:\Documents and
Settings\rmanocha\workspace\TechSkillsInventory\..\TechSkillsInventory\users\views.py"
in set_user_id
  12. new_list_elem.save()
File "C:\Python25\Lib\site-packages\django\db\models\base.py" in save
  264. ','.join(placeholders)), db_values)
File "C:\Python25\Lib\site-packages\django\db\backends\util.py" in execute
  18. return self.cursor.execute(sql, params)
File "C:\Python25\Lib\site-packages\MySQLdb\cursors.py" in execute
  166. self.errorhandler(self, exc, value)
File "C:\Python25\Lib\site-packages\MySQLdb\connections.py" in
defaulterrorhandler
  35. raise errorclass, errorvalue

Exception Type: OperationalError at /userform/
Exception Value: (1048, "Column 'skill_id' cannot be null")


The POST variable has a value for skill, and printing out
form.cleaned_data['skill'] inside SkillListForm.clean_skill prints the
correct id. However, I am still getting this error. Can anyone see
what I'm doing wrong here??

Thanks,

R

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



Re: Is there a better way to strip CharFields?

2008-04-18 Thread Rishabh Manocha

You could just write a clean_mycharfield() (assuming mycharfield is
your field name) and just return
self.cleaned_data['mycharfield'].strip().

Check 
http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validation
for more details.

On Sat, Apr 19, 2008 at 2:37 AM, Peter Rowell <[EMAIL PROTECTED]> wrote:
>
>  I have an author who doesn't understand that a space is not nothing.
>  He persists in *sometimes* putting a leading space at the beginning of
>  a 'name' field. This name shows up in a ForeignKey drop down in the
>  admin interface. As a result, we often end up with two records. He
>  creates one named
>  " Foo" (note the leading space). When he goes to the dropdown he
>  doesn't see it because it is first in the sort order (not where he
>  would expect it to be) and so he creates another record with the name
>  "Foo" (i.e., without the space). He will then sometimes use the " Foo"
>  record and sometimes the "Foo"  record and things get screwed up.
>
>  I would love to have a CharField option, strip=True, that strips
>  leading/trailing spaces. I don't want to edit core, and I don't want
>  to monkey patch. So that leaves me with either a) create a save() for
>  each model that has one of these fields, or b) have a Field type that
>  does it for me. I have a number of these, so I opted for the later.
>
>  E.g.,
>  class CharFieldStripped(models.CharField):
> def get_db_prep_save(self, value):
> if value is not None:
> value = value.strip()
> return super(models.CharField, self).get_db_prep_save(value)
>
>  So, is this the "best" way to do this? Is there a more general/correct
>  mechanism for adding options to Fields?
>
>  Enquiring minds want to know!
>
>  >
>

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



Re: Images

2008-04-16 Thread Rishabh Manocha

Did you take a look at
http://www.djangoproject.com/documentation/static_files/#how-to-do-it.
If you are using the dev server, this is the way to do it.

Hence, you should not be using anything like (http://127.0.0.1:8000/detail/...) in your view.

R

On Wed, Apr 16, 2008 at 4:37 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>  I will post my code up here, it is just a small classroom project that
>  we are working on so I am not super concerned about reliability or
>  speed.
>  http://dpaste.com/45051/
>  Hopefully it is just something that I am missing or am being a
>  complete noobstick about.  Thanks for all of your help it is most
>  appreciated.  Static is the name of my image directory for anyone who
>  wanted to know.
>
>
>  On Apr 15, 3:28 pm, "Erik Vorhes" <[EMAIL PROTECTED]> wrote:
>  > In production environments, you need to use something like Apache or
>  > Lighttpd (sp?) to serve media--it's not something you should be doing
>  > directly through Django.
>  >
>  > Check the URL for your image and compare it to MEDIA_URL in your
>  > settings.py file (plus anything you're adding through
>  > upload_to='some/path'.
>  >
>  > EV
>  >
>  >
>  >
>
>
> > On Tue, Apr 15, 2008 at 2:19 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 
> > wrote:
>  >
>  > >  The error I get is the white box with the red X which means it can't
>  > >  find the image.
>  >
>  > >  On Apr 15, 1:39 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>  > >  > On Apr 15, 12:06 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>  >
>  > >  > > I have searched high and low to make it possible for me to display 
> an
>  > >  > > image via Django in an html template and it fail bombs so hard.
>  >
>  > >  > Can you put that in developer-friendly terms? :)
>  >
>  > >  > - What error do you get? Is here an error trace you can share?
>  > >  > - What's your template code excerpt that's supposed to create the HMTL
>  > >  > img tag?
>  >
>  > >  > -Rajesh D
>  >
>  > --
>  > portfolio:http://textivism.com/
>  > blog:http://erikanderica.org/erik/
>  >
>

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



Re: ModelMultipleChoiceField updating HTML choices after 2nd reload

2008-04-11 Thread Rishabh Manocha

Justin,

Thanks - that does exactly what I was looking for. Initially, I too
had to refresh the page once before I saw a list of options, but using
fields instead of base_fields fixed that.

This may be a stupid question, but is there a recommended/established
way of reading the django code. I am still fairly new to python, so I
don't quiet understand the nitty gritty's yet :(.

Best,

R

On Fri, Apr 11, 2008 at 8:50 AM, Justin <[EMAIL PROTECTED]> wrote:
>
>  In the __init__ method of the newforms.forms.BaseForm object, the
>  initialized fields
>  are copied as the fields as seen below
>
>  # The base_fields class attribute is the *class-wide* definition of
>  # fields. Because a particular *instance* of the class might want to
>  # alter self.fields, we create self.fields here by copying
>  base_fields.
>  # Instances should always modify self.fields; they should not modify
>  # self.base_fields.
>  self.fields = deepcopy(self.base_fields)
>
>
>  When I updated the attributes queryset like this:
>
>  form.base_fields['tasks'].queryset = tasks,
>
>  it was making the change to a stale copy of list.
>
>  Once I changed my code to say:
>
>  form.fields['tasks'].queryset = tasks,
>
>  everything worked out exactly how I planned.
>
>  Also, after the form has been submitted, you'll have to update the
>  queryset again like:
>  form = TestForm(request.POST)
>  form.fields['tasks'].queryset = Task.objects.filter(project=project)
>   if form.is_valid():
>  
>
>  This way, it will validate against the same queryset that the
>  selection was made from, otherwise, it'll throw a ValidationError
>
>
>
>
>  On Apr 10, 1:05 pm, Justin <[EMAIL PROTECTED]> wrote:
>  > You can also just call
>  >
>  > form.base_fields['tasks'].queryset =  tasks
>  >
>  > which will do this:
>  >
>  > form.base_fields['tasks']._set_queryset( tasks )
>  >
>  > How I found it?  I actually looked at the django code.  As you said in
>  > your post, I've never seen it documented anywhere.  I came across it
>  > after I found it in a few bug reports because apparently, there were
>  > similar issues.  I posted that ticket in my first post.
>  >
>  > When you use this, are you having the same issues with the page
>  > reloading without the set queryset until it's reloaded a second time?
>  >
>  > On Apr 10, 3:36 am, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote:
>  >
>  > > I would like to get an answer for this too. Just reading through
>  > > Justin's code, I have figured out the solution to a problem I was
>  > > stuck on for a few days (I am new to Django so reading and learning
>  > > about the _set_queryset function was a godsend).
>  >
>  > > Also, I was wondering if someone can point me in the direction of any
>  > > documentation which describes other *obscure* function calls like
>  > > _set_queryset etc. I didn't see it anywhere in the main documentation
>  > > section. Had I seen it, I probably would have saved myself a few hours
>  > > of pulling my hair out.
>  >
>  > > Best,
>  >
>  > > ROn Wed, Apr 9, 2008 at 11:19 PM, Justin <[EMAIL PROTECTED]> wrote:
>  >
>  > > >  I noticed when looking at some code that after setting the queryset,
>  > > >  it appears in the form.  I can call ._get_queryset() or .queryset and
>  > > >  it looks updated.
>  >
>  > > >  The problem occurs in the actual form rendered.
>  >
>  > > >  form.as_ul() does not have the updated choices for the checkbox.  I'm
>  > > >  digging through django code but still nothing.
>  >
>  > > >  On Apr 8, 11:05 pm, Justin <[EMAIL PROTECTED]> wrote:
>  > > >  > I have a form:
>  >
>  > > >  > class TestForm(forms.Form):
>  > > >  > name = forms.CharField(max_length=128, label="Test name")
>  > > >  > tasks = forms.ModelMultipleChoiceField(required=False,
>  > > >  > label="Tasks", widget=forms.CheckboxSelectMultiple,
>  > > >  > queryset=Task.objects.none())
>  >
>  > > >  > The goal is to have checkboxes for a set of models easy enough. 
>  I
>  > > >  > initialize it to none because my goal is to update the queryset from
>  > > >  > within the views based on specific conditions.
>  >
>  > > >  > Inside my views.py, I have this:
>  >
>  > > >  > >>After clicking link to create project
>  >
>  > > >  > tasks = Task.objects.filt

Re: ModelMultipleChoiceField updating HTML choices after 2nd reload

2008-04-10 Thread Rishabh Manocha

I would like to get an answer for this too. Just reading through
Justin's code, I have figured out the solution to a problem I was
stuck on for a few days (I am new to Django so reading and learning
about the _set_queryset function was a godsend).

Also, I was wondering if someone can point me in the direction of any
documentation which describes other *obscure* function calls like
_set_queryset etc. I didn't see it anywhere in the main documentation
section. Had I seen it, I probably would have saved myself a few hours
of pulling my hair out.

Best,

R

On Wed, Apr 9, 2008 at 11:19 PM, Justin <[EMAIL PROTECTED]> wrote:
>
>  I noticed when looking at some code that after setting the queryset,
>  it appears in the form.  I can call ._get_queryset() or .queryset and
>  it looks updated.
>
>  The problem occurs in the actual form rendered.
>
>  form.as_ul() does not have the updated choices for the checkbox.  I'm
>  digging through django code but still nothing.
>
>
>
>  On Apr 8, 11:05 pm, Justin <[EMAIL PROTECTED]> wrote:
>  > I have a form:
>  >
>  > class TestForm(forms.Form):
>  > name = forms.CharField(max_length=128, label="Test name")
>  > tasks = forms.ModelMultipleChoiceField(required=False,
>  > label="Tasks", widget=forms.CheckboxSelectMultiple,
>  > queryset=Task.objects.none())
>  >
>  > The goal is to have checkboxes for a set of models easy enough.  I
>  > initialize it to none because my goal is to update the queryset from
>  > within the views based on specific conditions.
>  >
>  > Inside my views.py, I have this:
>  >
>  > >>After clicking link to create project
>  >
>  > tasks = Task.objects.filter(project=project)
>  > form = TestForm()
>  > form.base_fields['tasks']._set_queryset( tasks )
>  > data = { "form": form, "project":project }
>  > return render_to_response("projects/create.html", data)
>  >
>  > When I click a link to this page from another, the checkboxes are not
>  > there because the tasks queryset is still set to Task.objects.none().
>  > If I hit F5 to reload, the correct tasks based on the project show
>  > up.  I can hit F5 infinitely and it's correct.  It's only on that
>  > first load.
>  >
>  > More weird...  I click back out to a different project page.  When I
>  > click the link, I expect it to show the form with a new set of tasks
>  > based on the second project as choices.  Instead of the correct
>  > choices or even none, it shows the choices from the first project.
>  > When I hit F5, it shows the correct choices.
>  >
>  > It's almost like it's caching the previous state between forwards.
>  >
>  > I also tried overriding __init__ in the form.  It followed the exact
>  > same behavior.  I'm using the most recent development version of the
>  > source.
>  >
>  > This ticket:http://code.djangoproject.com/ticket/4787 looks related
>  > but it seems to have been resolved.
>  >
>  > Can I update the queryset like this?
>  >
>

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



Re: newforms with the polls/choice example

2008-04-08 Thread Rishabh Manocha

Does anyone have any ideas here?? If the question is unclear, I'd be
happy to clarify myself.

Thanks,

Rishabh

On Fri, Apr 4, 2008 at 4:50 PM, Rishabh Manocha <[EMAIL PROTECTED]> wrote:
> Hey Guys,
>
>  I was trying to rewrite parts of the Poll app example described in the
>  Django docs. Relevant parts of the code can be seen at
>  http://dpaste.com/43069/. The urls.py can be seen at
>  http://dpaste.com/43070/ (I forgot to put it into the same one).
>
>  The app is running fine (not throwing any errors) but when I go to
>  polls/1/, all I see is the {{p.question}} part. I don't see any of the
>  choices listed.
>
>  Let me add that I am pretty new at this so excuse my naivety. That
>  said, is "choice = forms.CharField(widget=forms.RadioSelect)" the way
>  to go in ChoiceForm if I want 3 radio options with poll_choice.choice
>  printed out next to them?? Also, am I making some error in my view
>  here, 'cause I was trying to follow what was described at
>  
> http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/
>  and just changed code wherever I thought it was needed (btw, am I
>  right in assuming that what that piece of code would have accomplished
>  was to allow users to enter a poll question and then 3 poll
>  choices??). According to that post, and everything I have understood
>  about newforms so far, I would have thought that choice_form.as_table
>  would have at-least printed something out. Maybe not exactly what I
>  wanted (I don't think choice =
>  forms.CharField(widget=forms.RadioSelect) is the right way to go), but
>  something close, or maybe a descriptive error.
>
>  Some help would be appreciated.
>
>  Best,
>
>  R
>

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



Re: some help with urls

2008-03-31 Thread Rishabh Manocha

Thanks,

That works :). Are there any  good (django specific) resources to
learn up on regexp's??I have looked through the regexp page on
wikipedia and the python website itself, but i'm still as bad at them
as I was before.

Anyways, thanks again for your help,

R

On Mon, Mar 31, 2008 at 3:46 PM, Ronny Haryanto <[EMAIL PROTECTED]> wrote:
>
>  Try:
>
> r'^test/fullpath/(?P[\w/]+)
>
>  Ronny
>
>
>
>  On Mon, Mar 31, 2008 at 4:08 PM, Rishabh Manocha <[EMAIL PROTECTED]> wrote:
>  >
>  >  Hey guys,
>  >
>  >  I'm trying to setup my urls.py file and am having trouble getting the
>  >  args to be passed correctly to my view. I basically have something
>  >  link this:
>  >
>  >  urlpatterns = patterns('',
>  >(r'^test/fullpath/$',"test.browse.views.index"),
>  >
>  >  (r'^test/fullpath/(?P\w+)/$',"test.browse.views.index"),
>  >  )
>  >
>  >  What I would like to happen is this:
>  >
>  >  url = http://localhost:8000/test/fullpath   :
>  >  path_name = ""
>  >  url = http://localhost:8000/test/fullpath/private :
>  >  path_name = private
>  >  url = http://localhost:8000/test/fullpath/private/images :
>  >  path_name = private/images
>  >
>  >  I'm having trouble figuring out the correct regexp to get that third
>  >  case going. I have tried things like
>  >  "r'^test/fullpath/(?P\w+)/+",
>  >  "r'^test/fullpath/(?P\w+)+",
>  >  "r'^test/fullpath/(?P\w+)+/+" but none of these or the
>  >  other combinations that I have tried have worked. They all just return
>  >  private (in the 3'rd case) or throw a 404 error.
>  >
>  >  Is it the case that urls with "/" in them will automatically be cut
>  >  apart by Django or am I just screwing up my regexp real bad here (BTW,
>  >  I am a novice at writing regexp's).
>  >
>  >  Some help would be highly appreciated.
>  >
>  >  Best,
>  >
>  >  R
>  >
>  >  >
>  >
>
>  >
>

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



Re: How are you storing binary data in db

2008-03-27 Thread Rishabh Manocha

I think he meant recipes in that are there any recipes to accomplish
this (storing binary data to the DB). Unless I'm getting this
completely wrong, he was not talking about cooking recipes :).

I would be interested in a solution for this too. There are cases
where apps running as the apache/web user do not have write
permissions to the local FS (an example would be the sourceforge
servers). In these situations, having your db store this information
is the only way to go.

Best,

R

On Fri, Mar 28, 2008 at 7:45 AM, Dan Ellis <[EMAIL PROTECTED]> wrote:
>
>  On Mar 27, 9:05 pm, Mike H <[EMAIL PROTECTED]> wrote:
>
>  > Reading large
>  > chunks of file data from a db just wastes db resources
>
>  A recipe is unlikely to be a large chunk of file data. Pictures of
>  food, sure, don't store those in the DB. Storing the text in the DB
>  also means you can make use of its full text searching capability.
>
>
>
>  >
>

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



Where do I put the code to fetch data not coming from a DB

2008-03-27 Thread Rishabh Manocha

Hey guys,

I'm starting work on a project and for now, won't be using a db with
it. Instead, I'll be using a library which fetches all the data I need
from a local SVN store. I was wondering where should I access this
library from - the model (models.py) or the view (views.py)?? I don't
know if there are any restrictions built in for this case, but in
either case, I want to be doing things as are expected to be done in
Django. I'm inclined to just put all the code in views.py itself, but
I figured I'd ask what the community felt.

Thanks,

Rishabh

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