Categories
User Help

OperationalError at /admin/products/product/add/ no such table: main.auth_user__old DJANGO [closed]

main.auth_user__old in django tutorial going through mosh created a web server.When saving some polls or products or set i get this error instead of going to be saved on the site. Heres the error OperationalError at /admin/products/product/add/ no such table: main.auth_user__old Request Method: POST Request URL: http://127.0.0.1:8000/admin/products/product/add/ Django Version: 2.1 Exception Type: OperationalError Exception Value: […]

Categories
Mastering Development

MySQL 5.7: fine tuning for too many connections error

I have an old django 1.9 application connected to a mysql 5.7 database. Sometime I get this error: [Fri Mar 20 10:27:19.482820 2020] [wsgi:error] [pid 15215] ” [Fri Mar 20 10:28:20.502889 2020] [wsgi:error] [pid 15215] [NXU ts_fw20] [2020-03-20 Fri 10:28:20.1584696500]ERROR “Exception during GET request (user: AnonymousUser): <QueryDict: {u’udid’: [u’B8663A17-C121-4691-A561-E0F698CDD4EA’], u’client_os_version’: [u’13.3.1′], u’client_app_version’: [u’11.30.1.201910161040′], u’client_app_type’: [u’Jukebox’], […]

Categories
Development

Django, Materialize, Django-tables2: Expected table or queryset, not str

I have a form and one of the fields is a MultipleChoiceField. The form is rendered in a modal using Materialize. I had issues to render the choices in the form but found this answer I changed the field to: comp = forms.MultipleChoiceField(choices=COMP, widget=forms.Select(choices=COMP, attrs={‘class’: ‘browser-default’})) which solved the rendering issue. Once I submit the […]

Categories
Development

Unclear errors when trying to save data while overriding default ‘create’ method

Tried to write custom create method for my model, but run into some unclear errors. Here is my code: # models.py: class ItemModel(models.Model): item_id = models.CharField(max_length=10, primary_key=True) name = models.CharField(max_length=40) active = models.BooleanField(default=True) def __str__(self): return self.item_id class ItemVersion(models.Model): item_ver_id = models.CharField(max_length=13, primary_key=True) item_ver = models.TextField() config = models.TextField() model = models.ForeignKey(ItemModel, on_delete=models.CASCADE, default=0) session_id […]

Categories
Development

Custom model form on admin tabular inline gives Integrity Error

I have made a custom model form so that I can change the header text: forms.py class AddRoomAddRoomExtrasForm(ModelForm): roomextrafields = forms.ModelChoiceField(queryset=RoomExtra.objects.all(), label=_(‘Room Extras’)) class Meta: model = RoomExtra fields = (‘roomextrafields’, ) admin.py class RoomExtraInLine(admin.TabularInline): model = Room.roomextra.through extra = 1 verbose_name = _(‘extra’) verbose_name_plural = _(‘extras’) form = AddRoomAddRoomExtrasForm class RoomAdmin(admin.ModelAdmin): model = Room […]

Categories
Development

Django – Import Export – MultiValueDictKeyError at /upload/

Im using django import-export module and Im following this documentation: https://simpleisbetterthancomplex.com/packages/2016/08/11/django-import-export.html#importing-data I want to create an upload-page where the user can upload multiple files. This is how far I got: def upload_data(request): if request.method == ‘POST’: wo_resource = WorkordersResource() pl_resource = PlantResource() se_resource = SeriesResource() re_resource = ResourcesResource() rd_resource = ResourceDemandsResource() dataset = Dataset() wo_data […]

Categories
Development

Error “invalid literal for int() with base 10: ‘[‘”. Change ‘[‘ into string

I got this error: Error “invalid literal for int() with base 10: ‘[‘”. I’m trying to splits the tokens into k clusters, where each token belongs to the cluster with the nearest mean. I know the code fails because the string includes the character ‘[‘, and that is not a string. but how do i […]

Categories
Development

Django TypeError: sequence item 0: expected str instance, NoneType found

I tried sending email through smtp and email.mime with Django. I have decided not to use the django email because I want to automate sending of emails to several other emails from any user so the user will be required to put in his email and password to his gmail so smtp can send emails […]

Categories
Development

Rotate selfie image working in development but not working when saving to S3 bucket in production?

I’m trying to fix an image rotation error that I’m getting in production, but not getting in development. Been stuck on this for a few days and would really appreciate any help from anyone who has any insight into how to solve this! ==Context== I’m writing a Django web app with a profile pic upload […]

Categories
Development

unexpected keyword argument ‘instance’ in Django ModelForm with formsets

So I have a Folder model, and 2 other models that are related to it via a ForeignKey. I have this method for creating 3 separate objects using 3 forms (creating the Folder object, and uploading files to 2 separate models that are related to Folder): @login_required def nouveaudossier(request): DocumentFormSet = modelformset_factory(DocumentdeBase, form=DocumentdebaseForm, extra=5) PhotoAvantFormSet […]