Unable to add user through django admin page - django

I have been using django-admin page to add user to my application. Recently when I tried to add a new user I started getting TypeError.
The exact error is :-
Exception Type: TypeError at /admin/auth/user/add/ Exception Value: 'float' object is not subscriptable Request information
Since I have not changed anything in the code, I am not sure why I am getting this error now. That is why I am at a loss as what to try to solve the issue.
I am attaching the traceback here:-
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py" in wrapper
552. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/sites.py" in inner
224. return view(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python3.7/site-packages/django/contrib/auth/admin.py" in add_view
103. return self._add_view(request, form_url, extra_context)
File "/usr/local/lib/python3.7/site-packages/django/contrib/auth/admin.py" in _add_view
131. extra_context)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py" in add_view
1509. return self.changeform_view(request, None, form_url, extra_context)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py" in changeform_view
1409. return self._changeform_view(request, object_id, form_url, extra_context)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py" in _changeform_view
1449. self.save_model(request, new_object, form, not add)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py" in save_model
980. obj.save()
File "/usr/local/lib/python3.7/site-packages/django/contrib/auth/base_user.py" in save
80. super(AbstractBaseUser, self).save(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py" in save
808. force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py" in save_base
838. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py" in _save_table
924. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py" in _do_insert
963. using=using, raw=raw)
File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method
85. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py" in _insert
1079. return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
1119. return self.connection.ops.fetch_returned_insert_id(cursor)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/oracle/operations.py" in fetch_returned_insert_id
245. return int(cursor._insert_id_var.getvalue()[0])
It would be very helpful if someone can point me to the proper direction.

Related

How to save django manytomany field without through table

I face a vicious cycle that I cannot break out of;
Lets say I have a following model:
class AgregatorProductCoupon(models.Model):
AgregatorProductId = models.ManyToManyField(Product, related_name="coupons", db_column='AgregatorProductId', verbose_name=_("Agregator Product Id"))
class Meta:
managed = True
db_table = 'AgregatorProductCoupon'
when I try to save an instance, I get an integrity error stating
"<AgregatorProductCoupon: AgregatorProductCoupon object (None)>" needs to have a value for field "id" before this many-to-many relationship can be used.
but when I try to save without the m2m rel, I obviously get an error for a required field missing.
Cannot insert the value NULL into column 'AgregatorProductId', table 'test_dbo.dbo.AgregatorProductCoupon'; column does not allow nulls. INSERT fails.
I cannot redesign the tables as they are bound to other places too.
How to go about it?
Any help would be much appreciated.
EDIT: Traceback:
[2021-01-07 13:19:28,040] log_response - Internal Server Error: /admin/agregator/agregatorcoupons/78/change/
Traceback (most recent call last):
File "C:\David\.venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\David\.venv\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\David\.venv\lib\site-packages\django\core\handlers\base.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\David\.venv\lib\site-packages\django\contrib\admin\options.py", line 607, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\David\.venv\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\David\.venv\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\David\.venv\lib\site-packages\django\contrib\admin\sites.py", line 223, in inner
return view(request, *args, **kwargs)
File "C:\David\.venv\lib\site-packages\django\contrib\admin\options.py", line 1650, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "C:\David\.venv\lib\site-packages\django\utils\decorators.py", line 45, in _wrapper
return bound_method(*args, **kwargs)
File "C:\David\.venv\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\David\.venv\lib\site-packages\django\contrib\admin\options.py", line 1536, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "C:\David\.venv\lib\site-packages\django\contrib\admin\options.py", line 1576, in _changeform_view
self.save_related(request, form, formsets, not add)
File "C:\David\.venv\lib\site-packages\django\contrib\admin\options.py", line 1122, in save_related
self.save_formset(request, form, formset, change=change)
File "C:\David\.venv\lib\site-packages\django\contrib\admin\options.py", line 1110, in save_formset
formset.save()
File "C:\David\.venv\lib\site-packages\django\forms\models.py", line 669, in save
return self.save_existing_objects(commit) + self.save_new_objects(commit)
File "C:\David\.venv\lib\site-packages\django\forms\models.py", line 803, in save_new_objects
self.new_objects.append(self.save_new(form, commit=commit))
File "C:\David\.venv\lib\site-packages\django\forms\models.py", line 949, in save_new
obj.save()
File "C:\David\agregator\models.py", line 2745, in save
print(self.AgregatorProductId)
File "C:\David\.venv\lib\site-packages\django\db\models\fields\related_descriptors.py", line 526, in __get__
return self.related_manager_cls(instance)
File "C:\David\.venv\lib\site-packages\django\db\models\fields\related_descriptors.py", line 821, in __init__
raise ValueError('"%r" needs to have a value for field "%s" before '
ValueError: "<AgregatorProductCoupon: AgregatorProductCoupon object (None)>" needs to have a value for field "id" before this many-to-many relationship can be used.

Django - The 'image' attribute has no file associated with it

User can register without a profile image.
Now I get error that no file was associated with the login.
Why does it validate the form and then try to save the image?
It should not check for the image.
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/views.py" in dispatch
90. return super(LoginView, self).dispatch(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/edit.py" in post
183. return self.form_valid(form)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/views.py" in form_valid
119. auth_login(self.request, form.get_user())
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py" in login
161. user_logged_in.send(sender=user.__class__, request=request, user=user)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py" in send
193. for receiver in self._live_receivers(sender)
File "/home/django/django_project/accounts/views.py" in got_online
115. user.profile.save()
File "/home/django/django_project/accounts/models.py" in save
116. img = Image.open(self.image.path)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in path
64. self._require_file()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in _require_file
46. raise ValueError("The '%s' attribute has no file associated with it." % self.field.name)
Exception Type: ValueError at /login/
Exception Value: The 'image' attribute has no file associated with it.
accounts/models.py
class UserProfile(models.Model):
image = models.ImageField(upload_to=upload_image_path,null=True,blank=True)
def save(self, *args, **kwargs):
super(UserProfile,self).save(*args, **kwargs)
if self.image != None:
img = Image.open(self.image.path)
if img.height > 300 or img.width > 300:
output_size = (300, 300)
img.thumbnail(output_size)
img.save(self.image.path)
def post_save_user_receiver(sender, instance, created, *args, **kwargs):
if created:
new_profile = UserProfile.objects.get_or_create(user=instance)
The registration works without the user having a image, but the login does not.
Thank you for any help
I solved it by adding a default image to the file field:
image = models.ImageField(upload_to=upload_image_path,default='default.jpeg')
and by changing the if statement in the save method
from:
if self.image != None:
to:
if not self.image:
According to traceback, there is a signal receiver in accounts/views.py#115, that listens for user_logged_in signal and tries to save user profile:
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py" in login
161. user_logged_in.send(sender=user.__class__, request=request, user=user)
...
File "/home/django/django_project/accounts/views.py" in got_online
115. user.profile.save()
And in user profile save and tries to open the profile image to thumbnail it.

Error while uploading with django-audiofield

Hey i am trying to use django-field but came across this error:
Traceback (most recent call last):
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\core\handlers\exception.py", line 35, in inner
response = get_response(request)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\core\handlers\base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 575, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\sites.py", line 223, in inner
return view(request, *args, **kwargs)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 1557, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\utils\decorators.py", line 62, in _wrapper
return bound_func(*args, **kwargs)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\utils\decorators.py", line 58, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 1451, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 1491, in _changeform_view
self.save_model(request, new_object, form, not add)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 1027, in save_model
obj.save()
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\db\models\base.py", line 729, in save
force_update=force_update, update_fields=update_fields)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\db\models\base.py", line 769, in save_base
update_fields=update_fields, raw=raw, using=using,
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\dispatch\dispatcher.py", line 178, in send
for receiver in self._live_receivers(sender)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\dispatch\dispatcher.py", line 178, in <listcomp>
for receiver in self._live_receivers(sender)
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\audiofield\fields.py", line 223, in _rename_audio
self._convert_audio(dst_fullpath, instance, ext[1:4])
File "C:\Users\Sebastian\Envs\blog\lib\site-packages\audiofield\fields.py", line 140, in _convert_audio
response = subprocess.Popen(command.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "C:\Python36\Lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Python36\Lib\subprocess.py", line 992, in _execute_child
startupinfo)
[WinError 2] FileNotFoundError
The audiofile is actually saved in media directory in the root of the project as specified in settings.py
Don't know where to look for. Have not been able to find a similar topic and the way to solve this...

Cannot login to admin with custom backend in Django 1.11.rc1

Using Django 1.10 I have no problem using my custom backend to login (not a custom user just the auth) but in 1.11rc1 I get the following exception:
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version: 1.11rc1
Exception Type: FieldError
Exception Value:
Cannot resolve keyword 'request' into field. Choices are: clientcontact, crudevent, date_joined, email, <...just more fields>
The backend:
def authenticate(self, **kwargs):
if kwargs:
username = kwargs.pop("username", None)
if username:
username_or_email = Q(username=username) | Q(email=username)
password = kwargs.pop("password", None)
try:
user = User.objects.get(username_or_email, **kwargs)
except User.DoesNotExist:
pass
else:
if user.check_password(password):
return user
else:
...
In settings.py:
AUTHENTICATION_BACKENDS = ('base_app.auth_backend.JbcBackend', 'guardian.backends.ObjectPermissionBackend',)
I haven't been able to find anything, if someone could point me in the right direction that would be great.
Here is the full Traceback:
Traceback:
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/channels/handler.py" in process_exception_by_middleware
237. return super(AsgiHandler, self).process_exception_by_middleware(exception, request)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/admin/sites.py" in login
393. return LoginView.as_view(**defaults)(request)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/views.py" in dispatch
90. return super(LoginView, self).dispatch(request, *args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/edit.py" in post
182. if form.is_valid():
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in is_valid
183. return self.is_bound and not self.errors
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in errors
175. self.full_clean()
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in full_clean
385. self._clean_form()
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in _clean_form
412. cleaned_data = self.clean()
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/forms.py" in clean
187. self.user_cache = authenticate(self.request, username=username, password=password)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in authenticate
100. user = backend.authenticate(*args, **credentials)
File "/home/mat/PycharmProjects/jbc_services/base_app/auth_backend.py" in authenticate
19. user = User.objects.get(username_or_email, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
85. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in get
370. clone = self.filter(*args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in filter
781. return self._filter_or_exclude(False, *args, **kwargs)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in _filter_or_exclude
799. clone.query.add_q(Q(*args, **kwargs))
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in add_q
1260. clause, _ = self._add_q(q_object, self.used_aliases)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in _add_q
1286. allow_joins=allow_joins, split_subq=split_subq,
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in build_filter
1164. lookups, parts, reffed_expression = self.solve_lookup_type(arg)
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in solve_lookup_type
1044. _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in names_to_path
1362. "Choices are: %s" % (name, ", ".join(available)))
Exception Type: FieldError at /admin/login/
Exception Value: Cannot resolve keyword 'request' into field. Choices are: clientcontact, crudevent, date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, logged_in_user, loginevent, password, thirdpartycontact, user_bookmarks, user_permissions, user_preferences, username, userobjectpermission
try:
user = User.objects.get(username_or_email)
# The user is found, now check if the password matches
if user.check_password(password):
return user
except User.DoesNotExist:
pass
...

Django admin 'save_as' with inlines

Should 'save_as' work with inlines. I'm rather baffled by the traceback but it doesn't seem to show much involvement of my own code.
The problem seems to be the id's of inlines being set to '' when saving an add form. This is handled quite happily by when you do a normal 'add':
Traceback:
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
307. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
93. response = view_func(request, *args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
79. response = view_func(request, *args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
197. return view(request, *args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
28. return bound_func(*args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
93. response = view_func(request, *args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
24. return func(self, *args2, **kwargs2)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/transaction.py" in inner
217. res = func(*args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view
879. prefix=prefix, queryset=inline.queryset(request))
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/models.py" in __init__
682. queryset=qs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/models.py" in __init__
415. super(BaseModelFormSet, self).__init__(**defaults)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/formsets.py" in __init__
47. self._construct_forms()
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/formsets.py" in _construct_forms
108. self.forms.append(self._construct_form(i))
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
691. form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
437. connection=connections[self.get_queryset().db])
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/subclassing.py" in inner
53. return func(*args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/subclassing.py" in inner
53. return func(*args, **kwargs)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/__init__.py" in get_db_prep_lookup
306. value = self.get_prep_lookup(lookup_type, value)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/__init__.py" in get_prep_lookup
292. return self.get_prep_value(value)
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/__init__.py" in get_prep_value
479. return int(value)
Exception Type: ValueError at /admin/property_manager/property/add/
Exception Value: invalid literal for int() with base 10: ''
Could be related to this if you're using FileFields? https://code.djangoproject.com/ticket/14760