0
votes
0answers
16 views

Django Admin: Default values in StackedInLine / TabularInLine

I'm creating a website and it needs support for internationalization. The default languages are Portuguese, English and Spanish. I'm using the django-i18nmodel and so far it works great. When the ...
0
votes
1answer
33 views

Django “Cannot resolve keyword” error. Can someone explain this?

I am just begining to learn how to use django. I am comming up with this error in my CLI File "C:\Python27\Lib\site-packages\django\db\models\sql\query.py", line 1337, in setup_ "Choices ...
0
votes
0answers
25 views

django app: Cannot assign “''”: “ImageText.link” must be a “Link” instance

I'm building an app for my Django 1.5.1 and Django-cms installation. The app meant to permit to upload an image linked to an URL. My code : cms_plugins.py from cms.plugin_base import CMSPluginBase ...
0
votes
2answers
36 views

Django: How to get count of ValuesQuerySet?

I am trying to get count to work on a ValuesQuerySet. According to Django documentation values = Model.objects.values() will return a ValuesQuerySet which is a subclass of QuerySet Returns a ...
0
votes
1answer
38 views

Django1.6, will transaction works for raw SQL?

Examples from offical document from django.db import connection def my_custom_sql(self): cursor = connection.cursor() cursor.execute("UPDATE bar SET foo = 1 WHERE baz = %s", [self.baz]) ...
0
votes
1answer
18 views

Insert a new field in a specific admin view?

I'm trying to extend default Django's model with a new field. In localsite/models.py I have the following code: from django.db import models from django.utils.translation import ugettext_lazy as _ ...
3
votes
2answers
45 views

How to remove Add button in Django admin, for specific Model?

I have Django model "AmountOfBooks" that is used just as balance for Book model. If this is not good pattern for database modeling just say so. Anyway AmountOfBooks have two fields: class ...
0
votes
1answer
22 views

Django request.session.save() authentication

Bit of a strange one and I have my reasons for doing this, I know Django does this out-of-the-box so put that to the side when I ask..... is it possible to create a authenticated session in Django ...
1
vote
1answer
22 views

How to force django to save immediately instead of doing a batch update after loop

I have this django views.py method that aims to insert many data into the db. It loops through arrays of models and, if an object isn't already on the db, it gets inserted. This is what the code ...
0
votes
2answers
26 views

Django: Refactoring models into sub-modules

After the models.py in one app grew quite large, I've tried to move some of the classes into subpackages. The old structure was something like this: # File: assets/models.py class Asset(...): # ...
2
votes
1answer
28 views

How to get the class name of a ContentType in django

How do I get the class name in string of a ContentType? I tried it this way, but it didn't worked out: class StreamItem(models.Model): user = models.ForeignKey(User) content_type = ...
0
votes
2answers
22 views

Django model search concatenated string

I am trying to use a Django model to for a record but then return a concatenated field of two different tables joined by a foreign key. I can do it in SQL like this: SELECT ...
0
votes
1answer
37 views

multiple tables join on basis of foreign key in single query set in django?

i am using sqlite3 database in my python django application: i am defining my table structure which is similar to my actual table schema. table1 having three column: 1. id | primary key | int ...
0
votes
1answer
26 views

Django 1.5 Custom User for m2m field 'groups' clashes

Have I done this right? I have created a custom user in Django 1.5 which works. I now want to add a completely different type of user to the mix called WebUser allowing very simple access to front-end ...
0
votes
2answers
24 views

Can't update django datetime field to Null

My code is Message.objects.filter(id=message_id).update(read_at='Null') getting this error ValidationError: [u'Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format.'] and the ...
0
votes
1answer
27 views

Django ORM non-strict search through multiple fields

There is the Model with some fields. I need to search some rows in the table and check multiple fields: f1,f2,f3. So, query may be matched one to three fields. For example, f1 matches, but f2 and f2 ...
0
votes
1answer
40 views

Django - Insert Multiple Fields Into DB When Submitting Form

Sorry for kind of a newbie question, but I am looking to get this sorted and if it works with my current implementation with some minor tweaking, that would be ideal. What I want to do is have a form ...
0
votes
1answer
16 views

Python Django Multiple Database Committing Objects with Foreign Key Relations

I am using Django with multiple databases. I have a 'preview' database that takes messages uploaded by the user and these have to be previewed by an admin and 'accepted', at which point they are ...
0
votes
1answer
21 views

Django 1.5 Custom User Model not validating in templates

I have info in the django documentation to create my custom user profile, something pretty similar to what they show here, the problem is that when I am trying to access information about if the user ...
0
votes
1answer
30 views

django models - conditionally set blank=True

I am trying to build an app, where user can customize forms. The Following example contains classes for creating Fields (QuestionField, AnswerField) which is used by the admin and the BoolAnswer which ...
1
vote
1answer
23 views

The best way to insert new record with ID(PK) in other fields with Django ORM

I know django row queries - great. But, is it possible make it in Django ORM? For example for SQL: INSERT INTO table (extra_ident) VALUES (id);
0
votes
1answer
34 views

Change Django Authentication Model password field

I am trying to modify my Django project authentication so I can use my own User model. I have got it working so far, however I am unable to override the "password" field. I want to change the name to ...
0
votes
3answers
28 views

Django password = models.CharField(_('password'), max_length=128)

What relevance does the underscore have before ('password') in this line? password = models.CharField(_('password'), max_length=128) I looked at the Django documentation and it states that the first ...
0
votes
0answers
28 views

django translate model choices

I need translate a choices for a field on the model. I have something like this: from django.utils.translation import ugettext as _ from django.db import models class MyModel(models.Model): ...
1
vote
2answers
51 views

Custom Login Django

I am new to django and i have a model that holds information about a account username password password salt. models .py - has some RegExValdation on fields. class modelName(models.Model): ...
0
votes
1answer
46 views

Django Admin Panel. Display and Edit Parent Fields in Child's Object (ModelAdmin.inlines reverse)

I am trying to create admin panel. I have three classes in my model. 1) Company 2) Executive 3) CompanyExecutive (Which have one to Many relation between Company and Executive) I only have to show ...
0
votes
0answers
23 views

Django Admin: How to add multi select dropdown of second level foreign table

I want to add a multi select drop-down element of Term to Post admin form through Rel[ation] mapper model. Flow Diagram Rel[ation] is actually a mapper model class of Post and Term as showing here: ...
-1
votes
1answer
30 views

When is a Django QuerySet evaluated?

I've read django queryset are lazy. But does that mean lazy in that I can chain multiple operations on one statement or lazy in that the query is delayed to when the results are needed. For example, ...
0
votes
0answers
37 views

Django get_queryset() trouble creating multiple annotation labels

I am trying to get a few different annotation results to show in the Django Admin. I need these new results to be sortable columns as well. I came up with this (after reading EXTENSIVELY on SO): def ...
0
votes
1answer
36 views

Change choices attribute of model's field

This question is similar to Set model field choices attribute at run time? However, my problem is that I want to change the default value of the choices attribute, at class level. I have this class ...
0
votes
4answers
38 views

Property in Model-View design

(Caveat: I am fairly new to Django and MVC model) Assuming that I have the following classes in the models: class Member(models.Model): user = models.OneToOneField(User) class ...
1
vote
1answer
66 views

Expire User Session if he is inactive for a certain period of time and record his session start and end time in database

I am working on a Django back end application where I need to Record the user activities i.e his login time and his logout time. If he is inactive for more than 30 minutes I want user to logout ...
0
votes
1answer
31 views

Extending Django's User model

I have been dealing for a while with Django's authentication system and I just cannot understand why I have to go through this process Django doc! : from django.contrib.auth.models import User class ...
0
votes
2answers
60 views

Update existing form based on current user Django 1.6

I have a form that I want to update the values of based on the current user but I can not get my form to update when I click submit. Currently the Values are not updating here is my views.py ...
0
votes
1answer
57 views

django TransactionManagementError when using signals

I have a one to one field with django's users and UserInfo. I want to subscribe to the post_save callback function on the user model so that I can then save the UserInfo as well. @receiver(post_save, ...
0
votes
2answers
31 views

Django user accounts, extending accounts

I am trying to extend Django's user-accounts Account model to add to it a set of additional fields. The thing is that "Account" objects have a set of methods that check some parameters and I would ...
0
votes
1answer
28 views

Save image in db from django model

How to save image in db from django model? I donot want to upload it in any folder , just want to save it in db from models.
0
votes
1answer
30 views

How to select users which is not paired with a custom user through many-to-one?

I have 2 models - WaitingUser and MarkedUserIds. class WaitingUser( models.Model ): user_id = models.IntegerField() class Meta: db_table = 'waiting_user' class MarkedUserIds( ...
0
votes
3answers
49 views

making query using class method in Django

I am trying to use this way, models.py class Father(models.Model): name = models.CharField(...) def last_child_age(self): children = self.child.order_by('-pk') if ...
0
votes
0answers
34 views

Django define and store dictionary field in a model

i am using Django and trying to define a model class with the ability of storing history information of another model after modification. Currently, i have some methods like this History Model, but ...
1
vote
1answer
31 views

Django foreign key starting with nothing

So often it is important to have a ForeignKey connection that starts with nothing and then has something added here are my models class Class(models.Model): title = ...
0
votes
0answers
21 views

Merge Duplicates in a model in django

I am using a snippet to delete duplicate objects in django, I need to iterate over objects in a model and look for duplicate values. And split duplicate values into primary and duplicate based on some ...
-3
votes
2answers
32 views

how to extract value from bound method in python? [duplicate]

I have the following code: model = MyModel() field = model._meta.get_field_by_name('my_field')[0] my_type = field.get_internal_type print str(my_type) This outputs: <bound method ...
-2
votes
2answers
53 views

how to get field type string from db model in django

I am doing the following: model._meta.get_field('g').get_internal_type() Which returns the following: <bound method URLField.get_internal_type of <django.db.models.fields.URLField: g>> ...
0
votes
0answers
26 views

Django - getting existing files into ImageField

I have a directory of files that I want to be recognized and saved as ImageField. Searching SO for an answer I tried the following: http://stackoverflow.com/a/8337264/1344854 - created custom file ...
0
votes
1answer
28 views

Django password and authentication for non standard users

I have been asked to introduce an unusual case and I'm wondering how others would go about it. I have users in my Django application. The model is a standard user model, authentication. etc. Each one ...
0
votes
1answer
19 views

how to pass column name dynamic in query?

My query col_name=('parole_state', 'hiv_treatment_state', 'receiving_hiv_treatment', 'mental_health_provider', 'employed', 'parole', 'employer_state') qs_new = ...
1
vote
1answer
23 views

Restrictive selection in django-admin panel

I have 3 simple models in my Django project as below: class Customer(models.Model): name = models.CharField(max_length=250) class Location(models.Model): name = ...
0
votes
1answer
20 views

Django database and information history

I am using Django framework to build a website with the ability to record user information and its history of modification. As what i can image, i can use a Django self-defined app to record the ...
0
votes
1answer
40 views

django submit image fom url file name stored wrong

I'm trying to submit image from url based on the answers of this question but as a result I have image file stored successfully , but with filename .jpg instead of image-name.jpg code import ...

15 30 50 per page