TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'TypeError: expected string or bytes-like object TensorflowHow to define Mode with generic ForeignKey in DjangoError connecting Django to MSSQL Server 2012Reverse for '' not found. '' is not a valid view function or pattern name - DJANGOdjango.db.utils.InterfaceError: (0, '')Is there a simple way to create Chained Dynamic Drop Down List in Django Admin Site?Django Unittest failing to run with TypeError: isinstance() arg 2 must be a type or tuple of types on one machine but not othersAttributeError: module 'django.db.models' has no attribute 'model'Django class view - MultipleObjectsReturned error

Right indicator flash-frequency has increased and rear-right bulb is out

Is this broken pipe the reason my freezer is not working? Can it be fixed?

How would Japanese people react to someone refusing to say “itadakimasu” for religious reasons?

Got a new frameset, don't know why I need this split ring collar?

Do my partner and son need an SSN to be dependents on my taxes?

Fill the maze with a wall-following Snake until it gets stuck

How do credit card companies know what type of business I'm paying for?

Why can't I craft scaffolding in Minecraft 1.14?

A medieval book with a redhead girl as a main character who allies with vampires and werewolves against scientific opposition

What does this Swiss black on yellow rectangular traffic sign with a symbol looking like a dart mean?

How to make all magic-casting innate, but still rare?

What is the precise meaning of "подсел на мак"?

How do I correctly reduce geometry on part of a mesh?

Is it possible to use just one shared folder for log shipping?

What kind of chart is this?

How did Frodo know where the Bree village was?

Why we can't jump without bending our knees?

Print the new site header

How to avoid offending original culture when making conculture inspired from original

What is "dot" sign in •NO?

Harmonic Series Phase Difference?

Expand command in an argument before the main command

How to ask if I can mow my neighbor's lawn

How can I detect if I'm in a subshell?



TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'


TypeError: expected string or bytes-like object TensorflowHow to define Mode with generic ForeignKey in DjangoError connecting Django to MSSQL Server 2012Reverse for '' not found. '' is not a valid view function or pattern name - DJANGOdjango.db.utils.InterfaceError: (0, '')Is there a simple way to create Chained Dynamic Drop Down List in Django Admin Site?Django Unittest failing to run with TypeError: isinstance() arg 2 must be a type or tuple of types on one machine but not othersAttributeError: module 'django.db.models' has no attribute 'model'Django class view - MultipleObjectsReturned error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-2















I am trying to print filtered sub_location drop down according to location attribute form extended admin user in Django.
I have a view which displays a form and saves the same form. There is no problem showing the view but when saving I get this following error:



TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'



Here is my code:-



MODEL:



class Location(models.Model):
name = models.CharField(max_length=30)
def __str__(self):
return self.name

class SubLocation(models.Model):
location = models.ForeignKey(Location, on_delete=models.CASCADE)
name = models.CharField(max_length=30)

def __str__(self):
return self.name

class AdminProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True)

def __str__(self): # __unicode__ for Python 2
return self.user.username


class Batch(models.Model):
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True)
sub_location = models.ForeignKey(SubLocation, on_delete=models.SET_NULL, null=True)
batch_name = models.CharField(max_length=30, unique=True)

def __str__(self):
return self.batch_name


FORM:



class BatchForm(forms.ModelForm):
class Meta:
model = Batch
fields = ('sub_location', 'batch_name')
def __init__(self, user, *args, **kwargs):
super(BatchForm, self).__init__(*args, **kwargs)
self.fields['sub_location'].queryset = SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location')))



VIEW:



def add_batch(request):
if request.user.is_authenticated:
msg = ""
if request.method == "GET":
batch_form = BatchForm(user=request.user)
else:
batch_form = BatchForm(request.POST, request.FILES)
if batch_form.is_valid():
try:
obj = batch_form.save(commit=False)
#logined admin location will be here

admin_object = AdminProfile.objects.filter(user = request.user)
obj.location = admin_object[0].location
obj.save()

batch_form = BatchForm()
msg = "Batch Added successfully....!"
except IntegrityError as e:
msg= "Batch already exist...!"
else:
batch_form = BatchForm(request.POST, request.FILES)
return render(request, 'add_new_batch.html', 'batch_form':batch_form,'msg':msg)
else:
return redirect('admin_login')


when I am clicking on submit button to save the form then I'm getting this error
ERROR



Internal Server Error: /admin_panel/add_batch
Traceback (most recent call last):
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:UsersmonuDesktopTaskAdminPanelviews.py", line 34, in add_batch
batch_form = BatchForm(request.POST, request.FILES)
File "C:UsersmonuDesktopTaskAdminPanelforms.py", line 27, in __init__
self.fields['sub_location'].queryset = SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location')))
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsmanager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsquery.py", line 844, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsquery.py", line 862, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1263, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1287, in _add_q
split_subq=split_subq,
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1225, in build_filter
condition = self.build_lookup(lookups, col, value)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1096, in build_lookup
lookup = lookup_class(lhs, rhs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelslookups.py", line 20, in __init__
self.rhs = self.get_prep_lookup()
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsfieldsrelated_lookups.py", line 115, in get_prep_lookup
self.rhs = target_field.get_prep_value(self.rhs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsfields__init__.py", line 965, in get_prep_value
return int(value)

TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'
[25/Mar/2019 09:31:03] "POST /admin_panel/add_batch HTTP/1.1" 500 125516










share|improve this question






















  • you are not providing user argument when instantiating batch form

    – Mohit Harshan
    Mar 25 at 4:58

















-2















I am trying to print filtered sub_location drop down according to location attribute form extended admin user in Django.
I have a view which displays a form and saves the same form. There is no problem showing the view but when saving I get this following error:



TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'



Here is my code:-



MODEL:



class Location(models.Model):
name = models.CharField(max_length=30)
def __str__(self):
return self.name

class SubLocation(models.Model):
location = models.ForeignKey(Location, on_delete=models.CASCADE)
name = models.CharField(max_length=30)

def __str__(self):
return self.name

class AdminProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True)

def __str__(self): # __unicode__ for Python 2
return self.user.username


class Batch(models.Model):
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True)
sub_location = models.ForeignKey(SubLocation, on_delete=models.SET_NULL, null=True)
batch_name = models.CharField(max_length=30, unique=True)

def __str__(self):
return self.batch_name


FORM:



class BatchForm(forms.ModelForm):
class Meta:
model = Batch
fields = ('sub_location', 'batch_name')
def __init__(self, user, *args, **kwargs):
super(BatchForm, self).__init__(*args, **kwargs)
self.fields['sub_location'].queryset = SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location')))



VIEW:



def add_batch(request):
if request.user.is_authenticated:
msg = ""
if request.method == "GET":
batch_form = BatchForm(user=request.user)
else:
batch_form = BatchForm(request.POST, request.FILES)
if batch_form.is_valid():
try:
obj = batch_form.save(commit=False)
#logined admin location will be here

admin_object = AdminProfile.objects.filter(user = request.user)
obj.location = admin_object[0].location
obj.save()

batch_form = BatchForm()
msg = "Batch Added successfully....!"
except IntegrityError as e:
msg= "Batch already exist...!"
else:
batch_form = BatchForm(request.POST, request.FILES)
return render(request, 'add_new_batch.html', 'batch_form':batch_form,'msg':msg)
else:
return redirect('admin_login')


when I am clicking on submit button to save the form then I'm getting this error
ERROR



Internal Server Error: /admin_panel/add_batch
Traceback (most recent call last):
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:UsersmonuDesktopTaskAdminPanelviews.py", line 34, in add_batch
batch_form = BatchForm(request.POST, request.FILES)
File "C:UsersmonuDesktopTaskAdminPanelforms.py", line 27, in __init__
self.fields['sub_location'].queryset = SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location')))
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsmanager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsquery.py", line 844, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsquery.py", line 862, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1263, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1287, in _add_q
split_subq=split_subq,
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1225, in build_filter
condition = self.build_lookup(lookups, col, value)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1096, in build_lookup
lookup = lookup_class(lhs, rhs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelslookups.py", line 20, in __init__
self.rhs = self.get_prep_lookup()
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsfieldsrelated_lookups.py", line 115, in get_prep_lookup
self.rhs = target_field.get_prep_value(self.rhs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsfields__init__.py", line 965, in get_prep_value
return int(value)

TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'
[25/Mar/2019 09:31:03] "POST /admin_panel/add_batch HTTP/1.1" 500 125516










share|improve this question






















  • you are not providing user argument when instantiating batch form

    – Mohit Harshan
    Mar 25 at 4:58













-2












-2








-2


0






I am trying to print filtered sub_location drop down according to location attribute form extended admin user in Django.
I have a view which displays a form and saves the same form. There is no problem showing the view but when saving I get this following error:



TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'



Here is my code:-



MODEL:



class Location(models.Model):
name = models.CharField(max_length=30)
def __str__(self):
return self.name

class SubLocation(models.Model):
location = models.ForeignKey(Location, on_delete=models.CASCADE)
name = models.CharField(max_length=30)

def __str__(self):
return self.name

class AdminProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True)

def __str__(self): # __unicode__ for Python 2
return self.user.username


class Batch(models.Model):
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True)
sub_location = models.ForeignKey(SubLocation, on_delete=models.SET_NULL, null=True)
batch_name = models.CharField(max_length=30, unique=True)

def __str__(self):
return self.batch_name


FORM:



class BatchForm(forms.ModelForm):
class Meta:
model = Batch
fields = ('sub_location', 'batch_name')
def __init__(self, user, *args, **kwargs):
super(BatchForm, self).__init__(*args, **kwargs)
self.fields['sub_location'].queryset = SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location')))



VIEW:



def add_batch(request):
if request.user.is_authenticated:
msg = ""
if request.method == "GET":
batch_form = BatchForm(user=request.user)
else:
batch_form = BatchForm(request.POST, request.FILES)
if batch_form.is_valid():
try:
obj = batch_form.save(commit=False)
#logined admin location will be here

admin_object = AdminProfile.objects.filter(user = request.user)
obj.location = admin_object[0].location
obj.save()

batch_form = BatchForm()
msg = "Batch Added successfully....!"
except IntegrityError as e:
msg= "Batch already exist...!"
else:
batch_form = BatchForm(request.POST, request.FILES)
return render(request, 'add_new_batch.html', 'batch_form':batch_form,'msg':msg)
else:
return redirect('admin_login')


when I am clicking on submit button to save the form then I'm getting this error
ERROR



Internal Server Error: /admin_panel/add_batch
Traceback (most recent call last):
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:UsersmonuDesktopTaskAdminPanelviews.py", line 34, in add_batch
batch_form = BatchForm(request.POST, request.FILES)
File "C:UsersmonuDesktopTaskAdminPanelforms.py", line 27, in __init__
self.fields['sub_location'].queryset = SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location')))
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsmanager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsquery.py", line 844, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsquery.py", line 862, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1263, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1287, in _add_q
split_subq=split_subq,
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1225, in build_filter
condition = self.build_lookup(lookups, col, value)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1096, in build_lookup
lookup = lookup_class(lhs, rhs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelslookups.py", line 20, in __init__
self.rhs = self.get_prep_lookup()
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsfieldsrelated_lookups.py", line 115, in get_prep_lookup
self.rhs = target_field.get_prep_value(self.rhs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsfields__init__.py", line 965, in get_prep_value
return int(value)

TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'
[25/Mar/2019 09:31:03] "POST /admin_panel/add_batch HTTP/1.1" 500 125516










share|improve this question














I am trying to print filtered sub_location drop down according to location attribute form extended admin user in Django.
I have a view which displays a form and saves the same form. There is no problem showing the view but when saving I get this following error:



TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'



Here is my code:-



MODEL:



class Location(models.Model):
name = models.CharField(max_length=30)
def __str__(self):
return self.name

class SubLocation(models.Model):
location = models.ForeignKey(Location, on_delete=models.CASCADE)
name = models.CharField(max_length=30)

def __str__(self):
return self.name

class AdminProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True)

def __str__(self): # __unicode__ for Python 2
return self.user.username


class Batch(models.Model):
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True)
sub_location = models.ForeignKey(SubLocation, on_delete=models.SET_NULL, null=True)
batch_name = models.CharField(max_length=30, unique=True)

def __str__(self):
return self.batch_name


FORM:



class BatchForm(forms.ModelForm):
class Meta:
model = Batch
fields = ('sub_location', 'batch_name')
def __init__(self, user, *args, **kwargs):
super(BatchForm, self).__init__(*args, **kwargs)
self.fields['sub_location'].queryset = SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location')))



VIEW:



def add_batch(request):
if request.user.is_authenticated:
msg = ""
if request.method == "GET":
batch_form = BatchForm(user=request.user)
else:
batch_form = BatchForm(request.POST, request.FILES)
if batch_form.is_valid():
try:
obj = batch_form.save(commit=False)
#logined admin location will be here

admin_object = AdminProfile.objects.filter(user = request.user)
obj.location = admin_object[0].location
obj.save()

batch_form = BatchForm()
msg = "Batch Added successfully....!"
except IntegrityError as e:
msg= "Batch already exist...!"
else:
batch_form = BatchForm(request.POST, request.FILES)
return render(request, 'add_new_batch.html', 'batch_form':batch_form,'msg':msg)
else:
return redirect('admin_login')


when I am clicking on submit button to save the form then I'm getting this error
ERROR



Internal Server Error: /admin_panel/add_batch
Traceback (most recent call last):
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:UsersmonuDesktopTaskAdminPanelviews.py", line 34, in add_batch
batch_form = BatchForm(request.POST, request.FILES)
File "C:UsersmonuDesktopTaskAdminPanelforms.py", line 27, in __init__
self.fields['sub_location'].queryset = SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location')))
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsmanager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsquery.py", line 844, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsquery.py", line 862, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1263, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1287, in _add_q
split_subq=split_subq,
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1225, in build_filter
condition = self.build_lookup(lookups, col, value)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelssqlquery.py", line 1096, in build_lookup
lookup = lookup_class(lhs, rhs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelslookups.py", line 20, in __init__
self.rhs = self.get_prep_lookup()
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsfieldsrelated_lookups.py", line 115, in get_prep_lookup
self.rhs = target_field.get_prep_value(self.rhs)
File "C:UsersmonuAppDataLocalProgramsPythonPython37libsite-packagesdjangodbmodelsfields__init__.py", line 965, in get_prep_value
return int(value)

TypeError: int() argument must be a string, a bytes-like object or a number, not 'QueryDict'
[25/Mar/2019 09:31:03] "POST /admin_panel/add_batch HTTP/1.1" 500 125516







python django






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 4:53









Monuprasad GaudMonuprasad Gaud

31




31












  • you are not providing user argument when instantiating batch form

    – Mohit Harshan
    Mar 25 at 4:58

















  • you are not providing user argument when instantiating batch form

    – Mohit Harshan
    Mar 25 at 4:58
















you are not providing user argument when instantiating batch form

– Mohit Harshan
Mar 25 at 4:58





you are not providing user argument when instantiating batch form

– Mohit Harshan
Mar 25 at 4:58












1 Answer
1






active

oldest

votes


















0














You have provided a user argument in your form's init method. In a couple if your else clauses you are not providing this user when instantiating the form:



else:
batch_form = BatchForm(request.user,request.POST, request.FILES)





share|improve this answer

























  • if I'm adding user=request.user then it is giving: SyntaxError: positional argument follows keyword argument ``` batch_form = BatchForm(user=request.user, request.POST, request.FILES) ```

    – Monuprasad Gaud
    Mar 25 at 5:06












  • also ,give SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first()

    – Mohit Harshan
    Mar 25 at 5:09











  • @MonuprasadGaud try rearranging the fields

    – Mohit Harshan
    Mar 25 at 5:11











  • SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first() gives: AttributeError: 'SubLocation' object has no attribute 'all'

    – Monuprasad Gaud
    Mar 25 at 5:15











  • When I'm rearranging the parameters like this: ``` batch_form = BatchForm(request.POST, request.FILES, user=request.user) ``` then it is giving this exception: ``` TypeError: __init__() got multiple values for argument 'user' ```

    – Monuprasad Gaud
    Mar 25 at 8:25












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331434%2ftypeerror-int-argument-must-be-a-string-a-bytes-like-object-or-a-number-not%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You have provided a user argument in your form's init method. In a couple if your else clauses you are not providing this user when instantiating the form:



else:
batch_form = BatchForm(request.user,request.POST, request.FILES)





share|improve this answer

























  • if I'm adding user=request.user then it is giving: SyntaxError: positional argument follows keyword argument ``` batch_form = BatchForm(user=request.user, request.POST, request.FILES) ```

    – Monuprasad Gaud
    Mar 25 at 5:06












  • also ,give SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first()

    – Mohit Harshan
    Mar 25 at 5:09











  • @MonuprasadGaud try rearranging the fields

    – Mohit Harshan
    Mar 25 at 5:11











  • SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first() gives: AttributeError: 'SubLocation' object has no attribute 'all'

    – Monuprasad Gaud
    Mar 25 at 5:15











  • When I'm rearranging the parameters like this: ``` batch_form = BatchForm(request.POST, request.FILES, user=request.user) ``` then it is giving this exception: ``` TypeError: __init__() got multiple values for argument 'user' ```

    – Monuprasad Gaud
    Mar 25 at 8:25
















0














You have provided a user argument in your form's init method. In a couple if your else clauses you are not providing this user when instantiating the form:



else:
batch_form = BatchForm(request.user,request.POST, request.FILES)





share|improve this answer

























  • if I'm adding user=request.user then it is giving: SyntaxError: positional argument follows keyword argument ``` batch_form = BatchForm(user=request.user, request.POST, request.FILES) ```

    – Monuprasad Gaud
    Mar 25 at 5:06












  • also ,give SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first()

    – Mohit Harshan
    Mar 25 at 5:09











  • @MonuprasadGaud try rearranging the fields

    – Mohit Harshan
    Mar 25 at 5:11











  • SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first() gives: AttributeError: 'SubLocation' object has no attribute 'all'

    – Monuprasad Gaud
    Mar 25 at 5:15











  • When I'm rearranging the parameters like this: ``` batch_form = BatchForm(request.POST, request.FILES, user=request.user) ``` then it is giving this exception: ``` TypeError: __init__() got multiple values for argument 'user' ```

    – Monuprasad Gaud
    Mar 25 at 8:25














0












0








0







You have provided a user argument in your form's init method. In a couple if your else clauses you are not providing this user when instantiating the form:



else:
batch_form = BatchForm(request.user,request.POST, request.FILES)





share|improve this answer















You have provided a user argument in your form's init method. In a couple if your else clauses you are not providing this user when instantiating the form:



else:
batch_form = BatchForm(request.user,request.POST, request.FILES)






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 25 at 5:09

























answered Mar 25 at 5:00









Mohit HarshanMohit Harshan

510212




510212












  • if I'm adding user=request.user then it is giving: SyntaxError: positional argument follows keyword argument ``` batch_form = BatchForm(user=request.user, request.POST, request.FILES) ```

    – Monuprasad Gaud
    Mar 25 at 5:06












  • also ,give SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first()

    – Mohit Harshan
    Mar 25 at 5:09











  • @MonuprasadGaud try rearranging the fields

    – Mohit Harshan
    Mar 25 at 5:11











  • SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first() gives: AttributeError: 'SubLocation' object has no attribute 'all'

    – Monuprasad Gaud
    Mar 25 at 5:15











  • When I'm rearranging the parameters like this: ``` batch_form = BatchForm(request.POST, request.FILES, user=request.user) ``` then it is giving this exception: ``` TypeError: __init__() got multiple values for argument 'user' ```

    – Monuprasad Gaud
    Mar 25 at 8:25


















  • if I'm adding user=request.user then it is giving: SyntaxError: positional argument follows keyword argument ``` batch_form = BatchForm(user=request.user, request.POST, request.FILES) ```

    – Monuprasad Gaud
    Mar 25 at 5:06












  • also ,give SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first()

    – Mohit Harshan
    Mar 25 at 5:09











  • @MonuprasadGaud try rearranging the fields

    – Mohit Harshan
    Mar 25 at 5:11











  • SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first() gives: AttributeError: 'SubLocation' object has no attribute 'all'

    – Monuprasad Gaud
    Mar 25 at 5:15











  • When I'm rearranging the parameters like this: ``` batch_form = BatchForm(request.POST, request.FILES, user=request.user) ``` then it is giving this exception: ``` TypeError: __init__() got multiple values for argument 'user' ```

    – Monuprasad Gaud
    Mar 25 at 8:25

















if I'm adding user=request.user then it is giving: SyntaxError: positional argument follows keyword argument ``` batch_form = BatchForm(user=request.user, request.POST, request.FILES) ```

– Monuprasad Gaud
Mar 25 at 5:06






if I'm adding user=request.user then it is giving: SyntaxError: positional argument follows keyword argument ``` batch_form = BatchForm(user=request.user, request.POST, request.FILES) ```

– Monuprasad Gaud
Mar 25 at 5:06














also ,give SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first()

– Mohit Harshan
Mar 25 at 5:09





also ,give SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first()

– Mohit Harshan
Mar 25 at 5:09













@MonuprasadGaud try rearranging the fields

– Mohit Harshan
Mar 25 at 5:11





@MonuprasadGaud try rearranging the fields

– Mohit Harshan
Mar 25 at 5:11













SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first() gives: AttributeError: 'SubLocation' object has no attribute 'all'

– Monuprasad Gaud
Mar 25 at 5:15





SubLocation.objects.filter(location = Subquery(AdminProfile.objects.filter(user = user).values('location'))).first() gives: AttributeError: 'SubLocation' object has no attribute 'all'

– Monuprasad Gaud
Mar 25 at 5:15













When I'm rearranging the parameters like this: ``` batch_form = BatchForm(request.POST, request.FILES, user=request.user) ``` then it is giving this exception: ``` TypeError: __init__() got multiple values for argument 'user' ```

– Monuprasad Gaud
Mar 25 at 8:25






When I'm rearranging the parameters like this: ``` batch_form = BatchForm(request.POST, request.FILES, user=request.user) ``` then it is giving this exception: ``` TypeError: __init__() got multiple values for argument 'user' ```

– Monuprasad Gaud
Mar 25 at 8:25




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331434%2ftypeerror-int-argument-must-be-a-string-a-bytes-like-object-or-a-number-not%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript