Hello all,
          So, I setup django in a virtualenv on my Ubuntu environment.  I 
was reading the docs and thought I had things right 
for creating the 3 models I wanted with this application. I am using 
Postgresql.  I have the Postgresql driver for Python/Django installed
in the virtualenv.  It is a "Contacts" app.  
First question: Do django model fields default to required unless you use 
blank=True, null=True?
Many of my fields, I want to have optional.

I have a class called Contact, a class called Organization and a class 
called Connection.  
I wanted to use the Organization as a foreign key on the Contact model.  I 
could have more than one contact from
an Organization.  The Connection model is inspired by the Google Plus idea 
of "Circles" - e.g. friends,
family, following, etc.   So, this would be a many-to-many relationship.  

My problems are (1) I cannot create connections without specifying a 
contact.  
(2) If I was adding a contact using the admin interface, how do I allow no 
value for that foreign field
or allow for some kind of ajax type of text completion?  If a person is 
family or friend, I may not need
to list an Organization for them.
(3) I would like to support multiple connection types - e.g. following, 
employer, etc.

So, here is my apps models.py file:
>>>>

from django.db import models


class Contact(models.Model):
    name = models.CharField(max_length=40)
    Organization = models.CharField(max_length=50)
    street_line1 = models.CharField("Street Line 1", max_length=50)
    street_line2 = models.CharField("Street Line 2", max_length=50)
    city = models.CharField(max_length=40)
    state = models.CharField(max_length=40)
    zipcode = models.CharField(max_length=20, blank=True, null=True)
    phone1 = models.CharField(max_length=20)
    phone2 = models.CharField(max_length=20)
    email = models.EmailField(max_length=60)


class Organization(models.Model):
    name = models.CharField(max_length=60)
    street_line1 = models.CharField("Street Line 1", max_length=50)
    street_line2 = models.CharField("Street Line 2", max_length=50)
    city = models.CharField(max_length=40)
    state = models.CharField(max_length=40)
    zipcode = models.CharField(max_length=20, blank=True, null=True,)
    phone = models.CharField(max_length=20)
    email = models.EmailField(max_length=60)
    website = models.URLField(max_length=90)
    contact_name = models.ForeignKey(Contact, on_delete=models.CASCADE)


class Connection(models.Model):
    type = models.CharField(max_length=60)
    contact_name = models.ManyToManyField(Contact)   

>>>
Thanks in advance for any suggestions,
Bruce 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/caede40b-640c-4e8d-997d-b76c62922c19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to