django models

63 views
Skip to first unread message

ngangsia akumbo

unread,
May 31, 2014, 7:41:12 AM5/31/14
to django...@googlegroups.com
please i need some legit answer please

we have in the models forexaple

class Book():

name = InputTextField
Autho = 


Please are there not more parmaters that can hel you to better define your model. Are there no library for models?

Tom Lockhart

unread,
Jun 1, 2014, 2:42:13 PM6/1/14
to django...@googlegroups.com
On 2014-05-31, at 4:41 AM, ngangsia akumbo <ngan...@gmail.com> wrote:

please i need some legit answer please

Please give one or two specific examples of functionality you need. There are parameters for fields which can help specialize some behaviours without needing a new model. And there are hooks to allow specialization of behaviours in interpretation or handling when reading or saving values which you may find useful.

afaik there is no large library of model specializations for Django, but that may be because there is no clear large set of specializations that would be useful.

So give an example please. Is it the book name, the book author, or something else which needs extra or restricted behaviours?

                - Tom



we have in the models forexaple

class Book():

name = InputTextField
Autho = 


Please are there not more parmaters that can hel you to better define your model. Are there no library for models?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cb57997d-ac3e-40a4-b7f8-791db1bbbb76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not waive any related rights and obligations.  Any distribution, use or copying of this message or the information it contains by other than an intended recipient is unauthorized.  If you received this message in error, please immediately advise me by return e-mail or phone.  All information, references, images, programs, source code, or other materials whatsoever contained in, or supplied with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets Act.  User assumes all direct and consequential liabilities and costs that result from any unauthorized disclosure or use of this information.

ngangsia akumbo

unread,
Jun 2, 2014, 8:51:27 PM6/2/14
to django...@googlegroups.com


On Sunday, June 1, 2014 7:42:13 PM UTC+1, Thomas wrote:

On 2014-05-31, at 4:41 AM, ngangsia akumbo <ngan...@gmail.com> wrote:

please i need some legit answer please

Please give one or two specific examples of functionality you need. There are parameters for fields which can help specialize some behaviours without needing a new model. And there are hooks to allow specialization of behaviours in interpretation or handling when reading or saving values which you may find useful.

afaik there is no large library of model specializations for Django, but that may be because there is no clear large set of specializations that would be useful.

So give an example please. Is it the book name, the book author, or something else which needs extra or restricted behaviours?

                - Tom


This is an example. Where did the get all these parameter like CharField, DateTimeField etc.
 
class Item(models.Model):
    name = models.CharField(max_length=60)
    created = models.DateTimeField(auto_now_add=True)
    priority = models.IntegerField(default=0)
    difficulty = models.IntegerField(default=0)
    done = models.BooleanField(default=False)

class ItemAdmin(admin.ModelAdmin):
    list_display = ["name", "priority", "difficulty", "created", "done"]
    search_fields = ["name"]

admin.site.register(Item, ItemAdmin)

Andrew Farrell

unread,
Jun 2, 2014, 9:16:37 PM6/2/14
to django...@googlegroups.com
Hi Mr. Akumbo,

The options for Model Fields that come with django in the django.db library and are listed and explained here: https://docs.djangoproject.com/en/dev/ref/models/fields/#model-field-types


Each corresponds to a different type of data. For example

name = models.CharField(max_length=60)
just means that the the database will store a 60-character text string (VARCHAR).

Other libraries can define other field types. For example, the https://pypi.python.org/pypi/django-localflavor package has Model fields specific to different nations such as localflavor.za.forms.ZAPostCodeField for South African postal codes. If you really need to, you can look at the source code of that project for an example of defining your own.

It sounds like you are working through someone else's django project but would find some broader context useful. If you haven't already, I would recommend working through the tutorial, starting here:

best regards,
Andrew Farrell


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

ngangsia akumbo

unread,
Jun 4, 2014, 4:50:58 AM6/4/14
to django...@googlegroups.com
Thanks for this reply , am not using anybody's code. I am still studying django and was wondering where those fields where from. Thanks for the clarification. With time i will write my own field since am from Cameroon.
Reply all
Reply to author
Forward
0 new messages