Search Results

Search found 4109 results on 165 pages for 'django paypal'.

Page 66/165 | < Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >

  • django - order query set by postgres function

    - by thebiglife
    My initial question was here and was related to the postgres backend. http://stackoverflow.com/questions/2408965/postgres-subquery-ordering-by-subquery Now my problem has moved onwards to the Django ORM layer. I essentially want to order a query by a postgres function ('idx', taken from the above stackoverflow work) I've gone through trying to use model.objects.extra(order_by ) or simply order_by but I believe both of these need the order_by parameter to be an attribute or a field known to Django. I'm trying to think how to solve this without having to revert to using an entirely raw SQL query through a model manager.

    Read the article

  • User authentication in Django. Problems with is_authenticated

    - by tim
    I have one problem with users menu. So, I want, that authenticated user can see his/her profile page and logout (links) in menu. It works (when I logging in) on index page: index, page1, profile, logout ,but, if I go to the, for example, page1 I can see in menu: index, page1, login, not profile and logout. How to fix it? in urls: url(r'^accounts/login/$', 'django.contrib.auth.views.login' ), url(r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login' ), url(r'^accounts/profile/$', 'my_app.views.profile' ), in views: def profile(request): if not request.user.is_authenticated(): return HttpResponseRedirect("/accounts/login/") else: user = request.user.is_authenticated() return render_to_response('profile.html',locals()) Part of index.html: {% if user.is_authenticated or request.user.is_authenticated %} <li><a href="/accounts/profile/">Profile</a></li> <li><a href="/accounts/logout/">logout</a></li> {% else %} <li><a href="/accounts/login/">login</a></li> {% endif %} login.html: {% extends "index.html" %} {% load url from future %} {% block application %} {% if form.errors %} <p>Try one more time</p> {% endif %} <form method="post" action="{% url 'django.contrib.auth.views.login' %}"> {% csrf_token %} <table> <tr> <td>{{ form.username.label_tag }}</td> <td>{{ form.username }}</td> </tr> <tr> <td>{{ form.password.label_tag }}</td> <td>{{ form.password }}</td> </tr> </table> <input type="submit" value="Login" /> <input type="hidden" name="next" value="{{ next }}" /> </form> {% endblock %} profile.html: {% extends "index.html" %} {% block application %} {% if request.user.is_authenticated %} <p>Welcome, {{ request.user.username }}. Thanks for logging in.</p> {% else %} <p>Welcome, new user. Please log in.</p> {% endif %} {% endblock %}

    Read the article

  • Django, javascript and code ruse problem

    - by dragoon
    Hi, I have some sort of a design problem with my Django AJAX application. I have a template where I initialize js variable from django context variable like so: var test = "{{ test }}"; This variable is than used in a number of js functions that are needed for interface to work properly. So now I'm trying to reuse some content from this page in another page that loads it dynamically on some user interaction using jQuery.load(..), and I don't see any way how I can initialize that variable, so js functions don't work now. Is there any solution for this or may be I'm doing it wrong? Thanks.

    Read the article

  • Database Error django

    - by Megan
    DatabaseError at /admin/delmarva/event/ no such column: delmarva_event.eventdate I created a class in my models.py file: from django.db import models from django.contrib.auth.models import User class Event(models.Model): eventname = models.CharField(max_length = 100) eventdate = models.DateField() eventtime = models.TimeField() address = models.CharField(max_length = 200) user = models.ForeignKey(User) def __unicode__(self): return self.eventname and now when i try to view my events in my admin or my main_page it gives me the error that there is no eventdate. I tried syncing the db again but nothing changed. Also, I hashtagged eventdate out to see if I get a different error and then it states that delmarva_event.eventtime does not exist as well. I It is weird because it does not have a problem with eventname. Any suggestions would be greatly appreciated!

    Read the article

  • default model field attribute in Django

    - by Rosarch
    I have a Django model: @staticmethod def getdefault(): print "getdefault called" return cPickle.dumps(set()) _applies_to = models.TextField(db_index=True, default=getdefault) For some reason, getdefault() is never called, even as I construct instances of this model and save them to the database. This seems to contradict the Django documentation: Field.default The default value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created. Am I doing something wrong? Update: Originally, I had this, but then I switched to the above version to debug: _applies_to = models.TextField(db_index=True, default=cPickle.dumps(set())) I'm not sure why that wouldn't work.

    Read the article

  • Django Redundancy

    - by Sunsu
    I've read many things about scaling Django and the new multiple-DB support makes it so much easier. However, I have not been able to find much information on good ways to create a fully redundant system (not just one that scales). I realize there are many things that go into this problem, but the real thing I'm having trouble solving well is Database redundancy. Is it possible to set up a "write slave" using django's new multiple-DB support? If I had IP failover support it seems like having a write slave would help solve the problem. Simple MySQL replication doesn't seem like it will work due to slave lag right? What's the typical method of creating a redundant database system? Any input or guidance you guys have would be greatly appreciated. I realize I could be asking the wrong questions!

    Read the article

  • Django - Static content display based on URL

    - by Steven Potter
    I'm working on a Django site with a basic three column design. Left column navigation, center column content and right column URL specific content blocks. My question is about the best method of controlling the URL specific content blocks in the right column. I am thinking of something along the lines of the Flatpages app that will make the content available to the template context if the URL matches a pre-determined pattern (perhaps regex?). Does anyone know if such an app already exists? If not, I am looking for some advice about the best way to implement it. Particularly in relation to the matching of patterns to the current URL. Is there any good way to re-use parts of the Django URL dispatcher for this use?

    Read the article

  • Handling static files with Django / lighttpd

    - by ptikobj
    I know that there is already a question (actually some more) about this, but the answers to them didn't help me out very much, as I am pretty new to lighttpd. I have one folder which contains .pdf-files. When doing a HttpResponseRedirect to the locations of one of those .pdf-files, the user should be able to download the .pdf file (or view it in the browser). Right now, Django just redirects to my "home" html page, without showing any pdf-file. Somehow, I will have to tell lighttpd that Django shouldn't handle this directory anymore. Is this the only thing I need to do? If yes, how should i do it?

    Read the article

  • Deleting inline model in Django admin

    - by Overclocked
    I am trying to use Django admin to remove an inline model. I get an error saying [u'Select a valid choice. That choice is not one of the available choices.'] I check the location where the exception is raised. It seems like the inline model was removed, then a form validation happened on the parent model with the deleted inline model still as value of the form. That caused the failure. In my admin model, I had a save_formset method defined, that called formset.save(commit=False). Is the commit=False not telling Django to not delete the related models? Thanks.

    Read the article

  • Django Import Error with URLS and ROOT_URLCONF confusion

    - by tipu
    The error can be seen here: http://djaffry.selfip.com:8080/ In httpd conf, <VirtualHost *:8080> ServerName tweet_search_engine DocumentRoot /var/www/microblogsearchengine/twingle </VirtualHost> <Directory /var/www/microblogsearchengine/twingle> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE settings PythonOption django.root /var/www/microbloggingsearchengine/twingle PythonDebug On </Directory> Running python manage.py runserver and visiting localhost:8000 returns a splash page telling me everything is okay. However when I visit this site through apache, I get an import error with urls. In my settings.py file I have a line, ROOT_URLCONF = 'twingle.urls' I'm assuming this is the cause of the error. The project folder contains only 4 files: __init__.py manage.py settings.py urls.py I tried replacing twingle.urls with urls.py but then it gave me a different error. What is it I can do to get this working?

    Read the article

  • Django AND .htaccess rewrites/redirects, is this possible?

    - by Infinity
    Is it possible to have Apache htaccess rewrites take effect before it hits django? For example so I can redirect iPhone users to a completely different domain without even hitting django. We're using apache2 with mod_wsgi and the apache vhost looks like this: <VirtualHost *:80> DocumentRoot /usr/local/www/site/static Alias /css/ /usr/local/www/site/static/css/ Alias /js/ /usr/local/www/site/static/js/ Alias /img/ /usr/local/www/site/static/img/ Alias /flash/ /usr/local/www/site/static/flash/ <Directory /usr/local/www/site/static> AllowOverride All Order allow,deny Allow from all </Directory> WSGIDaemonProcess mallorca-site threads=15 WSGIScriptAlias / /usr/local/www/site/config/dev/dev.wsgi </VirtualHost> Thanks

    Read the article

  • Django form to enter/save html to database

    - by Ian
    I'm in my first week of Django development and am working on an admin page that will let me write some quick html using TinyMCE and then save it to the database. I don't need to display this web page on the site or add it to urls.py, etc. The html snippet will be loaded from the database and used in a view function. I've read in "Practical Django Projects" how to integrate TinyMCE, so my question is more concerned with the best approach for the form itself. Specifically: 1. Is there a built-in form like flatpage that works well for this? I only need one field in the form for the html. 2. How do I save the form's text after it's entered? I created a model with a JSONField to save the html in, but I'm not clear on what to do next. Thanks.

    Read the article

  • Storing task state between multiple django processes

    - by user366148
    I am building a logging-bridge between rabbitmq messages and Django application to store background task state in the database for further investigation/review, also to make it possible to re-publish tasks via the Django admin interface. I guess it's nothing fancy, just a standard Producer-Consumer pattern. Web application publishes to message queue and inserts initial task state into the database Consumer, which is a separate python process, handles the message and updates the task state depending on task output The problem is, some tasks are missing in the db and therefore never executed. I suspect it's because Consumer receives the message earlier than db commit is performed. So basically, returning from Model.save() doesn't mean the transaction has ended and the whole communication breaks. Is there any way I could fix this? Maybe some kind of post_transaction signal I could use? Thank you in advance.

    Read the article

  • Django naturaltime Localization error

    - by Edwin Lunando
    My language ID is 'id'. I used localized humanize library for my Django template tags and use the naturaltime, but the translation is partially wrong. The now translated to sekarang is right. second to detik. minute to menit, but when it comes to date, week, or months, the word is not translated to my language. It keeps printing date, week, and months. Here are my Django configuration TIME_ZONE = 'Asia/Jakarta' LANGUAGE_CODE = 'id' SITE_ID = 1 USE_I18N = True USE_L10N = True USE_TZ = True Here how I used the naturaltime template tags. <time class="discussion__info__item">{{ object.created|naturaltime }}</time> Do I forgot something? Thank you.

    Read the article

  • Lighttpd + fastcgi + python (for django) slow on first request

    - by EagleOne
    I'm having a problem with a django website I host with lighttpd + fastcgi. It works great but it seems that the first request always takes up to 3seconds. Subsequent requests are much faster (<1s). I activated access logs in lighttpd in order to track the issue. But I'm kind of stuck. Here are logs where I 'lose' 4s (from 10:04:17 to 10:04:21): 2012-12-01 10:04:17: (mod_fastcgi.c.3636) handling it in mod_fastcgi 2012-12-01 10:04:17: (response.c.470) -- before doc_root 2012-12-01 10:04:17: (response.c.471) Doc-Root : /var/www 2012-12-01 10:04:17: (response.c.472) Rel-Path : /finderauto.fcgi 2012-12-01 10:04:17: (response.c.473) Path : 2012-12-01 10:04:17: (response.c.521) -- after doc_root 2012-12-01 10:04:17: (response.c.522) Doc-Root : /var/www 2012-12-01 10:04:17: (response.c.523) Rel-Path : /finderauto.fcgi 2012-12-01 10:04:17: (response.c.524) Path : /var/www/finderauto.fcgi 2012-12-01 10:04:17: (response.c.541) -- logical -> physical 2012-12-01 10:04:17: (response.c.542) Doc-Root : /var/www 2012-12-01 10:04:17: (response.c.543) Rel-Path : /finderauto.fcgi 2012-12-01 10:04:17: (response.c.544) Path : /var/www/finderauto.fcgi 2012-12-01 10:04:21: (response.c.128) Response-Header: HTTP/1.1 200 OK Last-Modified: Sat, 01 Dec 2012 09:04:21 GMT Expires: Sat, 01 Dec 2012 09:14:21 GMT Content-Type: text/html; charset=utf-8 Cache-Control: max-age=600 Transfer-Encoding: chunked Date: Sat, 01 Dec 2012 09:04:21 GMT Server: lighttpd/1.4.28 I guess that if there is a problem, it's whith my configuration. So here is the way I launch my django app: python manage.py runfcgi method=threaded host=127.0.0.1 port=3033 And here is my lighttpd conf: server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect", "mod_rewrite", "mod_fastcgi", "mod_accesslog", ) server.document-root = "/var/www" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" accesslog.filename = "/var/log/lighttpd/access.log" debug.log-request-header = "enable" debug.log-response-header = "enable" debug.log-file-not-found = "enable" debug.log-request-handling = "enable" debug.log-timeouts = "enable" debug.log-ssl-noise = "enable" debug.log-condition-cache-handling = "enable" debug.log-condition-handling = "enable" fastcgi.server = ( "/finderauto.fcgi" => ( "main" => ( # Use host / port instead of socket for TCP fastcgi "host" => "127.0.0.1", "port" => 3033, #"socket" => "/home/finderadmin/finderauto.sock", "check-local" => "disable", "fix-root-scriptname" => "enable", ) ), ) alias.url = ( "/media" => "/home/user/django/contrib/admin/media/", ) url.rewrite-once = ( "^(/media.*)$" => "$1", "^/favicon\.ico$" => "/media/favicon.ico", "^(/.*)$" => "/finderauto.fcgi$1", ) index-file.names = ( "index.php", "index.html", "index.htm", "default.htm", " index.lighttpd.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) ## Use ipv6 if available #include_shell "/usr/share/lighttpd/use-ipv6.pl" dir-listing.encoding = "utf-8" server.dir-listing = "enable" compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain" ) include_shell "/usr/share/lighttpd/create-mime.assign.pl" include_shell "/usr/share/lighttpd/include-conf-enabled.pl" If any of you could help me finding out where I lose these 3 or 4 s. I would much appreciate. Thanks in advance!

    Read the article

  • Django Forms save_m2m

    - by John
    Hi I have a model which has 2 many to many fields in it. one is a standard m2m field which does not use any through tables whereas the other is a bit more complecated and has a through table. I am using the Django forms.modelform to display and save the forms. The code I have to save the form is if form.is_valid(): f = form.save(commit=False) f.modified_by = request.user f.save() form.save_m2m() When i try to save the form I get the following error: Cannot set values on a ManyToManyField which specifies an intermediary model. I know this is happening when I do the form.save_m2m() because of the through table. What I'd liek to do is tell Django to ignore the m2m field with the through table but still save the m2m field without the through table. I can then go on to manually save the data for the through table field. Thanks

    Read the article

  • Django: Change models without clearing all data?

    - by Rosarch
    I have some models I'm working with in a new Django installation. Is it possible to change the fields without losing app data? I tried changing the field and running python manage.py syncdb. There was no output from this command. Renavigating to admin pages for editing the changed models caused TemplateSyntaxErrors as Django sought to display fields that didn't exist in the db. I am using SQLite. I am able to delete the db file, then re-run python manage.py syncdb, but that is kind of a pain. Is there a better way to do it?

    Read the article

  • Creating readable html with django templates

    - by rileymat
    When using Django for html templating how do I create good html markup formatting. I am trying to make use of content blocks. But the content blocks show up at different levels of indentation in different templates. How do I get the content blocks to show indented like it would be if someone was to hand write the html. I am having the same problem with newlines; I can smash all the blocks together in the template. At that point the html looks better, but the templates are unmaintainable. I guess the question is how to you create pretty html markup with the django templating system?

    Read the article

  • Django: how to pass form variable to simple tag in template

    - by Remigijus
    Hello. I am trying to do some custom things in Django comments form. I have simple tag named "get_flatpage_by_id" that returns flatpage model data as array. This is working I expected: {% get_flatpage_by_id 14 as page %} It's returning flatpage that ID is 14. But this is not working, if I try to pass {{ form.object_pk.data }} (that returns 14). This is how it should look like: {% get_flatpage_by_id form.object_pk.data as page %} Simple tag receives value "form.object_pk.data" (string), not 14. I don't know how to tell Django that "form.object_pk.data" is variable, not a string!

    Read the article

  • Django shell command to change a value in json data

    - by crozzfire
    I am a django newbie and i was playing around in django's manage.py shell. Here is something i am trying in the shell: >>> data [{'primary_program': False, 'id': 3684}, {'primary_program': True, 'id': 3685}] >>> data[0] {'primary_program': False, 'id': 3684} >>> data[1] {'primary_program': True, 'id': 3685} >>> data[0].values() [False, 3684] >>> data[1].values() [True, 3685] >>> How should i give a command here to update the value of primary_program in data[1] to False and keep the rest of the json the same?

    Read the article

  • Iterating over a database column in Django

    - by curious
    I would like to iterate a calculation over a column of values in a MySQL database. I wondered if Django had any built-in functionality for doing this. Previously, I have just used the following to store each column as a list of tuples with the name table_column: import MySQLdb import sys try: conn = MySQLdb.connect (host = "localhost", user = "user", passwd="passwd", db="db") except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit (1) cursor = conn.cursor() for table in ['foo', 'bar']: for column in ['foobar1', 'foobar2']: cursor.execute('select %s from %s' % (column, table)) exec "%s_%s = cursor.fetchall()" % (table, column) cursor.close() conn.commit() conn.close() Is there any functionality built into Django to more conveniently iterate through the values of a column in a database table? I'm dealing with millions of rows so speed of execution is important.

    Read the article

< Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >