Django:Getting List of values from query set

I have the following query country=employees.objects.filter(manager_id__emp_id=111).values('emp_loc').distinct() I get Output as <QuerySet [{'emp_loc': 'IND'}, {'emp_loc': 'MLA'}]> But I need list ['IND','MLA'] How Can I do it? ...
more »

2017-11-09 14:11 (1) Answers

Slug in Django URL

I need your help. I working on my own project. And I need show single news from news list.I do next steps: in model: class Notice(models.Model): notice_header = models.CharField(max_length=150, verbose_name="Notice header", blank=False) ...
more »

2017-11-09 13:11 (1) Answers

At which point in UpdateView is the data saved?

I was wondering when the data given to an UpdateView was saved. I have the following situation: I update a model object via a form. I would expect the changes to the model only to be saved after the UpdateView's form_valid is through. But when I pr...
more »

2017-11-09 11:11 (3) Answers

Django: Best way to retrieve object

Lets assume that I have a class Person with a field email. I want to get a single record based on queryset and assign it to variable person. Sadly I cannot do person = Person.objects.filter(email="xxx@xxx.xxx")[0] because I might get an exception...
more »

2017-11-09 00:11 (3) Answers

Dynamic filter in Django

In my app, I have a form. Depending of the form, one or many filters could be configured by the user. In my view, I have for exemple : query = Test.objects.filter(filter1 = request.post['filter1'], filter2 = request.post['filter2'], filter3 = reque...
more »

2017-11-08 15:11 (1) Answers

How to get extension of file

I am trying to get mimetype from decoded string. I sent base64 string of a xls file, This is my code: def save_file(request_data, id=None): """ """ data = base64.b64decode(request_data.get('file')) mime = magic.Magic(mime=True) c...
more »

2017-11-08 12:11 (0) Answers

Apache2 : Limit virtual host to one domain name

i want to do something but i can't find an answer (Maybe i baldy searched). I don't know if it is possible so say me if it's not. I would like to limit an apache virtual host to one and only domain name : bde.yggdrasil.cafe. So that if the user try ...
more »

2017-11-07 17:11 (1) Answers

Single model dynamic database settings in Django

For example assume that I have 100 clients who uses WordPress and I have to write a service in Django which should return list of posts from WordPress's MySQL DB. The problem is 100 clients are having different database connection settings. I know t...
more »

2017-11-06 13:11 (2) Answers

Django models ForeignKey return IDs

I have been trying to search forums to get an answer for this, but it seems like its a bit tricky to search. I have the following model which is pulling users from django User table: class trendingidea(models.Model): iname = models.CharFiel...
more »

2017-11-06 12:11 (1) Answers

How to filter csv file?

I have a csv file containing random data but I want to filter the data from the file. I want to filter all rows that have contents starting with $ and ending with # 2017-09-07 03:11:03,5,hello 2017-09-07 03:11:16,6,yellow 2017-09-07 03:11:22,28,some...
more »

2017-11-06 10:11 (1) Answers

Django Firebase

I am trying to connect my Django website with Firebase. There is not enough material for that, luckily I got this https://github.com/thisbejim/Pyrebase but I am not able to understand where to write this code. I have written this code in pyrebase.py...
more »

2017-11-05 15:11 (1) Answers

Django ManytoManyField and widgets

I have two models, Product and Category and ManytoMany field in Product. The Category appear as key on ProductCreate View. I need to customize the widget and field for Categories. I checked in Django source Fields and Widgets but I don't see a ref...
more »

2017-11-05 09:11 (1) Answers

Django passing variables into string

I'm trying to pass: >img src="{% static '/static_dirs/images/itcg/01_{{ card_id }}.jpg' %}" alt="{{ card_id }}"> to load image with file name 01_xx.jpg, but the result is just xx without image. Basically what happens is that {{ card_id }} wo...
more »

2017-11-05 09:11 (1) Answers