Hi,

You can use a Meta class for your models and add a db_table property to 
control the table name related to the model, that way, you can name your 
model as you like (and differently from the DB table name).
You can also use the db_column parameter to Fields to control the name of 
the column in the table you are associating the model fields. That allows 
you to use lowercase field names as customary for Python, for example:

class Organism(models.Model):
    author = models.CharField(max_length=200, db_column='Author')
    ...

Please, read this documentation:
https://docs.djangoproject.com/en/1.11/ref/models/options/
https://docs.djangoproject.com/en/1.11/ref/models/fields/#db-column


On Sunday, April 16, 2017 at 6:01:16 PM UTC-4, alkha...@mymail.vcu.edu 
wrote:
>
> Hello everyone,
>
> Again, I'm super new to django so please bare with me. 
>
> I have just connected my mysql database to my django project in 
> settings.py. I then manually made models for the tables in my database. I 
> originally used inspectdb to do this, but I was getting a bunch of errors. 
> I decided to just do it manually from there, although I'm not necessarily 
> sure if it is correct yet. Do my models have to perfectly match my sql 
> relations? My tables already have unique ids as a field. I now that django 
> automatically does this, that is, make unique ids? Will this be a problem. 
>
> Anyway, I then ran makemigrations and migrate (which worked wonderfully), 
> and now I am trying to simply view some data from my database in the 
> manage.py shell. I am not exactly sure how to do this, so any help would be 
> great. Further, am I missing any steps as far connecting the mysql database 
> to my django project? Lastly, a rather huge disconnect I am having with all 
> of this is simply understanding how exactly the models.py in my apps are 
> actually connected to my database?
>
> Here are a few snapshots of my files:
>
> Models.py 
>
>    
> <https://scontent.xx.fbcdn.net/v/t34.0-12/17909331_10208121547186599_508598864_n.png?oh=1c21c01e48b70f99479c3a915eaa1161&oe=58F6563E>
>  
>
> manage.py shell
>
>
>
> <https://scontent.xx.fbcdn.net/v/t34.0-12/17909331_10208121547186599_508598864_n.png?oh=1c21c01e48b70f99479c3a915eaa1161&oe=58F6563E>
>

-- 
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/a0345dda-370e-40f8-8e68-0fbf37e4c422%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to