Re: Best Practices Django Questions

2015-01-30 Thread Babatunde Akinyanmi
On 30 Jan 2015 21:03, "G Z"  wrote:
>
> Hello, I'm in the design stages of a site that I'm building. It is going
to be a basic social media site for a game I'm designing in unity. I'm not
entirely sure how to do some of the things I want to in Django. Thus, my
first question is generally best practices question as well as a how do I
do this question.
>
> Qustion #1: How do I set up my models field so that when a user uploads
an image to a filefield it attaches the users name to the file that is
being uploaded? Should I do this in the view or in the database?
>

Database. You can adjust the name after validation and just before it is
saved to the database so you can just override the save method.

> Question #2: Examine my model design and tell me what I can do better, if
I'm missing anything etc. I'm new to django so go easy. I didn't do the def
and functions and class stuff just the over all structure. If it would be
better if I posted that let me know and I will.
>
> Question#3 How do I make the page when a user logs in resolve to his
username, and how do I use the username as the url so when you click on a
list of friends it uses that friends username as the url for their profile
and resolves to thier page, a quick overview on the best way to do this
would be just fine. Just point me and kinda explain the theory and I'm sure
I can figure out the rest.
>
> Please just help me think of things I need to worry about design with
django im just starting and I dont have a good base to go on.
>
>
> User
>
> id = models.AutoField(primary_key=True)
>
> username = models.CharField(max_length=4000)
>
> password = models.CharField(max_length=4000)
>
> email = models.CharField(max_length=4000)
>
> phone = models.CharField(max_length=4000)
>
> profile_image = models.FileField()
>
> about = models.CharField(max_length=4000)
>
> hometown = models.CharField(max_length=4000)
>
> job = models.CharField(max_length=4000)
>
> score = models.CharField(max_length=4000)
>
> hobbies = models.CharField(max_length=4000)
>
> datetime = models.DateField()
>
>
> Album
>
> id = models.AutoField(primary_key=True)
>
> userid = models.ForeignKey(User)
>
> name = models.CharField(max_length=4000)
>
> imageid = models.ForeignKey(Image)
>
> datetime = models.DateField()
>
>
> Image
>
> id = models.AutoField(primary_key=True)
>
> userid = models.ForeignKey(User)
>
> image = models.FileField()
>
> imgdesc = models.CharField(max_length=4000)
>
> datetime = models.DateField()
>
> Image_Comment
>
> id = models.AutoField(primary_key=True)
>
> userid = models.ForeignKey(User)
>
> imageid = models.ForeignKey(Image)
>
> comment = models.CharField(max_length=4000)
>
> datetime = models.DateField()
>
>
> Image_Likes
>
> id = models.AutoField(primary_key=True)
>
> imageid = models.ForeignKey(Image)
>
> userid = models.ForeignKey(User)
>
> datetime = models.DateField()
>
>
> Post
>
> id = models.AutoField(primary_key=True)
>
> userid = models.ForeignKey(User)
>
> message = models.CharField(max_length=4000)
>
> image = models.FileField()
>
> embed_link = models.CharField(max_length=4000)
>
> liked_count = models.CharField(max_length=4000)
>
> datetime = models.DateField()
>
>
> Post_Comment
>
> id = models.AutoField(primary_key=True)
>
> userid = models.ForeignKey(User)
>
> postid = models.ForeignKey(Post)
>
> comment = models.CharField(max_length=4000)
>
> datetime = models.DateField()
>
>
> Post_User_Likes
>
> id = models.AutoField(primary_key=True)
>
> postid = models.ForeignKey(Post)
>
> userid = models.ForeignKey(User)
>
> datetime = models.DateField()
>
>
> User_Friends
>
> id = models.AutoField(primary_key=True)
>
> userid = models.ForeignKey(User)
>
> friendid = models.ForeignKey(User)
>
> blocked = models.CharField(max_length=4000)
>
> datetime = models.DateField()
>
>
> Reported
>
> id = models.AutoField(primary_key=True)
>
> userid = models.ForeignKey(User)
>
> friendid = models.ForeignKey(User)
>
> comment = models.CharField(max_length=4000)
>
> datetime = models.DateField()
>
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/71830c67-c98c-4e38-95f8-235f7c1b9d81%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
h

Re: Best Practices Django Questions

2015-01-30 Thread G Z
 class User(models.Model):

 

 id = models.AutoField(primary_key=True) 

 username = models.CharField(max_length=4000) 

 password = models.CharField(max_length=4000) 

 email = models.CharField(max_length=4000) 

 phone = models.CharField(max_length=4000) 

 profile_image = models.FileField() 

 about  = models.CharField(max_length=4000) 

 hometown  = models.CharField(max_length=4000) 

 job  = models.CharField(max_length=4000) 

 score  = models.CharField(max_length=4000) 

 hobbies  = models.CharField(max_length=4000) 

 datetime  = models.DateField() 

 class Meta: 

managed=True 


 

class Message(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 friendid = models.ForeignKey(User) 

 msg  = models.CharField(max_length=4000) 

 subject = models.CharField(max_length=4000) 

 datetime  = models.DateField() 

 class Meta: 

managed=True 


 

class MsgQueue(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 friend = models.CharField(max_length=4000) 

 msg  = models.CharField(max_length=4000) 

 type  = models.CharField(max_length=4000) 

 dest  = models.CharField(max_length=4000) 

 datetime  = models.DateField() 

 class Meta: 

managed=True 


 

class UserCode(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 code  = models.CharField(max_length=4000) 

 datetime  = models.DateField() 

 class Meta: 

managed=True 


 

class Album(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 name  = models.CharField(max_length=4000) 

 imageid = models.ForeignKey(Image) 

 datetime  = models.DateField() 

 class Meta: 

managed=True 


 

class Image(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 image = models.FileField() 

 imgdesc  = models.CharField(max_length=4000) 

 datetime  = models.DateField() 

 class Meta: 

managed=True 

 

class ImageComment(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 imageid = models.ForeignKey(Image) 

 comment = models.CharField(max_length=4000) 

 datetime = models.DateField() 

 class Meta: 

managed=True 


 

class ImageLike(models.Model): 

 id = models.AutoField(primary_key=True) 

 imageid = models.ForeignKey(Image) 

 userid = models.ForeignKey(User) 

 datetime = models.DateField() 

 class Meta: 

managed=True 


 

class Post(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 message = models.CharField(max_length=4000) 

 image = models.FileField() 

 embed_link  = models.CharField(max_length=4000) 

 liked_count  = models.CharField(max_length=4000) 

 datetime = models.DateField() 

 class Meta: 

managed=True 


 

class PostComment(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 postid = models.ForeignKey(Post) 

 comment = models.CharField(max_length=4000) 

 datetime = models.DateField() 

 class Meta: 

managed=True 


 

class PostLike(models.Model): 

 id = models.AutoField(primary_key=True) 

 postid = models.ForeignKey(Post) 

 userid = models.ForeignKey(User) 

 datetime = models.DateField() 

 class Meta: 

managed=True 


 

class UserFriend(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 friendid = models.ForeignKey(User) 

 datetime = models.DateField() 

 class Meta: 

managed=True 


 


 

class UserEnviroment(models.Model): 

 id = models.AutoField(primary_key=True) 

 userid = models.ForeignKey(User) 

 elementid = models.ForeignKey(User) 

 datetime = models.DateField() 

 class Meta: 

managed=True 


 

class EnvElement(models.Model): 

 id = models.AutoField(primary_key=True) 

 elementname = models.CharField(max_length=4000) 

 elementfile = models.FileField() 

 elementcost =  models.CharField(max_length=4000) 

 elementmaturetime = models.CharField(max_length=4000) 

 elementposition = models.CharField(max_length=4000) 

 datetime = models.DateField() 

 class Meta: 

managed=True





-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d0f9542-4559-490c-a6dd-4d578bd11bc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best Practices Django Questions

2015-01-30 Thread G Z
 

class *User*(models.Model):

id = models.*AutoField*(primary_key=True)

username = models.CharField(max_length=4000)

password = models.CharField(max_length=4000)

email = models.CharField(max_length=4000)

phone = models.CharField(max_length=4000)

profile_image = models.FileField()

about = models.CharField(max_length=4000)

hometown = models.CharField(max_length=4000)

job = models.CharField(max_length=4000)

score = models.CharField(max_length=4000)

hobbies = models.CharField(max_length=4000)

datetime = models.DateField()

class *Meta*:

managed=True


 class *Album*(models.Model):

id = models.*AutoField*(primary_key=True)

userid = models.ForeignKey(User)

name = models.CharField(max_length=4000)

imageid = models.ForeignKey(Image)

datetime = models.DateField()

class *Meta*:

managed=True


 class *Image*(models.Model):

id = models.*AutoField*(primary_key=True)

userid = models.ForeignKey(User)

image = models.FileField()

imgdesc = models.CharField(max_length=4000)

datetime = models.DateField()

class *Meta*:

managed=True


 class *ImageComment*(models.Model):

id = models.*AutoField*(primary_key=True)

userid = models.ForeignKey(User)

imageid = models.ForeignKey(Image)

comment = models.CharField(max_length=4000)

datetime = models.DateField()

class *Meta*:

managed=True


 class *ImageLike*(models.Model):

id = models.*AutoField*(primary_key=True)

imageid = models.ForeignKey(Image)

userid = models.ForeignKey(User)

datetime = models.DateField()

class *Meta*:

managed=True


 class *Post*(models.Model):

id = models.*AutoField*(primary_key=True)

userid = models.ForeignKey(User)

message = models.CharField(max_length=4000)

image = models.FileField()

embed_link = models.CharField(max_length=4000)

liked_count = models.CharField(max_length=4000)

datetime = models.DateField()

class *Meta*:

managed=True


 class *PostComment*(models.Model):

id = models.*AutoField*(primary_key=True)

userid = models.ForeignKey(User)

postid = models.ForeignKey(Post)

comment = models.CharField(max_length=4000)

datetime = models.DateField()

class *Meta*:

  managed=True


 class *PostLike*(models.Model):

id = models.*AutoField*(primary_key=True)

postid = models.ForeignKey(Post)

userid = models.ForeignKey(User)

datetime = models.DateField()

class *Meta*:

 managed=True


 class *UserFriend*(models.Model):

id = models.*AutoField*(primary_key=True)

userid = models.ForeignKey(User)

friendid = models.ForeignKey(User)

datetime = models.DateField()

 class *Meta*:

   managed=True

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/558c3cb4-ca69-4497-81bd-a6dd4268b22a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.