I'd like to remove some object with many-to-many relationship using Django admin interface. Standard removing also removes all related objects and the list of removed objects displayed on confirmation page. But I don't need to remove related objects!
Assume we have ContentTopic and ContentItem:
class ContentTopic(models.Model):
nam...
Hi,
Does anybody know how to get the selected item of a dropdown menu from within a clean method in a modelform object, before the object has been saved? I have tried the following:
def clean_something(self):
dropdown = self.cleaned_data.get('dropdown')
where 'dropdown' is the field representing the dropdown menu, but this doesn't...
Recently, I have become increasingly familiar with Django. I have a new project that I am working on that will be using Python for a desktop application. Is it possible to use the Django ORM in a desktop application? Or should I just go with something like SQLAlchemy?
...
I have the following admin setup so that I can add/edit a user and their profile at the same time.
class ProfileInline(admin.StackedInline):
"""
Allows profile to be added when creating user
"""
model = Profile
class UserProfileAdmin(admin.ModelAdmin):
"""
Options for the admin interface
"""
inlines = ...
I'm finding myself typing the following a lot (developing for Django, if that's relevant):
if testVariable then:
myVariable = testVariable
else:
# something else
Alternatively, and more commonly (i.e. building up a parameters list)
if 'query' in request.POST.keys() then:
myVariable = request.POST['query']
else:
# somethin...
I'm trying to write a custom inclusion_tag in django.
Following the example on http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
I'm just writing
@register.inclusion_tag('test.html')
where test.html is a file in the same directory ( apps/my_app/templatetags) as the .py file which defines it.
But I'm getting a
Templa...
Hi guys, i want to save data in two table mysql, that was nice, but now i change a field form Interget to FK.. the problem is that now i cant send the data to the field FK....
im new with Django, but im working in this way:
@login_required
def agregar_diligencia(request):
if request.method =='POST':
form = DiligenciaFor...
It seems like a simple question, but I've been looking for a couple of hours.
I'm trying to process incoming JSON/Ajax requests with Django/Python.
request.is_ajax() is True on the request, but I have no idea where the payload is with the JSON data
request.POST.dir contains this
['__class__', '__cmp__', '__contains__', '__copy__', '_...
there is almost no documentation for it here:
http://docs.djangoproject.com/en/dev/ref/models/fields/#commaseparatedintegerfield
maybe someone could , by example, show me how to populate a commaseperatedintegerfield in django?
-thanks.
...
I'm writing a member-based web application, and I need to be able to redirect the page after login. I want to use the named url from my urls.py script in my views.py file for the login application, but I can't for the life of me figure out what to do. What I have is this:
def login(request):
if request.session.has_key('user'):
if requ...
I am working on a calendar application in django and want to support events which repeat an infinite amount of times after a given start date. I will store "block events" where each block includes data about a certain event (title, description...) as well as the pattern with which it repeats and an "expiration date". This way I only stor...
I have a model which represents the user's display preferences. Just about all of these preferences are boolean values. Instead of having 50 boolean columns, is there a better way to go about this? In the future when I want to add a new item, I don't want to have to add a new column in my database.
...
I am using json in some AJAX request and am currently manually validating each entry using (if "key" in json.some_location.keys()) over and over again.
Is there a simpler way to do this (like XML validation)?
Note: I am open to validation libraries, but would like something I can drop into django itself (not python eggs).
...
Hi,
I have a many to many relationship table whith some datas in the jointing base
a basic version of my model look like:
class FooLine(models.Model):
name = models.CharField(max_length=255)
class FooCol(models.Model):
name = models.CharField(max_length=255)
class FooVal(models.Model):
value = models.CharField(max_length...
It seems to by my nightmare for the last 4 weeks,
I can't come up with a solution for a "related posts" app in django/python in which it takes the users input and comes out with a related post that matches closely with the original input. I've tried using like statements but it seems that they are not sensitive enough.
Such as which i ...
I have two Django model classes that are structured similar to the following:
class Build(models.Model):
project = models.CharField(max_length=100)
...
class CustomBuild(Build):
custom_type = ...
...
I want to select all Builds and CustomBuilds (each CustomBuild has a one-to-one relationship with a Build) from the data...
I'm sort of stitching together contrib.databrowse (to view) and contrib.admin (to edit), and I'd like to override the *response_change* function in admin.ModelAdmin so that when you click save, it redirects back to the object in databrowse rather than the admin. I know how to do this for a specific model in admin.py, like:
class Whateve...
Is there an easy way in Django to find the number of Users, Number of Users with profile objects, and ideally number of logins per month (but could do this with Google Analytics). I can see all the data is there in the admin interface, but I'm unsure of how to get to it in Python land. Has anyone seen any examples of counting number of ...
I am trying to run a Django app on my VPS running Debian 5. When I run a demo app, it comes back with this error:
File "/usr/local/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.5/site-packages/django/db/backends/sqlite3/base.py", line 30, in <...
Hi, guys, how or where is the "join" query in Django?
i think that Django dont have "join"..but how ill make join?
Thanks
...