Search Results

Search found 3555 results on 143 pages for 'django queryset'.

Page 22/143 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • haystack's RealTimeSearchIndex causes django to hang on data entry

    - by lsc
    I'm using django-haystack and a xapian backend with real time indexing (haystack.indexes.RealTimeSearchIndexing) of model data and it works fine on my Ubuntu server. However, it causes django to hang upon data entry when I deployed the app on a RHEL5 server. Everything is hunky dory if I switch to a standard SearchIndex. Running ./manage.py rebuild_index manually works fine too. The major differences between the two setups would be the versions of Python (2.4.3 vs 2.6.4) and the xapian (1.0.4-1 vs 1.0.15). Any suggestions on what may be the problem? Nothing interesting appears in the logs, and I've tried different databases (mysql, sqlite3) and deployment methods (mod_python, wsgi) with no luck yet. I have noted the warning on the haystack docs stating that RealTimeSearchIndex is only handled gracefully with a Solr backend, however I'm running a very traffic site with only occasional writes so I'm fine with some CPU overheads on writes.

    Read the article

  • Putting a block inside another in Django

    - by hekevintran
    I have a Django template that I want to extend in multiple places. In some the div must be inside a form, and in others it must not be. To do this I put a block above and below the div so I could add and in them respectively. Desired: <form> <div class="my_div"> {% block div_content %} ... {% endblock %} </div> </form> Template: {% block div_top %}{% endblock %} <div class="my_div"> {% block div_content %} {% endblock %} </div> {% block div_bottom %}{% endblock %} Looking at this I can't help but think that there is a better way to do it. What is the standard Django way of doing this?

    Read the article

  • Django: many-to-one fields and data integrity

    - by John
    Let's say that I have a Person who runs an inventory system. Each Person has some Cars, and each Car has a very large number of Parts (thousands, let's say). A Person, Bob, uses a Django form to create a Car. Now, Bob goes to create some Parts. It is only at the form level that Django knows that the Parts belong to some specific Car, and that the Parts.ForeignKey(Car) field should only have a specific Car as a choice. When creating a Part, you have to mess with the form's constructor or similar in order to limit the choice of Cars to only the cars owned by Bob. It does not seem proper that to enforce this ownership at the form level. It seems that other users' Cars must be inaccessible to anyone but the owner of the Car. What do you all think about this, and is there any way to enforce this?

    Read the article

  • Template error with django-photologue: 'Permission Denied'

    - by Ellie P.
    I'm in the process of re-setting up my Django development environment after reinstalling my OS. We use django-photologue with our project, which I installed using easy_install. However, I'm getting a template error on every template that has a photologue photo: TemplateSyntaxError at /newsroom/news/ Caught an exception while rendering: (13, 'Permission denied') One example of the line where the error is located: <img src="{{ photo.get_list_url }}"> I'm totally stumped--I've used photologue for this project on many different platforms and have never had this problem. Google yields nothing. I'm currently using Jolicloud (based on Ubuntu Jaunty). I'm working with a pre-existing database, so all of the photo sizes and everything have already been set up.

    Read the article

  • Can I suppress newlines with Django's template engine?

    - by ento
    In Rails ERB, you can suppress newlines by adding a trailing hyphen to tags: <ul> <% for @item in @items -%> <li><%= @item %></li> <% end -%> </ul> becomes: <ul> <li>apple</li> <li>banana</li> <li>cacao</li> </ul> Is there a way to do this in Django? (Disclosure: I'm generating a csv file with Django)

    Read the article

  • sending email templates in with django

    - by Anakin
    hey, i wanna send emails in html template like this. <html> <body> hello <strong>{{username}}</strong> your account activated. <img src="mysite.com/logo.gif" /> </body> it means, i want to send fully html powered templates, with django datas. i cant find anything about send_mail, and django-mailer only sends html templates, not with dynamic datas? any idea about html emails ? thanks.

    Read the article

  • Dropdown sorting in django-admin

    - by Andrey
    I'd like to know how can I sort values in the Django admin dropdowns. For example, I have a model called Article with a foreign key pointing to the Users model, smth like: class Article(models.Model): title = models.CharField(_('Title'), max_length=200) slug = models.SlugField(_('Slug'), unique_for_date='publish') author = models.ForeignKey(User) body = models.TextField(_('Body')) status = models.IntegerField(_('Status')) categories = models.ManyToManyField(Category, blank=True) publish = models.DateTimeField(_('Publish date')) I edit this model in django admin: class ArticleAdmin(admin.ModelAdmin): list_display = ('title', 'publish', 'status') list_filter = ('publish', 'categories', 'status') search_fields = ('title', 'body') prepopulated_fields = {'slug': ('title',)} admin.site.register(Article, ArticleAdmin) and of course it makes the nice user select dropdown for me, but it's not sorted and it takes a lot of time to find a user by username.

    Read the article

  • Programmatically sync the db in Django

    - by Attila Oláh
    I'm trying to sync my db from a view, something like this: from django import http from django.core import management def syncdb(request): management.call_command('syncdb') return http.HttpResponse('Database synced.') The issue is, it will block the dev server by asking for user input from the terminal. How can I pass it the '--noinput' option to prevent asking me anything? I have other ways of marking users as super-user, so there's no need for the user input, but I really need to call syncdb (and flush) programmatically, without logging on to the server via ssh. Any help is appreciated.

    Read the article

  • Django's manage.py shell won't indent

    - by hora
    I seem to have run into a strange bug or more likely some setting I am unfamiliar with on my system that is not allowing me to tab when I am in Django's shell (python manage.py shell is how I run it). For obvious reasons this is proving to be annoying since I can't do any loops or conditonals in the shell. If I hit tab it completes all functions that are available to me, like bash does in a terminal. I've tried just using spaces for my indents but I always get an indentation error. Does anyone know why this is happening and what I can do to get tab to work in my shell again? (It may be relevant to know that this is on a Ubuntu 9.04 system). Edit: tab works fine in the regular pythong shell, it's only in django's that it doesn't. Thanks.

    Read the article

  • How to combine 2 or more querysets in a Django view?

    - by Espen Christensen
    Hi, I am trying to build the search for a Django site I am building, and in the search I am searching in 3 different models. And to get pagination on the search result list I would like to use a generic object_list view to display the results. But to do that i have to merge 3 querysets into one. How can i do that? Ive tried this: result_list = [] page_list = Page.objects.filter(Q(title__icontains=cleaned_search_term) | Q(body__icontains=cleaned_search_term)) article_list = Article.objects.filter(Q(title__icontains=cleaned_search_term) | Q(body__icontains=cleaned_search_term) | Q(tags__icontains=cleaned_search_term)) post_list = Post.objects.filter(Q(title__icontains=cleaned_search_term) | Q(body__icontains=cleaned_search_term) | Q(tags__icontains=cleaned_search_term)) for x in page_list: result_list.append(x) for x in article_list: result_list.append(x) for x in post_list: result_list.append(x) return object_list(request, queryset=result_list, template_object_name='result', paginate_by=10, extra_context={'search_term': search_term}, template_name="search/result_list.html") But this doesnt work I get an error when i try to use that list in the generic view. The list is missing the clone attribute. Anybody know how i can merge the three lists, page_list, article_list and post_list?

    Read the article

  • where is everything in django admin?

    - by FurtiveFelon
    Hi all, I would like to figure out where everything is in django admin. Since i am currently trying to modify the behavior rather heavily right now, so perhaps a reference would be helpful. For example, where is ModelAdmin located, i cannot find it anywhere in C:\Python26\Lib\site-packages\django\contrib\admin. I need that because i would like to look at how it is implemented so that i can override with confidence. I need to do that in part because of this page: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-methods, for example, i would like to override ModelAdmin.add_view, but i can't find the original source for that. As well as i would like to see the url routing file for admin, so i can easily figure out which url corresponding to which template etc. Thanks a lot for any pointers!

    Read the article

  • Can django lazy-load fields in a model?

    - by Leopd
    One of my django models has a large TextField which I often don't need to use. Is there a way to tell django to "lazy-load" this field? i.e. not to bother pulling it from the database unless I explicitly ask for it. I'm wasting a lot of memory and bandwidth pulling this TextField into python every time I refer to these objects. The alternative would be to create a new table for the contents of this field, but I'd rather avoid that complexity if I can.

    Read the article

  • Iterating dictionary indexes in django templates

    - by unclaimedbaggage
    Hi folks...I have a dictionary with embedded objects, which looks something like this: notes = { 2009: [<Note: Test note>, <Note: Another test note>], 2010: [<Note: Third test note>, <Note: Fourth test note>], } I'm trying to access each of the note objects inside a django template, and having a helluva time navigating to them. In short, I'm not sure how to extract by index in django templating. Current template code is: <h3>Notes</h3> {% for year in notes %} {{ year }} # Works fine {% for note in notes.year %} {{ note }} # Returns blank {% endfor %} {% endfor %} If I replace {% for note in notes.year %} with {% for note in notes.2010 %} things work fine, but I need that '2010' to be dynamic. Any suggestions much appreciated.

    Read the article

  • Pass errors in Django using HttpResponseRedirect

    - by JPC
    I know that HttpResponseRedirect only takes one parameter, a URL. But there are cases when I want to redirect with an error message to display. I was reading this post: How to pass information using an http redirect (in Django) and there were a lot of good suggestions. I don't really want to use a library that I don't know how works. I don't want to rely on messages which, according to the Django docs, is going to be removed. I thought about using sessions. I also like the idea of passing it in a URL, something like: return HttpResponseRedirect('/someurl/?error=1') and then having some map from error code to message. Is it good practice to have a global map-like structure which hard codes in these error messages or is there a better way? Or should I just use a session EDIT: I got it working using a session. Is that a good practice to put things like this in the session?

    Read the article

  • Writing custom Django fields and widgets

    - by hekevintran
    Django has very good documentation that describes how to write custom database fields and custom template tags and filters. I cannot find the document that describes how to write custom form fields and widgets. Does this document exist? The way I've been able to write custom form fields and widgets is by reading the Django source code and imitating what I see there. I know that there are still things about implementing fields and widgets that I do not completely understand because I have not read any high level document that describes their interfaces.

    Read the article

  • Django: Extending User Model - Inline User fields in UserProfile

    - by Jack Sparrow
    Is there a way to display User fields under a form that adds/edits a UserProfile model? I am extending default Django User model like this: class UserProfile(models.Model): user = models.OneToOneField(User, unique=True) about = models.TextField(blank=True) I know that it is possible to make a: class UserProfileInlineAdmin(admin.TabularInline): and then inline this in User ModelAdmin but I want to achieve the opposite effect, something like inverse inlining, displaying the fields of the model pointed by the OneToOne Relationship (User) in the page of the model defining the relationship (UserProfile). I don't care if it would be in the admin or in a custom view/template. I just need to know how to achieve this. I've been struggling with ModelForms and Formsets, I know the answer is somewhere there, but my little experience in Django doesn't allow me to come up with the solution yet. A little example would be really helpful!

    Read the article

  • Writing custom Django form fields and widgets

    - by hekevintran
    Django has very good documentation that describes how to write custom database fields and custom template tags and filters. I cannot find the document that describes how to write custom form fields and widgets. Does this document exist? The way I've been able to write custom form fields and widgets is by reading the Django source code and imitating what I see there. I know that there are still things about implementing fields and widgets that I do not completely understand because I have not read any high level document that describes their interfaces.

    Read the article

  • app_label in an abstract Django model

    - by rayan
    Hi all, I'm trying to get an abstract model working in Django and I hit a brick wall trying to set the related_name per the recommendation here: http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name This is what my abstract model looks like: class CommonModel(models.Model): created_on = models.DateTimeField(editable=False) creared_by = models.ForeignKey(User, related_name="%(app_label)s_%(class)s_created", editable=False) updated_on = models.DateTimeField(editable=False) updated_by = models.ForeignKey(User, related_name="%(app_label)s_%(class)s_updated", editable=False) def save(self): if not self.id: self.created_on = datetime.now() self.created_by = user.id self.updated_on = datetime.now() self.updated_by = user.id super(CommonModel, self).save() class Meta: abstract = True My common model is in [project_root]/models.py. It is the parent object of this model, which is located in an app called Feedback [project_root]/feedback/models.py: from django.db import models from mediasharks.models import CommonModel class Feedback(CommonModel): message = models.CharField(max_length=255) request_uri = models.CharField(max_length=255) domain = models.CharField(max_length=255) feedback_type = models.IntegerField() Basically I'm trying to set up a common model so that I'll always be able to tell when and by whom database entries were created. When I run "python manage.py validate" I get this error message: KeyError: 'app_label' Am I missing something here?

    Read the article

  • Django form and User data

    - by Dean
    I have a model that looks like this: class Client(models.Model): name = models.CharField(max_length=100, primary_key=True) user = models.ForeignKey(User) class Contract(models.Model): title = models.CharField(max_length=100, primary_key=True) start_date = models.DateField() end_date = models.DateField() description = models.TextField() client = models.ForeignKey(Client) user = models.ForeignKey(User) How can i configure a django form so that only clients associated with that user show in the field in the form? My initial thought was this in my forms.py: client = forms.ModelChoiceField(queryset=Client.objects.filter(user__username = User.username)) But it didn't work. So how else would I go about it?

    Read the article

  • Django refresh page if change data by other user

    - by Fran Sobrino
    I have a test django app. In one page the test show the same question to all users. I'd like that when a user answers correctly, send a signal to other active user's browser to refresh to the next question. I have been learning about signals in django I learning work with them but I don't now how send the "refresh signal" to client browser. I think that it can do with a javascript code that check if a certain value (actual question) change and if change reload the page but I don't know this language and the information that I find was confused. Can anybody help me? Many Thanks.

    Read the article

  • Django updating a single model

    - by Hellnar
    Hello How can I use the update() method on a single model which I retrieved via Queryset.get() ? It seems like model. Model doesn't have an update() method yet I cannot invoke .save() as I have a pre-save signals which messes things up. EDIT: An idea would be passing some parameter to the save method and catching it at the pre_save signal, so that I can understand the purpose, how can this be done ? Thanks

    Read the article

  • how to do server side form validation for dynamic inputs with Django

    - by Satoru.Logic
    Hi, all. I am using django.forms.Form to validate form data in a survey applications. In a survey-creating form, a user can submit multiple questions that belong to the survey being created. Names for the question inputs are in the form of 'question_seq' , where seq is maintained using Javascript. Back in the server side, my code doesn't know before hand how many such questions will be submitted. Is there any way to do this with Django form so that the form can automatically recognizes the questions and validate them?

    Read the article

  • Django startup importing causes reverse to happen

    - by nicknack
    This might be an isolated problem, but figured I'd ask in case someone has thoughts on a graceful approach to address it. Here's the setup: -------- views.py -------- from django.http import HttpResponse import shortcuts def mood_dispatcher(request): mood = magic_function_to_guess_my_mood(request) return HttpResponse('Please go to %s' % shortcuts.MOODS.get(mood, somedefault)) ------------ shortcuts.py ------------ MOODS = # expensive load that causes a reverse to happen The issue is that shortcuts.py causes an exception to be thrown when a reverse is attempted before django is done building the urls. However, views.py doesn't yet need to import shortcuts.py (used only when mood_dispatcher is actually called). Obvious initial solutions are: 1) Import shortcuts inline (just not very nice stylistically) 2) Make shortcuts.py build MOODS lazily (just more work) What I ideally would like is to be able to say, at the top of views.py, "import shortcuts except when loading urls"

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >