Tagged Questions
0
votes
1answer
21 views
Python/Django: Get record from DB based on a dictionary field
I have a database table and one of the fields is a serialized python dictionary (or stringified JSON) in this form:
{"full_name":"first_name=John&last_name=Smith", "id":24354,"username":"hello"}
...
2
votes
0answers
15 views
Django's cascade delete is executing the DELETE SQL twice
I've got an odd situation here, any idea why the delete SQL for the myapp_entry_tag table is being performed twice?
>>> from myapp.models import Tag
>>> from django.db import ...
0
votes
0answers
24 views
Find related objects and display relation
I am using django-follow to allow users to "follow" objects (for this example lets call these objects film actors)
I am pulling back a list of film actors using
actors_user_is_following = ...
-3
votes
0answers
24 views
Creating custom permissions [closed]
How will i hide the "Log" option for any users other than Admin?
===========================
default_panel = 'Log'
def get_default_panel(self, request):
is_admin = ...
0
votes
1answer
24 views
Django 1.5 : OperationalError in windows when running “python manage.py syncdb” using postgresql-psycopg2
This is my settings.py file in my Django project. OS : Windows, hosting : localhost
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': ...
0
votes
2answers
30 views
How to modify a model after bulk update in django?
I try some code like this:
mymodels = MyModel.objects.filter(status=1)
mymodels.update(status=4)
print(mymodels)
And the result is an empty list
I know that I can use a for loop to replace the ...
0
votes
0answers
18 views
django xml model specification?
I'm using django with many related projects. All those projects are using their own models. But unfortunately this is not DRY, because each model differ from each other very slightly, for example some ...
-2
votes
0answers
13 views
How to create Create CRUD in django?
How create models organization, groups and skills using django. Please help me thanks to all.
Create Organizations
People involved in different organizations
Organization contains different groups
...
0
votes
0answers
30 views
Appropriate max_length for atom id field?
I am using atom feeds within a Django application, and was planning on using a CharField to represent the id field of an entry. Given that max_length is required, what would be an appropriate length?
1
vote
1answer
29 views
Django one-to-one reverse relationship DoesNotExist
I've got an odd problem here, where my one-to-one relationship doesn't seem to be working in reverse. It's easiest to explain with code.
I have extended the default Django User to add a timezone, as ...
1
vote
1answer
29 views
Representing ManyToMany relation in Django as two multichoices
I have some many2many fields with a lot of options to choose from and I'd like to have two multichoices for each one, on the left the available options and on the right side the chosen ones. Here is ...
1
vote
2answers
35 views
Django: delete related object via OneToOneField
Is there some clever way how to perform delete in this situation?
class Bus(models.Model):
wheel = OneToOneField(Wheel)
class Bike(models.Model):
wheel = OneToOneField(Wheel)
...
1
vote
2answers
38 views
Django custom user model and usermanager
i'm building a web application with Django 1.5. I'm using a custom User model with a custom UserManager.
I followed the instructions and examples of the official Django documentation.
Now, when i'm ...
1
vote
1answer
18 views
User Types In Django using the same login and registration form
I've been hitting my head for the best way to implement this. I want to create two user type in my django site: Free and Premium users. Both users will register through the same registration form and ...
3
votes
1answer
36 views
Django model not saving when calling save()
so i am trying to save a django model, and for some reason i am only getting a 500 internal server error. the thing is,
if i comment the social_auth.save() it works and i can manipulate the
...
0
votes
0answers
37 views
Saving foreign key field for linked model
I have models Client and Requisites. Requisites is OneToOneField for Client. No overwritten save methods and other.
I wonder when attribute requisites_id is set for Client objects.
c = Client()
...
0
votes
1answer
39 views
Are ModelForms in django used only for POSTing?
ModelForms are a nice way to prevent repeating the definitions of models one creates. What I would like to do is take advantage of that feature and use it for more than just processing POST requests. ...
0
votes
2answers
36 views
Missing metaclass in Django 1.5
How do you override a model's metaclass in Django 1.5? I was overriding the metaclass on some models inheriting from an abstract model so I could set appropriate choices. e.g.
class ...
0
votes
2answers
21 views
Get all “grand”-Children of a given Model
im trying to learn python/django at the moment and came across the following problem.
Let's say i have 3 models:
Model Category(models.Model)
name = models.Charfield(max_length64)
Model ...
-1
votes
1answer
24 views
Define a django model which use in a foreign key a specific instance of an other model
Let's take an example for my problem : the models of a blog.
I would have django models like this :
class Category(models.Model):
name = models.CharField(max_length=30)
class ...
0
votes
2answers
58 views
Thumbnail now showing in django admin list view
I have created a basic file upload app and i'd like to be able to view a thumbnail of the image on the django admin list view. I've tried implementing the code on this blog post - ...
2
votes
1answer
259 views
Connecting my django app to the redis installation
I have a django app. The app is a normal application. Everything is running fine for me.
I want to implement a leaderboard as of now. Read couple of places that redis helps in doing it. And is ...
1
vote
1answer
54 views
How to set NULL for IntegerField instead of setting 0?
I'm uploading some data from an excel file using xlrd and turning that data into models (with mainly IntegerField values) in Django. My excel file has a bunch of missing data. Unfortunately, these ...
0
votes
1answer
44 views
Removing a file from the server once the entry has been removed [duplicate]
I've created a basic files app in django so clients can upload files and copy the relative url and use it in the content of the website. One of the ideas of the app was once an entry has been removed ...
1
vote
1answer
46 views
TypeError: __init__() got an unexpected keyword argument category
I'm creating a basic app where my client can upload files through the app. It will then provide them with a URL so they can add images/pdf's etc to content in the website. What i'd like to do is have ...
3
votes
2answers
58 views
Why isn't __dict__ a callable
Why are __dict__ and for example __unicode__ not both callable or the other way around?
Django tells me to set a unicode return as a method on an Model, for example:
class Obj(models.Model):
def ...
1
vote
2answers
43 views
In Django, how can I view all the properties of my user?
If I do something like:
print request.user.is_authenticated()
Then True is printed. However
print request.user
just prints the username even though 'request.user' is definitely not just a ...
0
votes
1answer
23 views
Filter django objects based number of foreign references
I have an object that represents a list of items. Each item has a foreign key to this list.
class ItemList(Model):
pass
class Item(Model):
list = ForeignKey(ItemList, related_name="items")
...
1
vote
0answers
24 views
Using Django ORM inside Tornado, “syncdb” doesn't work
I'm using Django ORM inside Tornado, and everything is going well except that "syncdb" doesn't work.
So this is my directory structure:
APP_NAME/
APP_NAME/
models.py
settings.py
...
0
votes
1answer
29 views
Django - Functions in models and views don't return correct Boolean value
I am creating a django app/website and am in trouble with some Boolean results I don't understand.
In my models, I have a Article class with 2 functions :
class Article(models.Model):
#some vars
...
0
votes
2answers
18 views
Django Models Create a Coustom Query
I am trying to get all the post in a thread before or on a certain time. So how do I get Django to allow me the privilege to enter my own queries?
This is the closes I could come using Django's model ...
1
vote
2answers
48 views
Is there any more elegant way to add a value sensitive unique together constraint in Django Model?
Here is the problem:
I have a model like this:
class UserBook(models.Model):
user = models.ForeignKey(User)
book = models.ForeignKey(Book)
is_active = models.BooleanField(default=False)
...
0
votes
1answer
187 views
How to cast model to instance of its descendant proxy model
I have a proxy model.
Now I would like to cast from a given instance of its parent model to an instance of the proxy.
I have this code in my manager:
def from_parent_user(self, user):
instance ...
1
vote
1answer
43 views
Django custom manager get_queryset() not working
I can't make my custom manager work...
class PublicArtigoManager(models.Manager):
def get_queryset(self):
return super(PublicArtigoManager, ...
1
vote
0answers
41 views
Changing the log level
I have set the log level as WARN in platform_settings.py and loggings.py file.
I have also changed the initial value to WARN in forms.py with (self.fields['log_level'].initial='WARN').
Now, if I ...
0
votes
1answer
33 views
Django South editing field names in model with --auto --update
In the South Docs,when changing the name of a field it wants you to use ./manage.py schemamigration southtut --auto --update. When I use it I get the following./manage.py: error: no such option: ...
0
votes
1answer
45 views
django query to use annotate with a filter for each annotations
I have the following database model -
class ObjectDetail(models.Model):
title = models.CharField()
img = models.ImageField()
description = models.TextField()
uploaded_by = ...
0
votes
2answers
25 views
how do i get the string inside the charfield in django?
I'm trying to create a user in my model by calling the create_user function but I want it to have properties of what the user enters into my model. How do I do this?
This is what I have:
class ...
0
votes
1answer
31 views
Django error: “Accessor for field clashes with related field”
When I run "python manage.py runserver", the following 2 error messages are printed 4 times:
transcription.treatment: Accessor for field 'treatment_ptr' clashes with related field ...
0
votes
0answers
33 views
Django accessing related fields prefetched by prefetch_related
So I have this loop:
for t in ts.prefetch_related('u__v_set'):
bla = t.x
...
Running this code in debugsqlshell I see three (constant amount in general) sql statements:
one getting all ...
2
votes
2answers
37 views
Django lookup tables and fields
Can I look around in a database with Django? I mean outputting a list of all tables, all fields in tables and all objects in a specific table?
I know how to build models and lookup objects, but can I ...
0
votes
1answer
40 views
Django - overriding save/delete functions of the model vs doing it in the view
I have a model Quote, which has a foreign key to the user model. A user can have between 0 and 10 quotes, and if there s/he has one or more quotes, one of them should be the primary quote(primary is a ...
0
votes
0answers
33 views
Django Admin delete image
I Have the following function by delete the image in the admin Django when you check the checkbox and after save the image.
This checkbox appear, when you go to the modify the register the field ...
0
votes
1answer
31 views
How to Stored Multiple Select option Database
I need to store multiple select option data to the database.I try with that but it takes only one option. I given the code below.
Templates
<select name="qualification" multiple>
<option ...
0
votes
2answers
25 views
Manage pages in database in Django 1.5
Is it possible to organize your urls.py with a Django model? I would like to create a admin interface to manage pages, and output the pages as links in the navigation, but I will run into problems ...
0
votes
1answer
51 views
Multiple Django Model Queries Changing Independently in One View
I have three models being called separately -- one in my first column, the second in my second column, and the third in my third column. The first is the categories and will stay the same. The second ...
0
votes
1answer
35 views
Incorporate third-party module into Django models
I'm creating a product ID conversion app. I have two models representing the two ID styles:
class Id1(models.Model):
number = models.CharField(max_length=10)
converted = ...
2
votes
2answers
87 views
Django : how to display actual objects in admin
I have a model defination as follows:
class Artist(models.Model):
"""Model class to record Artist"""
artist_name = models.CharField(max_length=200)
artist_id = ...
0
votes
0answers
24 views
Django model method - create_or_update
Similar to get_or_create, I would like to be able to update_or_create in Django.
Until now, I have using an approaching similar to how @Daniel Roseman does it here. However, I'd like to do this more ...
0
votes
0answers
87 views
Django - Multiple Databases
So I'm somewhat new to the whole Django databases and maybe I just don't fully understand the Django routers talked about here:
...