Need Django experts to explain some of my questions in bay Area, CA
Hi, I am building a website for non-profit work using Django but i got stuck at one place. It would be great if somebody help me in resolving some of my question. I need only an hr of you. Regards ~Nirmal -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/yLw7kyBX80wJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Can somebody help me on how to handle this scenario?
--This is the model definition FEEDBACK_CHOICES = ( (1, 'FOR'), (-1, 'AGAINST'), (0, 'NEUTRAL'), ) class user (models.Model): user_name = models.CharField(max_length=150) class comments (models.Model): comment = models.CharField(max_length=1000) root_comment = models.ForeignKey('self', null=True, blank=True, related_name="children") user_id = models.ForeignKey(user) class comment_feedback (models.Model): feedback_user_id = models.ForeignKey(user) comment_id = models.ForeignKey(comments) feedback_type_id = models.CharField(max_length=20, choices=FEEDBACK_CHOICES) class Meta: unique_together = [("feedback_user_id", "info_id")] We are trying build a html page that will do the following. Once a user logs in, he can write a new comment (that would result in an insert into comments table) Alternatively he can do one of the following: select a comment of some other user and give his feedback (that would result in an insert into comment_feedback table) select a comment and write his own comment with a feedback on the original comment (that would result in an insert into comments table with root_comment as the original comment and an insert into comment_feedback table for the original comment) We tried doing this inlineformset_factory and nested formsets. However we are quite confused on how to proceed with this. Also the comment_feedback table has 2 foreign keys. How do we handle this at the form and template level? Regards ~Nirmal -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/oVRPCd9uzpgJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Can somebody help me on how to handle this scenario?
Hi, I read all the tutorials and i know the Django basics as well. I think you misunderstood what i asked. Dont get confused with the 'user' class i mentioned below with "User class which would be better extended using a User Profile" . Just to give an example i used the name 'user'. Let me rephrase the question. class People (models.Model): person_name = models.CharField(max_length=150) class comments (models.Model): comment = models.CharField(max_length=1000) root_comment = models.ForeignKey('self', null=True, blank=True, related_name="children") People_id = models.ForeignKey(People) class comment_feedback (models.Model): feedback_People_id = models.ForeignKey(People) comment_id = models.ForeignKey(comments) feedback_type_id = models.CharField(max_length=20, choices=FEEDBACK_CHOICES) class Meta: unique_together = [("feedback_People_id", "info_id")] We are trying build a html page that will do the following. Once a user logs in, he can write a new comment (that would result in an insert into comments table) Alternatively he can do one of the following: select a comment of some other peoples and give his feedback (that would result in an insert into comment_feedback table) select a comment and write his own comment with a feedback on the original comment (that would result in an insert into comments table with root_comment as the original comment and an insert into comment_feedback table for the original comment) We tried doing this inlineformset_factory and nested formsets. However we are quite confused on how to proceed with this. Also the comment_feedback table has 2 foreign keys. How do we handle this at the form and template level? Regards ~Nirmal On Tuesday, August 21, 2012 1:57:05 PM UTC-7, Nirmal Sharma wrote: > > > --This is the model definition > > FEEDBACK_CHOICES = ( > (1, 'FOR'), > (-1, 'AGAINST'), > (0, 'NEUTRAL'), > ) > > > class user (models.Model): > user_name = models.CharField(max_length=150) > > > class comments (models.Model): > comment = models.CharField(max_length=1000) > root_comment = models.ForeignKey('self', null=True, blank=True, > related_name="children") > user_id = models.ForeignKey(user) > > > class comment_feedback (models.Model): > feedback_user_id = models.ForeignKey(user) > comment_id = models.ForeignKey(comments) > feedback_type_id = models.CharField(max_length=20, > choices=FEEDBACK_CHOICES) > class Meta: > unique_together = [("feedback_user_id", "info_id")] > > > > We are trying build a html page that will do the following. > Once a user logs in, he can write a new comment (that would result in an > insert into comments table) > Alternatively he can do one of the following: > select a comment of some other user and give his feedback (that would > result in an insert into comment_feedback table) > select a comment and write his own comment with a feedback on the > original comment (that would result in an insert into comments table with > root_comment as the original comment and an insert into comment_feedback > table for the original comment) > > We tried doing this inlineformset_factory and nested formsets. However we > are quite confused on how to proceed with this. Also the comment_feedback > table has 2 foreign keys. > How do we handle this at the form and template level? > > Regards > ~Nirmal > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/DMy4tCQfv7cJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Can somebody help me on how to handle this scenario?
Thanks everybody for your help. I will try what you have suggested and will come back with some more questions. On Wednesday, August 22, 2012 4:57:47 PM UTC-7, Melvyn Sopacua wrote: > > Hi Nirmal, > > I'll try to answer your question instead of assuming you're working with > django's auth system. > > On 22-8-2012 7:13, Nirmal Sharma wrote: > > > class People (models.Model): > > person_name = models.CharField(max_length=150) > > > > > > class comments (models.Model): > > comment = models.CharField(max_length=1000) > > root_comment = models.ForeignKey('self', null=True, blank=True, > > related_name="children") > > People_id = models.ForeignKey(People) > ^^^ > That's bad practice, because you're not designing a database, you're > designing a model that is built from things, not id's. So name this > field person or commentator or written_by: > written_by = models.ForeignKey(People) > > Same applies on numerous fields below. The reason it's bad practice is > because when you request an attribute the name of the attribute should > describe what you get. When you request comments.people_id the > expectation is that you get an id, while in actuality you get a model > instance. > > > class comment_feedback (models.Model): > > feedback_People_id = models.ForeignKey(People) > > comment_id = models.ForeignKey(comments) > > feedback_type_id = models.CharField(max_length=20, > > choices=FEEDBACK_CHOICES) > > class Meta: > > unique_together = [("feedback_People_id", "info_id")] > > > > We are trying build a html page that will do the following. > > Once a user logs in, he can write a new comment (that would result in an > > insert into comments table) > > Alternatively he can do one of the following: > > select a comment of some other peoples and give his feedback (that > > would result in an insert into comment_feedback table) > > select a comment and write his own comment with a feedback on the > > original comment (that would result in an insert into comments table > with > > root_comment as the original comment and an insert into comment_feedback > > table for the original comment) > > Here's how to dissect your problem description: > - The person can do three things ("actions") that he cannot do at the > same time: the obvious solution is to use three different forms in the > same HTML page or use popup windows for action 2 and 3. > - The second and third option are mostly a UI problem, because how does > the user select the comment she's providing feedback for. Unless you put > a form below each comment (which will make the page possibly incredibly > long), you need to do some JavaScript programming that shows the form > below the right comment and stores the comment being commented on in > some hidden variables in that form. This is where I would hire a UI > programmer. > > > We tried doing this inlineformset_factory and nested formsets. However > we > > are quite confused on how to proceed with this. Also the > comment_feedback > > table has 2 foreign keys. > That isn't a problem as long as the foreign keys are to different > tables. inlineformset_factory will find the foreign key that goes from > parent_model to model in it's function signature. It uses > _get_foreign_key() in forms/models.py for that. > > > How do we handle this at the form and template level? > > Like I said, the selection process is mostly a UI nightmare. If you > solve that, creating the forms for it will be much easier to grasp. > -- > Melvyn Sopacua > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/72cZbiUA9qkJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Pinterest like UI implementation
Hi, I am creating a website in django where in i am trying to display all the comments and pictures like Pinterest. Can somebody help me on how to implement the same easily in django. Is there any easy way to implement the Pinterest like UI in django? Regards ~Nirmal -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/jEN6S-FRdRYJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Pinterest like UI implementation
Thanks Peith. I will try Masonry and infinite-scroll. Regards ~Nirmal On Friday, September 28, 2012 8:07:34 PM UTC-7, Peith wrote: > > I use Masonry to get that Pinterest-like tile of images. Then I use > Infinite-scroll to detect user scrolling event and load more images by > sending an AJAX request to the server. > > You can learn about Masonry and infinite-scroll here: > http://masonry.desandro.com/ > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/yPhJYgKnyn8J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.