Re: Recommendations for a Django development book?

2009-07-22 Thread Marco Buttu

On Tue, 2009-07-21 at 09:36 -0700, Stodge wrote:

> What is currently the best Django development book?

My favorites are "The Definitive Guide to Django" (2nd edition), also
called djangobook:

http://www.djangobook.com/en/2.0/

and "Pratical Django Projects" (2nd edition):

http://www.apress.com/book/view/1430219386

They are complementary. The first is a wonderful book, mainly suited for
beginners, and the second is very useful for more advanced readers.

-- 
Marco Buttu | www.pypeople.com




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



Re: Django model problem

2009-04-03 Thread Marco Buttu

On Fri, 2009-04-03 at 13:14 -0700, Albert wrote:
> 
> class Musician(models.Model):
> first_name = models.CharField(max_length=50)
> last_name = models.CharField(max_length=50)
> 
> class Album(models.Model):
> artist = models.ForeignKey(Musician)
> name = models.CharField(max_length=100)
> 
> 
> Now in `Musician` I want to add a field "last_album".
> How can I do that? I'd like to be able to write:
> 
> m = Musician(pk=1)
> print m.last_album.name

I suggest you this solution:

class Musician(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
albums = models.ManyToManyField("Album")

def last_album(self):
return self.albums.order_by("pub_date")[-1]

class Album(models.Model):
artist = models.ForeignKey(Musician)
name = models.CharField(max_length=100)
pub_date = models.DateField()

-- 
Marco Buttu




--~--~-~--~~~---~--~~
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: http links without using URLs.py

2009-01-27 Thread Marco Buttu

On Tue, 2009-01-27 at 08:42 -0800, May wrote:

> I'm converting PHP pages to Django.  I'm using base.html  for my
> formatting.  I've included the left-side bar in the base.html, which
> includes links that do not require using a database, such as the
> "contact us" page.  Since I'm using localhost for testing my link
> looks something like this:
> 
> http://127.0.0.1/contactus.html/; >Contact Us
> 
> Since the left-side bar is in base.html when the link is selected
> django requires that I place the link in the URL.py and include it in
> View.py.  I have many links like this and would prefer that the links
> go directly to the page ignoring the django requests.

If you want to bypass the view you can try direct_to_template:

http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-simple-direct-to-template


-- 
Marco Buttu




--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-08 Thread Marco Buttu

On Wed, 2009-01-07 at 13:06 +, Adam Stein wrote:

> I have omnicomplete working (haven't used it too much yet).  I have
> this
> in my $HOME/.vimrc file:
...
> Also, I have vim starting automatically importing the Django db.  I
> have
> a little script (below) that will automatically find my settings.py
> file
> and start vim.  I do this by starting at the location of the file on
> the
> vim command line and working upwards in the directory structure until
> I
> find it:
...
> I only use Django on Unix/Linux so I'm guessing it would need some
> tweaking for Windows.

I am using PySmell to autocomplete Django code, but I think omnicomplete
is better. Tomorrow I'll try it :-)
Thanks
-- 
Marco Buttu


--~--~-~--~~~---~--~~
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: ManyToManyField with extra content and Django admin

2008-10-16 Thread Marco Buttu

On Wed, 2008-10-15 at 21:21 -0700, Brandon Taylor wrote:

> Hi everyone,

Hi Brandon

> I'm using 1.0 final. I have the following models:
> 
> Page
> SidebarModule
> PageSidebarModule (the intermediary table)
> ... 
> The admin no longer shows Sidebar Modules as a fieldset. In fact, it
> doesn't show at all.
> ... 

Maybe this one:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-many-to-many-intermediary-models

but I think there is a problem about managemant of intermadiary models
by admin interface:

http://groups.google.com/group/django-users/browse_thread/thread/141d50f3b91ee877

Regards,
-- 
Marco Buttu


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



ManyToMany via intemediary model and admin interface

2008-10-08 Thread Marco Buttu

Hi. I wrote an intemediary model like this one:

http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships

## models.py #

from django.db import models

class Person(models.Model):
name = models.CharField(max_length=128)


class Group(models.Model):
name = models.CharField(max_length=128)
members = models.ManyToManyField(Person, through='Membership')


class Membership(models.Model):
person = models.ForeignKey(Person)
group = models.ForeignKey(Group)
invite_reason = models.CharField(max_length=64)

## admin.py #

from django.contrib import admin
from intermediary_test.models import Person, Group, Membership

class MembershipInline(admin.TabularInline):
model = Membership
extra = 1


class GroupAdmin(admin.ModelAdmin):
inlines = (MembershipInline,)

admin.site.register(Person)
admin.site.register(Group, GroupAdmin)

##

The problem is that by the admin interface I can't add more than
two persons in a group (adding them by ``save and continue editing''). 
Here's what happens when I try to add another person:

http://www.nanoelectronic.net/temp/intermediary.png

I don't have any problem adding more than two persons 
in a group by shell instead.
Any suggestion? Thanks in advance,
-- 
Marco




--~--~-~--~~~---~--~~
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: Error while importing URLconf '{{ project_name }}.urls'...

2008-05-29 Thread Marco Buttu

On Thu, 2008-05-29 at 06:56 -0700, nib wrote:

> As you can see there is not reference to {{ project_name }}.urls in
> this file, there is a reference in settings.py, I changed it to:
> ROOT_URLCONF = 'CSP.urls'
> 
> but now I get the same error as above but with this reference:
> Error while importing URLconf 'csp.urls': No module named csp.urls

Why in the ROOT_URLCONF ``CSP'' is uppercase and in the error message it
is lowercase?

-- 
Marco Buttu


--~--~-~--~~~---~--~~
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 newbie with an install problem - bad interpreter

2008-05-20 Thread Marco Buttu

On Tue, 2008-05-20 at 05:23 -0700, lorax wrote:

> I tried to execute the command django-admin.py startproject mysite.
> That gave me an error:
> 
> -sh: /usr/local/Django-0.96.2/django/bin/django-admin.py: /usr/bin/
> env: bad interpreter: No such file or directory
> 
> I thought my symlink might be bad so I tried executing the command
> using the full path to django-admin.py which gave me the same message.

You can try without use env:

python /usr/local/Django-0.96.2/django/bin/django-admin.py startproject
mysite

-- 
Marco Buttu


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