Answered by the Godfather himself. Thank you, Massimo. Great explanation!

On Monday, January 2, 2017 at 12:25:54 AM UTC-5, Massimo Di Pierro wrote:
>
>
> In web2py you would do
>
> CLASS_TYPE = (('field1', 'Field1'), ('field2', 'Field2'))
>
> db.define_table('myclass',
>     Field('type', length=12, requires=IS_IN_SET(CLASS_TYPE)),
>     Field('name',length=10),
>     Field('set','boolean',default=False),
>     Field('isset','boolean',default=False),
>     Field('enable','boolean',default=False),
>     Field('source','reference source'))
>
> Then you can do
>
> rows = db(db.myclass).select() # kind of like MyClass.objects
>
> The difference in philosophical because:
>
> 1) In web2py methods maps 1-1 into SQL, in Django no
>    db.table.insert(...)
>    db(...).select()
>    db(...).update(...)
>    db(...).delete()
> 2) In web2py SQL TABLES are difference instances of one class Table, in 
> Django each table is its own class
> 3) In web2py a record is a Row object (like a dict) while in Django a 
> record is an instance of the corresponding class. 
>
> The problem with the latter which motivated web2py is the results of joins 
> and aggregates? What classes are those rows? In web2py they are always Row 
> objects. They can contain columns from multiple tables or results of 
> expressions that are not associated with any of the original tables and the 
> syntax is always the same.
>
>
> On Sunday, 1 January 2017 15:04:25 UTC-6, LoveWeb2py wrote:
>>
>> Here is what I'm really trying to do:
>>
>>
>>
>>
>>
>>
>>
>>
>> *class MyClass(models.Model):    CLASS_TYPE = (('field1', 'Field1'), 
>> ('field2', 'Field2'))    type = models.CharField(max_length=12, 
>> choices=CLASS_TYPE)    name = models.CharField(max_length=10)    set = 
>> models.BooleanField(default=False)    isset = 
>> models.BooleanField(default=False)    enable = 
>> models.BooleanField(default=True)    source = models.ForeignKey(Source)*
>>
>>
>> Then I could do something like MyClass.objects
>>
>> Does web2py have a similar function?
>>
>>
>>
>> On Sunday, January 1, 2017 at 2:15:46 PM UTC-5, LoveWeb2py wrote:
>>>
>>> I'm noticing a lot of different syntax such as the ManyToMany model, 
>>> self.save(), and general layout difference.
>>>
>>> Does anyone know if there is a guide to port a django app into web2py or 
>>> do I just need to learn django a little better?
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to