Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
AngularJS and Django
new to both django and AngularJs especially. I have my data coming in from an SQL database into a table and i want to be able to sort and search it. Basic Django model and view, i think it would be the html and js that i'm stuck with. The data displays in the text with not issues, just the search and sort don't work. This is my HTML: <form> <div class="form-group"> <div class="input-group"> <div class="input-group-addon"><i class="fa fa-search"></i></div> <input type="text" class="form-control" placeholder="Search table" ng-model="searchTable"> </div> </div> </form> <table class="table table-bordered table-striped"> <thead> <tr> <td> <a href="#" ng-click="sortType = 'name'; sortReverse = !sortReverse"> Name <span ng-show="sortType == 'name' && !sortReverse" class="fa fa-caret-down"></span> <span ng-show="sortType == 'name' && sortReverse" class="fa fa-caret-up"></span> </a> </td> <td> <a href="#" ng-click="sortType = 'cost'; sortReverse = !sortReverse"> Cost <span ng-show="sortType == 'cost' && !sortReverse" class="fa fa-caret-down"></span> <span ng-show="sortType == 'cost' && sortReverse" class="fa fa-caret-up"></span> </a> </td> <td> <a href="#" ng-click="sortType = 'resource_type'; sortReverse = !sortReverse"> Resource Type <span ng-show="sortType == 'resource_type' && !sortReverse" class="fa fa-caret-down"></span> <span ng-show="sortType == 'resource_type' && sortReverse" class="fa fa-caret-up"></span> </a> </td> <td> <a href="#" ng-click="sortType = 'unit'; sortReverse = !sortReverse"> Unit <span ng-show="sortType == 'unit' && !sortReverse" class="fa fa-caret-down"></span> <span ng-show="sortType == 'unit' … -
Python Package Paths :: Finding Directories that Should Be .py Files
@Luc Saffre As I work through the Django tutorials, I like to see with my own eyes the module and class/attribute that I am inheriting via import by going to the source code at Github. However, and I have attached pics to illustrate that I (think) I went to the right place, but the files seem to be missing. For example, in Django tutorial Part 1: from django.conf.urls import include ,url So I go to Github django code and I find: django/django/conf/urls What I find is that urls is a directory with only files : init.py, i18n.py and static.py. There is no urls.py file which might have url() or include() methods. Same with models.Models. from django.db import models On django Github site I follow the directories... django/django/db/models #models is a directory, not a file with a class Model() So, what am I missing here? Looking forward to a few bread crumbs :) -
Django: Which mysql is compatible with Django 1.10.4?
I have installed python 3.4, Django 1.10.4 and mysql 5.6 My question is are they compatible with eachother? -
decorator() got an unexpected keyword argument
I have this error on Django view: TypeError at /web/host/1/ decorator() got an unexpected keyword argument 'host_id' Request Method: GET Request URL: http://127.0.0.1:8000/web/host/1/edit Django Version: 1.10.4 Exception Type: TypeError Exception Value: decorator() got an unexpected keyword argument 'host_id' and the urlpatterns is: url(r'^host/(?P<host_id>[0-9]+)$', host, name='host'), the view function is : @check_login def host(request, host_id, *args, **kwargs): h = Host() # resultHost = h.get_host(host_id) return render(request, 'web/host.html') if I use the url without parameter "host_id" and the host function without host_id, the program will run perfect. so what's the problem? Thank you. -
Django Python - No connection could be made because the target machine actively refused it
I have a Django python server in a virtual environment at the root of my hard drive. In the command line, when I activate the env and run python manage.py 192.168.0.47:80 it starts the server normal (no migration notice or anything), but when I load the page from the browser (using instancegaming.net locally, which is in my servers host file and has worked fine in the past locally and remotely) it loads and loads forever, and when I go to the Django server window and do Ctrl+C it updates the console and gives me the following error. Keep in mind that this env is a fresh install, with no other site packages other than Django. I've had successfully ran servers before on the same server (Windows 10 64-bit) and with the same router config. I've looked at other posts like this (Python Django-Helpdesk Error: No connection could be made because the target machine actively refused it) and a handful of others, but none of these seem to solve the problem. Console Window: (env) C:\server\www>python manage.py runserver 192.168.0.47:80 Performing system checks... System check identified no issues (0 silenced). December 28, 2016 - 19:07:06 Django version 1.10.4, using settings 'www.settings' Starting development … -
Django rest framwork unit testing : SQLite vs MySql?
Can some one explain how TestCase and TransactionTestCase class behavior differ based on database (SQlite and MySQL) ? Issue : Wrote tests considering DB will be flushed between different tests using TransactionTestCase and MySQL. And now when I change my DB to SQlite to run tests is failing. I can get same behavior but SQlite using TestCase class. Thanks -
Using Multiple URL Parameters to get_object in Class-Based-View
Alright, I'm fairly new to this, I've been working on my Project for a couple months now and I'd like to create URLs that accept multiple parameters to call a View. A sample URL would look like this: http://www.sample.com/builders//m// I've got this implemented successfully, by overriding get_object in my DetailView, but I'm wondering if there is a better/easier method for accomplishing this or if this is considered a bad practice. Any guidance would be appreciated. urls.py urlpatterns = [ # url(r'^$', builder_list, name='list'), # url(r'^create/$', builder_create, name='create'), # url(r'^(?P<slug>[\w-]+)/$', builder_detail, name='detail'), # url(r'^(?P<slug>[\w-]+)/edit/$', builder_update, name='update'), # url(r'^(?P<slug>[\w-]+)/delete/$', builder_delete, name='delete'), # url(r'^$', builder_list, name='sub_list'), # url(r'^m/create/$', sub_create, name='sub_create'), url(r'^(?P<builder>[\w-]+)/m/(?P<market>[\w-]+)/$', sub_detail, name='sub_detail'), # url(r'^m/(?P<slug>[\w-]+)/edit/$', sub_update, name='sub_update'), # url(r'^m/(?P<slug>[\w-]+)/delete/$', sub_delete, name='sub_delete'), ] views.py class BuilderSubDetailView(DetailView): model = BuilderSub template_name = "builders/sub_detail.html" def get_context_data(self, **kwargs): context = super(BuilderSubDetailView, self).get_context_data(**kwargs) context['now'] = timezone.now() print(context) return context def get_object(self, queryset=None): if queryset is None: queryset = self.get_queryset() # Next, try looking up by primary key. builder = self.kwargs['builder'] builder_id = Builder.objects.filter(slug=builder).first().pk market = self.kwargs['market'] market_id = Market.objects.filter(slug=market).first().pk if builder is not None and market is not None: queryset = BuilderSub.objects.filter(parent=builder_id).filter(market=market_id) # If none of those are defined, it's an error. if builder is None or market … -
Django Calculate Aggregated Totals
I am trying to build a table that will aggregate stats based on a user ID. This is the first time asking a question, so bear with me if I miss anything major. Here is the model: class Batting(models.Model): player = models.ForeignKey( 'Player', on_delete=models.CASCADE, null=True, ) game = models.ForeignKey( 'Game', on_delete=models.CASCADE, null=True, blank=True, ) season = models.ForeignKey( 'Season', on_delete=models.CASCADE, null=True, ) games_played = models.IntegerField( blank=True, default=1, ) plate_appearances = models.IntegerField( blank=True, default=0, ) at_bats = models.DecimalField( default=0, max_digits=6, decimal_places=3, ) hits = models.DecimalField( blank=True, max_digits=6, decimal_places=3, default=0, ) ... batting_average = models.DecimalField( max_digits=6, decimal_places=3, editable=False, null=True ) slugging_percentage = models.DecimalField( max_digits=6, decimal_places=3, editable=False, null=True ) on_base_percentage = models.DecimalField( max_digits=6, decimal_places=3, editable=False, null=True ) on_base_plus_slugging_percentage = models.DecimalField( max_digits=6, decimal_places=3, editable=False, null=True ) def save(self, *args, **kwargs): self.total_bases = self.singles + (self.doubles * 2) + (self.triples * 3) + (self.home_runs * 4) self.extra_base_hits = self.doubles + self.triples + self.home_runs self.batting_average = float(self.hits) / float(self.at_bats) self.slugging_percentage = self.total_bases / float(self.at_bats) self.on_base_percentage = (self.hits + self.base_on_balls + self.hit_by_pitch) / float(self.at_bats + self.base_on_balls + self.sacrifice_flys + self.hit_by_pitch) self.on_base_plus_slugging_percentage = (self.hits + self.base_on_balls + self.hit_by_pitch) / float(self.at_bats + self.base_on_balls + self.sacrifice_flys + self.hit_by_pitch) super(Batting, self).save(*args, **kwargs) class Meta: verbose_name = u'Batting Stat' verbose_name_plural = u'Batting Stats' … -
Userena group based categorization on signup/registration
I would like to separate users into two different groups, sellers or buyers, at signup. I'm using django-userena and for the athentication and registration of users. I'm thinking of using a clone of the same signup view except with a different url tied to it. So whoever signs up at url(r'^account/signup/seller/$) linked to a seller signup button will be added to the seller group and whoever signs up at url(r'^account/signup/$) linked to a buyer signup button will be added to the buyer group. note: i will be using this grouping to grant access to view functions in another django app in my project via signals/decorators. in my accounts/form.py file, i have: class SellerSignupFormExtra(SignupForm): def save(self): new_user = super(SignupFormExtra, self).save() new_user.groups.add(Group.objects.get(name='seller')) return new_user and i added this to accounts/urls.py file url(r'^accounts/signup/seller$', 'userena_views.signup', {'signup_form': SellerSignupFormExtra}), So my question is that can i add the other users that click the buyer signup button by doing the same thing i did for sellers above or is their a better way to achieve this so that i remain DRY. -
How do I increment an IntegerField variable in django?
I have a small detail, I have a form and in one of its fields I want to get a number (example 1) and fill out the form I want to add another product and to increase and exit the consecutive number (that would be 2) and So successively. When I run the python manage.py migrate it marks an error in my model.py and I do not know how to fix it. I want it to come out in the textbox automatically the increase when I upload a new product but I do not know how it is done, can you help me please! Model.py class Equipo(models.Model): folio = models.IntegerField() marca = models.CharField(max_length=100) modelo = models.CharField(max_length=100) serie = models.CharField(max_length=100) express = models.CharField(max_length=100) numem = models.CharField(max_length=100) responsable = models.CharField(max_length=100) departamento = models.ForeignKey(Departamento) puesto = models.CharField(max_length=100) descripcion = models.CharField(max_length=100) estado = models.ForeignKey(Estado) estatus = models.ForeignKey(Estatus) hdd = models.CharField(max_length=100) procesador = models.CharField(max_length=100) ram = models.CharField(max_length=100) ubicacion = models.ForeignKey(Ubicacion) fechaal = models.CharField(max_length=12, null=True) ultman = models.CharField(max_length=12, null=True) proxman = models.CharField(max_length=12, null=True) status = models.BooleanField(default=True) def __unicode__(self): return unicode(self.folio) def number(): folio = Equipo.objects.count() #Here I frame error when I do the migration if folio == None: return 1 else: return no + 1 incremcode … -
Placeholders not rendering after upgrade to django CMS 3.4
I am trying to upgrade django CMS to version 3.4.1 from 3.3.0. I am following the upgrade instructions here. After running python manage.py migrate python manage.py cms fix-tree I boot up my dev server and navigate to one of my pages, but none of the configured placeholders render. I have verified that there are placeholders for the page, and plugins for those placeholders, in the database. Furthermore, by simply downgrading back to version 3.3.0, the placeholders and plugins all render correctly again. I am not manually rendering the placeholders, as is mentioned as a possible issue here in the upgrade notes. I am simply using the placeholder tag from cms_tags as mentioned in the documentation here. Does anyone have any idea what the issue could be? Let me know if I can provide any further information or clarification. Thanks in advance! -
How to display an image using the image URL on my template html Django Python
I've looked everywhere and tried what I can using the resources online. I don't really understand how to just display an image using the image URL on my template html Django Python. I have this image that I got from the user twitter account userProfileImage = "http://pbs.twimg.com/profile_images/688032813866549248/FqOZWxmM.jpg" What are the steps to take in order to display it on the page ? Do I "need' to save it in a database? I just want to be able to display userProfileImage. Thank you ! -
Django - ModelForm custom required message
I want to override my required message but my code is not working. Can someone help me? Here's what I got: models. py class grupos(models.Model): nombre_grupo = models.CharField(max_length=100) def __unicode__(self): return self.nombre_grupo def __str__(self): return self.nombre_grupo forms.py class gruposModelForm(forms.ModelForm): class Meta: model = grupos fields = ["nombre_grupo"] def __init__(self, *args, **kwargs): super(gruposModelForm, self).__init__(*args, **kwargs) self.fields['nombre_grupo'].error_messages = {'required': 'custom required message'} Thanks in advance!!! -
Mass creation of data in Django
Have a model Unit each Unit have a property class Property1(CommonInfo): unit = models.ForeignKey(Unit) is_true = models.BooleanField(default=False) propertytype = models.ForeignKey(Propertytype, related_name='propertytype') date = models.DateTimeField(null=True, blank=True) followup_date = models.DateTimeField(null=True, blank=True) quantity = models.PositiveSmallIntegerField() Is there is a way to mass create all the property to all the units with some default value? -
Django bootstrap alerts not working as expected
I need help with this. I'm trying to make my app looks better with bootstrap alert, I have one alert to add an item and other alert to delete an item. When I add an item my alert looks great and work fine but when I delete the item it's not working properly.. Only shows my message with no bootstrap alert.... What am I doing wrong? Here's what I got: <div class="container"> {% if messages %} <div class="row"> <div class="col-sm-6 col-sm-offset-3"> {% for message in messages %} <p{% if message.tags == "success" %} class="alert alert-success "{% endif %}>{{ message }}</p> {% if message == 'danger' %} <p{% if message.tags == 'danger' %} class="alert alert-danger"{% endif %}>{{ message }}</p> {% endif %} {% endfor %} </div> </div> {% endif %} Views for my success msg messages.success(request, 'Has been added!.') Views for my danger msg messages.error(request, 'Has been deleted!.') Thanks in advance..! -
Django - Get Related Key and Insert into Database
Ok, so what I'm trying to do is allow the user to add a "product" to their shop but without having to choose the shop to add it to as each user will only have ONE shop. I'm getting the: "IntegrityError at /shop/product/add/ NOT NULL constraint failed: shop_product.business_id" This is what's being shown in the local variables: Local Vars Local Vars: Variable Value __class__ <class 'shop.views.ProductCreate'> form <AddProductForm bound=True, valid=True, fields=(product_name;product_desc;product_image)> s <Shop: 4> self <shop.views.ProductCreate object at 0x048B0370> user 10 Now I believe the issue might be the "s" variable's as the code is actually getting the correct shop.. but it's also adding that weird " My Code as it is right now. models.py # Shop Model. A Shop Object will be created when the user registers class Shop(models.Model): name = models.CharField(max_length=150) owner = models.OneToOneField(User, related_name="owner") shop_logo = models.FileField() def __str__(self): return str(self.name) + ": " + str(self.owner) def create_shop(sender, **kwargs): user = kwargs["instance"] if kwargs["created"]: up = Shop(owner=user) up.save() post_save.connect(create_shop, sender=User) def shoplogo_or_default(self, default_path='/static/images/dft/no-img.png'): if self.shop_logo: return self.shop_logo return default_path # The class that will link a product to the shop class Product(models.Model): product_name = models.CharField(max_length=250) # connect the product to the shop business = models.ForeignKey(Shop, on_delete=models.CASCADE, related_name="products") … -
Stop a thread from outside parent
My Django server creates threads. The threads were introduced because I didn't want to wait till the process is complete to return the response to the request (the processes can last for hours). Now I want to stop some of those threads on user request. How can I do this? The problem I face is that the parent of the thread (the function which created it) dies out after returning the response so I'm not able to access the threads at all. I found the following answer interesting. http://stackoverflow.com/a/325528/4954434 -
Django can't make migrate or run server
I'm trying to make migrations or create user or run server but i can't because i have errors: File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/piotr/Pulpit/myapp/v/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/home/piotr/Pulpit/myapp/v/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute django.setup() File "/home/piotr/Pulpit/myapp/v/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/home/piotr/Pulpit/myapp/v/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/home/piotr/Pulpit/myapp/v/local/lib/python2.7/site-packages/django/apps/config.py", line 199, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/piotr/Pulpit/myapp/datamanager/models.py", line 18, in <module> exp = Workflow.objects.get(name="Expenditure") File "/home/piotr/Pulpit/myapp/v/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/piotr/Pulpit/myapp/v/local/lib/python2.7/site-packages/django/db/models/query.py", line 385, in get self.model._meta.object_name workflows.models.DoesNotExist: Workflow matching query does not exist. A lot of error are in v (virtuaenv) but is impossible that I make bad virtualenv. I have not idea what is wrong later after backend changes all was good. What is wrong? -
django-contact-form how to use the form inside any template, without a new url?
I have installed django-contact-form, and the default url to the form is 'contact/'. But, I already have my own contact page, let's call it 'contact_us/', I wish to include the form inside 'contact_us/', using the url and view I already have for 'contact_us/'. The usual way to do that is by using {% extends 'contact_us' %}, but if I do this, and remove my original 'contact_us/' url, it gives me an ReverseError. The way I think that would be possible is if sent the ContactFormView (from django-contact-form) as context to 'contact_us/', but I think that's not possible because each view has it's own url. I want to know a way to be able to put the form easily inside of any template. There's probably a simple way to do that and I don't know. -
Django: generate div class tag value with max value
I am trying to dynamically create div class tag value for my blocks in Django. I have comments tree and decided to create limit on max value for comment block (only in template not in db). So I created next template. It works fine, but has too big line and I can't insert any spaces and new line symbol, because they break template or keep in page html-source. This is line right after comment. {% extends 'myblog/base.html' %} {% load bleach_tags %} {% block title %}{{ article.name|bleach }}{% endblock %} {% block content %} <a href="{% url 'myblog:article_detail' article.id %}"><h2>{{ article.name|bleach }}</h2></a> <div class = "post_body_detail"> {{ article.text|bleach }} </div> <div class = "comments"> {% for comment in comment_list %} <li> {# (next line is too big) div class comment level can not be bigger max value for marking purposes #} <div class = "comment{% if comment.level <= comment.MAX_COMMENT_DIV_BLOCK_DEEP %}{{comment.level}}{% else %}comment.MAX_COMMENT_DIV_BLOCK_DEEP{% endif %}"> {{ comment.text|bleach}} </div> </li> {% empty %} <li>No comments yet.</li> {% endfor %} </div> {% endblock %} -
How to organize data after using filter
Let's say I have a database table like this: NumCOL NameCol AgeCOL ColourCOL ---------------------------------------- 1 Joel 18 Blue 2 Joey 22 Red 3 Jacob 25 Green 4 Jack 27 Blue 5 Joey 21 Red In this example, NumCOL is unique and icrements by 1, NameCOL, AgeCOL & ColourCOL are not unique. I need to filter them in a way that I can grab all entries based on ColourCOL, and then grab the entries in NameCOL & AgeCOLthat are assiocated to the colour. I use this code below (where a user selects the colour blue): colour = request.POST.get('FormColour') #colour = blue name = Database.objects.filter(ColourCOL=colour).values_list('NameCOL', flat=True) Now there two names that have the colour blue, so I was thinking to use a list and append all the data into a list and just call from the list when needs be, like this: ex_list = [] tracker = 0 for x in name: age = Database.objects.filter(ColourCOL=colour, NameCOL=name).values_list('AgeCOL', flat=True) ex_list.append([name[tracker], name, age]) tracker += 1 My concern is that I won't be able to retrieve data from the list effectively (if at all) if I need to write to a PDF or display it in a table. Another solution is sorting by the NumCOL … -
'str' object has no attribute 'len'
Ive got a method that use to work by checking the first three letters/numbers and making sure they are the same before it continues like so def combineProcess(request): carID1 = request.POST['carID1'] carID2 = request.POST['carID2'] for x in range (0,3): a += carID1.length(x) b += carID2.length(x) if a.equals(b): //do something before it use to work now it stopped and i get this error Exception Type: UnboundLocalError Exception Value: local variable 'a' referenced before assignment which i never use to get a few weeks ago didnt change anything so i made a and b global then my new errors were def combineProcess(request): carID1 = request.POST['carID1'] carID2 = request.POST['carID2'] global a,b for x in range (0,3): a += carID1.length(x) b += carID2.length(x) if a.equals(b): //do something Exception Type: NameError Exception Value: name 'a' is not defined then i removed the global line and just put this a = "P" and got this error str object has no attribute length() or len() which now has me puzzled how has this code stop working and why cant it recognize that a string object has a len() method. mainly im lost how my code went from working to not working over a two weeks off -
Django Saving Data into Database
I'm having an issue, what I need is to save a part number into a database table. So everytime a user enters the SOSS it should be save in my table. This is my code but is not saving anything, not sure what I'm doing wrong. manifiestos.html <form action="{% url 'manifiestos' %}" method="post"> {% csrf_token %} <p><label for="date"> Date:</label> <input type="text" name="date" value={% now "Y-m-d" %} /> </p> <p><label for="soss"> SOSS:</label> <input type="text" name="soss" id="soss" /> </p> <input type="submit" value="Submit" /> </form> models.py class manifiestos_bts(models.Model): soss = models.CharField(max_length=50) date = models.DateTimeField(null=True, blank=True) user = models.CharField(max_length=50) forms.py class ManifiestosForm(forms.Form): soss = forms.CharField() date = forms.DateTimeField() user = forms.CharField() html_views @login_required(login_url='/msr/login') def manifiestos(request): if request.method == 'POST': form = ManifiestosForm(request.POST) if form.is_valid(): soss = request.POST.get('soss', '') date = request.POST.get('date', '') manifiestos_obj = manifiestos_bts(soss= soss, date= date) manifiestos_obj.save() return HttpResponseRedirect(reverse('manifiestos')) else: form = ManifiestosForm() return render(request, 'manifiestos.html', {'form': form}) urls.py url(r'^manifiestos$', html_views.manifiestos, name='manifiestos'), Thanks for your time :) If you need more details just let me know. -
Django test print or log failure
I have a django_rest_framework test (the problem is the same with a regular django test) that looks like this: from rest_framework.test import APITestCase class APITests(APITestCase): # tests for unauthorized access def test_unauthorized(self): ... for api in apipoints: response = self.client.options(api) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) I have a url that fails, the terminal shows this: FAIL: test_unauthorized (app.misuper.tests.APITests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/alejandro/...", line 64, in test_unauthorized self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) AssertionError: 200 != 403 Ok, how can I know which url failed the test? I am iterating through all urls that require login, that is many urls, how can I print the one that failed the test? -
django rest create model instances from angular2 frontend
I have a django rest backend with couple of models like following: class Hall(Product): product = models.OneToOneField(Product, parent_link=True, ) localities = ChainedForeignKey( Localities, chained_field="city", chained_model_field="city", show_all=False, auto_choose=True, sort=True ) landmarks = models.CharField(max_length=50, blank=False, verbose_name="Landmarks of the Marriage Hall", ) seating_capacity = models.IntegerField(null=False, verbose_name="Seating capacity of the Marriage Hall",) ac = models.BooleanField(null=False, verbose_name="Is the Marriage Hall AC?",) garden_lounge = models.BooleanField(null=False, verbose_name="Is the Marriage Hall garden_lounge?",) comments = models.CharField(max_length=50, blank=False, verbose_name="Customer comments for this Marriage Hall", ) gallery = models.ForeignKey(Gallery, related_name='halls') If I had to create/update/delete model instances from my angular2 frontend (which is completely separate), what are the steps that I need to follow? Right now I have serializers in addition to model like following: class HallSerializer(serializers.ModelSerializer): category = serializers.ReadOnlyField() class Meta: model = Hall fields = '__all__' Also, as you can see this specific model has other model as OneToOne or as ChainedForeignKey, how to handle that?