Hi all,
In widget's code I need to get access to HTML id of the rendered element. I know I can run regexp on the rendered string and get the ID, but I believe there must be an easy way.
Let's assume this is the widget I have:
class TextInputWithHint(TextInput):
...
def render(self, name, value, attrs):
res = super(Tex...
I have a model for which the need is to show the form multiple times. I have used it under a modelformset. I seem to have a problem with the id of this model which is also the primary key for the model.
I prepopulate the formset with data which I wish to edit.
But whenever I click on submit it refreshes the page back with an error saying...
I have a model that has a field named "state":
class Foo(models.Model):
...
state = models.IntegerField(choices = STATES)
...
For every state, possible choices are a certain subset of all STATES. For example:
if foo.state == STATES.OPEN: #if foo is open, possible states are CLOSED, CANCELED
...
if foo.state == STA...
I have got Pydev configured properly so it runs my app, however when I want to inspect/trace my code by setting up breakpoints the debugger does not kick in (can't trace). Does anyone got any idea what's going on here?
...
When I have a given django model class like this:
class BaseClass(models.Model):
some_field = models.CharField(max_length = 80)
...
and some subclasses of it, for example
class SomeClass(BaseClass):
other_field = models.CharField(max_length = 80)
Then I know I can get the derived object by calling
base = BaseClass...
Here's a Django model class I wrote. This class gets a keyerror when I call get_object_or_404 from Django (I conceive that keyerror is raised due to no kwargs being passed to __init__ by the get function, arguments are all positional). Interestingly, it does not get an error when I call get_object_or_404 from console.
I wonder why, and ...
We're running django alongside - and sharing a database with - an existing application. And we want to use an existing "user" table (not Django's own) to store user information.
It looks like it's possible to change the name of the table that Django uses, in the Meta class of the User definition.
But we'd prefer not to change the Dja...
I have a status field which has 3 values: pending, activated
and rejected. If I am changing the value of status I want to
have a check that activated cannot be changed to pending. I
do not want to write stored-procs for this. Can I have the
previous value in Django before saving?
Means new and old value.
...
I am tying to write a digg , hackernews , http://collectivesys.com/ like application where users submit something and other users can vote up or down , mark items as favorite ect .
I was just wondering if there are some open source implementations django/python that i could use as starting point , instead of reinventing the wheel by s...
I am trying to write a facebook app where user can see the status history of his friends.
Everything seems to work fine until I try to save the status information in my DB.
here is code :
class UserStatus(models.Model):
facebookid = models.IntegerField()
time = models.IntegerField()
status_msg = models.CharFie...
I'm about to start working with Django and would like to familiarize myself with the community a bit.
Which blogs or news sites should I follow?
...
I am a junior programmer in Enterprise desktop application,
and I want to transfer my knowledge field into web base application.
I'm learning django, and want to build a small web application for practice,(and I know it well now)
Is there any guide book for this?(web application building , not django specific)
ps: I know there are tut...
I am writing a action in django.I want to now about the rows which are updated by the action or say id field of the row.I want to make a log of all the actions.
I am having a field status which has 3 values :'activate','pending','reject'.I have made action for changing the status to activate.when i perform the action i want to have the ...
On my Google App Engine application, i'm storing an auto-updated date/time in my model like that :
class MyModel(db.Model):
date = db.DateTimeProperty(auto_now_add=True)
But, that date/time is the local time on server, according to it's time zone.
So, when I would like to display it on my web page, how may I format it according th...
Hello,
I would like to generate an HttpResponse that contains a certain string. For each of the characters in the string I have a background color I want to use.
For simplification, let's assume I can only have shades of green in the background, and that the "background colors" data represents "level of brightness" in the green domain...
Given a model with ForeignKeyField (FKF) or ManyToManyField (MTMF) fields with a foreignkey to 'self' how can I prevent self (recursive) selection within the Django Admin (admin).
In short, it should be possible to prevent self (recursive) selection of a model instance in the admin. This applies when editing existing instances of a mod...
Imagine that I have an mptt tree of objects and their population like:
Animal, 60
aardvark, 30
bobcat, 20
chipmunk, 10
Vegetable, 6
apple, 1
beet, 2
cauliflower, 3
Mineral 0
How would you sort the above by population on each sublevel? I want to get to:
Animal, 60
aardvark, 30
bobcat, 20
chipmunk, 10
Vegetable, 6
caul...
I have an Atom feed set up according to http://docs.djangoproject.com/en/dev/ref/contrib/syndication/ which means I have something like
(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds})
in my urls.py and something like
class MyFeed(Feed):
...
in my feeds.py.
I'd like to redirect traffic f...
I am making a custom form object in django which has an overloaded __init__ method. The purpose of overloading the method is to dynamically generate drop-down boxes based on the new parameters.
For example,
class TicketForm(forms.Form):
Type = Type.GetTicketTypeField()
def __init__(self, data=None, files=None, auto_id='id_%s',...
Let's say that I have this string:
s = '<p>Hello!</p>'
When I pass this variable to a template, I want it to be rendered as raw html. Looking at the docs I see that I can either use the safe filter:
{{s|safe}}
or disable autoescape:
{%autoescape off}
{{s}}
{%endautoescape%}
or inside the python code declare it safe:
from django...