Re: forms.Form, models.Model, forms.ModelForm? (self.django)

2016-08-14 Thread Andrew Emory
for client facing POST requests? On Sunday, August 14, 2016 at 6:35:49 PM UTC-5, Alex Heyden wrote: > > forms.Form makes front-end widgets and some validation logic. models.Model > defines a database interface and wraps it in a Python class. The two have > nothing to do with each othe

Re: forms.Form, models.Model, forms.ModelForm? (self.django)

2016-08-14 Thread Alex Heyden
forms.Form makes front-end widgets and some validation logic. models.Model defines a database interface and wraps it in a Python class. The two have nothing to do with each other aside from vaguely similar APIs for defining the classes. The intersection of the two is forms.ModelForm, which uses a

forms.Form, models.Model, forms.ModelForm? (self.django)

2016-08-14 Thread Andrew Emory
Would someone explain to me when you would choose one class over the other? Does forms.Form not create a database? Can't you just render models.Model as a form? I understand forms.ModelForm is a helper class for creating a form from a model. But I still don't really understand why

Re: Pickling of dinamically created models.Model subclasses: "attribute lookup failed", django 1.5

2013-05-21 Thread akaariai
I have finally found the time to work on this issue. There is a patch in the ticket (https://code.djangoproject.com/ticket/20289), and I think the patch does solve the regression. I didn't find a simple test case that works in 1.4 but fails in 1.5. If anybody knows how to reproduce the original re

Re: Pickling of dinamically created models.Model subclasses: "attribute lookup failed", django 1.5

2013-04-18 Thread akaariai
On 18 huhti, 22:07, Greg H wrote: > Running into a similar issue on my own project, seems to be when you try an > cache a model which has a related model which in turn has a many to many > field. So for example, I have an instance of a Student, which has a > ForeignKey to Book, which in turn has a

Re: Pickling of dinamically created models.Model subclasses: "attribute lookup failed", django 1.5

2013-04-18 Thread Greg H
ango-audit-log>witch > actively creates dynamic models by calling type('%sAuditLogEntry' > % meta_name, (models.Model,), > attrs)<https://github.com/SirAnthony/django-audit-log/blob/master/audit_log/models/managers.py#L201>. > > In django 1.5 I getting error when

Pickling of dinamically created models.Model subclasses: "attribute lookup failed", django 1.5

2013-03-20 Thread Sir Anthony
Hello, I'm using django-audit-log <https://github.com/SirAnthony/django-audit-log>witch actively creates dynamic models by calling type('%sAuditLogEntry' % meta_name, (models.Model,), attrs)<https://github.com/SirAnthony/django-audit-log/blob/master/audit_log/models

Re: models.Model

2011-10-18 Thread Daniel Roseman
; 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) > >

Re: models.Model

2011-10-17 Thread youpsla
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 __in

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('',

Re: models.Model

2011-10-17 Thread Daniel Roseman
ot;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 traduc

Re: models.Model

2011-10-17 Thread youpsla
> 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):

Re: models.Model

2011-10-17 Thread youpsla
-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=

Re: models.Model

2011-10-17 Thread Webb Newbie
t; 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

Re: models.Model

2011-10-17 Thread Daniel Roseman
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) > &

models.Model

2011-10-16 Thread youpsla
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 ?

Re: Multiple inheritance from models.Model and admin.ModelAdmin

2011-05-31 Thread Lee
Discovered that save_model() is still available even if I don't inherit admin.ModelAdmin, which avoids the metaclass conflict. On May 31, 10:36 am, Lee wrote: > I'm trying to create a class that inherits from both models.Model and > admin.ModelAdmin, so that I can use models.Man

Multiple inheritance from models.Model and admin.ModelAdmin

2011-05-31 Thread Lee
I'm trying to create a class that inherits from both models.Model and admin.ModelAdmin, so that I can use models.ManyToManyField and save_model() from admin.ModelAdmin. Unfortunately this combination gives "metaclass conflict: the metaclass of a derived class must be a (non-strict) subcl

Re: Subclassing models.Model to extend base functionalities and attributes

2010-05-11 Thread thierry
No, I don't talk about model inheritance. Mainly because base class fields are propagated to subclasses. I'd like to overload some base methods of the "models.Model" class to making them available from all classes of a model. But a metaclass mechanism makes overloading impossib

Re: Subclassing models.Model to extend base functionalities and attributes

2010-05-07 Thread zinckiwi
Are you asking about factoring out certain common functionality shared between models? It's quite common; for example most of my projects have something like this as a starting point for many models: class DatestampedModel(models.Model): created = models.DateTimeField(default=datetim

Subclassing models.Model to extend base functionalities and attributes

2010-05-07 Thread thierry
Hi everybody, Is there a way to subclass the 'models.Model' class behavior to extend base functionnalities and attributes to all classes contained in an application model ? It seems that the metaclass mechanism force the Python inheritance notation to a Database model inheritanc

Re: constraint unique with models.Model

2009-12-27 Thread Marc Aymerich
On Mon, Dec 28, 2009 at 5:15 AM, Karen Tracey wrote: > On Sun, Dec 27, 2009 at 11:08 PM, Marc Aymerich wrote: > >> hi guys! >> >> I'm writing my first project with django and I have doubts in how to >> declare a constraint unique for two fields of the same tabl

Re: constraint unique with models.Model

2009-12-27 Thread Karen Tracey
On Sun, Dec 27, 2009 at 11:08 PM, Marc Aymerich wrote: > hi guys! > > I'm writing my first project with django and I have doubts in how to > declare a constraint unique for two fields of the same table using > models.Model. > See: http://docs.djangoproject.com/en/1.1/ref

constraint unique with models.Model

2009-12-27 Thread Marc Aymerich
hi guys! I'm writing my first project with django and I have doubts in how to declare a constraint unique for two fields of the same table using models.Model. In MySQL would be something like: CREATE TABLE `virtual_aliases` ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, domainid INT(11

Re: Determine subclass of object in models.Model

2009-02-07 Thread Frank Becker
2009/2/7 Frank Becker : Hi, > My question: I have a CommonInfo(models.Model) and I do subclassing it for a > couple of models. Getting CommonInfo.objects.all() returns a list of all > objects of CommonInfo and it's subclasses. Q: How to determine what subclass > the > obj

Determine subclass of object in models.Model

2009-02-07 Thread Frank Becker
Hi, First of all thanks for the Django framework. It's fun to work with it. My question: I have a CommonInfo(models.Model) and I do subclassing it for a couple of models. Getting CommonInfo.objects.all() returns a list of all objects of CommonInfo and it's subclasses. Q: How to dete

Re: bug in models.Model __str__ return and non-ascii characters !?

2009-01-08 Thread adrian
have a model like this: > > > --- > > class Test(models.Model): > >    testname = models.CharField(max_length=60, null=False, > > blank=False, unique=True) > >    [... some more fields ...] > >    def __str__(self): > >        return self.testname &

Re: bug in models.Model __str__ return and non-ascii characters !?

2009-01-08 Thread Karen Tracey
On Thu, Jan 8, 2009 at 6:14 PM, adrian wrote: > > hi, > i am posting here to follow the "i found a bug" guide ... > > let's assume i have a model like this: > > --- > class Test(models.Model): >testname = models.CharField(max_length=

bug in models.Model __str__ return and non-ascii characters !?

2009-01-08 Thread adrian
hi, i am posting here to follow the "i found a bug" guide ... let's assume i have a model like this: --- class Test(models.Model): testname = models.CharField(max_length=60, null=False, blank=False, unique=True) [... some more fields ...] def __str__(self):

Re: ultra-n00b models.Model syntax error

2008-09-21 Thread Karen Tracey
", line 3 > >class Poll(models.Model) > > ^SyntaxError: invalid syntax > > i'm working with the tutorial code here: > http://docs.djangoproject.com/en/dev/intro/tutorial01/#id3 > > any ideas what's gone wrong? > > Assuming the caret i

ultra-n00b models.Model syntax error

2008-09-21 Thread notatoad
ad_app(app_name, True) File "/usr/lib/python2.4/site-packages/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/django-apps/mysite/../mysite/polls/models.py", line 3 clas

Re: inheriting a models.Model inherited class

2007-06-06 Thread Russell Keith-Magee
On 6/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Advice? Model inheritance is a planned, but not-yet-implemented feature. Watch this space! http://code.djangoproject.com/wiki/ModelInheritance However, there is a workaround, using OneToOneFields. http://www.djangoproject.com/document

inheriting a models.Model inherited class

2007-06-06 Thread [EMAIL PROTECTED]
I hope the subject isn't too confusing but what I want to do seems pretty common so I think I might be missing something obvious (or should be doing in a different way) class Person(models.Model): name = models.TextField() def get_whatever:

Re: error in subclassing models.Model

2007-04-09 Thread checco
Thanks a lot James, I've just tried the same modifying an existing file of the cheeserater source code: to be precise I added the following lines: class Person(models.Model): pass at the end of the file models.py under c:\cheeserater\packages but I still get the same error Ma

Re: error in subclassing models.Model

2007-04-09 Thread James Bennett
On 4/9/07, checco <[EMAIL PROTECTED]> wrote: > Then, these really basic statements give me this error: > > >>> from django.db import models > >>> class Person(models.Model): > pass This is somewhat counterintuitive unless you know a bit about how

error in subclassing models.Model

2007-04-09 Thread checco
> import os, sys >>> os.environ['DJANGO_SETTINGS_MODULE'] = 'cheeserater.settings' >>> sys.path.append("C:\\") (The cheeserater package is under the C drive.) Then, these really basic statements give me this error: >>> from django.db import

Re: inheriting from models.Model

2006-06-29 Thread spako
nt: CHOICES = () comment = models.TextField() choice = models.charField(choices=CHOICES) class VideoComment(models.Model, Comment): CHOICES = (('a', 'Apple'), ('p', 'Pear')) video = models.ForeignKey(Video) class UserComment(models.Model,

Re: inheriting from models.Model

2006-06-29 Thread knobi
Hi, some time ago i did something similar and wondered to get some problems using the query manager. So when i used class Comment(models.Model): class VideoComment(Comment): and then asked VideoComment.objects.get(id='xyz') the Manager tried to to look up the Comment Table My solut

Re: inheriting from models.Model

2006-06-28 Thread James Bennett
On 6/28/06, spako <[EMAIL PROTECTED]> wrote: > is there a way to achieve this? or should i not bother and just do have > a Comment Model and just have VideoComment and UserComment have a > OneToOneField to Comment? Generally when you want to do something like this you define only one model, and a

Re: inheriting from models.Model

2006-06-28 Thread Julio Nobrega
A Comment class and the new GenericForeignKey() seems like a good idea. Allows you to have one Comment model and have it applied to other models (like Video and User). I haven't used the GenericForeignKey(), but from what I've read about it... should fit your problem. On 6/28/06, spako <[EM

inheriting from models.Model

2006-06-28 Thread spako
=True) class VideoComment(models.Model, Comment): video = models.ForeignKey(Video) class UserComment(models.Model, Comment): user = models.ForeignKey(User) i've also tried a variation, by declarinthe classes like this (the contents of the classes are the same as above): class Comment(mo