Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Changing Choice Field value from a function
models.py class Leave_Application(models.Model): name = .. employee = .. leave_reason = ... status_field = ( ('Pending','Pending'), ('Approved','Approved'), ('Declined','Declined'), ) status = models.CharField(max_length=10,choices=status_field,default='Pending') I have both 'approve' and 'decline' function which are called by respective 'approve' or 'decline' button and then it sends confirmation message to the employee. I want now , with the 'respective function call' the value of status should change like if i call approve function then it should be changed to 'Approved' and when i press decline button it should call decline function and status should be 'Declined' How can i achieve that? Thanks in advance -
can't we use only mongodb as database for backend while creating django application?
I am new to python world and I want to make larger apps just using MongoDB as the database and Django as the framework for web application creation, can I use only MongoDB as the database and not SQLite or MySQL for database if it is possible please can someone give me some idea need help thanks -
add records instead of updating records - firebase python
I have a project in python/django. In this project, i am taking information and I want to create an activity object in the firebase dataabase with that informaiton. I am currently using the database.update() command to add the record. I noticed that this replaces the existing infromation with the information that was already existant. Is there a command for me to add a new object instead of updating an old one. This is the code that I have: accepter_activity = { accepter:{ 'description':accepter_description, 'friend':requester, 'friends':True, 'requests':False, 'group':False } } new_activity = database.child('activity').child('users').update(accepter_activity) requester_description = 'You and ' + accepter + ' are now friends' requester_activity = { requester:{ 'description':requester_description, 'friend':accepter, 'friends':True, 'requests':False, 'group':False, } } new_activity = database.child('activity').child('users').update(requester_activity) this is what it looks like in the database: rather than it adding new activity with the old activity, it is replacing it. how can I get it to add the new activity. -
How to get the folder name in InMemoryUploadedFile in django?
In the django project I was working on, the uploaded tar file is stored as an InMemoryUploadedFile. I want to know the name of folder obtained by extracting that tar file. How can I do that? For example, a folder named "abcd" is created and it is compressed. We get "abcd.tar.gz". Now it's name is changed to "addition.tar.gz". I have uploaded this "addition.tar.gz". It is stored as an InMemoryUploadedFile.How can I get the name of folder i.e. "abcd" which is inside the uploaded tar.gz file? -
Django not running from Docker image, cant access
My Dokerfile FROM python:3.5 RUN apt-get update USER root WORKDIR /app ADD . /app RUN pip install -r requirements.txt WORKDIR /app/etalentNET EXPOSE 8000 CMD ["python", "manage.py", "makemigrations"] CMD ["python", "manage.py", "migrate"] CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] When I run the image docker run -p 8002:8000 demo it doenst do anything But when i run docker run -p 8002:8000 -it demo bash and then there python manage.py runserver 0.0.0.0:8000the servers start running.(But cant access via host_ip:8000 I dont know why) Im running in a GoogleCloud Machine with ubuntu 16.04, and Django-2.0.6 -
Deploy django 2.0 with python3.6 on ubuntu 16.04 with mod_wsgi and apache2.4
I'm trying deploy django with apache2.4 mod_wsgi on ubuntu,but i'm giving an error. First install packages: sudo apt upgrade && sudo apt install virtualenv python-setuptools python3.6(from ppa) python3-pip python3.6-dev libapache2-mod-wsgi-py3 apache2 mysql-server Ok, All install correctly. So, I create a folder project mkdir /mnt/g/development/matrix Create a virtualenv virtualenv --python=python3.6 env and activate Install django2.0 from pip pip install django - ok install and check which python /mnt/g/development/matrix/env/bin/python python -V Python 3.6.3 So I create a vhost on apache <VirtualHost *:80> ServerName 127.0.0.50 ServerAlias matrix.local DocumentRoot /mnt/g/development/matrix/framework Alias /static /mnt/g/development/matrix/framework/static Alias /media /mnt/g/development/matrix/framework/media <Directory /mnt/g/development/matrix/framework/framework> <Files wsgi.py> Require all granted </Files> </Directory> <Directory /mnt/g/development/matrix/framework/media/> Require all granted </Directory> <Directory /mnt/g/development/matrix/framework/static/> Require all granted </Directory> WSGIDaemonProcess matrix processes=2 threads=5 display-name=%{GROUP} python-path=/mnt/g/development/matrix/framework/:/mnt/g/development/matrix/env/lib/python3.6/site-packages WSGIProcessGroup matrix WSGIScriptAlias / /mnt/g/development/matrix/framework/framework/wsgi.py </VirtualHost> So, I start apache and mysql server, but I give an error (env) root@WILLIAM:/mnt/g/development/matrix# tail /var/log/apache2/error.log [Tue Jun 19 04:01:10.947533 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] mod_wsgi (pid=14811): Target WSGI script '/mnt/g/development/matrix/framework/framework/wsgi.py' cannot be loaded as Python module. [Tue Jun 19 04:01:10.948034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] mod_wsgi (pid=14811): Exception occurred processing WSGI script '/mnt/g/development/matrix/framework/framework/wsgi.py'. [Tue Jun 19 04:01:10.948034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] Traceback (most recent call last): [Tue Jun 19 04:01:10.948034 … -
How to Save multiselect in django model?
I have two model Business and Category. I want to save Multiple categories in Business. class Business(models.Model): user = models.ForeignKey('User', on_delete=models.CASCADE) business_name = models.CharField(max_length=100) category = models.IntegerField() keyword = models.CharField(max_length=100) and Category Model Is Here class Category(models.Model): name = models.CharField(max_length=100) slug = models.CharField(max_length=100) Category Model is already filled with values. -
Django: prepopulate formset
I have a formset, but I can't figure out how to prepopulate it with data from the database. Truth be told, I have a model Library and a model Book that has a foreign key to Library. I want someone to be able to edit all of the book in one library (at a time). html {{ book_form.management_form }} {% for form in book_form.forms %} {{ form.as_p }} {% endfor %} views.py class LibraryUpdateView(LoginRequiredMixin, UpdateView): model = Library form_class = LibraryChangeForm template_name = 'libraries/library_update.html' def get_context_data(self, *args, **kwargs): context = super(LibraryUpdateView, self).get_context_data(*args, **kwargs) if self.request.POST: context['book_form'] = BookFormSet(self.request.POST) else: context['book_form'] = BookFormSet() return context forms class LibraryChangeForm(forms.ModelForm): class Meta: exclude = ['updated'] BookFormSet = inlineformset_factory(Library, Book, exclude = () ) How do I prepopulate the html page to show the data in the formset. In my loop there are 3 loops for {{form.as_p}}. When I run print(BookFormsSet()) I see the following <input type="hidden" name="perdateinfo_set-TOTAL_FORMS" value="3"... So it looks like it is generating three blank forms. When I run print(PerDateInfoFormSet(qs,qs2)) for qs = Library.objects.filter(library_id='slkdfj') and qs2=Book.objects.filter(library_id='slkdfj') It tells me too many values to unpack (expected 2) Can I pass in a query set? I imagine that I will be passing in … -
Is there a way to search for a keyword in a word document stored whereis document urls are stored in postgre database
Everyone I have a django webapp. And postgre as database. Where i have a column which contains the url of some saved word document. I was wondering if there is any better way to search for a keyword inside the attached word documents. -
how to pass objects with django and ajax?
I have an application in Django 2.0 in which I use a template with an ajax function from which I want to receive the result of a filter but it generates the following error: TypeError: <QuerySet [<Curso: Curso object (1)>, <Curso: Curso object (2)>, <Curso: Curso object (3)>]> is not JSON serializable Views.py def activaAjax(request): curso = Curso.objects.filter(pk = request.GET['id']) cursos = Curso.objects.all() try: curso.update(estado=Case(When(estado=True, then=Value(False)),When(estado=False, then=Value(True)))) mensaje = "Proceso de ACTIVACIÓN/INACTIVACIÓN correcto!!!" data = {'mensaje': mensaje, 'cursos':cursos} return HttpResponse(json.dumps(data), content_type="application/json") except: return HttpResponse(json.dumps({"mensaje":"Error"}), content_type='application/json', status = 500) return HttpResponse(json.dumps({"mensaje":"Error"}), content_type='application/json') -
Retrieve a list from Data store for django choicefield
In forms.py, I defined the dropdown list as follow: DEPARTMENT_CHOICES = ( ('SALES', 'sales'), ('TECH', 'tech'), ('HR', 'hr'),) class MyForm(forms.Form): department_s = forms.ChoiceField( widget=forms.SelectMultiple, choices=DEPARTMENT_CHOICES, required=True,) It works fine in this way. But I want to retrieve the choice list from Google data store based on username dynamically. For example, if user1 is accessing to the form, then retrieve department list of his company(say company A). If user2 is accessing, then retrieve department list of his company (company B). User list and department list are stored in data store. I know that I may need to obtain the keys from data store, but really not sure how to do this right. Any body have sample codes for this case? Thanks in advance! -
Prevent makemigrations and migrate commands in production envnt
I want to prevent execution of make-migrations and migrate commands on production servers unless it is required. How can this be accomplished? -
ImportError: cannot import name 'RemovedInDjango20Warning'
I am using django 1.11 and django rest version 3. urls.py router = routers.SimpleRouter() router.register(r'abc',AbcViewset) abc_router = routers.NestedSimpleRouter(router,r'abc', lookup='abc') abc_router.register(r'xyz', XyzViewset, base_name='abc-xyz') urlpatterns = [ url(r'', include(router.urls)), And I got above mentioned error. ] -
Django Allauth custom Welcome email from Signup
I am using Allauth to Signin a new User which is followed by an Email Verification for that user. But instead of sending the standard email address verification email I would like to send a special "Welcome" email. Is there anyway to specify a different email when verifying for Signup? So I need two different emails upon verification. One for the Signup email verification and the other for normal email verification. Possible? Thanks. -
django-compressor CommandError: An error occurred during rendering file/path.html: Invalid class path 'css'
I'm trying to use django-compressor for my project. So far in my development environment, when I run python manage.py compress I been get this error CommandError: An error occurred during rendering D:path/to/a/template.html: Invalid class path 'css' I have lots of template files spread across many apps. The error pops up randomly, pointing to a different template each time I run python manage.py compress. I have also tried first running python manage.py collectstatic, but to no avail and nothing in the docs seem to mention this error OS: Windows 10, Django==2.0.5, django-compressor==2.2 Relevant settings.py section below DEBUG = True STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),) MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' COMPRESS_ROOT = STATIC_ROOT COMPRESS_URL = STATIC_URL COMPRESS_PARSER = 'compressor.parser.HtmlParser' COMPRESS_ENABLED = True COMPRESS_OFFLINE = True COMPRESS_OFFLINE_MANIFEST = 'compressor_manifest.json' COMPRESS_CSS_FILTERS = { 'css': ['compressor.filters.css_default.CssAbsoluteFilter'], 'js': ['compressor.filters.jsmin.JSMinFilter'] } COMPRESS_PRECOMPILERS = ( ('text/x-scss', 'django_libsass.SassCompiler'), ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'compressor.finders.CompressorFinder', ) Inside the <head></head> tag of my project's base.html template I have {% load compress %} {% load staticfiles %} {% load static %} {% compress css file %} <link rel="stylesheet" href="{% static 'css/fname.css' %}"> {% endcompress %} {% compress js file %} <script type="text/javascript" src="{% … -
Select related models by date range only and serialize as nested list
If my models look like this: class ImageUpload(models.Model): created = models.DateTimeField(default=timezone.now) iot_device = models.ForeignKey(IotDevice, related_name = 'uploads') datafile = models.ImageField(upload_to = upload_path_handler) class IotDevice(models.Model): device_name = models.CharField(max_length=100, default='device1') class Batch(models.Model): begindate = models.DateTimeField(auto_now_add = False, blank = True, null = True) enddate = models.DateTimeField(auto_now_add = False, blank = True, null = True) iot_device = models.ForeignKey(IotDevice, related_name = 'batch_iotdevice') I would like to select all ImageUpload where a batch is active (only a begindate, enddate needs to be NULL). I wrote the following code in my view: active_batch = ImageUpload.objects.filter(iot_device__batch_iotdevice__enddate__isnull = True, iot_device__batch_iotdevice__begindate__lte = F('created')).select_related('iot_device') It generates the correct SQL query when doing active_batch.query SELECT "api_imageupload"."id", "api_imageupload"."created", "api_imageupload"."iot_device_id", "api_imageupload"."datafile", "api_iotdevice"."id", "api_iotdevice"."device_name" FROM "api_imageupload" INNER JOIN "api_iotdevice" ON ("api_imageupload"."iot_device_id" = "api_iotdevice"."id") INNER JOIN "api_batch" ON ("api_iotdevice"."id" = "api_batch"."iot_device_id") WHERE ("api_batch"."enddate" IS NULL AND "api_batch"."begindate" <= ("api_imageupload"."created")) ORDER BY "api_imageupload"."created" DESC How can I write my serializers in a way that I would get Batch and every ImageUpload under it as child, e.x.: [ { "begindate": "2018-03-01T12:00:07.501686", "enddate": "NULL" "device_name": "CONTAINER_1", "uploads": [ { "created": "2018-06-18T12:00:07.501686", "datafile": "/media/cam/CONTAINER_1/20180618_120007.jpg", "thumbnail_path": "/media/cache/80/d3/80d34e2e28773d2c2e11548525e9fd19.jpg" }, { "created": "2018-06-18T00:00:05.017622", "datafile": "/media/cam/CONTAINER_1/20180618_000005.jpg", "thumbnail_path": "/media/cache/b7/f8/b7f836e52b975a61558ae62d0a6132a6.jpg" }, ] }, { "begindate": "2018-06-01T12:00:07.501686", "enddate": "NULL" "device_name": "CONTAINER_2", "uploads": [ { "created": "2018-06-18T12:00:07.501686", … -
Multiple Django Database Connection
I'm using django 2.0. I need to execute a large sql query on another database rather than default, is it possible to specify the database name (that is defined in settings.py) when importing connection from django.db?? PS: No routers suggestions -
I have a the source of a java program and I want to make it work online
So, here's the deal: I want to make a program, written in java, to work online, like getting some parameters from users, doing a kind of optimization and return the results. Maybe a single page website will do the task. Here's the question: I don't know what I need to learn/do to fulfill the job, Like: Do I need a Database? How to implement the back- or front-end? I only know python, which is likely to be irrelevant to this project, Can I do the server side scripting using Django and Python? or is it recommended? How to change the original code to make some web/database integration? I've done a little bit of research, and found out that I have to learn JAVA EE. Aside from those mentioned earlier, The Main Big question is : Which technologies or solutions are the most efficient for doing such a thing, like if I'm going to learn a whole new platform which one is at least easier to implement for this project? I know it may sound a little broad/dumb but for someone like me, who had never got the chance to be in a real web project, I'm completely confused with the … -
the JSON object must be str, not 'bytes' django throwing error
the JSON object must be str, not 'bytes' i am getting the error message as the JSON object must be str, not 'bytes' can anyone help me to fix def loginemployee(request): payload = json.loads(request.body) if payload: employee=models.Employees.objects.filter(Q(username=payload['username']) & Q(password=payload['password']) & (Q(role=payload['role']) | Q(backup_role=payload['role']))) # employees1=models.Employees.objects.filter(Q(email=payload['username']) & Q(role=payload['role'])) # empl=(employee+employees1); if employee: emp = serializers.serialize('json', employee) return HttpResponse(emp,content_type='application/json') -
How to create new issues without selecting 'project'(manually select project_id)?
I am doing my school project by using Django to create a task management web application. My responsibilities are to create 'issue tracker', something like 'StackOverflow', but I am still at the very early stage of it. So I used crispy form to let the user create their own new issues. Since we use 'project_id' and 'issue_id' as parameters to direct users to different pages, so I encountered this problem, users have to manually choose 'project' when they create a new issue. I do not know how to put the issue which created by the user under right project without having to choose 'project' manually. form.py from django import forms from .models import Comment,Issue class CommentForm(forms.ModelForm): class Meta: model = Comment fields = ('body',) class IssueForm(forms.ModelForm): class Meta: model = Issue fields = ('title','content','project','status') class NewIssueForm(forms.ModelForm): class Meta: model = Issue fields = ('title','content','project','status') new_issue.html {% extends 'base.html' %} {% load crispy_forms_tags %} {% block content %} <h1>Add New Issue </h1> <form method="POST" class="Issue-form">{% csrf_token %} {{form|crispy}} <button type="submit" class="btn btn-success">Submit</button> </form> {% endblock %} models.py class Issue(models.Model): STATUS_CHOICES = ( ('draft', 'Draft'), ('published', 'Published'), ) project = models.ForeignKey(Project,on_delete=models.CASCADE) title = models.CharField(max_length=250) slug = models.SlugField(max_length=250) content = models.TextField() author = … -
How to query for a particular foreign record in django models
Given these models: class Cluster(models.Model): name = models.TextField() class Vmt(models.Model): added = models.DateField(default=datetime.date.today, blank=True, null=True) purpose = models.TextField(blank=True, null=True) status = models.TextField(blank=True, null=True) cluster = models.ForeignKey(Cluster, null=True) class Meta: unique_together = (("cluster", "added"),) I would like to be able to have a result set that only contains Vmt records that were 'added' today. I have tried this: for c in Cluster.objects.filter(vmt__added='2018-06-18'): print "%s Vmt count = %s" % (c.name, c.vmt_set.count()) for vmt in c.vmt_set.all(): print "vmt added %s" % (vmt.added) But I get results that look like this: GL-AURM24 Vmt count = 2 vmt added 2018-06-18 vmt added 2018-06-17 GL-AURM23 Vmt count = 2 vmt added 2018-06-18 vmt added 2018-06-17 JCK-AURM10 Vmt count = 2 vmt added 2018-06-18 vmt added 2018-06-17 I was hoping for: GL-AURM24 Vmt count = 1 vmt added 2018-06-18 GL-AURM23 Vmt count = 1 vmt added 2018-06-18 JCK-AURM10 Vmt count = 1 vmt added 2018-06-18 -
Django Models custom methods
is there any way to call a specific model custom method from a view? i need to subtract or increment depending on the view a field on my model, I want to create a button for each of the two options and after imputing that data update the field in my database. if so how can i go about implementing it, currently my save method is doing the two operations at once models.py class Items(models.Model): nombre = models.CharField(max_length=250) descripcion = models.CharField(max_length=250) codigo_proveedor = models.CharField(max_length=250) categoria = models.ForeignKey('Categorias', on_delete=models.CASCADE) c_minima = models.PositiveIntegerField() c_actual = models.PositiveIntegerField() c_descuento = models.PositiveIntegerField(blank=True) c_incremento = models.PositiveIntegerField(blank=True) proveedor = models.ForeignKey('Proveedores', on_delete=models.CASCADE) carrito = models.ForeignKey('Carrito', on_delete=models.CASCADE, null=True ) p_unitario = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True ) total = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True) material = models.ForeignKey(Materiales, null=True, blank=True) tipo = models.ForeignKey(Tipo, null=True, blank=True) active = models.BooleanField() def save(self, *args, **kwargs): self.c_actual = self.c_actual - self.c_descuento self.c_actual =self.c_actual + self.c_incremento self.total = self.c_actual * self.p_unitario super(Items, self).save(*args, **kwargs) def __str__(self): return '%s %s %s %s' % (self.nombre, str(self.categoria), str(self.c_actual), str(self.total)) -
OperationalError: could not connect to server: Operation timed out - when trying to change database from sqlite to postresql
I'm following this tutorial to configure my zappa app so I can use AWS lambda functions for my django app. I'm up to "Configure the database" so that's what I'm trying to do. My django app uses postgresql so I'm trying to change my zappa app to postgresql (from the default sqlite). I've successfully created a postgres DB instance on Amazon RDS. The instance setting Publicly accessible is set to Yes. I've also successfully installed psycopg2 and psycopg2-binary in my zappa app, as well as changing my DB settings: DATABASES = { 'default': { 'ENGINE': config('DB_ENGINE'), 'NAME': config('DB_NAME'), 'USER': config('DB_USER'), 'PASSWORD': config('DB_PASSWORD'), 'HOST': config('DB_HOST'), 'PORT': '5432', } } However when I perform makemigrations in my zappa app I get the following error: Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/Users/zorgan/Desktop/zappatest/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/Users/zorgan/Desktop/zappatest/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/zorgan/Desktop/zappatest/env/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/Users/zorgan/Desktop/zappatest/env/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/Users/zorgan/Desktop/zappatest/env/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 110, in handle loader.check_consistent_history(connection) File "/Users/zorgan/Desktop/zappatest/env/lib/python3.6/site-packages/django/db/migrations/loader.py", line 282, in check_consistent_history applied = recorder.applied_migrations() File "/Users/zorgan/Desktop/zappatest/env/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations self.ensure_schema() File "/Users/zorgan/Desktop/zappatest/env/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()): File … -
I am trying to make and ajax call to my django backend
I have ths code tyng to make a call to my django backed using ajax but it gives me this error: Reverse for 'delete_skill' with arguments '('',)' not found. 1 pattern(s) tried: ['jobs/delete_skill/(?P[0-9]+)$'] <a href="{% url 'freelance:delete_skill' id_number %}" class="glyphicon glyphicon-trash delete_skill" style="padding:0px; margin:0px; background:grey; color:red; border:0px;" id="{{skill.id}}"></a> </span> {% endfor %} {% endif %} <script> $(document).ready(function() { $(".delete_skill").click(function(){ var id_number = this.id; alert(id_number); $.ajax({ type: 'DELETE', url: "{% url 'freelance:delete_skill' id_number %}", dataType: "json", data: 'identifier='+id_number, 'csrfmiddlewaretoken': '{{ csrf_token }} success: function(){ if(data) {alert("Success! skill has been deleted")} }); }); }); my url is like this url(r'^delete_skill/(?P<identifier>[0-9]+)$', views.delete_skill, name='delete_skill'), any help on what is going on or what I should add please -
Update views is not updating imagefield Django
I have an updated view and I need to change image field models.py where the table i need to edit : class Item(models.Model): # custom validators alphanumeric = RegexValidator(r'^[0-9a-zA-Z]*$', 'Only alphanumeric characters are allowed.') # fields dress_name = models.ForeignKey(Name, on_delete=models.DO_NOTHING, blank=False, verbose_name='نوع الفستان',) dress_rate = models.ForeignKey(Rate, on_delete=models.DO_NOTHING, blank=False, verbose_name='تصنيف الفستان',) dress_size = models.ForeignKey(Size, on_delete=models.DO_NOTHING, verbose_name='مقاس الفستان', blank=False) dress_color = models.CharField(max_length=50, verbose_name='لون الفستان', blank=False) dress_description = models.TextField(max_length=800, verbose_name=' وصف إضافى للفستان', blank=False) dress_image1 = models.ImageField(upload_to='documents/%Y/%m/%d', null=False, blank=False, verbose_name='الصورة الأساسية للفستان', help_text='لا يمكنك تركها فارغة') dress_image2 = models.ImageField(upload_to='documents/%Y/%m/%d', null=False, blank=False, verbose_name='صورة إضافية ') dress_image3 = models.ImageField(upload_to='documents/%Y/%m/%d', null=False, blank=False, verbose_name='صورة إضافة ') dress_image4 = models.ImageField(upload_to='documents/%Y/%m/%d', null=True, blank=True, verbose_name='صورة إضافة ') dress_image5 = models.ImageField(upload_to='documents/%Y/%m/%d', null=True, blank=True, verbose_name='صورة إضافة ') dress_action = models.ForeignKey(Action, on_delete=models.DO_NOTHING, verbose_name='الفستان معروض لل ', help_text='للبيع او للإيجار ', blank=False) dress_price = models.IntegerField(default=1, verbose_name='السعر', blank=False) dress_mobile = models.CharField(max_length=20, validators=[alphanumeric], verbose_name='رقم الهاتف ', blank=False) created_by = models.CharField(max_length=250,) created_username = models.CharField(max_length=250, default='unknown') created_at = models.DateTimeField(auto_now=True) dress_active = models.BooleanField(default=False) dress_special = models.BooleanField(default=False) dress_town = models.ForeignKey(Town, on_delete=models.DO_NOTHING, verbose_name='المحافظة', blank=False) urls.py where the URL for the update view : path('dress/<int:pk>/update/', views.dress_update.as_view(), name="dress_update"), views.py where the view itself : class dress_update(UpdateView): model = Item fields = ['dress_name', 'dress_rate', 'dress_size', 'dress_color','dress_description', 'dress_image1', 'dress_image2', 'dress_image3', 'dress_image4', 'dress_image5', 'dress_action', 'dress_price', 'dress_mobile', …