Re: Askani

2010-11-20 Thread Joseph (Driftwood Cove Designs)
Alvaro -
this is a nifty idea - will save time and improve consistency.

Opens up model proto-typing to non-Django, non-Python, maybe even non-
programmer?  Could be used for collaboration during model design -
especially if it presents an ER'ish diagram as you build the data
model.

look forward to seeing this progress - nice work.

cheers.
...Joseph

On Nov 20, 6:56 pm, Alvaro Mouriño  wrote:
> 2010/11/21 Huy Ton That :
>
> > Behaves the same way with Opera 10 and chrome.
> > click new model
> > typed in 'testmodel'
> > in testmodel added 'testfield'. doubleclicked on charfield testfield
> > clicked on model fields docs link
> > opens 9 tabs in background, hm, in chrome it was just 2...
>
> I could reproduce it following those steps. Thanks, I'm working on
> this strange bug.
>
> --
> Alvaro Mouriñohttp://askani.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User model optional

2010-11-20 Thread Joseph (Driftwood Cove Designs)
You can - it's just Python, so you can do virtually anything - auth is
a contrib module, so you can just choose not to use it.
But the User model does a ton of work and is hooked into many other
modules - including all the base auth layer you might want to build
your custom authorization on top of.

might be better to port the data into the User model (maybe with a
related custom Profile class for extra profile info) and write a
facade and custom forms to present your preferred naming conventions
to the rest of your system?

just a thought...

On Nov 20, 2:55 pm, VB  wrote:
> I'm interested in porting a custom CMS from Rails to Django. We
> currently have a User model and I would like to keep it intact, keep
> naming conventions, etc. So, two questions:
>
> If I intend to write my own authentication, can I use my define my own
> User model? Or, am I better off naming the model something else?
>
> Thanks in advance.
>
> VB

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



Re: problems with model inheritance if base class is not abstract

2010-11-20 Thread Joseph (Driftwood Cove Designs)
Ramiro - you made my day.  Somehow I missed this little tid bit in the
docs - what a super handy feature!! thank you.

On Nov 20, 4:36 pm, Ramiro Morales  wrote:
> On Sat, Nov 20, 2010 at 7:59 AM, marco.ferrag...@gmail.com
>
>
>
>  wrote:
> > Hi all! I'm new to django and I'm experimenting with models but I have
> > some trouble. I've minimized my problem to this code:
>
> > class TestBase(models.Model):
> >    base = models.CharField(max_length=255)
>
> > from django.contrib import admin
> > class TestA(TestBase):
> >    testb = models.CharField(max_length=255)
>
> > admin.site.register(TestA)
>
> > class TestB(TestBase):
> >    testc = models.CharField(max_length=255)
>
> > admin.site.register(TestB)
>
> > Trying to add TestA instances from admin interface I have this error:
> > Cannot assign "''": "TestA.testb" must be a "TestB" instance.
>
> > why testb should be a TestB instance?? It's a simple field!
>
> I suspect this is because of something that is described in the MTI docs:
>
> http://docs.djangoproject.com/en/1.2/topics/db/models/#multi-table-in...
>
> Translated to you example the relevant paragraph says:
>
> "If you have a TestBase that is also a TestB, you can get from the TestBase
> object to the TestB object by using the lower-case version of the model name:
>
> >>> p = TestBase.objects.get(id=12)
>
> # If p is a TestB object, this will give the child class:>>> p.testb
>
> 
>
> "
>
> The TestA model is inheriting that 'testb' accesor from TestBase to TestB
> and it is clashing with the identically named field.
>
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: database relationships, many to one

2010-11-20 Thread Joseph (Driftwood Cove Designs)
unless a dept. can belong to several Universities (?), Carlos has the
right model.

On Nov 20, 8:23 pm, Carlos Daniel Ruvalcaba Valenzuela
 wrote:
> Depends on you requirements, you could have used a Foreign Key to the
> University on the Department model and marking it as required, thus
> there cannot be a Department without university and set the
> related_name property on the ForeignKey to the "departments" so you
> can access University.departments property for the list of
> departments.
>
> You may not want this if you only want to have 1 kind of department
> which will be linked to many universities, but I see this may not be
> the case, thus your models may end like this:
>
> class departments(models.Model):
>
>         GENDER = ((u'M', u'Male'),(u'F', u'Female'),)
>
>         university = models.ForeignKey(university, related_name="departments")
>         name = models.CharField(max_length=60)
>         head_name = models.CharField(max_length=60)
>         head_email = models.EmailField(max_length=60)
>         head_gender = models.CharField(max_length=2, choices=GENDER)
>
> Regards,
> Carlos Ruvalcaba
>
> On Sat, Nov 20, 2010 at 6:19 PM, Bruno Amaral  wrote:
> > I have been trying to create a database for Universities, Departments
> > and Courses.
>
> > The idea is that a University has many departments, which in turn have
> > one or more courses.
>
> > So far, this model works:http://dpaste.com/277850/
>
> > With one caveat, it allows a department to exist without a University
> > linked to it.
>
> > I am at a loss here, even after reading over all the documentation I
> > could find on the website, does anyone have an idea on what I am doing
> > wrong, or where I should look for a solution?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



Re: Multiple inheritance model

2010-11-20 Thread Joseph (Driftwood Cove Designs)
Below is the basic layout - I posted a simplified version of the two
model classes here: http://pastebin.com/Xc3KLrQx

ModelA.save():
   if (some condition):
  super().save_base()
   else:
 super().save()

ModelB.save():
   is_new_model = pk == None
   super().save()
   if (is_new_model):
   do some stuff
   else:  # update
   do some other stuff


On Nov 20, 5:06 am, Marc Aymerich  wrote:
> On Sat, Nov 20, 2010 at 4:37 AM, Joseph (Driftwood Cove Designs) <
>
>
>
> powderfl...@gmail.com> wrote:
> > I'm trying to integrate two existing apps, both of which provide a
> > django Model - call them ModelA and ModelB - my app's model needs to
> > inherit from both of these.
> > I know django models support multiple inheritance, but both ModelA and
> > ModelB define a Meta class, override the save() method, etc., so that
> > won't work.
>
> > What will work very nicely is for ModelB to simply inherit from
> > ModelA, but since both are 3rd party apps, I don't want to hack their
> > code.
>
> > So, I need a clever idea for how I can take this inheritance
> > hierarchy:
>
> >   django.Model
> >     /            \
> >  ModelA   ModelB
> >      \           /
> >      MyModel
>
> > and **logically** convert it, without touching code in ModelA or
> > ModelB, to this:
>
> >   django.Model
> >            |
> >       ModelA
> >            |
> >       ModelB
> >            |
> >       MyModel
>
> > One idea I had was this:
> >   class MyModel(ModelA, ModelB):
> >         ...
> >         Meta:
> >             # copy of ModelB's Meta code
>
> >         def foo(self, *args, **kwargs):
> >              ModelA.foo(self, *args, **kwargs)
> >              ModelB.foo(self, *args, **kwargs)
>
> > But this approach fails on the save() - both Models do some processing
> > before and after the call to super.save().
>
> Hi,
> How ModelA and ModelB save method looks like?
>
> --
> Marc

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



Re: database relationships, many to one

2010-11-20 Thread Carlos Daniel Ruvalcaba Valenzuela
Depends on you requirements, you could have used a Foreign Key to the
University on the Department model and marking it as required, thus
there cannot be a Department without university and set the
related_name property on the ForeignKey to the "departments" so you
can access University.departments property for the list of
departments.

You may not want this if you only want to have 1 kind of department
which will be linked to many universities, but I see this may not be
the case, thus your models may end like this:

class departments(models.Model):

GENDER = ((u'M', u'Male'),(u'F', u'Female'),)

university = models.ForeignKey(university, related_name="departments")
name = models.CharField(max_length=60)
head_name = models.CharField(max_length=60)
head_email = models.EmailField(max_length=60)
head_gender = models.CharField(max_length=2, choices=GENDER)

Regards,
Carlos Ruvalcaba

On Sat, Nov 20, 2010 at 6:19 PM, Bruno Amaral  wrote:
> I have been trying to create a database for Universities, Departments
> and Courses.
>
> The idea is that a University has many departments, which in turn have
> one or more courses.
>
> So far, this model works: http://dpaste.com/277850/
>
> With one caveat, it allows a department to exist without a University
> linked to it.
>
> I am at a loss here, even after reading over all the documentation I
> could find on the website, does anyone have an idea on what I am doing
> wrong, or where I should look for a solution?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



database relationships, many to one

2010-11-20 Thread Bruno Amaral
I have been trying to create a database for Universities, Departments
and Courses.

The idea is that a University has many departments, which in turn have
one or more courses.

So far, this model works: http://dpaste.com/277850/

With one caveat, it allows a department to exist without a University
linked to it.

I am at a loss here, even after reading over all the documentation I
could find on the website, does anyone have an idea on what I am doing
wrong, or where I should look for a solution?

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



Re: [RFC] Askani

2010-11-20 Thread Alvaro Mouriño
2010/11/21 Huy Ton That :
> Behaves the same way with Opera 10 and chrome.
> click new model
> typed in 'testmodel'
> in testmodel added 'testfield'. doubleclicked on charfield testfield
> clicked on model fields docs link
> opens 9 tabs in background, hm, in chrome it was just 2...

I could reproduce it following those steps. Thanks, I'm working on
this strange bug.

-- 
Alvaro Mouriño
http://askani.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [RFC] Askani

2010-11-20 Thread Huy Ton That
Behaves the same way with Opera 10 and chrome.

click new model
typed in 'testmodel'
in testmodel added 'testfield'. doubleclicked on charfield testfield
clicked on model fields docs link
opens 9 tabs in background, hm, in chrome it was just 2...

On Sat, Nov 20, 2010 at 9:11 PM, Alvaro Mouriño  wrote:

> 2010/11/20 Huy Ton That :
> > From a visualizing data standpoint, I think it is very good. Model help
> on
> > the web opens three tabs though. For what it is intended for, I think it
> is
> > superior to a CLI.
>
> Hi. I couldn't reproduce the bugs you mention. Which link are you
> clicking on? There are two links to django docs, in metadata options
> and field edition. I just tried both and work fine. Which browser are
> you using?
>
> Thanks for the feedback.
>
> --
> Alvaro Mouriño
> http://askani.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: [RFC] Askani

2010-11-20 Thread RadicalEd
I didn't see it, thanks is an easy way.

On Sat, Nov 20, 2010 at 9:11 PM, Alvaro Mouriño  wrote:

> 2010/11/20 Huy Ton That :
> > From a visualizing data standpoint, I think it is very good. Model help
> on
> > the web opens three tabs though. For what it is intended for, I think it
> is
> > superior to a CLI.
>
> Hi. I couldn't reproduce the bugs you mention. Which link are you
> clicking on? There are two links to django docs, in metadata options
> and field edition. I just tried both and work fine. Which browser are
> you using?
>
> Thanks for the feedback.
>
> --
> Alvaro Mouriño
> http://askani.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
The past are just memories, the future are just dreams!!!
http://foros.solocodigo.com
http://radicalpython.blogspot.com
http://revistacodigolatino.blogspot.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [RFC] Askani

2010-11-20 Thread Alvaro Mouriño
2010/11/20 Huy Ton That :
> From a visualizing data standpoint, I think it is very good. Model help on
> the web opens three tabs though. For what it is intended for, I think it is
> superior to a CLI.

Hi. I couldn't reproduce the bugs you mention. Which link are you
clicking on? There are two links to django docs, in metadata options
and field edition. I just tried both and work fine. Which browser are
you using?

Thanks for the feedback.

-- 
Alvaro Mouriño
http://askani.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [RFC] Askani

2010-11-20 Thread Alvaro Mouriño
2010/11/20 RadicalEd :
> Is awesome, I will start an app tomorrow and I'll use it to make me the life
> easier, I'm thinking in combox with the different types of data (CharField,
> DateField, etc)

When you create a field you can edit it by double-clicking it. In the
edition dialog the system autocompletes the field as you type. I
thought that it was faster than choosing from a combo because you
usually know which field you need. In case you don't the whole list
appears when you type "field" (or just "fi" actually)

Methods are also editable the same way but you don't get completion.
On the other hand, the system validates the arguments. For example,
you can't have any more arguments after a keyword argument (**) and so
on.

How could I make field and method edition more "obvious"? Thanks for
the feedback!

-- 
Alvaro Mouriño
http://askani.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [RFC] Askani

2010-11-20 Thread Huy Ton That
>From a visualizing data standpoint, I think it is very good. Model help on
the web opens three tabs though. For what it is intended for, I think it is
superior to a CLI.

On Nov 20, 2010 8:33 PM, "Alvaro Mouriño"  wrote:

2010/11/20 rafael.nu...@gmail.com :

> Didn't you consider a command-line tool to do that, like Rails scaffold?
> Would be nice.
Hi Rafael.

Sorry but I never used Rails, I thought scaffolds were something
different. Could you please explain your idea a little?

Anyway, I think a graphical interface helps you see the relevant
information clearly and hide the bits you don't need. It also helps
you sketch ideas quickly. I'm very used to CLI (I use debian and coded
askani in vim) but I believe that a GUI really makes a difference.


Regards,

-- 
Alvaro Mouriño
http://askani.net/

-- 
You received this message because you are subs...

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



Re: [RFC] Askani

2010-11-20 Thread RadicalEd
Is awesome, I will start an app tomorrow and I'll use it to make me the life
easier, I'm thinking in combox with the different types of data (CharField,
DateField, etc)

On Sat, Nov 20, 2010 at 8:33 PM, Alvaro Mouriño  wrote:

> 2010/11/20 rafael.nu...@gmail.com :
> > Didn't you consider a command-line tool to do that, like Rails scaffold?
> > Would be nice.
>
> Hi Rafael.
>
> Sorry but I never used Rails, I thought scaffolds were something
> different. Could you please explain your idea a little?
>
> Anyway, I think a graphical interface helps you see the relevant
> information clearly and hide the bits you don't need. It also helps
> you sketch ideas quickly. I'm very used to CLI (I use debian and coded
> askani in vim) but I believe that a GUI really makes a difference.
>
> Regards,
>
> --
> Alvaro Mouriño
> http://askani.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
The past are just memories, the future are just dreams!!!
http://foros.solocodigo.com
http://radicalpython.blogspot.com
http://revistacodigolatino.blogspot.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [RFC] Askani

2010-11-20 Thread Alvaro Mouriño
2010/11/20 rafael.nu...@gmail.com :
> Didn't you consider a command-line tool to do that, like Rails scaffold?
> Would be nice.

Hi Rafael.

Sorry but I never used Rails, I thought scaffolds were something
different. Could you please explain your idea a little?

Anyway, I think a graphical interface helps you see the relevant
information clearly and hide the bits you don't need. It also helps
you sketch ideas quickly. I'm very used to CLI (I use debian and coded
askani in vim) but I believe that a GUI really makes a difference.

Regards,

-- 
Alvaro Mouriño
http://askani.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: problems with model inheritance if base class is not abstract

2010-11-20 Thread Ramiro Morales
On Sat, Nov 20, 2010 at 7:59 AM, marco.ferrag...@gmail.com
 wrote:
> Hi all! I'm new to django and I'm experimenting with models but I have
> some trouble. I've minimized my problem to this code:
>
> class TestBase(models.Model):
>    base = models.CharField(max_length=255)
>
> from django.contrib import admin
> class TestA(TestBase):
>    testb = models.CharField(max_length=255)
>
> admin.site.register(TestA)
>
> class TestB(TestBase):
>    testc = models.CharField(max_length=255)
>
> admin.site.register(TestB)
>
> Trying to add TestA instances from admin interface I have this error:
> Cannot assign "''": "TestA.testb" must be a "TestB" instance.
>
> why testb should be a TestB instance?? It's a simple field!

I suspect this is because of something that is described in the MTI docs:

http://docs.djangoproject.com/en/1.2/topics/db/models/#multi-table-inheritance

Translated to you example the relevant paragraph says:

"If you have a TestBase that is also a TestB, you can get from the TestBase
object to the TestB object by using the lower-case version of the model name:

>>> p = TestBase.objects.get(id=12)
# If p is a TestB object, this will give the child class:
>>> p.testb


"

The TestA model is inheriting that 'testb' accesor from TestBase to TestB
and it is clashing with the identically named field.

-- 
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: problems with model inheritance if base class is not abstract

2010-11-20 Thread Michael Sprayberry


--- On Sat, 11/20/10, marco.ferrag...@gmail.com  
wrote:


From: marco.ferrag...@gmail.com 
Subject: problems with model inheritance if base class is not abstract
To: "Django users" 
Date: Saturday, November 20, 2010, 5:59 AM


Hi all! I'm new to django and I'm experimenting with models but I have
some trouble. I've minimized my problem to this code:

class TestBase(models.Model):
    base = models.CharField(max_length=255)

from django.contrib import admin
class TestA(TestBase):
    testb = models.CharField(max_length=255)

admin.site.register(TestA)

class TestB(TestBase):
    testc = models.CharField(max_length=255)

admin.site.register(TestB)

Trying to add TestA instances from admin interface I have this error:
Cannot assign "''": "TestA.testb" must be a "TestB" instance.

why testb should be a TestB instance?? It's a simple field!

If TestBase is declared as abstract using the internal Meta Class I no
more have the error. Is this a bug or there is something that I don't
understand?

Thanks in advance :)

I think your issue is in how you are registering
 
is should look like
 
admin.site.register(TestBase, TestA)
admin.site.register(TestBase, TestB)


  

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



User model optional

2010-11-20 Thread VB
I'm interested in porting a custom CMS from Rails to Django. We
currently have a User model and I would like to keep it intact, keep
naming conventions, etc. So, two questions:

If I intend to write my own authentication, can I use my define my own
User model? Or, am I better off naming the model something else?

Thanks in advance.

VB

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



Pydoc and security

2010-11-20 Thread Robert S
Hi
I'm trying generate documentation for a django project.

The obvious tool is pydoc, which does work.  The trouble is, pydoc
publishes everything ... including passwords.

Is there a simply way of controlling the output from pydoc?

TIA

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



Re: representing a possible future object in a form?

2010-11-20 Thread derek
Preston

Having not done this before (but maybe needing to soon...) the grid
approach seems the best solution.

Actually this is not really a Django issue per se; more a "mismatch"
between the "excel-type" view and the underlying database reality.
Django is just the middle-man, translating "filled-in holes" to clean
database records.

I would think there must be a neat JQuery interface one could
construct for the view?

Derek

On Nov 16, 1:01 am, Preston Holmes  wrote:
> This is a cart/horse pattern I run now and then, and while I can think
> of several sort of ugly ways to do it, I'm wondering if someone has a
> clean solution in Django.
>
> I'm going to use a gradebook as an example.  The goal is to present a
> user with a grid of lets say students and assignments to enter
> grades.  The models would be
>
> - Students
>
> - Assignments
>
> - Grades (a M2M between students and assignments)
>
> Now on the grade entry form, with multiple students and assignments,
> the grades don't yet exist for all students, and may not all be
> entered.  How does one generate the form for the possibilities,
> without pre-creating all the empty grades.
>
> It would be nice to use modelform here, but it seems that that the
> only way to do it is just with a form and then create objects for
> grades that get filled out in the view.  How do others solve this
> problem of representing a "possible future" object in a form that is
> then only optionally created if filled out.
>
> -Preston

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



Re: django-admin.py not functional on 64 bit Vista

2010-11-20 Thread michael11717
I just found the BitNami DjangoStack

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



Re: django-admin.py not functional on 64 bit Vista

2010-11-20 Thread michael11717
well, seems like the ole good-news/bad-news cliche:

it would seem that you are correct, it does not seem to be a problem
with version of windows;

however I am still not able to get Django functioning on my Widows
Vista




the only version of Django that I was able to find to install was
Django-1.2.3.tar.gz
which I decompressed and de-tared via Cygwin;
then ran "Python setup.py install" via MS-DOS Command Prompt "as
Administrator"

I'm thinking that perhaps the Django-1.2.3.tar.gz version is a Linux
version,
however like I say it was the only version I could find,
is there perhaps a Django-1.2.3.zip or Django-1.2.3.exe version
somewhere?


I'm now thinking that it might very well be a configuration problem

I tried "unsetting" "the environmental variable for
DJANGO_SETTING_MODULE" by commenting out:
# ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE" in __init__.py
however django-admin.py did not like that, and complained:
 File "C:\hp\bin\Python\lib\site-packages\django\conf
\__init__.py", line 32, in  _setup
 settings_module = os.environ[ENVIRONMENT_VARIABLE]
 NameError: global name 'ENVIRONMENT_VARIABLE' is not defined

I looked around a bit, however I can not figure out how to go about
configuring Django for Windows Vista


like I say, is there perhaps a Django-1.2.3.zip or Django-1.2.3.exe
version somewhere?
or might someone be able to explain how to configue Django for Windows
Vista?








the complete MS-DOS stack trace was:

 Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\michael>path
PATH=c:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows
\system32;
C:\Windows;C:\Windows\System32\Wbem;C:\hp\bin\Python;C:\Program Files
(x86)\Quic
kTime\QTSystem\;C:\cygwin;C:\Program Files (x86)\Google
\google_appengine\;C:\hp\
bin\Python\Lib\site-packages\django\bin

C:\Users\michael>django-admin.py startproject myproject
Usage: django-admin.py subcommand [options] [args]

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal
output,
2=all output
  --settings=SETTINGS   The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't
provided, the
DJANGO_SETTINGS_MODULE environment variable
will be
used.
  --pythonpath=PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
  --traceback   Print traceback on exception
  --version show program's version number and exit
  -h, --helpshow this help message and exit
Traceback (most recent call last):
  File "C:\hp\bin\Python\Lib\site-packages\django\bin\django-
admin.py", line 5,
in 
management.execute_from_command_line()
  File "C:\hp\bin\Python\lib\site-packages\django\core\management
\__init__.py",
line 429, in execute_from_command_line
utility.execute()
  File "C:\hp\bin\Python\lib\site-packages\django\core\management
\__init__.py",
line 368, in execute
sys.stderr.write(self.main_help_text() + '\n')
  File "C:\hp\bin\Python\lib\site-packages\django\core\management
\__init__.py",
line 239, in main_help_text
commands = get_commands().keys()
  File "C:\hp\bin\Python\lib\site-packages\django\core\management
\__init__.py",
line 101, in get_commands
apps = settings.INSTALLED_APPS
  File "C:\hp\bin\Python\lib\site-packages\django\utils
\functional.py", line 276
, in __getattr__
self._setup()
  File "C:\hp\bin\Python\lib\site-packages\django\conf\__init__.py",
line 32, in
 _setup
settings_module = os.environ[ENVIRONMENT_VARIABLE]
NameError: global name 'ENVIRONMENT_VARIABLE' is not defined

C:\Users\michael>











On Nov 19, 4:03 am, Robbington  wrote:
> Hi Micheal,
>
> Pretty sure it has nothing to do with your version of windows.
>
>  appended MS-DOS PATH: with "C:\hp\bin\Python\Lib\site-packages
> \django
> \bin"
> which allows me to run django-admin.py
>
> If you have installed Python and django propely, there is no need to
> append anything. It should work straight out the box.
>
> I'm thinking you disabled Django-admin.py by setting the environmental
> varible for DJANGO_SETTINGS_MODULE. Try unsetting it to see if that
> works.
>
> Rob

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



Re: [RFC] Askani

2010-11-20 Thread rafael.nu...@gmail.com
Didn't you consider a command-line tool to do that, like Rails scaffold?
Would be nice.



On Sat, Nov 20, 2010 at 12:28 PM, Alvaro Mouriño  wrote:

> Hi.
>
> I'd like to introduce to you this idea I've been working on for the
> last month, a django models generator: http://askani.net/
>
> Field options definition it's repetitive. Writing meta options leads
> to inconsistent use due to the variety available. "Inspired" by the
> repetitiveness of coding django models and the required memory load of
> defining meta options I decided to create a graphical interface that
> would guide the user in the creation of models.
>
> Askani.net is the result of scratching those itches. It represents
> models, fields, attributes and meta options in a UML-and-MER-ish way
> (but doesn't follow it strictly). It displays all the possible
> information for a model so the user only has to fill in the blanks the
> desired options, not remember all of them.
>
> The python code that outputs it's far from perfect, I know, this is
> just a barely-usable system to prove the concept, a prototype.
>
> The reason for this email is to request comments, suggestions and
> critics on the idea and specially on the usability. Clone the source,
> read the README file and play with it. Have fun =)
>
> Regards,
>
> --
> Alvaro Mouriño
> http://askani.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Cache problem after new image uploaded?

2010-11-20 Thread mathphreak
Are you sure that time.time() is evaluating rather than just being
text?  If you're just appending "?rand=time.time()" to your page, then
you'll be having the exact same problem.  If you're appending "?rand="
+ time.time() then you'll have better luck.

On Nov 19, 12:02 pm, vcarney  wrote:
> Doing a redirect to the page with ?rand=time.time() did not work
> either.
>
> On Nov 19, 12:47 pm, vcarney  wrote:
> > This can be replicated in ie8 100% of the time and FF about 10% of the
> > time.
>
> > On Nov 19, 12:42 pm, vcarney  wrote:
>
> > > I have a custom settings form with a photo field: photo =
> > > forms.ImageField(max_length=200, required=False)
>
> > > On submission with a new photo being uploaded, I delete any existing
> > > image including its parent folder and replace with the new one. When
> > > the settings page is reloaded, the old image is still displayed.
> > > However, if I do a power refresh in the browser, ctrl+F5 the cache is
> > > removed and the uploaded image displays fine.
>
> > > Here are some of the response headers from the server:
>
> > > HTTP/1.1 200 OK
> > > Server: nginx/0.7.65
> > > Date: Fri, 19 Nov 2010 18:32:38 GMT
> > > Content-Type: image/jpeg
> > > Connection: keep-alive
> > > Last-Modified: Fri, 19 Nov 2010 18:32:34 GMT
> > > Etag: "1a0685-d65-4956c214f7f1b"
> > > Accept-Ranges: bytes
> > > Content-Length: 3429

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



[RFC] Askani

2010-11-20 Thread Alvaro Mouriño
Hi.

I'd like to introduce to you this idea I've been working on for the
last month, a django models generator: http://askani.net/

Field options definition it's repetitive. Writing meta options leads
to inconsistent use due to the variety available. "Inspired" by the
repetitiveness of coding django models and the required memory load of
defining meta options I decided to create a graphical interface that
would guide the user in the creation of models.

Askani.net is the result of scratching those itches. It represents
models, fields, attributes and meta options in a UML-and-MER-ish way
(but doesn't follow it strictly). It displays all the possible
information for a model so the user only has to fill in the blanks the
desired options, not remember all of them.

The python code that outputs it's far from perfect, I know, this is
just a barely-usable system to prove the concept, a prototype.

The reason for this email is to request comments, suggestions and
critics on the idea and specially on the usability. Clone the source,
read the README file and play with it. Have fun =)

Regards,

-- 
Alvaro Mouriño
http://askani.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



problems with model inheritance if base class is not abstract

2010-11-20 Thread marco.ferrag...@gmail.com
Hi all! I'm new to django and I'm experimenting with models but I have
some trouble. I've minimized my problem to this code:

class TestBase(models.Model):
base = models.CharField(max_length=255)

from django.contrib import admin
class TestA(TestBase):
testb = models.CharField(max_length=255)

admin.site.register(TestA)

class TestB(TestBase):
testc = models.CharField(max_length=255)

admin.site.register(TestB)

Trying to add TestA instances from admin interface I have this error:
Cannot assign "''": "TestA.testb" must be a "TestB" instance.

why testb should be a TestB instance?? It's a simple field!

If TestBase is declared as abstract using the internal Meta Class I no
more have the error. Is this a bug or there is something that I don't
understand?

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Display ForeignKey label rather than ID in a CharField

2010-11-20 Thread Marcos Moyano
You need to specify the __unicode__ method of the model holding the Fish
object.
ie:
class FishHolder(models.Model):
name = models.CharField(...)
.
def __unicode__(self):
return self.name

That should display the names instead of the ids.

Rgds,
Marcos

On Fri, Nov 19, 2010 at 3:34 PM, Jamie Pittock wrote:

> I have to override the default display of a foreignkey field in a form
> and instead display it as a CharField.  Currently it displays the
> selection's ID but I need to display the label instead
>
> To be clear, the select option would be the default display for the
> ForeignKey.  At the moment after I've turned the display to a
> CharField it displays 23 in the field.  I need to display Fish.
>
> Fish
>
> Any help appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Some people, when confronted with a problem, think “I know, I'll use regular
expressions.” Now they have two problems.

Jamie Zawinski, in comp.emacs.xemacs

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



Re: A Model to store links to other models

2010-11-20 Thread Micah Carrick
I had not seen the generic relationships and ContentType. I'm going to play
with that a bit.

Thanks everybody!

2010/11/20 Łukasz Rekucki 

> On 20 November 2010 02:51, Micah Carrick  wrote:
> > I'm having trouble coming up with a pretty solution to a seemingly simple
> > task. I'm relatively new to Django.
> >
> > I want to allow the end user to control various lists of links on the
> site
> > used for navigation. The admin should allow the creation of "link groups"
> > which have a collection of "links". These links would reference a
> > pre-determined list of models. Let's say, for example, that there is a
> "link
> > group" created for the footer links of a website. In the admin section, a
> > user could add a link to a specific blog (from the Blog model), another
> link
> > to the about us page (flatpages), etc.
> >
> > In other words, I'm trying to associate individual records from a number
> of
> > tables together as a group of objects having a URL. I'm trying to find a
> > nice, abstract solution. Obviously I don't want actual URLs in the
> database.
> > This is something I would use frequently so I want to see if I can find
> or
> > write an app to do this--if I can come up with an elegant solution.
> >
> > This would be nice, but, I can't imagine how it could be possible:
> >
> >
> > class LinkGroup(models.Model):
> > site = models.ForeignKey(Site)
> > name = models.CharField()
> >
> > class Links(models.Model):
> > link_group = ForeignKey(LinkGroup)
> > model_type = ???
> > model_id = ForeignKey() # no
> can
> > do!
> > sort_order = PositiveIntegerField(default=100)
> >
> >
> > This is an idea, however, I don't like having to reference the import in
> the
> > DB. It's just begging for problems.
> >
> >
> > class LinkModel(models.Model):
> > name = models.CharField() # such as "Flat Page"
> > model = models.CharField() # such as "myapp.models.FlatPage"
> >
> > class LinkGroup(models.Model):
> > site = models.ForeignKey(Site)
> > name = models.CharField() # such as "Navigation Links"
> >
> > class Link(models.Model):
> > text = CharField() # such as "About Us"
> > link_group = ForeignKey(LinkGroup)
> > model = ForeignKey(LinkModel)
> > model_id = PositiveIntegerField() # such as the PK for the
> > myapp.models.FlatPage model
> > sort_order = PositiveIntegerField(default=100)
> >
> >
> > Any suggestions?
>
> You should checkout generic foreign keys[1]. It's a standard way of
> building models that need to reference rows in more then one table. So
> your models would be something like this:
>
> from django.contrib.contenttypes.models import ContentType
> from django.contrib.contenttypes import generic
>
> class LinkGroup(models.Model):
>site = models.ForeignKey(Site)
>name = models.CharField() # such as "Navigation Links"
>
> class Link(models.Model):
> link_group = ForeignKey(LinkGroup)
>content_type = models.ForeignKey(ContentType)
>object_id = models.PositiveIntegerField()
>linked_object = generic.GenericForeignKey('content_type', 'object_id')
>
>
> [1]:
> http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations
>
> --
> Łukasz Rekucki
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: I have an idea for a new tag

2010-11-20 Thread ringemup

Is there a reason you wouldn't do the sorting in the view before
passing it to the template?

On Nov 19, 11:55 am, Paweł Roman  wrote:
> When rendering dictionary, there is absolutely no way to display
> values sorted by keys. The only workaround is to copy all the dict
> items to a sortable structure e.g. list and pass the list to the
> template, instead of the dictionary.
>
> Why not introduce a new tag to solve this problem:
>
> I say, it should be called {%secretfor%} and the usage would be
>
> {%secretfor k,v in mydict %}
> ... do stuff
> {%endsecretfor%}
>
> would work like sorted(mydict.keys)
>
> I won't stick with the tag name, but you see my point.

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



Re: django charts

2010-11-20 Thread Darrel Herbst
I haven't used this, but this provides a way to interface with google
charts: 
https://github.com/jacobian/django-googlecharts/blob/master/docs/examples.txt

On Nov 19, 1:56 am, Priya  wrote:
> Hi,
> I am a new user to django ,can anybody please help me resolve this
> issue.I am trying to construct a Gant chart based on the certain
> constraints.Now i am unable to make a line of approach for this.I have
> defined a class for chart and defined function for it in views.Now how
> do i pass my values to the gant chart .
> So the idea is..i have n number of task who have deadlines.So i want
> to show thiese tasks thru a gant chart and then want to show a pie
> chart giving the perfomance eg. 4% work done til so and so date.
> Can anybody help me with the coding of all these.

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



Re: A Model to store links to other models

2010-11-20 Thread Łukasz Rekucki
On 20 November 2010 02:51, Micah Carrick  wrote:
> I'm having trouble coming up with a pretty solution to a seemingly simple
> task. I'm relatively new to Django.
>
> I want to allow the end user to control various lists of links on the site
> used for navigation. The admin should allow the creation of "link groups"
> which have a collection of "links". These links would reference a
> pre-determined list of models. Let's say, for example, that there is a "link
> group" created for the footer links of a website. In the admin section, a
> user could add a link to a specific blog (from the Blog model), another link
> to the about us page (flatpages), etc.
>
> In other words, I'm trying to associate individual records from a number of
> tables together as a group of objects having a URL. I'm trying to find a
> nice, abstract solution. Obviously I don't want actual URLs in the database.
> This is something I would use frequently so I want to see if I can find or
> write an app to do this--if I can come up with an elegant solution.
>
> This would be nice, but, I can't imagine how it could be possible:
>
>
> class LinkGroup(models.Model):
>     site = models.ForeignKey(Site)
>     name = models.CharField()
>
> class Links(models.Model):
>     link_group = ForeignKey(LinkGroup)
>     model_type = ???
>     model_id = ForeignKey() # no can
> do!
>     sort_order = PositiveIntegerField(default=100)
>
>
> This is an idea, however, I don't like having to reference the import in the
> DB. It's just begging for problems.
>
>
> class LinkModel(models.Model):
>     name = models.CharField() # such as "Flat Page"
>     model = models.CharField() # such as "myapp.models.FlatPage"
>
> class LinkGroup(models.Model):
>     site = models.ForeignKey(Site)
>     name = models.CharField() # such as "Navigation Links"
>
> class Link(models.Model):
>     text = CharField() # such as "About Us"
>     link_group = ForeignKey(LinkGroup)
>     model = ForeignKey(LinkModel)
>     model_id = PositiveIntegerField() # such as the PK for the
> myapp.models.FlatPage model
>     sort_order = PositiveIntegerField(default=100)
>
>
> Any suggestions?

You should checkout generic foreign keys[1]. It's a standard way of
building models that need to reference rows in more then one table. So
your models would be something like this:

from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

class LinkGroup(models.Model):
site = models.ForeignKey(Site)
name = models.CharField() # such as "Navigation Links"

class Link(models.Model):
link_group = ForeignKey(LinkGroup)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
linked_object = generic.GenericForeignKey('content_type', 'object_id')


[1]: 
http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations

-- 
Łukasz Rekucki

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



Re: A Model to store links to other models

2010-11-20 Thread Mark (Nosrednakram)
Hello Micah,

I'm not sure I understand what you're attempting to do but if so I'd
look at using a foreign key to ContentType, and storing the pk for
associating objects rather than a CharField.  The key is using
ContentType.model_class() to re-create the class.  This allows you to
store any object using two fields and re-generate it easly in two
calls.

Hope This Helps,
Mark

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



Re: Multiple inheritance model

2010-11-20 Thread Marc Aymerich
On Sat, Nov 20, 2010 at 4:37 AM, Joseph (Driftwood Cove Designs) <
powderfl...@gmail.com> wrote:

> I'm trying to integrate two existing apps, both of which provide a
> django Model - call them ModelA and ModelB - my app's model needs to
> inherit from both of these.
> I know django models support multiple inheritance, but both ModelA and
> ModelB define a Meta class, override the save() method, etc., so that
> won't work.
>
> What will work very nicely is for ModelB to simply inherit from
> ModelA, but since both are 3rd party apps, I don't want to hack their
> code.
>
> So, I need a clever idea for how I can take this inheritance
> hierarchy:
>
>   django.Model
> /\
>  ModelA   ModelB
>  \   /
>  MyModel
>
> and **logically** convert it, without touching code in ModelA or
> ModelB, to this:
>
>   django.Model
>|
>   ModelA
>|
>   ModelB
>|
>   MyModel
>
> One idea I had was this:
>   class MyModel(ModelA, ModelB):
> ...
> Meta:
> # copy of ModelB's Meta code
>
> def foo(self, *args, **kwargs):
>  ModelA.foo(self, *args, **kwargs)
>  ModelB.foo(self, *args, **kwargs)
>
> But this approach fails on the save() - both Models do some processing
> before and after the call to super.save().
>

Hi,
How ModelA and ModelB save method looks like?


-- 
Marc

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



Re: I have an idea for a new tag

2010-11-20 Thread Łukasz Rekucki
On 19 November 2010 19:53, Adam Hallett  wrote:
> Just a thought, what about:
>
> {% for k,v in mydict|order:'key' %}
>
> or
>
> {% for k,v in mydict orderby key %}

Here's a quick hack that works right now:

{% for k, v in mydict.items|dictsort:"0" %}
  {{ k }}: {{ v }}
{% endfor %}

> On Nov 19, 10:55 am, Paweł Roman  wrote:
>> When rendering dictionary, there is absolutely no way to display
>> values sorted by keys. The only workaround is to copy all the dict
>> items to a sortable structure e.g. list and pass the list to the
>> template, instead of the dictionary.

Keep in mind that sorting a built-in dictionary in Python will always
require some copying, because it's a hashtable. If you need a sorted
dictionary, you must write a new datastructure like in this recipe[1]

>>
>> Why not introduce a new tag to solve this problem:
>>
>> I say, it should be called {%secretfor%} and the usage would be
>>
>> {%secretfor k,v in mydict %}
>> ... do stuff
>> {%endsecretfor%}
>>
>> would work like sorted(mydict.keys)
>>
>> I won't stick with the tag name, but you see my point.

The name is *really* awkward - what does sorting have to do with "secret"?

-- 
Łukasz Rekucki

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



Conf/locale

2010-11-20 Thread Tsolmon Narantsogt
Hello fellows.

I'm using Django 1.1 version. My goals is create multiple language site.

I make po file
myprojectname/conf/locale/mn/LC_MESSAGES/django.po

and some msgid, msgstr.

But it's don't work.


My index.html
   {% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_current_language_bidi as LANGUAGE_BIDI %}




{% for lang in LANGUAGES %}

{{ lang.1 }}
{% endfor %}




 {% trans "current language" %}: {{ request.LANGUAGE_CODE }}
My urls.py

(r'^i18n/', include('django.conf.urls.i18n')),

Thanks.
Tsolmon

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



Re: -bash: django-admin.py: command not found

2010-11-20 Thread Robbington
You are welcome Errit,

Have fun Django-ing. :)

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



Re: Using the Django Admin to change a password.

2010-11-20 Thread Martin Melin
On Sat, Nov 20, 2010 at 10:44 AM, James Hancock  wrote:
> I have a strange problem and don't really know where to start looking to fix
> it. Can someone point me in the right direction to figure this one out.
>
>
> In the Admin interface when I try to use the  "change password form" on any
> of my users it gives me a
>
> "Page not found (404)
> Request Method:    GET
> Request URL:    http://goeigo.org/admin/auth/user/21/password/
> user object with primary key u'21/password' does not exist.
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard 404
> page.
> "
> error..
>
> I can change the passwords from the terminal and create users and stuff, but
> the admin page doesn't seem to work.
>
> Any hints?

I assume that the rest of the admin is working?

What version of Django are you using?

Have you done anything out of the ordinary in urls.py?

The problem seems to be that there is no URL pattern for the password
change form, which means the user edit URL pattern will match instead,
or that the pattern for password change comes after a broader pattern.

Regards,
Martin Melin

>
> Cheers,
> James Hancock
>
> P.S. I love django

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



Using the Django Admin to change a password.

2010-11-20 Thread James Hancock
I have a strange problem and don't really know where to start looking to fix
it. Can someone point me in the right direction to figure this one out.


In the Admin interface when I try to use the  "change password form" on any
of my users it gives me a

"Page not found (404)
Request Method:GET
Request URL:http://goeigo.org/admin/auth/user/21/password/
user object with primary key u'21/password' does not exist.
You're seeing this error because you have DEBUG = True in your Django
settings file. Change that to False, and Django will display a standard 404
page.
"
error..

I can change the passwords from the terminal and create users and stuff, but
the admin page doesn't seem to work.

Any hints?

Cheers,
James Hancock

P.S. I love django

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