 Allan
    Allan 
    
    
        
        
        
        The models are entries that each one should belong to a user. Let's say for example a Journal: each entry in the journal table should belong and accessed by only the owner. But this user thing wasn't planned and now I'm trying to fix this. I'm good at python, but I am not experienced in Django.
    
 
     Allan
    Allan 
    
    
        
        
        
        The first approach is to have a different database for each user. But there are some models (tables) that are general and not user specific, and after the user log in he need to use there (ie. I cannot run a different instance of Django for each user). This one I believe is pretty impractical with Django.
    
 
     Allan
    Allan 
    
    
        
        
        
        The other one is using an internal user field. So, as all models that are user specific user a Custom Abstract Base model to save creation and update times, and no one else uses it, It’s already on the way.
    
 
     Allan
    Allan 
    
    
        
        
        
        I override the save function on this Base class to always take the user (with a few hacks) and save it. And created a custom manager that filter the results for the ones the user owns.
        
        I’m having a lot of trouble with this approach, I don't now if it's the best one.
    
 
     Allan
    Allan 
    
    
        
        
        
        What I would like to now is if this is the best approach, if there is any realistic possible approach besides those, what would be the better ones. Or even if I’m missing something like a django module that makes this, or anything.
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        Hey, can anybody help please. I'm making models for my db. The First model is dish, it has name and price. And the second one is order, it should have 4 fields, two of which are 'total price' and 'consists of'. These fields are foreign keys from dish and may have any number of elements. How do i properly bound them in model?
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        I don't understand what you're trying to say
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Website
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        ?
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        http://graphql.org/learn/
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        It's is python version GraphQL
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        I don't know how to do it
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        The first field will have several values from another class. Is it:
        value = models.ForeignKey('another class')
        
        ?
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        But what if i want to store several values there? How i can do it?
    
 
     Abhi
    Abhi 
    
    
        
        
        
        @Formalin extend the user model
    
 
     Abhi
    Abhi 
    
    
        
        
        
        and make a one-to-one relationship with that extended user model
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        Could you please show me an example?
    
 
     Abhi
    Abhi 
    
    
        
        
        
        Okay wait
    
 
     Abhi
    Abhi 
    
    
        
        
        
        https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
    
 
     Abhi
    Abhi 
    
    
        
        
        
        hope it help
    
 
     Anonymous
    Anonymous 
    
    
 
     inchidi
    inchidi 
    
    
 
     inchidi
    inchidi 
    
    
        
        
        
        so for every order you will store the dishes ordered, and how many is it. your views gonna do the math and you get the bills
    
 
     Django Bot
    Django Bot 
    
    
        
        
        
        >> Blogs
        - Is Django the Right Fit for your Project?
    
 
     Elizaveta
    Elizaveta 
    
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
 
     inchidi
    inchidi 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        But it have disadvantage that the frontend man have to communicate many time with backend man
    
 
     inchidi
    inchidi 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Unless you're full stuck
    
 
     inchidi
    inchidi 
    
    
        
        
        
        i see, sounds like its gonna give flexibility for front end
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Then frontend man pick what his wanted
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        You are welcome
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Frontend developer can do whatever he can
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Then back end developer ask him to change something
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Agree with you
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        I thought he said opposite
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Anyway
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        If Meaning same, no problem
    
 
     Anonymous
    Anonymous 
    
    
 
     Allan
    Allan 
    
    
        
        
        
        The main problem is always filtering the query to just return the records that the user own. I extended the default Manager for this custom class, so the get_queryset always filter by the current user. It works fine on the shell, and on the views too I think.
    
 
     Allan
    Allan 
    
    
        
        
        
        But when I start the server it crashes because the ModelForm does a query when creating  the class or instance at the initialization. Because it doesn't pass any user, and there is no user related to that query, I can't handle it.
    
 
     Allan
    Allan 
    
    
        
        
        
        Because there's no sense for me making queries on a model without even a user been logged in.
    
 
     Allan
    Allan 
    
    
        
        
        
        It also breaks many others stuffs that I have no idea why.
    
 
     Allan
    Allan 
    
    
        
        
        
        That's why I'm questioning about if this is the right approach, because I would have to know in detail all Django source to know the answer for this, or how to fix stuffs.
    
 
     Django Bot
    Django Bot 
    
    
        
        
        
        >> Blogs
        - Two Scoops of Django Birthday Giveaway
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Congratulation....got 90 members....👍
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Anybody here wanna do for a gamble game website ?
    
 
     Lapanit ☃️
    Lapanit ☃️ 
    
    
        
        
        
        How much are you paying?
    
 
     Anonymous
    Anonymous 
    
    
 
     Val
    Val 
    
    
 
     Allan
    Allan 
    
    
 
     Allan
    Allan 
    
    
        
        
        
        My problem now is that the ModelForm populate the ForeginFields at startup, and then doesn't update (make the query again), so it only got results for this fileds of the first user...
    
 
     inchidi
    inchidi 
    
    
 
     inchidi
    inchidi 
    
    
 
     inchidi
    inchidi 
    
    
        
        
        
        if user will not input that fields, you can just exclude it for that ModelForm
    
 
     inchidi
    inchidi 
    
    
        
        
        
        then your views pass the request.user
    
 
     Django Bot
    Django Bot 
    
    
        
        
        
        >> Jobs
        - 2017 - 2018 Fall & Winter Django Web Developer Internship
        
        >> Blogs
        - Find static files defined in django-pipeline but not found
    
 
     Lapanit ☃️
    Lapanit ☃️ 
    
    
        
        
        
        /warn ad
    
 
     Group Butler
    Group Butler 
    
    
        
        
        
        Hacker Linux™ has been warned (1/3)
    
 
     Val
    Val 
    
    
        
        
        
        hello does any one have an article or book on recursion in python
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Book on recursion?
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        That's too much
    
 
     Val
    Val 
    
    
        
        
        
        i found something thanks
    
 
     Val
    Val 
    
    
        
        
        
        class Test(unittest.TestCase):
          def test_should_say_hello(self):
            self.assertEqual(say_hello("NAME"), "Hello, NAME!")
    
 
     Val
    Val 
    
    
        
        
        
        pls can someone explain this codes to me?
    
 
     Val
    Val 
    
    
        
        
        
        For this practice challenge, write a simple greeter function.
        
            If it is passed in a name NAME, return 'Hello, NAME!.
            If it is called without a name, return 'Hello there!.
    
 
     Val
    Val 
    
    
        
        
        
        class Test(unittest.TestCase):
          def test_should_say_hello(self):
            self.assertEqual(say_hello("Qualified"), "Hello, Qualified!")
    
 
     Val
    Val 
    
    
        
        
        
        def say_hello(name):