As an update to this... I decided to simplify things a bit. For my contacts application,
On Saturday, April 23, 2016 at 10:30:45 AM UTC-4, Bruce Whealton wrote:
-- I decided to start with just one table. I got that working in a Ubuntu Vbox
environment, inside a virtualenv.
I'm not sure if it is ok to use python manage.py makemigrations on the
production server or if one should just do that locally and then import it.
Thanks for any advice,
This should be part of a larger posting on workflows moving from development to
production.
Thanks,
Bruce
On Saturday, April 23, 2016 at 10:30:45 AM UTC-4, Bruce Whealton wrote:
Hello all,So, I setup django in a virtualenv on my Ubuntu environment. I was reading the docs and thought I had things rightfor creating the 3 models I wanted with this application. I am using Postgresql. I have the Postgresql driver for Python/Django installedin 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 froman 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 fieldor allow for some kind of ajax type of text completion? If a person is family or friend, I may not needto 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 modelsclass 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+unsubscribe@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/8c7ad7e0-485b-4da1-81c0-8a63f0b108be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment