Search Results

Search found 23428 results on 938 pages for 'django related manager'.

Page 7/938 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • [Django] Automatically Update Field when a Different Field is Changed

    - by Gordon
    I have a model with a bunch of different fields like first_name, last_name, etc. I also have fields first_name_ud, last_name_ud, etc. that correspond to the last updated date for the related fields (i.e. when first_name is modified, then first_name_ud is set to the current date). Is there a way to make this happen automatically or do I need to check what fields have changed each time I save an object and then update the related "_ud" fields. Thanks a lot!

    Read the article

  • django views question

    - by Hulk
    In my django views i have the following def create(request): query=header.objects.filter(id=a)[0] a=query.criteria_set.all() logging.debug(a.details) I get an error saying 'QuerySet' object has no attribute 'details' in the debug statement .What is this error and what should be the correct statemnt to query this.And the model corresponding to this is as follows where as the models has the following: class header(models.Model): title = models.CharField(max_length = 255) created_by = models.CharField(max_length = 255) def __unicode__(self): return self.id() class criteria(models.Model): details = models.CharField(max_length = 255) headerid = models.ForeignKey(header) def __unicode__(self): return self.id() Thanks..

    Read the article

  • Django url parameters

    - by Hulk
    How to pass two paramters in urls in django <script> url=/toolbox/display/" + id + "2"; window.location=url; </script> Also how is this handeled in urls.py (r'^display/(?P<rid>\d+)/(?P<param>\d+)/$', 'table_display'), In views, def table_display(request,rid,param): print param //This should print 2

    Read the article

  • Django forms "not" using forms from models

    - by zubinmehta
    I have a form generated from various models and the various values filled go and sit in some other table. Hence, in this case I haven't used the inbuilt Django forms(i.e. I am not creating forms from models ). Now the data which is posted from the self made form is handled by view1 which should clean the data accordingly. How do I go about it and use the various functions clean and define validation errors (and preferably not do validation logic in the view itself!)

    Read the article

  • Extended Django base-class with multiple instances

    - by Gijs
    I'm modeling a simple movie database using Django. models.py defines a base model Person. I extend Person into Actor and Director, which works as I imagined. Persons must be unique. When (in the Admin) I create an instance of Actor, and this person is also a Director, it won't save because of the unique = True. Any ideas how to solve this problem? (generic foreign keys?) Thx

    Read the article

  • Django: How to get current user in admin forms

    - by lazerscience
    In Django's ModelAdmin I need to display forms customized according to the permissions an user has. Is there a way of getting the current user object into the form class, so that i can customize the form in its __init__ method? I think saving the current request in a thread local would be a possibility but this would be my last resort think I'm thinking it is a bad design approach....

    Read the article

  • Django template-printing variables

    - by Hulk
    In django views def add(request): dict{} co_data = optarr dict.update({'co_data' : co_data}) logging.debug(co_data) return render_to_response('scheme/create.html',context_instance=RequestContext(request,{'dict': dict})) And data has the following string 1##2##3##4## And in the template when i say {{co_data}} it doesnt display the values.Please point out whats wrong in the code. Thanks..

    Read the article

  • Django filter vs exclude

    - by Enrico
    Is there a difference between filter and exclude in django? If I have self.get_query_set().filter(modelField=x) and I want to add another criteria, is there a meaningful difference between to following two lines of code? self.get_query_set().filter(user__isnull=False, modelField=x) self.get_query_set().filter(modelField=x).exclude(user__isnull=True) is one considered better practice or are they the same in both function and performance?

    Read the article

  • Django User model, adding function

    - by Hellnar
    Hello, I want to add a new function to the default User model of Django for retrieveing a related list of Model type. Such Foo model: class Foo(models.Model): owner = models.ForeignKey(User, related_name="owner") likes = models.ForeignKey(User, related_name="likes") ........ #at some view user = request.user foos= user.get_related_foo_models() Hwo can this be achieved ?

    Read the article

  • How to store an integer leaded by zeros in django

    - by Oscar Carballal
    Hello, I'm trying to store a number in django that looks like this: 000001 My problem is that if I type this inside an IntegerField it gets converted to "1" without the leading zeros. I've tried also with a DecimalField with the same result. How can I store the leading zeros whithout using a CharField? (I need to manipulate that number in it's integer form)

    Read the article

  • How to make custom join query with Django ?

    - by xRobot
    I have these 2 models: genre = ( ('D', 'Dramatic'), ('T', 'Thriller'), ('L', 'Love'), ) class Book(models.Model): title = models.CharField(max_length=100) genre = models.CharField(max_length=1, choices=genre) class Author(models.Model): user = models.ForeignKey(User, unique=True) born = models.DateTimeField('born') book = models.ForeignKey(Book) I need to retrieve first_name and last_name of all authors of dramatic's books. How can I do this in django ?

    Read the article

  • Django: name of many to many items in the admin interface

    - by Adam
    I have a many to many field, which I'm displaying in the django admin panel. When I add multiple items, they all come up as "ASGGroup object" in the display selector. Instead, I want them to come up as whatever the ASGGroup.name field is set to. How do I do this? My models looks like: class Thing(Model): read_groups = ManyToManyField('ASGGroup', related_name="thing_read", blank=True) class ASGGroup(Model): name = CharField(max_length=63, null=True) But what I'm seeing the m2m widget display is:

    Read the article

  • Accessing updated M2M fields in overriden save() in django's admin

    - by Jonathan
    I'd like to use the user updated values of a ManyToManyField in a model's overriden save() method when I save an instance in admin. It turns out that by design, django does not update the M2M field before calling save(), but only after the save() is complete as part of the form save... How can I access the new values of this field in the override save() ?

    Read the article

  • Django: Inherit Permssions from abstract models?

    - by lazerscience
    Is it possible to inherit permissions from an abstract model in Django? I can not really find anything about that. For me this doesn't work! class PublishBase(models.Model): class Meta: abstract = True get_latest_by = 'created' permissions = (('change_foreign_items', "Can change other user's items"),) EDIT: Not working means it fails silently. Permission is not created, as it wouldn't exist on the models inheriting from this class.

    Read the article

  • Django - problem with {% url facebook_xd_receiver %}

    - by Gaurav
    I'm using {% url facebook_xd_receiver %} in one of my HTML files. This works just fine when I run my project using the command python manage.py runserver But the same project stops running and gives me a "TemplateSyntaxError" at the line {% url facebook_xd_receiver %} Can anyone please tell me what could be the difference between the dev server run through the command line and the apache server. Is there anything I'm missing out on while configuring the Apache server? Or is it a Django problem?

    Read the article

  • django manage.py syncdb not working?

    - by Diego
    Trying to learn Django, I closed the shell and am getting this problem now when I call python manage.py syncdb, any idea what happened?: I've already set up a db. I have manage.py set up in the folder django_bookmarks. What's up here? Traceback (most recent call last): File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management my-computer:~/Django-1.1.1/django_bookmarks mycomp$ export PATH=/Users/mycomp/bin:$PATH my-computer:~/Django-1.1.1/django_bookmarks mycomp$ python manage.py syncdb Traceback (most recent call last): File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management my-computer:~/Django-1.1.1/django_bookmarks mycomp$

    Read the article

  • Django admin urls return INVALID REQUEST! - Django

    - by RadiantHex
    Hi folks, my admin urls are sat behind a prefix by doing the following. 1# (r'^admin/', include(admin.site.urls)), is placed within urls_core.py 2# (r'^api/', include('project.urls_core')), is palced within urls.py All admin URLs work fine except app indexes. If I go to any URL such as: /api/admin/core/ /api/admin/registration/ /api/admin/users/ /api/admin/filters/ I receive 'INVALID REQUEST' as my response. Status code is 200 (OK) though. I have never received this error message before. Does anyone have a clue? Thanks guys!

    Read the article

  • Putting a django login form on every page

    - by asciitaxi
    I'd like the login form (AuthenticationForm from django.contrib.auth) to appear on every page in my site if the user is not logged in. When the user logs in, they will be redirected to the same page. If there is an error, the error will be shown on the same page with the form. I suppose you'd need a context processor to provide the form to every template. But, then you'd also need every view to handle the posted form? Does this mean you need to create some middleware? I'm a bit lost. Is there an accepted way of doing this?

    Read the article

  • Django templates onchange data

    - by Hulk
    In the following code, i have a drop down box and a multi select box. My question is that using javascript and django .how will i changes the designation with changes in names from drop down box. <tr><td> name:</td><td><select id="name" name="name">{% for name in names %} <option value="{{name.id}}" {% for selected_id in names %}{% ifequal name.id selected_id %} {{ selected }} {% endifequal %} {% endfor %}>{{name.name}}</option>{% endfor %} </select> </td></tr> {% for desg in designation %} <tr><td><p>Topics:</td><td> <select id="desg" name="desg" multiple="multiple"> <option value="{{desg.id}}" >{{desg.desg}}</option> </select></p></td></tr> {% endfor %} Thanks..

    Read the article

  • Django syncdb error

    - by Hulk
    /mysite/project4 class notes(models.Model): created_by = models.ForeignKey(User) detail = models.ForeignKey(Details) Details and User are in the same module i.e,/mysite/project1 In project1 models i have defined class User(): ...... class Details(): ...... When DB i synced there is an error saying Error: One or more models did not validate: project4: Accessor for field 'detail' clashes with related field . Add a related_name argument to the definition for 'detail'. How can this be solved.. thanks..

    Read the article

  • queries in django

    - by Hulk
    How to query Employee to get all the address related to the employee, Employee.Add.all() doe not work.. class Employee(): Add = models.ManyToManyField(Address) parent = models.ManyToManyField(Parent, blank=True, null=True) class Address(models.Model): address_emp = models.CharField(max_length=512) description = models.TextField() def __unicode__(self): return self.name()

    Read the article

  • Get the currently saved object in a view in Django

    - by mridang
    Hi, I has a Django view which is accessed through an AJAX call. It's a pretty simple one — all it does is simply pass the request to a form object and save the data. Here's a snippet from my view: form = AddSiteForm(request.user, request.POST) if form.is_valid(): obj = form.save(commit=False) obj.user = request.user obj.save() data['status'] = 'success' data['html'] = render_to_string('site.html', locals(), context_instance=RequestContext(request)) return HttpResponse(simplejson.dumps(data), mimetype='application/json') How do I get the currently saved object (including the internally generated id column) and pass it to the template? Any help guys? Mridang

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >