Tagged Questions
1
vote
1answer
23 views
“object got multiple values for keyword argument” when writing database using dictionary
I have a django model with fields: city, country_name and country_code.
I have a dictionary which has more than 8 key-value pairs; I want use only 3 and write into database.
But I am getting an ...
2
votes
1answer
11 views
Pyodbc Query Failing on Model Without ID
I'm having difficulty understanding why one of my queries is failing.
I'm using pyodbc to connect to a SQL Server database on a Django application. All my other queries are working fine, except for ...
0
votes
1answer
12 views
Django Models when to use a GenericForeignKey
I have the following models:
class Dog(AbstractAnimals):
pass
class Meta:
app_label = 'animals'
class Cat(AbstractAnimals):
pass
class Meta:
app_label = 'animals'
...
1
vote
1answer
24 views
Is There a Way to Query Enumerated Types in Django Based on Values?
I am scratching my head over this. I have an enumerated data in my db. My model has something like:
class SomeModel(models.Model):
TWOCHOICE = (
('YES', 'YES'),
('NO', 'NO'),
('DK', ...
2
votes
2answers
62 views
Django: “Too many values to unpack” when calling user.objects.get()
In Django 1.6, I've defined a custom user model, but for some reason now when I create a superuser and try to get it or access the Django admin as that superuser, I get this ValueError: Too many ...
3
votes
1answer
27 views
Django model TimeField views.py cannot select hour or minute
When using a TimeField in a Django model I wish to be able to perform a query in a view, using the hour and minute elements of the TimeField separately.
However, when I do so, if I run the view I ...
0
votes
1answer
43 views
Django receiver check if first create
The idea of the code below should be that it only fires if the field verification_pin is empty i.e. on a new record. However, it seems that every time I save the model it generates a new pin ignoring ...
1
vote
2answers
30 views
Django ensure blank field
I would like to be able to disable the ability to fill in a field, while having it still be created in the DB.
This column will be dependent on the rest of the rows in the table, and always will, so ...
0
votes
1answer
39 views
How to save Django unsaved model with one-to-many relationship
I have a Django 1.5 one to many relationship between 2 models. It looks something like this
class Team(models.Model):
class Meta:
league = models.ForeignKey(League,related_name="teams")
...
0
votes
0answers
33 views
Django Admin - show json value as in tabular format
Example:
I have a model with columns as id and data, its populated as below
1 | {name: 'Foo', age: 65, grade : 'A'}
2 | {name: 'Bar', age: 56, grade: 'A+'}
now in admin(not in list display) I want ...
0
votes
1answer
21 views
using post_delete signal to delete a StreamItem
Here is a model that i have created to create a news feed. A StreamItem is created using post_save() signal whenever an instance of the Models Fe and Event is created. Its all working fine. Now i want ...
0
votes
1answer
31 views
Django — Multiple Databases — Data Migration
I am having difficulty in understanding Django Multiple Databases documentation. Below is what i am trying to achieve.
I have to migrate some data from one database to another in pyhton.
Both ...
1
vote
2answers
30 views
Setting up two different types of Users in Django 1.5/1.6
Please note--this is an updated version of my original question on this subject, but deserves to be asked again with the change in how Django deals with users and authentication.
I'm working on a ...
1
vote
1answer
15 views
Django Type Error No Exception Supplied
HI Here is my code for comparing two mobiles technical specifications
def getFormValues(request):
if ('mobile_a' in request.GET and request.GET['mobile_a']) and ('mobile_b' in request.GET and ...
0
votes
1answer
31 views
Django Custom Users Adding Second User Model
I'm currently using Django 1.5 custom user models. Using my code below, how can I add new second type of user?
I want to add a new user like called StandardUser I already have CompanyUser type i.e.
...
0
votes
1answer
17 views
Django Query with multiple attributes
How can get below result set ?
There are method to use AND after WHERE clause .
Is there any method to use OR in Where Clause ?
SELECT * FROM college_college WHERE id = 1 OR pub_name = 2
0
votes
2answers
29 views
Schema design (database architecture) for Boolean flag fields
Background
The architecture is for a personal app for nearby restaurants. I am toying with two ways to store single value Boolean (true/false) flag values.
My background in robotics is forcing me to ...
0
votes
1answer
29 views
Creating user feed using django signals
This my model to create a stream of other models.Its working fine. But, now I want to make the feed user specific. I am using django's predefine User model . What are the possible ways to do that?
...
1
vote
1answer
22 views
Creting feed using signals in Django
Here i have defined a model to create a feed instance in 'models.py':
class StreamItem(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
...
-2
votes
2answers
26 views
i want to make a diagram from some classes (not all) in my django model [closed]
I want to make a diagram from some classes (not all) in my django model. Using graph_model in django_extension i can make a diagram, but this diagram is very big and complex, because my model is very ...
0
votes
1answer
20 views
I can't figure out the django qeryset for retriving a value from a field by a condition
My model like this
mobile_name = models.CharField("Mobile Name", max_length=50)
opinion = models.CharField('Comments', max_length=2000)
total_mark = models.FloatField('Total Mark')
the sql query ...
1
vote
1answer
18 views
Creating new table while iterating through a queryset in django
This is a newbie question, but despite reading https://docs.djangoproject.com/en/dev/ref/models/instances/#saving-objects , I'm not quite sure how to do this. I have an existing table where I would ...
0
votes
1answer
36 views
Python Django - Accessing foreignkey data
I am trying to figure out how to get data from my models with ForeignKey relationships. I have the following models.py:
class wine(models.Model):
name = models.CharField(max_length=256)
year ...
0
votes
0answers
19 views
Can anyone explain about meta inheritance in django model
I read this doc https://docs.djangoproject.com/en/1.5/topics/db/models/#meta-inheritance
But I could not understand that how does it work.
0
votes
2answers
43 views
python_2_unicode_compatible error
I've models.py as follows,
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.timezone import now
...
-1
votes
0answers
26 views
In django, how do I compare fields between instances of a model and color the diff in an html table?
I'm a django newbie.
I have a model, say,
class A(models.Model):
id=models.IntergerField(null=True,primary_key=True,blank=True)
name=models.TextField()
grade=models.TextField()
....
...
0
votes
1answer
36 views
MultiValueDictKeyError generated in Django after POST request on login page
first off thanks for all the useful information on the site (it's partly to blame for why I'm currently wrestling with Django to begin with. I wish it were as simple to get working as all those silly ...
1
vote
1answer
50 views
Object level permissions in Django admin
I have a model which looks like this:
class Change(models.Model):
RFC = models.CharField(max_length=10)
Ticket_Number = models.CharField(max_length=10)
Plan_Owner = ...
0
votes
0answers
29 views
djang-guardian custom user permissions
Setup
I've just started working with django-guardian and have straight away run into some obstacles. I'm using custom users by extending the AbstractBaseUser class. I followed this example to setup ...
0
votes
1answer
30 views
Difficulty having Django find database user
I'm writing a web app which has a page for admin tasks. One of the tasks is that the admin users must be able to edit other users details. Alas, I've fallen at quite a simple roadblock.
I've set up ...
2
votes
2answers
50 views
What is the best way to add logging for creation of a Django Model instance?
Suppose I have the models defined in my Django models.py file as shown below.
I would like to add some generic code such that every time any instances of modelA or modelB are created, a log message ...
1
vote
2answers
51 views
Using Django's custom user model (Django1.6)
I have a Django app that needs an extra field (a manytomany mapping to a Book class) and I did that by extending the AbstractUser.
If you’re entirely happy with Django’s User model and you just ...
2
votes
1answer
34 views
Nested chain vs duplicated information
There is a models.py with 4 model.
Its standard record is:
class Main(models.Model):
stuff = models.IntegerField()
class Second(models.Model):
nested = ...
0
votes
1answer
58 views
Struggling with Django syncdb
This drives me mad... I'm reorganizing an existing Django project using the following structure:
[project_abc]
[app]
[core]
[app1]
admin.py
models.py
...
...
1
vote
2answers
28 views
Making 'permanent' changes to Django Model objects
I'm getting the details about the songs for a particular DJ from the Beatport API as follows.
if not get_obj_or_none(Song, name__iexact=song_name, artist=dj):
s = Song(song_id=song['id'], ...
0
votes
0answers
18 views
Creating many objects using django-polymorphic
I'm using django-polymorphic and have a base class with about 8 derived classes. It works great except when I try to create many objects at once, in this case the performance is very poor. My code ...
0
votes
1answer
29 views
Django related models aren't found in a view, but are in shell
For some reason when I check my user for related models in a view I get the following:
DoesNotExist at /user/profile/
User has no employee.
Which is being fired from the following line in my view's ...
-2
votes
0answers
57 views
2014, “Commands out of sync; you can't run this command now”- Django
I am working on a django project.I logged in as non-root user in my laptop with centos operating system,but via command prompt i logged in as root and installed python 2.7,django and other supporting ...
0
votes
1answer
41 views
Django ProgrammingError Caused By Model Field
I have a model called "news", defined below:
class News(models.Model):
title = models.CharField(max_length=30, null=False, blank=False, verbose_name="news title")
content = ...
2
votes
1answer
45 views
Django Model.objects.all().delete() not completing
I have a django app which deletes all the entries in a db and then enters another set. I am having a problem where Model.objects.all().delete() leaves objects in the database (The same entries every ...
0
votes
0answers
24 views
Django Multiple Table Advice
I need guidance in something that I need solved. I have multiple tables that have one field in common (ie. field).
I want to grab all rows from different tables that are not connected in any way via ...
0
votes
1answer
25 views
Django ORM Table Relationships
I have models defined like so:
class Games(models.Model):
title = models.CharField(max_length=50)
owned = models.BooleanField(default=False)
created = ...
-1
votes
0answers
54 views
Philips Hue Scene in Django
I am using phue (a python library for interfacing with the Philips Hue API) and have a backend working with a web interface, however I would like to implement "scenes" (predefined light settings), ...
0
votes
1answer
31 views
How can I tell Django to include tables for my models on a syncdb?
I suspect that I have not imported my models into some place they need to be reported for a syncdb to pick them up.
Where do I need to import my models.py (or otherwise register my models) so that ...
1
vote
2answers
52 views
Django 1.6, how to set field default value for CreateView
models.py
class App(models.Model):
name = models.CharField(max_length=10, default='')
desc = models.CharField(max_length=10, default='')
views.py
class AppCreate(CreateView):
...
1
vote
1answer
26 views
Django get_model returns None for Mezzanine BlogPost model
I'm having a problem with get_model for Django. get_model works with every model I'm trying to get except for the BlogPost model from Mezzanine.
I've tried:
model = get_model('mezzanine.blog', ...
0
votes
1answer
26 views
Per user soft-delete model design in Django
I am designing an application where users send/receive records and I would like deletes to be separated for each user listed in the record (one user's delete will not hide the record from the other ...
1
vote
1answer
18 views
django unique relations not unique table
Take the following model:
class Foo(models.Model):
bar = models.ForeignKey(Bar)
name = models.CharField(max_length=30)
#...
so what this does is connect a Foo model to a Bar model and ...
0
votes
3answers
66 views
syncdb command not working properlly
I am trying to run the existing project.I had restored my database and installed all the required dependencies.While running syncdb,i got the below errors.
[root@localhost ]# python manage.py syncdb
...
0
votes
3answers
79 views
python _mysql_exceptions.ProgrammingError: (2014, “Commands out of sync; you can't run this command now”)
I am trying to run the existing project in centos machine.I installed packages from requirements.txt and it installed sucessfully.But while run "python manage.py runserver" i am getting the following ...