Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
pydoc with django application fails with "AppRegistryNotReady: Apps aren't loaded yet."
i' ve a newly installed virtualenv with python3.4 and Django 1.9.2 . Nothing else is installed. I created a project (pydoctest) and an application (order), added one class to the models, and a line to the INSTALLED_APPS for the application. I ran pydoc -w ./ on the root directory, but it fails on some file. #order/models.py class Alma(models.Model): """Test docstring""" apple = models.CharField(max_length = 12) user@debpra:~/ve/pydoctest$ pydoc -w ./ wrote manage.html wrote order.html wrote order.admin.html wrote order.apps.html wrote order.migrations.html problem in order.models - AppRegistryNotReady: Apps aren't loaded yet. wrote order.tests.html wrote order.views.html wrote pydoctest.html wrote pydoctest.settings.html problem in pydoctest.urls - AppRegistryNotReady: Apps aren't loaded yet. wrote pydoctest.wsgi.html . What do i miss here? What be the right way to use pydoc with Django (1.9.2)? Also if i put import django django.setup() to the pydoctest/init.py, all problem will be solved. What does it exactly do? -
Running django channels with daphne on systemd
First of all, sorry for the long question, I hope a few of you have patience for this. TL; DR: How do I load django settings correctly in systemd? I am following this guide, Deploying Django Channels Using Daphne, so I can run some real-time apps (using WebSockets). Without nginx, and running from the command line the worker (python manage.py runworker) and interface (daphne), I can access the correct channels consumer class, as can be seen in the log below (these were triggered from a javascript client): 2017-10-09 21:10:35,210 - DEBUG - worker - Got message on websocket.connect (reply daphne.response.CYeWgnNQoY!mwuQrazQtv) 2017-10-09 21:10:35,211 - DEBUG - runworker - websocket.connect 2017-10-09 21:10:35,211 - DEBUG - worker - Dispatching message on websocket.connect to api.consumers.OrderConsumer 2017-10-09 21:10:48,132 - DEBUG - worker - Got message on websocket.receive (reply daphne.response.CYeWgnNQoY!mwuQrazQtv) 2017-10-09 21:10:48,132 - DEBUG - runworker - websocket.receive 2017-10-09 21:10:48,132 - DEBUG - worker - Dispatching message on websocket.receive to api.consumers.OrderConsumer These events were triggered by the following javascript calls: ws = new WebSocket("ws://localhost:8000/order/1/") ws.send("test") With nginx, and running both interface and worker on systemd, I get the following log despite using the exact same trigger input. 2017-10-09 20:38:35,503 - DEBUG - worker - Got message … -
is it possible to instantiate django object and then populate values?
I have a django model with a lot of fields so I don't want to create with a constructor. I am trying to save like this: org = Organization() org.name = 'my name' org.save() but it is not saving. How do I save and populate a django object in this way? -
What data type to use for storing version numbers in database in Django
What is the best data type to use for storing version data such as x.x.x ( ex: 1.1.0) using the django model fields. -
Static File Whitenoise Heroku Django issue
I have an API developed in Django and Django Rest Framework. We need one page in "normal" Django that will be open once a month maybe (so no need for CDN for the static files). Gunicorn + whitenoise is what we went ahead with. The collectstatic works fine in both build phase and after build phase. The url generated on the page is href=/static/css/edit_card.a1c6e0f9f12e.css/ Relevant django settings: # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static_media/') STATICFILES_DIRS = [ os.path.join(BASE_DIR + "/static_folder/"), ] STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' The relevant file in the repo is in /static_folder/css/edit_card.css The relevant file on the heroku instance after running collectstatic is in static_media/css/edit_card.a1c6e0f9f12e.css I can manually access this link url/static/css/edit_card.css which is ridiculously weird. This works fine when DEBUG = True. When in False/production it does not. Could someone point me in the right direction? Thanks. -
I am getting the following error when trying to save this form
Cannot assign "": "Product.partner" must be a "Partner" instance. I am trying to add a one to many relationship between two models. The 'one' model is a 'Partner. The 'many' are 'Product' which contain image description, price, etc. Here are my views.py def partner_create(request): #Trying to add multiple product functionality if not request.user.is_staff or not request.user.is_superuser: raise Http404 ProductFormSet = inlineformset_factory(Partner, Product, form=ProductForm, extra=3) if request.method == 'POST': partnerForm = PartnerForm(request.POST or None, request.FILES or None) formset = ProductFormSet(request.POST, request.FILES, queryset=Product.objects.none()) if partnerForm.is_valid() and formset.is_valid(): instance = partnerForm.save(commit=False) instance.save() for form in formset.cleaned_data: image = form['image'] product = Product(partner=partnerForm, image=image) product.save() messages.success(request, "Partner Successfully Created") else: print partnerForm.errors, formset.errors else: partnerForm = PartnerForm() formset = ProductFormSet(queryset=Product.objects.none()) return render(request, "partner_form.html", {"partnerForm": partnerForm, "formset": formset}) here is my admin.py class ProductImageInline(admin.TabularInline): model = Product extra = 3 #This works originally but doesn't do multiple products class PartnerModelAdmin(admin.ModelAdmin): list_display = ["__unicode__", "timestamp"] inlines = [ProductImageInline,] class Meta: model = Partner admin.site.register(Partner, PartnerModelAdmin) Here is my form.py class PartnerForm(forms.ModelForm): mission = forms.CharField(widget=PagedownWidget(show_preview=False)) vision = forms.CharField(widget=PagedownWidget(show_preview=False)) # publish = forms.DateField(widget=forms.SelectDateWidget) class Meta: model = Partner fields = [ "name", "logo", "banner_image", "mission", "vision", "website_link", "fb_link", "twitter_link", "ig_link", ] class ProductForm(forms.ModelForm): image = forms.ImageField(label='Image') class Meta: … -
django - How to make a simple shopping cart
I'm at a loss. I've searched most of the links on Google/YouTube and can't seem to figure out how to create a simple session-based cart in Django! My website is NOT an e-commerce store. I have a Post model which users can review via a Comment model. They review the Post's overall quality, overall difficulty, and workload based on a 1-5 rating system. All that I want is for users to be able to go to the Post page, press "Add to Cart" and be redirected to a "cart.html" page where they see the Post they just added, as well as that Post's ratings (Quality, Difficulty, Workload). These ratings come from my Comment model, which is 100% based on User input. I need this cart to exist in the session! It is very important that anonymous users have access to this feature. here's a brief snippet of my models.py class Post(models.Model): [...] title = models.CharField(max_length=250) # rest of code class Comment(models.Model): [...] post = models.ForeignKey(Post, related_name="comments") user = models.ForeignKey(User, related_name="usernamee") [...] overall_rating = models.FloatField(choices=overall_rating_choices, default=None) difficulty_rating = models.FloatField(choices=difficulty_rating_choices, default=None) workload_rating = models.FloatField(choices=workload_rating_choices, default=None) # rest of code I don't need a checkout page, I don't need any payment processing, I … -
How to integrate an Angular app with Django back-end into a Laravel website project
I have developed an API for a quiz which has an Angular Front that uses quite a lot of Statistics in django in the server-side using the pymc package. My main website back-end is meant to be kept PHP. So I have created the initial components with Laravel. I would want to know how to integrate these two in the main website. How do I organize the code? What do i do to make sure that the user can navigate smoothly and also how to optimize the integration workflow? I am literally having no leads on this. Even if someone can suggest some reading material, that would also be fine. I really need to solve this problem. I would be heartily grateful if someone could help me figure out the same. Thanks in Advance. -
Update ends in negative balance after massive update requests Django
Currently, I've this method inside my models.py def charge(self, amount): self.balance = (self.balance - Decimal(amount)) self.save() When A new request comes in I check if that user has current_balance >= price So I can do objectRow.charge(price) the issue is when I get 1000 request to the same ID I end up in -000 negative balance and the users ends up owing me money and that's not the point. This is my validation so far. accountObject = account.objects.get(auth_token=auth_token) if accountObject.balance >= settings.MT_COST: # Save ProductObject = product(application=applicationObject, account=accountObject, cost=settings.MT_COST, direction=2, status_log=1, product=product_id, ip_address=ip_address) ProductObject.save() # Charge User ProductObject.charge(settings.MT_COST) data = {'status': "ok"} return HttpResponse(json.dumps(data), content_type='application/json', status=200) # Not enough Balance else: data = {'status': "error"} return HttpResponse(json.dumps(data), content_type='application/json', status=406) -
Django unicode convertion
I did some research on Unicode strings, but I've unfortunately not been able to figure out why Python does some things. I have this piece of code: output["anything"] = { "type": "Feature", "properties": { "name": "somename", "amenity": "Store", "popupContent": "Store 3 " }, } When I use print(output) it prints this as: {u'anything': u'type': u'Feature', u'properties': {u'amenity': u'Store', u'name': u'somename', u'popupContent': u'Store 3'}} I would however like to have this without the u' ' as my javascript utility won't read this. If the answer would also give me some insight in why this is happening, I would really appreciate that. -
Update seconds dropdown based on the selection of the first dropdown using the database
I have two dropdowns in my HTML. The second select would change depending on the selection of the first one. I want my first element to be the one to make an AJAX call and extract what's inside of my database. I am not quite fluent in jQuery/AJAX and I need help on this one. Here is an example: <select name="menu"> <option value="meat"> Meat </option> <option value="seafood"> Seafood </option> <option value="vegetarian"> Vegetarian </option> <option value="dessert"> Dessert </option> </select> <select name="entrees"> {% for i in meat %} <option value='{{idx.0}}'> {{i.1}} </option> {% endfor %} //more loops for other menu </select> When the user select the type of food, different entrees appears on the second html dropdown. I am using python and django in my backend. The entrees are being updated regularly that is why I can't hardcode the options of the second dropdpwn, as many have suggested on some question here. LET'S SAY: I choose 'meat.' How do I make an ajax call to get all the meat entrees in an array so I can loop into it? I would greatly appreciate it if you can comment lines that are important so I can learn something new. Thank you very much … -
ValueError: Dictionary Update Sequence Element #0 has length 0; 2 is required
So, everything was working perfectly fine. But when I tried to "Log-out" I got this error: Internal Server Error: / Traceback (most recent call last): File "C:\Python36\lib\site-packages\django\core\handlers\exception.py", line 41, in inner response = get_response(request) File "C:\Python36\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Python36\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\admin\Desktop\infortion\home\views.py", line 28, in posts_list return render(request, 'home/post_list.html', context) File "C:\Python36\lib\site-packages\django\shortcuts.py", line 30, in render content = loader.render_to_string(template_name, context, request, using=using) File "C:\Python36\lib\site-packages\django\template\loader.py", line 68, in render_to_string return template.render(context, request) File "C:\Python36\lib\site-packages\django\template\backends\django.py", line 66, in render return self.template.render(context) File "C:\Python36\lib\site-packages\django\template\base.py", line 205, in render with context.bind_template(self): File "C:\Python36\lib\contextlib.py", line 82, in __enter__ return next(self.gen) File "C:\Python36\lib\site-packages\django\template\context.py", line 263, in bind_template updates.update(processor(self.request)) ValueError: dictionary update sequence element #0 has length 0; 2 is required [10/Oct/2017 00:21:10] "GET / HTTP/1.1" 500 90547 I tried every URL but getting the same error. Even if i'm trying to log into Admin panel it's showing the same error. What should I do? -
Django - How to get the top 10 highest scores, but limiting it to a single score per user?
I have a simple model to keep scores for any number of score based games: class Score(models.Model): game = models.ForeignKey(Game, related_name='leaderboards') value = models.IntegerField(db_index=True) uom = models.CharField('Unit of Measurement', max_length=10) user = models.ForeignKey(settings.AUTH_USER_MODEL) class Meta: ordering = ['-value'] ... My Django Rest Framework API view is as follows which is intended to get me the current leaderboard for a particular game: class LeaderboardView(APIView): ... def get(self, request, pk): game = get_object_or_404(Game, pk=pk) # This query doesn't work scores = Score.objects.filter(game=game).order_by('-value').distinct('user')[:5] serializer = ScoreSerializer(scores, many=True) return Response(serializer.data) The problem is I'm having trouble figuring out how to get the top 10 highest scores, but limiting it to a single score per user (eg - their highest) using the ORM rather than manually getting all scores and then looping through them to ensure I only grab the highest score per user. Thanks for any help in advance. -
Django Serializers not parsing foreign key objects
I have the models: class employees(models.Model): emp_id=models.PositiveIntegerField() emp_name = models.CharField(max_length = 100) manager_id=models.ForeignKey('self',null=True,blank=True) class leave(models.Model): employee = models.ForeignKey(employees, on_delete=models.CASCADE, default='1') start_date = models.DateField() end_date = models.DateField() class notify(models.Model): sender_id=models.ForeignKey(leave, related_name='%(class)s_sendername') receiver_id=models.ForeignKey(leave,related_name='%(class)s_receivername') viewed=models.CharField(max_length=2) In my views I am writing Query as: def notification(request): template = loader.get_template('base.html') user = employees.objects.get(emp_id=request.user.username) emp_id=user.emp_id; notification=notify.objects.filter(receiver_id__employee__emp_id=emp_id); data = serializers.serialize("json", notification) print(data); context={'notification':data,'notification_count':notification_count} femp = json.dumps(context) return JsonResponse(femp, safe=False, content_type="text/html") In print(data) its printing [{"model": "apply.notify", "pk": 32, "fields": {"sender_id": 121, "receiver_id": 44, "viewed": "N"}}] Here its printing the sender_id=121 which is id in leave table but if I want start_date and emp_name(as it is referenced from employee in leave table).What should I write in serializers.serialize()so that I can reference foreign key enteties. -
Unable to understand the flow of list serializer update after properly implementing create
I am using list Serializer by many = True. The create method is running perfectly but i am unable to understand the flow of custom update method of list serializer in documentation of django rest framework. Using the base of list serializer is clear but when i am using it in code the flow is not understandable. I am not able to understand what book.items mean in the fourth line. In the documentation it is also asking to add an explicit id field to the instance serializer. The default implicitly-generated id field is marked as read_only. Looking to understand what documentation is saying and how to implement it. The context from documentation is give below. class BookListSerializer(serializers.ListSerializer): def update(self, instance, validated_data): # Maps for id->instance and id->data item. book_mapping = {book.id: book for book in instance} data_mapping = {item['id']: item for item in validated_data} # Perform creations and updates. ret = [] for book_id, data in data_mapping.items(): book = book_mapping.get(book_id, None) if book is None: ret.append(self.child.create(data)) else: ret.append(self.child.update(book, data)) # Perform deletions. for book_id, book in book_mapping.items(): if book_id not in data_mapping:a book.delete() return ret class BookSerializer(serializers.Serializer): # We need to identify elements in the list using their primary key, … -
Postgres vs SQL lite page not found discrapancy
I have my dev environment with django - SQLlite and my prod is with django - Postgres I have view that works perfectly on SQL lite login_required def receipt_pdf(request,pk): try: Receipt_payment_id_dict = Receipt_payment.objects.filter(is_active = True ).aggregate(Max('id')) if Receipt_payment_id_dict: Receipt_payment_id = Receipt_payment_id_dict['id__max'] Receipt_payment_dict = get_object_or_404(Receipt_payment, pk=Receipt_payment_id) else: Receipt_payment_dict = "no data" except ValueError: raise Http404("At least one active value should be in -Receipt_payment-, contact your administrator") try: general_id_dict = General_configurations.objects.filter(is_active = True ).aggregate(Max('id')) if general_id_dict: general_id = general_id_dict['id__max'] general_dict = get_object_or_404(General_configurations, pk=general_id) else: general_dict = "no data" except ValueError: raise Http404("At least one active value should be in -General_configurations-, contact your administrator") payment = get_object_or_404(LeasePayment, pk=pk) # leasetenant = lease.tenant_set.all().order_by('-id') # Create the HttpResponse object with the appropriate PDF headers. response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="Receipt.pdf"' buffer = BytesIO() # Create the PDF object, using the BytesIO object as its "file." p = canvas.Canvas(buffer) But When I execute same code with Postgres I get No Receipt_payment matches the given query. What could be the problem? -
Query by datetime.now().date of lower from Django DateTimeRangeField
I use a postgres DateTimeRangeField in Django model. It is the existing database and all the existing rows has both lower range and upper range. Now I need to query for all the rows where date of the lower range is a specific date for example something like rangefield.lower.date==1 . Please don't tell me to use separate fields for Start date and end date. This system is in production and I need to query that to filter for analytics. -
images and css django files not loading
Hello everyone, Well i'm new to django, I made my first profissonal project and the problem is sometimes the site displays all the images correctly but sometimes everything disappears same with django admin css which is not working actually. and I have really tried everything but still I can't find a solution on my own. Here are my files : urls.py if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) settings.py STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, 'static'), ) MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media_cdn") Example of model containing imagefield class Article(models.Model): name = models.CharField(max_length=300,blank=True,null=True) price = models.IntegerField(default=5) image = models.ImageField(null=True, blank=True, height_field="height_field", width_field="width_field", verbose_name="profile picture" ) height_field = models.IntegerField(default=600, null=True) width_field = models.IntegerField(default=600, null=True) description = models.TextField() souscategorie = models.ForeignKey(SousCategorie, related_name="souscate") slug = models.SlugField(unique=True) how i display an image on template {% if sous.image %} <a href="{% url 'liste' slug=sous.slug %}"><img src="{{sous.image.url}}" width="100" height="100" alt="" /></a> {% endif %} -
Deploy to my server with Git
I have a development of a django project on my day-to-day laptop. Now I have put together a server with Ubuntu, nginx, gunicorn with postgreSQL. I have pip't git on both my laptop and server. And done a 'git init' in my project on the laptop. Now I am trying to push/deploy this on my local server. I have done tons of commands that, more or less, look like this git push --set-upstream ssh://admin@192.168.1.240/home/admin/Django/ master Do not think I have to say that I am new to all this exciting stuff. It is very interesting, but now my head is foggy and I am stuck. Pointers in right direction are much appreciated! =) -
Is JSON not serialise-able over http or Django doesn't know how to read it?
I have created a couple of projects with Django. Every time I try to send an ajax POST request from frontend to django, I have to use JSON.stringify() function, pass it inside the body of POST request and parse the JSON manually inside Django (using ujson, because of its faster). My question is that why do I need to do this manually? -
django edit user profile onetoone field
Hi i know how to allow users to edit user model in Django but its not working with onetoone field. please let me know how to allow users to edit user with onetoone field i tried but its not working model.py class userProfile(models.Model): userName = models.OneToOneField(User) nick = models.CharField(max_length=100) agreement = models.BooleanField(default=False) profileimage = models.ImageField(upload_to = profileimagepath, blank=True) def __unicode__(self): # __str__ return unicode(self.userName) forms.py class EditProfileForm(UserChangeForm): class Meta : model = User fields = ('email','password','nick','profileimage') views.py def edit_profile(request): if request.method == 'POST': form = EditProfileForm(request.POST, instance=request.user) if form.is_valid(): form.save() return redirect('/changeprofile') else: form = EditProfileForm(instance=request.user) args = {'form':form} return render(request, 'editprofile.html', args) editprofile.html <form method="post"> {% csrf_token %} {{ form.as_p }} <button type="submit">change</button> urls.py url(r'^profile/edit/$', views.edit_profile, name='edit_profile'), -
Get the subdomain in a Django view? using django-hosts library
I'm making a project in django. The aplication have to show diferent images and languages depending on the subdomain. For example: www.mysite.com will be the default page in english, but if the subdomain is mx.mysite.com the language must be spanish. Whith django-hosts I can make that each subdomain redirect to a diferent django-app and I works well. The problem is that I want to make only one app to all diferent subdomains, only changing the language. I think that is possible get the subdomain in a view and render the template with the language depending on the subdomain. But I don't know how to do it, please help. THIS IS MY DJANGO HOSTS.PY where the host 'www' and 'mx' redirect to the same app 'mysite' but must be in diferent languages. from django.conf import settings from django_hosts import patterns, host host_patterns = patterns('', host(r'www', 'mysite.urls', name='www'), host(r'help', 'help.urls', name='help'), host(r'mx', 'mysite.urls', name='mx'), ) -
Can't use Django in virtualenv
I had 2 django project , I created 2 different virtualenv for them. When I create another one virtualenv and install django and create djangoproj I tried python manage.py runserver and had this: Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line ImportError: No module named 'django' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 14, in <module> import django ImportError: No module named 'django' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 17, in <module> "Couldn't import Django. Are you sure it's installed and " ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? What I need to do? I already tried uninstall django, pip, virtualenv and install : sudo apt-get install python3-pip sudo pip3 install virtualenv sudo virtualenv ENV source newenv/bin/activate sudo -H pip3 install django -
What to use for caching dynamically generated pages
I'm planning to use Django as an application server, nginx as a web server for serving static files. I'd like something to cache pages that Django generates. Varnish seemed to be Ok. I started to study it. But faced difficulties. I ask questions here, at StackOverflow: help me with this case in the tutorial. And there is either no answer, or something like: "Well, this is an obsolete tutorial". Well, there is nothing else. And a suspicion bore: maybe nobody uses Varnish anymore. Look: all videos at YouTube is at least a year old. At stackoverflow search for Varnish tag gives only 1,521 questions. Whereas a tag for Django gives 154,093 questions. Well, Varnish must be a more general technology: any site needs an accelerator. I'd say there should be more questions about it. Anyway, could you tell me whether Varnish is dead or not? And what should I use instead of it? -
Error: Cannot assign ... "Product.partner" must be a "Partner" instance
I am attempting to save multiple 'products' to a single 'partner' using a formset and a ForeignKey. I am getting the following error when I attempt to create a Product: Cannot assign "<PartnerForm bound=True, valid=True, fields=(name;logo;banner_image;mission;vision;website_link;fb_link;twitter_link;ig_link)>": "Product.partner" must be a "Partner" instance. I am pretty sure that I am close any help would be greatly appreciated. My models.py looks as follows: class Partner(models.Model): name = models.CharField(max_length=120) logo = models.ImageField(upload_to=upload_location, null=True, blank=True, width_field="width_field", height_field="height_field") banner_image = models.ImageField(upload_to=upload_location, null=True, blank=True, width_field="width_field", height_field="height_field") mission = models.TextField() vision = models.TextField() height_field = models.IntegerField(default=0) width_field = models.IntegerField(default=0) # text = models.TextField() website_link = models.CharField(max_length=120) fb_link = models.CharField(max_length=120) twitter_link = models.CharField(max_length=120) ig_link = models.CharField(max_length=120) slug = models.SlugField(unique=True) updated = models.DateTimeField(auto_now=True, auto_now_add=False) timestamp = models.DateTimeField(auto_now=False, auto_now_add=True) def __unicode__(self): return self.name def get_absolute_url(self): return reverse("partners:detail", kwargs={"slug": self.slug}) # return "/partner/%s/" %(self.id) def get_markdown(self): mission = self.mission markdown_text = markdown(mission) return mark_safe(markdown_text) #Creating a many to one relationship so that one can upload many Products class Product(models.Model): partner = models.ForeignKey(Partner, default=None) name = models.CharField(max_length=120) product_image = models.ImageField(upload_to=upload_location, # product_image = models.ImageField(upload_to= (upload_location + '/' + name), Something like this need to append actual product name so these dont just get dumped in the media for partners null=True, blank=True, width_field="width_field", …