Re: name conflicts in static files

2011-10-17 Thread creecode
Just a general tip for folks.  Always namespace your template and static 
files to avoid problems.

Toodle-loo..
creecode

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

2011-10-17 Thread Kevin
Just a simple thought, if you'd prefer to avoid JavaScript/client-side
scripting entirely, and only code using Python.  It might be an idea
to look at Pyjamas to generate your page.  It technically uses Ajax,
but from the programmers point of view, it feels more like coding a
desktop application.  The exposed functions on the django server are
mapped as Python functions in pyjamas, so coding Ajax in this method
seems very natural for a python programmer.  Depending on what type of
web application you are attempting to build, this might be a good
solution for you.  The tools you use all come down to what the end
result should be.  Is it a website or a web application?  Should the
look and feel be more like a desktop app, or a newspaper?  Pyjamas
also strives for cross-platform/browser compatibility for a true code
once, run anywhere feeling without the Java.  Pyjamas also supports
some HTML5 features such as the canvas to further a desktop app like
feeling for the end user.  One can also mix traditional HTML and a
Pyjamas app onto a single page.  If, for example, your project
requires a small widget which updates from the server constantly(news
feed/chatbox), you can make the entire site using standard HTML/CSS
and embed a Pyjamas app into a DIV tag on the site.

Hopefully this gives you some ideas.

On Oct 14, 7:41 am, Phang Mulianto  wrote:
> ajax use usualy load a div part of html with new content fetch from the
> server when user do something,like click a submit button. and django process
> the request as a simple usual request.
>
> i have using prototype+scriptocolous for the simple syntax to make an ajax
> form.
> i see the jquery version also but a bit trouble coz need to add the event
> manually.
>
> and remember the crsf token when using ajax request..will need it generated
> properly..
>
> anyone using prototype to?
>
> or anyone have better way with ajax
> On Oct 14, 2011 7:47 PM, "Babatunde Akinyanmi"  wrote:
>
>
>
>
>
>
>
> > From what Iankesh said initially, I think he is having problems using
> > ajax to load part of a page not ajax as a whole.
> > Iankesh, it is possible to load only a portion of a page with ajax.
>
> > On 10/13/11, Sells, Fred  wrote:
> > >> On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 
> > wrote:
> > >> >  I am developing a web application where i need ajax like features.
> > >> > But I don't want to use ajax, so my question is- "is there any way to
> > >> > perform ajax like functions in django?"
>
> > > Use Flex, it's easier.
>
> > > --
> > > 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.
>
> > --
> > Sent from my mobile device
>
> > --
> > 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.

-- 
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: name conflicts in static files

2011-10-17 Thread SmileyChris
The first app in INSTALLED_APPS wins, just like how name conflicts with 
templates work.

You can use the following command to check what static file gets picked:
https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#findstatic

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



name conflicts in static files

2011-10-17 Thread dmitry b
Hi,

With the new way of handling static files in Django 1.3 what would
happen if two applications have identically named static files?  E.g.:



   |___ app1
   |  | static
   | |_ styles.css
   |___ app2
  | static
 |_ styles.css


Thanks
Dmitry

-- 
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: Class Based FormView - Initial Logic

2011-10-17 Thread Russell Keith-Magee
On Tue, Oct 18, 2011 at 1:57 AM, Kurtis  wrote:
> Hey,
>
> I have a FormView and a Form. I want to put in some logic that will
> take place before the Form is even displayed. I know I could throw
> this in a decorator and wrap the View but there's only a couple of
> views that need this specific functionality and didn't see a need for
> a whole new decorator.

"Before the form is even displayed" is a bit of an ambiguous
statement. The form isn't displayed until it's rendered on the
client's web browser, and the rendering doesn't happen until the very
last action in a view, so putting your logic *anywhere* would result
in it being executed "before the form is displayed".

The form is *constructed* much earlier (in, unsurprisingly, the
get_form() method).

However, the "right place" for your business logic will very much
depend on what behavior you're trying to add.

The easiest way to thing about this is probably to think about the
problem in terms of what the Class Based View is replacing. The
internals of a CBV is essentially just an implementation of the
following:

def my_view(request):
if request.method == 'POST':
form_class = get_form_class()
form = get_form(form_class, data=request.POST)
if form.is_valid():
return form_valid()
else:
return form_invalid()
else:
form_class = get_form_class()
form = get_form(form_class)
return render_to_response(context_data())

If you can find the appropriate place in a function-based view, just
find the analogous place in a CBV.

Yours,
Russ Magee %-)

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



Blank output from treemenus under nginx

2011-10-17 Thread Alastair Campbell
Hi everyone,

I got a surprise when using treemenus, where it worked really well on
my local dev (django-server) , but disappeared on live (nginx using
mod_wsgi on debian).

I installed the treemenu app, imported the data (menu items) from a
datadump of my local app, and uploaded the templates that use
treemenu.

No error, but no output either.

When I went to the Admin, the menus were there, but editing the items
resulted in a blank editing area.
I switched on debug briefly on live (in maintenance mode), but no
error was reported.

Has anyone else experienced blank output under mod_wsgi but not local dev?

If not, could someone suggest where I could start debugging? Usually I
check logs for errors or use the django error page, but both are blank
:-(

I've had to hard-code the navigation across the site in the meantime,
which is going to get time consuming very quickly!

Kind regards,

-Alastair

PS. a belated thank you to Bruno Desthuilliers for help with my
category question before, it worked!

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



Geodjango Tutorial: SRID problem when loading data from shapefile to PostGIS table

2011-10-17 Thread Pauline Emery
Dear all,

I'm having a problem doing the section "LayerMapping" of the GeoDjango
official Tutorial [1].

After creating load.py in the world directory. Leaving as specified:
"the transform keyword set to False because the data in the shapefile
does not need to be converted -- it's already in WGS84 (SRID=4326)"

I execute as indicate the following commands:

$ python manage.py shell
>>> from world import load
>>> load.run()

And obtain the following error:

Failed to save the feature (id: 0) into the model with the keyword arguments:
{'iso2': u'AG', 'pop2005': 83039, 'area': 44, 'region': 19, 'lon':
-61.7830001, 'iso3': u'ATG', 'subregion': 29, 'fips': u'AC',
'lat': 17.077, 'un': 28, 'mpoly': 'MULTIPOLYGON
(((-61.72917199949 17.6086084,-61.73111699983
17.5472220009,-61.7327791 17.54,-61.73889199964
17.540554001,-61.75194499921
...
17.64472200115,-61.73167399941
17.62499600067,-61.72917199949 17.6086084)))', 'name':
u'Antigua and Barbuda'}
[... stack trace]
IntegrityError: new row for relation "world_worldborder" violates
check constraint "enforce_srid_mpoly"

Postgres enforcing the check constraint for SRID=4326. I don't know to
say to Django to insert explicitely the SRID into the MULTIPOLYGON
command. Inserting the line by hand on Postgres work fine using
ST_Geomfromtext( 'MULTIPOLYGON(((...) (...)),4326).


The same problem occurs with other tutorials:
GeoDjango Database API  with the Zipcode model [2]
GeographicAdminQuickStart [3]

I'm working with Python 2.6 / Django 1.3 with GeoDjango  / GDAL 1.7.2
/ PostgreSQL 8.4.8 / PostGIS 1.5 / Pyscopg2 2.4

Thank you for your time and your help,

Pauline Emery

[1] https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/
[2] https://docs.djangoproject.com/en/1.3/ref/contrib/gis/model-api/
[3] http://code.google.com/p/geodjango-basic-apps/wiki/GeographicAdminQuickStart

-- 
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: Tutorial confusion: flat project layout with django 1.3.1

2011-10-17 Thread garyrob
Actually, it seems like the search popup should focus on whatever 
documentation you're looking at. So, instead of saying "Django 1.3" I would 
argue that it should have said "Django Dev". That would mean that it was 
defaulting to the use it would probably be put to, and simultaneously tell 
the reader which version of the docs he's looking at.

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

2011-10-17 Thread garyrob
Ah! Thanks everyone for the feedback.

The reason I was confused may be stupid, but FWIW here it is: Underneath the 
Search input area, there's a popup menu that says "Django 1.3". My eye went 
over there and registered the 1.3 without figuring out that it refers to 
what is being searched in. I recall the thought crossing my mind that if I 
went to a different item on the popup, it would take me to the equivalent 
docs for a different version. I see that you do have functionality like that 
-- it's just that it's in the bottom right rather than the top right. 

I'm not saying I didn't make a dumb mistake. Fact is, I didn't notice the 
"Documentation version" widget in the bottom right. I'm quite rushed right 
now, and don't spend a lot of time looking at the django docs, and did not 
absorb the fact that the popup that said "Django 1.3" is between the text 
input area for the search and the search button itself -- I just glanced 
over, and saw the version number. If the text to the left of the popup said 
"Search in version" rather than just "Version" the probability that I would 
have avoided the mistake would have been increased, but I'm not sure how 
much. If the popup text itself was "Search Django 1.3" rather than just 
"Django 1.3" I am pretty sure I wouldn't have made the mistake.


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

2011-10-17 Thread Brian Bouterse
I've done it before using a post save signal, although I had lat,lng = NULL
in the schema so that differs from your request here.  After saving, I would
issue an update.  I forget why I didn't use a pre-save signal.

Aside from signals, you may also be able to use a model field default with a
callable to set the lat/lng of the FarmersMarket object.  It's an idea I
haven't tested, so I'm not positive it will work.

You could write some geocoding middleware that sets request.POST data in
some way as it passes through.  I don't really like this solution since it
is kind of "magical."

Brian

On Mon, Oct 17, 2011 at 3:30 PM, Jeff Heard wrote:

> class FarmersMarket(ModelForm):
>   class Meta:
>  model = models.FarmersMarket
>  exclude = ('location',)
>
>   def clean(self):
>  place, (lat, lng) = _g.geocode(self.cleaned_data['address'])
>  self.cleaned_data['location'] = Point(lng,lat)
>  return self.cleaned_data
>
> 
>
> Here's my code minus the exception handling.  Now what I *want* to
> have happen is that the models.FarmersMarket.location field on the
> model is set sometime shortly after the form is submitted by the user,
> by way of geocoding the data, rather than having them tediously enter
> a POINT wkt string in the textarea field.  So my idea was to put a
> call to geopy.Google.geocode in FarmersMarket.self.clean.  I can
> confirm clean() is getting called, but for some reason, the 'location'
> field isn't being set in the model.  I get a whine from Django that
> the location field cannot be NULL (which is true, it can't).
>
> Can anyone tell me how I'm supposed to be doing this? I want them to
> enter an address on the form, not a latitude/longitude pair.
>
> -- Jeff
>
> --
> 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.
>
>


-- 
Brian Bouterse
ITng Services

-- 
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 1.3: how to use pagination with class based views?

2011-10-17 Thread Andriyko
Ok. page_obj is what I need.

On Oct 17, 10:34 pm, Andriyko  wrote:
> Hello,
>
> I have following view in views.py:
> .
> class  ArticleArchiveIndexView(ArticleViewAbstractClass,
> ArchiveIndexView):
>     queryset = Article.live.all()
>     date_field = 'pub_date'
>     context_object_name = 'articles_list'
>     paginate_by = ARTICLES_PER_PAGE
> ..
>
> How do I use 'paginate_by'?
> Should the Article model have Paginator instance?
> Please provide an example with template.
>
> Thanks

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



Re: Suse Linux installation

2011-10-17 Thread aledr
In case of openSUSE 11.3, as root type:

zypper ar 
http://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_11.3/devel:languages:python.repo

In case of openSUSE 11.4, as root type:

zypper ar 
http://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_11.4/devel:languages:python.repo

Then install Django itself, as root type:

zypper in python-django

Thanks.

On Mon, Oct 17, 2011 at 5:55 PM, Andrew Johnson
 wrote:
> Thanks again for your reply.  On the django installation guide is
> says:
>
> A Django package is available for  openSUSE Linux in the  openSUSE
> Build Service. The current package can be installed by subscribing to
> the  devel:languages:python project and typing 'zypper install python-
> django'. Alternatively, you can use a  one-click-install link.
>
> How do I "subscribe to the  devel:languages:python project"?
>
> Sorry for my complete ignorance and thanks in advance for your
> patience.
>
>
> On Oct 17, 3:02 pm, aledr  wrote:
>> It is the openSUSE software repos site. You can check how to usage it 
>> here[1].
>> Choose the correct folder from the openSUSE version you are using.
>>
>> [1]:http://en.opensuse.org/SDB:Zypper_usage
>>
>> On Mon, Oct 17, 2011 at 4:37 PM, Andrew Johnson
>>
>>  wrote:
>> > Thanks for the response!
>>
>> > Where can I get more guidance about how to use the website you
>> > reference?  I go there and see nothing about django and am unsure how
>> > to proceed.
>>
>> > On Oct 14, 1:07 pm, aledr  wrote:
>> >> You can get it directly from the Python repo[1].
>> >> Otherwise you need python-distribute or python-setuptools to build it
>> >> (you can just install one of them with 'zypper in python-...' or
>> >> download from the same[1] repo).
>>
>> >> [1]:http://download.opensuse.org/repositories/devel:/languages:/python/
>>
>> >> On Fri, Oct 14, 2011 at 1:54 PM, Andrew Johnson
>>
>> >>  wrote:
>> >> > I download and untar Django-1.3.1 and try to install and get:
>>
>> >> > django/Django-1.3.1> sudo python setup.py install
>> >> > Traceback (most recent call last):
>> >> >  File "setup.py", line 1, in ?
>> >> >    from distutils.core import setup
>> >> > ImportError: No module named distutils.core
>>
>> >> > I don't see a file named distutils.core anywhere I look.  Did
>> >> > something go wrong with my download?
>>
>> >> > --
>> >> > 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 
>> >> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> >> --
>> >> [ ]'s
>> >> Aledr - Alexandre
>> >> "OpenSource Solutions for SmallBusiness Problems"
>>
>> > --
>> > 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 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> [ ]'s
>> Aledr - Alexandre
>> "OpenSource Solutions for SmallBusiness Problems"
>
> --
> 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.
>
--
[ ]'s
Aledr - Alexandre
"OpenSource Solutions for SmallBusiness Problems"

-- 
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: Suse Linux installation

2011-10-17 Thread Andrew Johnson
Thanks again for your reply.  On the django installation guide is
says:

A Django package is available for  openSUSE Linux in the  openSUSE
Build Service. The current package can be installed by subscribing to
the  devel:languages:python project and typing 'zypper install python-
django'. Alternatively, you can use a  one-click-install link.

How do I "subscribe to the  devel:languages:python project"?

Sorry for my complete ignorance and thanks in advance for your
patience.


On Oct 17, 3:02 pm, aledr  wrote:
> It is the openSUSE software repos site. You can check how to usage it here[1].
> Choose the correct folder from the openSUSE version you are using.
>
> [1]:http://en.opensuse.org/SDB:Zypper_usage
>
> On Mon, Oct 17, 2011 at 4:37 PM, Andrew Johnson
>
>  wrote:
> > Thanks for the response!
>
> > Where can I get more guidance about how to use the website you
> > reference?  I go there and see nothing about django and am unsure how
> > to proceed.
>
> > On Oct 14, 1:07 pm, aledr  wrote:
> >> You can get it directly from the Python repo[1].
> >> Otherwise you need python-distribute or python-setuptools to build it
> >> (you can just install one of them with 'zypper in python-...' or
> >> download from the same[1] repo).
>
> >> [1]:http://download.opensuse.org/repositories/devel:/languages:/python/
>
> >> On Fri, Oct 14, 2011 at 1:54 PM, Andrew Johnson
>
> >>  wrote:
> >> > I download and untar Django-1.3.1 and try to install and get:
>
> >> > django/Django-1.3.1> sudo python setup.py install
> >> > Traceback (most recent call last):
> >> >  File "setup.py", line 1, in ?
> >> >    from distutils.core import setup
> >> > ImportError: No module named distutils.core
>
> >> > I don't see a file named distutils.core anywhere I look.  Did
> >> > something go wrong with my download?
>
> >> > --
> >> > 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 
> >> > athttp://groups.google.com/group/django-users?hl=en.
>
> >> --
> >> [ ]'s
> >> Aledr - Alexandre
> >> "OpenSource Solutions for SmallBusiness Problems"
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> [ ]'s
> Aledr - Alexandre
> "OpenSource Solutions for SmallBusiness Problems"

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



django 1.3: how to use pagination with class based views?

2011-10-17 Thread Andriyko
Hello,

I have following view in views.py:
.
class  ArticleArchiveIndexView(ArticleViewAbstractClass,
ArchiveIndexView):
queryset = Article.live.all()
date_field = 'pub_date'
context_object_name = 'articles_list'
paginate_by = ARTICLES_PER_PAGE
..

How do I use 'paginate_by'?
Should the Article model have Paginator instance?
Please provide an example with template.

Thanks

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



Question on cleaning ModelForms

2011-10-17 Thread Jeff Heard
class FarmersMarket(ModelForm):
   class Meta:
  model = models.FarmersMarket
  exclude = ('location',)

   def clean(self):
  place, (lat, lng) = _g.geocode(self.cleaned_data['address'])
  self.cleaned_data['location'] = Point(lng,lat)
  return self.cleaned_data



Here's my code minus the exception handling.  Now what I *want* to
have happen is that the models.FarmersMarket.location field on the
model is set sometime shortly after the form is submitted by the user,
by way of geocoding the data, rather than having them tediously enter
a POINT wkt string in the textarea field.  So my idea was to put a
call to geopy.Google.geocode in FarmersMarket.self.clean.  I can
confirm clean() is getting called, but for some reason, the 'location'
field isn't being set in the model.  I get a whine from Django that
the location field cannot be NULL (which is true, it can't).

Can anyone tell me how I'm supposed to be doing this? I want them to
enter an address on the form, not a latitude/longitude pair.

-- Jeff

-- 
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: Iteration over queryset in a model

2011-10-17 Thread eyscooby
Ok, sorry I thought I was starting to understand it a little better,
but now I think I took a step backwards, so if it is ok with you let's
step back and take it a step at a time.

So, my first step is wondering if I really need a manager or not??
I was thinking from your first response to me that you might be
suggesting that I did.  Let's start there.
If I understand it correctly the Manager is a way of retrieving
specific information.

thanks



On Oct 12, 11:30 am, Daniel Roseman  wrote:
> On Tuesday, 11 October 2011 15:17:18 UTC+1, eyscooby wrote:
>
> > slowly getting there thanks to your help.
> > I am actually trying to accomplish this in the Admin interface, so I
> > am not sure how to use the template tag {{ ticket.days_old }} in that
> > situation.
>
> > the other part I left off yesterday under my model I then had..
> > (trying to get code formatting correct but keeps going to the left
> > margin on me when i post)
>
> > def days_old(self):
> >     return self.objects.datecalc()
> > days_old.short_discription = 'Days Old'
>
> > more or less is that a correct way I would pull in a custom manager,
> > lets say if this one didn't have the iteration to it which seems be to
> > be my problem part now.
>
> > thanks
>
> No, because that's not what managers are for. Managers are interacting with
> the database, and getting and returning one or more new model instances. If
> you already have an object, and you want to calculate the date on it, you
> want a model method that simply returns a value, not call the manager.
> --
> DR.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Suse Linux installation

2011-10-17 Thread aledr
It is the openSUSE software repos site. You can check how to usage it here[1].
Choose the correct folder from the openSUSE version you are using.

[1]: http://en.opensuse.org/SDB:Zypper_usage

On Mon, Oct 17, 2011 at 4:37 PM, Andrew Johnson
 wrote:
> Thanks for the response!
>
> Where can I get more guidance about how to use the website you
> reference?  I go there and see nothing about django and am unsure how
> to proceed.
>
> On Oct 14, 1:07 pm, aledr  wrote:
>> You can get it directly from the Python repo[1].
>> Otherwise you need python-distribute or python-setuptools to build it
>> (you can just install one of them with 'zypper in python-...' or
>> download from the same[1] repo).
>>
>> [1]:http://download.opensuse.org/repositories/devel:/languages:/python/
>>
>> On Fri, Oct 14, 2011 at 1:54 PM, Andrew Johnson
>>
>>  wrote:
>> > I download and untar Django-1.3.1 and try to install and get:
>>
>> > django/Django-1.3.1> sudo python setup.py install
>> > Traceback (most recent call last):
>> >  File "setup.py", line 1, in ?
>> >    from distutils.core import setup
>> > ImportError: No module named distutils.core
>>
>> > I don't see a file named distutils.core anywhere I look.  Did
>> > something go wrong with my download?
>>
>> > --
>> > 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 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> [ ]'s
>> Aledr - Alexandre
>> "OpenSource Solutions for SmallBusiness Problems"
>
> --
> 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.
>
>
--
[ ]'s
Aledr - Alexandre
"OpenSource Solutions for SmallBusiness Problems"

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



cannot concatenate 'str' and 'FilterExpression' objects

2011-10-17 Thread nav
Dear Folks,

I am using a number of subdomains for my website and decided to create
a custom url tag and try as shown on

http://stackoverflow.com/questions/3461806/django-subdomains-and-mod-rewrite-urls-messing-up-on-deployment-setups

My template tag being used in my template like this:
About
Us

My template tags functions looks like this:

class SubdomainURLNode(URLNode):
def render(self, context):
request = context['request']
domain = request.get_host()
subdomain = re.sub(r'^www\.','',domain).split('.')[0]
path = super(SubdomainURLNode, self).render(context)
return "%s/%s" % (str(request.get_host()), path)

@register.tag
def subdomainurl(parser, token, node_cls=SubdomainURLNode):
"""Just like {% url %} but checks for a subdomain."""
node_instance = url(parser, token)
return node_cls(view_name=node_instance.view_name,
args=node_instance.args,
kwargs=node_instance.kwargs,
asvar=node_instance.asvar)

While trying to render the template tag it comes back saying:

TemplateSyntaxError at /

Caught TypeError while rendering: cannot concatenate 'str' and
'FilterExpression' objects

My template tag function does not return the path value from the
statement:
path = super(SubdomainURLNode, self).render(context)

because the URLNode function fails on line 442 because of a type
mismatch:
url = reverse(project_name + '.' + view_name,

I just tried using the standard url method in django {% url
"app.views.view_decider" "about" %} and this works. I would like to
know where I am going wrong with my function so I can get this to
work.

The full traceback of the error is below:

Thanks in advance.
nav

The full traceback of the error is below:
--
Environment:


Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.3.1
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'swanlotus_site',
 'south']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'middleware.SubdomainMiddleware')


Template error:
In template /home/nandu/django/swanlotus/templates/navigation.html,
error at line 6
   Caught TypeError while rendering: cannot concatenate 'str' and
'FilterExpression' objects
   1 : {% load custom_tags %}


   2 : {% load url from future %}


   3 : 


   4 : http://localhost:8000/;>Home


   5 : 


   6 : About Us


   7 : 


   8 : http://chandra.localhost:
8000">Chandra


   9 : 


   10 : 


   11 : http://downloads.localhost:8000;>Downloads


   12 : {% if thesis and phd_guide%}


   13 : 


   14 : http://downloads.localhost:8000/
#thesis">Thesis Writing


   15 : http://downloads.localhost:8000/
#phd">PhD Guide


   16 : {% if calculus_sheet and app_maths_sheet %}


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
  111. response = callback(request,
*callback_args, **callback_kwargs)
File "/home/nandu/django/swanlotus/swanlotus_site/views.py" in
view_decider
  21. return render(request, template, context)
File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
__init__.py" in render
  44. return HttpResponse(loader.render_to_string(*args,
**kwargs),
File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py" in render_to_string
  188. return t.render(context_instance)
File "/usr/local/lib/python2.6/dist-packages/django/template/base.py"
in render
  123. return self._render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/base.py"
in _render
  117. return self.nodelist.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/base.py"
in render
  744. bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py"
in render_node
  73. result = node.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
loader_tags.py" in render
  127. return compiled_parent._render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/base.py"
in _render
  117. return self.nodelist.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/base.py"
in render
  744. bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py"
in render_node
  73.

Re: Suse Linux installation

2011-10-17 Thread Andrew Johnson
Thanks for the response!

Where can I get more guidance about how to use the website you
reference?  I go there and see nothing about django and am unsure how
to proceed.

On Oct 14, 1:07 pm, aledr  wrote:
> You can get it directly from the Python repo[1].
> Otherwise you need python-distribute or python-setuptools to build it
> (you can just install one of them with 'zypper in python-...' or
> download from the same[1] repo).
>
> [1]:http://download.opensuse.org/repositories/devel:/languages:/python/
>
> On Fri, Oct 14, 2011 at 1:54 PM, Andrew Johnson
>
>  wrote:
> > I download and untar Django-1.3.1 and try to install and get:
>
> > django/Django-1.3.1> sudo python setup.py install
> > Traceback (most recent call last):
> >  File "setup.py", line 1, in ?
> >    from distutils.core import setup
> > ImportError: No module named distutils.core
>
> > I don't see a file named distutils.core anywhere I look.  Did
> > something go wrong with my download?
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> [ ]'s
> Aledr - Alexandre
> "OpenSource Solutions for SmallBusiness Problems"

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



Looking for a good Document Management System (DMS) to plug into my Django app

2011-10-17 Thread CareerDhaba tech
Hi folks,

I have been looking around all over to find a high quality DMS to plug into
my Django application. I'd like to be able to upload and download .docx or
.pdf files, edit the metadata, and also be able to serve the content of the
files on the front end. If the plugin allows for preview, that would be
great as well.

I am currently building a content rich django app and need to be able to do
something like this: http://bit.ly/pUyLyC

I have come across Mayan, and although it has all the features I need, its a
separate app in itself and there is no API for me to connect my app to data
sitting on Mayan. Any other insight or points in the right direction would
be tremendously helpful.

Best,
Harshil

-- 
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: Class Based FormView - Initial Logic

2011-10-17 Thread Andre Terra
Maybe some place inside get(), dispatch() or get_form_kwargs()?


Cheers,
AT

On Mon, Oct 17, 2011 at 3:57 PM, Kurtis  wrote:

> Hey,
>
> I have a FormView and a Form. I want to put in some logic that will
> take place before the Form is even displayed. I know I could throw
> this in a decorator and wrap the View but there's only a couple of
> views that need this specific functionality and didn't see a need for
> a whole new decorator.
>
> I know I can override the form_valid and form_invalid methods. There's
> also several "get_foo" methods I see in the source. I'm just not
> really sure where I would/could put code in that will run before the
> Form is even displayed or processed (in case they just bypass my view
> and try to throw POST data right at it, which probably wouldn't matter
> because of the CSRF).
>
> Any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To 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.



Class Based FormView - Initial Logic

2011-10-17 Thread Kurtis
Hey,

I have a FormView and a Form. I want to put in some logic that will
take place before the Form is even displayed. I know I could throw
this in a decorator and wrap the View but there's only a couple of
views that need this specific functionality and didn't see a need for
a whole new decorator.

I know I can override the form_valid and form_invalid methods. There's
also several "get_foo" methods I see in the source. I'm just not
really sure where I would/could put code in that will run before the
Form is even displayed or processed (in case they just bypass my view
and try to throw POST data right at it, which probably wouldn't matter
because of the CSRF).

Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Automaticall list all fields of generic model in template

2011-10-17 Thread Tom Evans
Did either of you read the OPs email? He is not looking for forms...

OP:

There is nothing built in, but you can easily iterate through a
model's fields, they are all available in the _meta attribute on a
model instance:

>>> u = User.objects.get(id=1)
>>> for field in u._meta.fields:
...   print "%s => %s" % (field.name, getattr(u, field.name))
...
id => 1
username => tevans@...
first_name => Tom
last_name => Evans
email => tevans@...
is_staff => True
is_active => True
is_superuser => True
last_login => 2011-10-17 15:46:33
date_joined => 2008-11-10 10:54:33

Using this information, you can easily produce a method that will
output a HTML table of that data. If you can modify your model
classes, you can make them inherit from an abstract base model that
includes this method, and then it will be available in all your
classes (that inherit from the base class, obviously).

Much more hackily, you could monkey patch models.Model instead.

Cheers

Tom

On Mon, Oct 17, 2011 at 2:43 PM, Andre Terra  wrote:
> Even better, use django-form-utils!
>
> https://bitbucket.org/carljm/django-form-utils/overview
>
>
> Cheers,
> AT
>
> On Sun, Oct 16, 2011 at 7:57 PM, Mario Gudelj 
> wrote:
>>
>> I think you need
>> this https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>>
>> On 16 October 2011 18:24, bovender  wrote:
>>>
>>> Hi all,
>>> new to Django and loving it.
>>> Is there a way to automatically generate HTML output for the fields of a
>>> model instance?
>>> I'm looking for something similar to form.as_table, just without the form
>>> widgets.
>>> Currently I find myself manually repeating all the typing work for the
>>> detail view templates that I already did for the model definitions.
>>> Thanks
>>> bovender
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/django-users/-/iGP654BL2HMJ.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To 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: Newbee question about PostgreSQL

2011-10-17 Thread Nico
Hi Phil,

Thank you!
I moved the line a few positions up and it now works.

All people who responded to my question, thanks very much!

Kind regards,
Nico


On Oct 17, 3:08 pm, Philip Mountifield 
wrote:
> The order of configuration in the file is also important; on a
> connection attempt the records are examined sequentially. Perhaps you
> problem lies here if you just added the new details to the bottom of the
> config file.

-- 
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: models.Model

2011-10-17 Thread youpsla
Hello Daniel
thanks for your answer and sorry for my english. As you said, it could be a 
problem of translation !!! :-)

I really appreciate your help, I'm doing lots of progress in my python 
object programming curve ...

OK, then to be sure how Python works ... let see this code:

1 from django.db import models 
2 
3 class Person(models.Model): 
4 first_name = models.CharField(max_length=30) 
5 last_name = models.CharField(max_length=30) 

Ligne 1 imports module "models". I've browse the source code of Django. In 
the "models" folder, there is a __init__.py file and a lots of .py other 
files.
There is folders too and specially one called "fields".

Here is my question :

   - When importing models on line 1, doest it import all the .py files in 
   this module, then  all classes, Class, functions, variables at the top level 
   of each .py are available for use ? Or there is only an automatic import of 
   the __init__.py ?


Line 4 : : The CharField Class definition is in models/fields/__init__.py. 
In the code above, there nowhere a reference at "fields". But the line 10 of 
the the __init__.py in models is " This file is automatically loaded by 
Python. In this file on line 10, there is "from django.db.models.fields 
import *". "

Here is my question :

   - Does it means that the CharField Class is available inside Person Class 
   because there is a cascading import following this way:
  - models contains an __init__.py wich import fields and __init.py in 
  fields has a definition of Class CharField on line 601
   
Hope it's enugh clear ... don't spend much time when it is not and just ask 
for reformulation, I'll dot it ...
Regards

Alain


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WBCgsHwa0e0J.
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: Automaticall list all fields of generic model in template

2011-10-17 Thread Andre Terra
Even better, use django-form-utils!

https://bitbucket.org/carljm/django-form-utils/overview


Cheers,
AT

On Sun, Oct 16, 2011 at 7:57 PM, Mario Gudelj wrote:

> I think you need this
> https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
>
> On 16 October 2011 18:24, bovender  wrote:
>
>> Hi all,
>>
>> new to Django and loving it.
>>
>> Is there a way to automatically generate HTML output for the fields of a
>> model instance?
>>
>> I'm looking for something similar to form.as_table, just without the form
>> widgets.
>>
>> Currently I find myself manually repeating all the typing work for the
>> detail view templates that I already did for the model definitions.
>>
>> Thanks
>>
>> bovender
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/iGP654BL2HMJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To 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 models design question

2011-10-17 Thread omerd
Thank you very much!
I choose the first option for now.
If I have any problems, I will write them here

On Oct 17, 2:51 pm, Stuart  wrote:
> Hello Omer --
>
> I believe you have two options. You could use the AttributeValue
> approach I described earlier. You could add features to take care of
> 'data types' and the like. The work may be quite tedious, but it has
> the advantage of not being clever. In other words, you would do the
> work to implement each feature as you like, with no magic involved.
>
> The other approach is to extend django/python itself. Basically the
> approach here is what has been called dynamic models. You can google
> for it, but your best bet is probably this blog post and the pages it
> references.http://martyalchin.com/2007/aug/14/dynamic-models-in-real-world/
> However, note that the article is over four years old. You would no
> doubt have to update this approach for django 1.3. This approach would
> require knowledge of django/python extension points and likely some
> internals. It's probably the "better" approach assuming you are up for
> it. You would have to decide when to construct these dynamic models,
> among many other decisions.
>
> I'm on holiday for the next couple days, but I will check back with
> the list to see how you're getting on when I return.
>
> Good luck!
>
> --Stuart

-- 
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: Newbee question about PostgreSQL

2011-10-17 Thread Philip Mountifield
The order of configuration in the file is also important; on a 
connection attempt the records are examined sequentially. Perhaps you 
problem lies here if you just added the new details to the bottom of the 
config file.


Regards, Phil

On 17/10/2011 14:01, Nico wrote:

Yes, I have restarted the service.
Of course :)

Nico

On Oct 17, 2:47 pm, Philip Mountifield
wrote:

Have you sent a HUP signal to the postmaster or restarted the service
since making those changes?

Regards, Phil



--

Philip Mountifield
Formac Electronics Ltd
tel  +44 (0) 1225 837333
fax  +44 (0) 1225 430995

pmountifi...@formac.net
www.formac.net
www.telgas.net

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-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: Tutorial help: Make the poll app modifiable in the admin

2011-10-17 Thread Daniel
thanks for your reply.
1. yes i am following the tutorial explicitly.
2. yes, i haven't removed it.
3. yes using 1.3

I did manage to find a workaround though. I simply executed the
commands via the python shell (run-> shell).
the error i was getting was when i went to run->run module. Can you
please explain

thanks,
daniel
On Oct 17, 9:53 pm, Ramiro Morales  wrote:
> On Mon, Oct 17, 2011 at 7:05 AM, Daniel  wrote:
> > Hello i am progressing well on the tutorial here:
> >https://docs.djangoproject.com/en/1.3/intro/tutorial02/
> > however, I am stuck on Make the poll app modifiable in the admin.
>
> > I have created an admin.py file within my polls directory. with the
> > suggested code. However I keep getting this error ImportError: No
> > module named polls.models
>
> > any suggestions??
>
> 1. Have you followed part #1 of the tutorial where you create the 'polls'
>     application (that creates the polls/ subdir) and then edit the
>     paceholder models.py file inside it adding the Poll and Choice
>     model definitions?
> 2. Make sure you don't remove the __init__.py file inside that polls/ subdir
> 3. Are you effectively using Django 1.3?
>
> --
> Ramiro Morales

-- 
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: Newbee question about PostgreSQL

2011-10-17 Thread Nico
Yes, I have restarted the service.
Of course :)

Nico

On Oct 17, 2:47 pm, Philip Mountifield 
wrote:
> Have you sent a HUP signal to the postmaster or restarted the service
> since making those changes?
>
> Regards, Phil

-- 
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 models design question

2011-10-17 Thread Stuart
Hello Omer --

I believe you have two options. You could use the AttributeValue
approach I described earlier. You could add features to take care of
'data types' and the like. The work may be quite tedious, but it has
the advantage of not being clever. In other words, you would do the
work to implement each feature as you like, with no magic involved.

The other approach is to extend django/python itself. Basically the
approach here is what has been called dynamic models. You can google
for it, but your best bet is probably this blog post and the pages it
references. http://martyalchin.com/2007/aug/14/dynamic-models-in-real-world/
However, note that the article is over four years old. You would no
doubt have to update this approach for django 1.3. This approach would
require knowledge of django/python extension points and likely some
internals. It's probably the "better" approach assuming you are up for
it. You would have to decide when to construct these dynamic models,
among many other decisions.

I'm on holiday for the next couple days, but I will check back with
the list to see how you're getting on when I return.


Good luck!

--Stuart

-- 
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: Newbee question about PostgreSQL

2011-10-17 Thread Philip Mountifield
Have you sent a HUP signal to the postmaster or restarted the service 
since making those changes?


Regards, Phil

On 17/10/2011 13:45, Nico wrote:

Thanks for the feedback!

I have edited /etc/postgresql/8.4/main/pg_hba.conf and added the
following line at the bottom:
local   myproject   george  trust
(by the way; I am using a Kubuntu workstation)

It should give me local access using a trusted connection for the
database myproject, for user george.

However, psql still refuses the connection:
psql myproject -U george

This is a PostgreSQL related problem.
Any ideas what I overlook here?

Regards, Nico




--

Philip Mountifield
Formac Electronics Ltd
tel  +44 (0) 1225 837333
fax  +44 (0) 1225 430995

pmountifi...@formac.net
www.formac.net
www.telgas.net

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-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: Newbee question about PostgreSQL

2011-10-17 Thread Nico
Thanks for the feedback!

I have edited /etc/postgresql/8.4/main/pg_hba.conf and added the
following line at the bottom:
local   myproject   george  trust
(by the way; I am using a Kubuntu workstation)

It should give me local access using a trusted connection for the
database myproject, for user george.

However, psql still refuses the connection:
psql myproject -U george

This is a PostgreSQL related problem.
Any ideas what I overlook here?

Regards, Nico

-- 
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: Tutorial help: Make the poll app modifiable in the admin

2011-10-17 Thread Ramiro Morales
On Mon, Oct 17, 2011 at 7:05 AM, Daniel  wrote:
> Hello i am progressing well on the tutorial here:
> https://docs.djangoproject.com/en/1.3/intro/tutorial02/
> however, I am stuck on Make the poll app modifiable in the admin.
>
> I have created an admin.py file within my polls directory. with the
> suggested code. However I keep getting this error ImportError: No
> module named polls.models
>
> any suggestions??

1. Have you followed part #1 of the tutorial where you create the 'polls'
application (that creates the polls/ subdir) and then edit the
paceholder models.py file inside it adding the Poll and Choice
model definitions?
2. Make sure you don't remove the __init__.py file inside that polls/ subdir
3. Are you effectively using Django 1.3?

-- 
Ramiro Morales

-- 
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: Newbee question about PostgreSQL

2011-10-17 Thread kenneth gonsalves
On Mon, 2011-10-17 at 12:04 +0100, Simon Riggs wrote:
> > find pg_hba.conf and change 'ident' to 'password' on the lines at
> the
> > end of the file
> 
> Changing the rules in that way would break all existing connections.

I do not understand
> 
> You should always use md5 rather than password, since the latter
> doesn't encrypt the password.

this depends on a lot of things - in some circumstances one can even use
'trust'. In this case the OP is learning django, not postgres - he can
focus on this later when he is learning postgres.
>  
-- 
regards
Kenneth Gonsalves

-- 
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: models.Model

2011-10-17 Thread Daniel Roseman


On Monday, 17 October 2011 12:18:00 UTC+1, youpsla wrote:
>
> hello again, sorry for eventually annoying. But later in the Django 
> tutorial, 
>
> there is this code: 
>
> from django.conf.urls import patterns, include, url 
> . 
> urlpatterns = patterns('', 
> (r'^polls/$', 'polls.views.index'), 
> ..)), 
> ) 
>
> What I understand here is that "patterns", "include" and "url" modules 
> are imported. 
>
> After the result of the function "patterns" is assigned to 
> "urlpatterns". AS Daniel said that a function can't be imported, this 
> means that a method can be called (but not imported) or this means 
> that a function and a method are not the same thing ? 
>
> Regards 
>
> Alain 
>

I didn't say that a function can't be imported. It definitely can. As you 
say, function and method aren't the same thing - a method is a function that 
belongs to a class. It's not possible to import just a method, because 
there's no way of referring to it except via the class. But anything at the 
base level of a module - whether it's a class, a function, a variable, 
anything - *can* be imported.
--
DR. 

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

2011-10-17 Thread Daniel Roseman
On Monday, 17 October 2011 12:04:41 UTC+1, youpsla wrote:
>
> Thanks you 2 for your answers. 
>
> I think I've understood now. Again I apologize for the newby Python 
> question but I've read three times "Dive in Python" and it hasn't made 
> me thnigs clear. That's the reason why I've posted. 
>
> I thought there was a hierarchy like this models.Model.CharField  
>
> That's the reason why I didn't understood. 
>
> Daniel, you said, that a method can be imported, this mean that an 
> external method (method from a class like Model) can't be used 
> directly in the Person class for example ? 
>
> If I understand well, in "first_name = 
> models.CharField(max_length=30)", first_name is an instance of class 
> CharField. This instance send "30" to the "max_length" parameter of 
> class CharField. This parameter is used by an internal method of class 
> CharFiled. Is that right ? :-) 
>
> Thanks again to all 
>
> Regards 
>
> Alain 
>

I'm having a little difficulty understanding your question (problème de 
traduction, sans aucun doute). Person inherits from models.Model, so all 
methods that are defined in the superclass are also available to the 
subclass - that's how Person gets methods such as `save`.

As for `max_length=30`, when you instantiate a class Python calls the 
`__init__` method of that class, which in this case accepts a number of 
arguments including max_length.
--
DR.

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

2011-10-17 Thread youpsla
hello again, sorry for eventually annoying. But later in the Django
tutorial,

there is this code:

from django.conf.urls import patterns, include, url
.
urlpatterns = patterns('',
(r'^polls/$', 'polls.views.index'),
..)),
)

What I understand here is that "patterns", "include" and "url" modules
are imported.

After the result of the function "patterns" is assigned to
"urlpatterns". AS Daniel said that a function can't be imported, this
means that a method can be called (but not imported) or this means
that a function and a method are not the same thing ?

Regards

Alain

On 17 oct, 08:53, Webb Newbie  wrote:
> "models" is a module that contains classes Model and CharField.
>
> Person inherits from Model.
>
> first_name and last_name are instances of CharField.
>
> There's no functional programming here.
>
> -WN.
>
>
>
>
>
>
>
> On Sun, Oct 16, 2011 at 6:43 PM, youpsla  wrote:
> > 1 from django.db import models
> > 2
> > 3 class Person(models.Model):
> > 4     first_name = models.CharField(max_length=30)
> > 5     last_name = models.CharField(max_length=30)

-- 
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: models.Model

2011-10-17 Thread youpsla
Thanks you 2 for your answers.

I think I've understood now. Again I apologize for the newby Python
question but I've read three times "Dive in Python" and it hasn't made
me thnigs clear. That's the reason why I've posted.

I thought there was a hierarchy like this models.Model.CharField 

That's the reason why I didn't understood.

Daniel, you said, that a method can be imported, this mean that an
external method (method from a class like Model) can't be used
directly in the Person class for example ?

If I understand well, in "first_name =
models.CharField(max_length=30)", first_name is an instance of class
CharField. This instance send "30" to the "max_length" parameter of
class CharField. This parameter is used by an internal method of class
CharFiled. Is that right ? :-)

Thanks again to all

Regards

Alain



On 17 oct, 08:53, Webb Newbie  wrote:
> "models" is a module that contains classes Model and CharField.
>
> Person inherits from Model.
>
> first_name and last_name are instances of CharField.
>
> There's no functional programming here.
>
> -WN.
>
>
>
>
>
>
>
> On Sun, Oct 16, 2011 at 6:43 PM, youpsla  wrote:
> > 1 from django.db import models
> > 2
> > 3 class Person(models.Model):
> > 4     first_name = models.CharField(max_length=30)
> > 5     last_name = models.CharField(max_length=30)

-- 
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: Newbee question about PostgreSQL

2011-10-17 Thread Simon Riggs
On Mon, Oct 17, 2011 at 11:58 AM, kenneth gonsalves
 wrote:
> On Mon, 2011-10-17 at 03:00 -0700, Nico wrote:
>> So I tried the command line:
>>    psql myproject george -W
>> This prompted my for the password of george and then returned an
>> error:
>>    psql: FATAL:  Ident authentication failed for user "george"
>
> find pg_hba.conf and change 'ident' to 'password' on the lines at the
> end of the file

Changing the rules in that way would break all existing connections.

You should always use md5 rather than password, since the latter
doesn't encrypt the password.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
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: Newbee question about PostgreSQL

2011-10-17 Thread Simon Riggs
On Mon, Oct 17, 2011 at 11:00 AM, Nico  wrote:
> Hi, I am new to Django AND PostgreSQL. I want to setup a PostgreSQL
> backend.
>
> I have created a database
>    createdb myproject
> Then, as superuser in psql:
>    CREATE USER george WITH PASSWORD 'password';
>    GRANT ALL PRIVILEGES ON DATABASE money TO george;
> Then I added this info in settings.py
>
> But, Django gives me an exception:
>   Ident authentication failed for user "george"
>
> So I tried the command line:
>   psql myproject george -W
> This prompted my for the password of george and then returned an
> error:
>   psql: FATAL:  Ident authentication failed for user "george"
>
> For now I have entered my superuser name in settings.py, so I could
> syncdb. The application works. But, of course I need to get this
> working with the user 'george' (fake name for this example) too, so I
> can use that in production environment.
>
> What am I doing wrong?

You need to set your pg_hba.conf settings to allow the user to connect.

The default config on Debian/Ubuntu is to allow you to connect to
Postgres as the same username as the OS user.

This can be modified to allow whatever authentication rule you wish,
per the manual.
http://developer.postgresql.org/pgdocs/postgres/client-authentication.html
or other docs depending upon your db version.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
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: Newbee question about PostgreSQL

2011-10-17 Thread kenneth gonsalves
On Mon, 2011-10-17 at 03:00 -0700, Nico wrote:
> So I tried the command line:
>psql myproject george -W
> This prompted my for the password of george and then returned an
> error:
>psql: FATAL:  Ident authentication failed for user "george" 

find pg_hba.conf and change 'ident' to 'password' on the lines at the
end of the file
-- 
regards
Kenneth Gonsalves

-- 
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: models.Model

2011-10-17 Thread Webb Newbie
"models" is a module that contains classes Model and CharField.

Person inherits from Model.

first_name and last_name are instances of CharField.

There's no functional programming here.

-WN.

On Sun, Oct 16, 2011 at 6:43 PM, youpsla  wrote:

> 1 from django.db import models
> 2
> 3 class Person(models.Model):
> 4 first_name = models.CharField(max_length=30)
> 5 last_name = models.CharField(max_length=30)
>

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



Tutorial help: Make the poll app modifiable in the admin

2011-10-17 Thread Daniel
Hello i am progressing well on the tutorial here:
https://docs.djangoproject.com/en/1.3/intro/tutorial02/
however, I am stuck on Make the poll app modifiable in the admin.

I have created an admin.py file within my polls directory. with the
suggested code. However I keep getting this error ImportError: No
module named polls.models

any suggestions??

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



Newbee question about PostgreSQL

2011-10-17 Thread Nico
Hi, I am new to Django AND PostgreSQL. I want to setup a PostgreSQL
backend.

I have created a database
createdb myproject
Then, as superuser in psql:
CREATE USER george WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE money TO george;
Then I added this info in settings.py

But, Django gives me an exception:
   Ident authentication failed for user "george"

So I tried the command line:
   psql myproject george -W
This prompted my for the password of george and then returned an
error:
   psql: FATAL:  Ident authentication failed for user "george"

For now I have entered my superuser name in settings.py, so I could
syncdb. The application works. But, of course I need to get this
working with the user 'george' (fake name for this example) too, so I
can use that in production environment.

What am I doing wrong?

Thanks in advance!

Nico

-- 
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: models.Model

2011-10-17 Thread Daniel Roseman
On Sunday, 16 October 2011 23:43:56 UTC+1, youpsla wrote:
>
> Hello, 
> I'm new to Django and I've only a medium background in funtionnal 
> programming in Python. 
>
> I'm currently reading and working on the Django tutorial. I've few 
> questions on a example of code because things are not so clear for me. 
>
> Here is the code example 
>
> 1 from django.db import models 
> 2 
> 3 class Person(models.Model): 
> 4 first_name = models.CharField(max_length=30) 
> 5 last_name = models.CharField(max_length=30) 
>
> Can you say me if I'm wrong or not on the followings: 
>
> - line 1 : Import of the" models" method from the "django.db" 
> module ? 
>
> - line 3 : Définition of the "Person" classs wich heritates from the 
> "models.Model class ? If true, and assuming that "models" is a method, 
> a class can be nested in a method ? 
>
> - ligne 4 : Creation of variable "first_name" by calling the method 
> CharField with one argument. But how "CharFiled" is written, isn't it 
> a class ? ANd here we use only "models", then why on line 3 we use 
> "models.Model" ? 
>
> I hope it's not to much confusing  :-) 
>
> Help would be REALLY appreciated !!! 
>
> Regards 
>
> Alain



This is fairly basic stuff - sounds like you would benefit from doing an 
introductory Python tutorial.

At the root of your confusion, I think, is that you're mixing up methods and 
modules. `models` in the code above is a module[*] containing multiple 
classes. You can't import a method, as that's simply a function belonging to 
a class. You can import modules - `from django.db import models` - or 
elements such as classes and constants directly inside a module - `from 
django.db.models import Model`.

So, the `models` module includes a class named Model, and also several other 
classes which represent fields - CharField, BooleanField, etc. All of these 
live directly inside the models namespace, so are referred to in exactly the 
same way - models.Model, models.CharField, etc.
--
DR.

[*] Yes, strictly speaking it's a package, but that's probably too confusing 
at this stage

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