Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print(user) always prints 'None' in the terminal #8

Open
apoorvpatne10 opened this issue Jul 11, 2018 · 0 comments
Open

print(user) always prints 'None' in the terminal #8

apoorvpatne10 opened this issue Jul 11, 2018 · 0 comments

Comments

@apoorvpatne10
Copy link

apoorvpatne10 commented Jul 11, 2018

print(user) always prints None and the restaurant drop-down menu (/items/create/) is totally blank. Why is this happening? Here's the code from my forms.py of menus app. I've logged in and logged out time again and checked the code multiple times. But I still end up with this.

from django import forms
from restaurants.models import RestaurantLocation`
from .models import Item


class ItemForm(forms.ModelForm):
   class Meta:
       model = Item
       fields = [
            'restaurant',
            'name',
            'contents',
            'excludes',
            'public'
       ]

    def __init__(self, user=None, *args, **kwargs):
        # print(kwargs.pop('user'))
       print(user)
       super(ItemForm, self).__init__(*args, **kwargs)
       self.fields['restaurant'].queryset = RestaurantLocation.objects.filter(owner=user)

Django version 1.11.2, using settings 'muypicky.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
None
[11/Jul/2018 16:00:23] "GET /items/create/ HTTP/1.1" 200 2309
Performing system checks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant