Generate admin files. Views and Templates with Django?

2008-08-28 Thread Daniel A.

I'm a Rails switcher to Django. In Rails there's an option to generate
all the scaffold files, ie, there's a command line script that creates
all the files in the project folder of the admin interface. I want to
know if there's something similar for Django. 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: Many to One Relationship

2008-08-27 Thread Daniel A.

Thanks, now is working fine.

On 27 ago, 19:22, lingrlongr <[EMAIL PROTECTED]> wrote:
> The error is generated because you have two fields in the Swap model
> that refer to the User model, and two that refer to the Shifts model.
> As the error states you need to specify the related_name value for
> those ForeignKeys.  Take a look at the documentation for related_name
> here:http://www.djangoproject.com/documentation/model-api/#many-to-one-rel...
>
> class Swaps(models.Model):
>         origin_shift = models.ForeignKey(Shifts,
> related_name='origin_shift')
>         origin_user = models.ForeignKey(User,
> related_name='origin_user')
>         destination_shift = models.ForeignKey(Shifts,
> related_name='destination_shift')
>         state = models.CharField(maxlength=25)
>         swap_user = models.ForeignKey(User, related_name='swap_user')
>
> HTH
>
> Keith
>
> On Aug 27, 11:42 am, "Daniel A." <[EMAIL PROTECTED]> wrote:
>
> > Hi! I'm a switcher from Rails and I'm learning Django. I'm stuck with
> > something I thing should be easy but for some reason I can't find the
> > error.
>
> > I'm trying to define a model to manage shifts for volunteers. I have
> > three diferent models, Shifts, Users and Swaps. A User have many
> > Shifts and a Shift have many Swaps, while a Shift only have one User,
> > and a Swap only have one Shift. A Shift have two users. Well, then I
> > wrote something like this:
>
> > from django.db import models
> > from django.contrib.auth.models import User
>
> > # Create your models here.
> > class Shifts(models.Model):
> >     date = models.DateField()
> >     user_1 = models.ForeignKey(User)
> >     user_2 = models.ForeignKey(User)
> >     turno = models.IntegerField()
>
> > class Swaps(models.Model):
> >         origin_shift = models.ForeignKey(Shifts)
> >         origin_user = models.ForeignKey(User)
> >         destination_shift = models.ForeignKey(Shifts)
> >         state = models.CharField(maxlength=25)
> >         swap_user = models.ForeignKey(User)
>
> > Does anybody knows what I'm doing wrong? I get messages of validation
> > like this:
>
> > turno.shifts: Accessor for field 'user_1' clashes with related field
> > 'User.shifts_set'. Add a related_name argument to the definition for
> > 'user_1'.
> > turno.shifts: Accessor for field 'user_2' clashes with related field
> > 'User.shifts_set'. Add a related_name argument to the definition for
> > 'user_2'.
> > turno.swaps: Accessor for field 'origin_shift' clashes with related
> > field 'Shifts.swaps_set'. Add a related_name argument to the
> > definition for 'origin_shift'.
> > turno.swaps: Accessor for field 'origin_user' clashes with related
> > field 'User.swaps_set'. Add a related_name argument to the definition
> > for 'origin_user'.
> > turno.swaps: Accessor for field 'destination_shift' clashes with
> > related field 'Shifts.swaps_set'. Add a related_name argument to the
> > definition for 'destination_shift'.
> > turno.swaps: Accessor for field 'swap_user' clashes with related field
> > 'User.swaps_set'. Add a related_name argument to the definition for
> > 'swap_user'.
>
> > Thanks in advance.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Many to One Relationship

2008-08-27 Thread Daniel A.

Hi! I'm a switcher from Rails and I'm learning Django. I'm stuck with
something I thing should be easy but for some reason I can't find the
error.

I'm trying to define a model to manage shifts for volunteers. I have
three diferent models, Shifts, Users and Swaps. A User have many
Shifts and a Shift have many Swaps, while a Shift only have one User,
and a Swap only have one Shift. A Shift have two users. Well, then I
wrote something like this:


from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Shifts(models.Model):
date = models.DateField()
user_1 = models.ForeignKey(User)
user_2 = models.ForeignKey(User)
turno = models.IntegerField()

class Swaps(models.Model):
origin_shift = models.ForeignKey(Shifts)
origin_user = models.ForeignKey(User)
destination_shift = models.ForeignKey(Shifts)
state = models.CharField(maxlength=25)
swap_user = models.ForeignKey(User)


Does anybody knows what I'm doing wrong? I get messages of validation
like this:

turno.shifts: Accessor for field 'user_1' clashes with related field
'User.shifts_set'. Add a related_name argument to the definition for
'user_1'.
turno.shifts: Accessor for field 'user_2' clashes with related field
'User.shifts_set'. Add a related_name argument to the definition for
'user_2'.
turno.swaps: Accessor for field 'origin_shift' clashes with related
field 'Shifts.swaps_set'. Add a related_name argument to the
definition for 'origin_shift'.
turno.swaps: Accessor for field 'origin_user' clashes with related
field 'User.swaps_set'. Add a related_name argument to the definition
for 'origin_user'.
turno.swaps: Accessor for field 'destination_shift' clashes with
related field 'Shifts.swaps_set'. Add a related_name argument to the
definition for 'destination_shift'.
turno.swaps: Accessor for field 'swap_user' clashes with related field
'User.swaps_set'. Add a related_name argument to the definition for
'swap_user'.

Thanks in advance.

--~--~-~--~~~---~--~~
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: Request Context and Generic Views

2007-07-19 Thread Daniel A.

As has been mentioned, they all use a RequestContext to begin with,
but if you need additional custom variables to be exposed to your
template, then you can pass them as a dict for the extra_context
variable.

On Jul 19, 5:08 am, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> Hi there!
>
> How does it exactly work when I want a RequestContext to be used in a
> generic view. There's the context_processors key in the dict you gotta
> pass it, but "A list of template-context processors to apply to the
> view's template" doesn't really mean much to me, and even less after
> giving it a "list" and seeing python complain about callables ;)
>
> Might anyone give me an example of a dict I might pass a generic view?
>
> Thanks guys!
>
>  signature.asc
> 1KDownload


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