Search Results

Search found 15813 results on 633 pages for 'django settings'.

Page 74/633 | < Previous Page | 70 71 72 73 74 75 76 77 78 79 80 81  | Next Page >

  • Django site runs into "504 timeout error"

    - by jack
    I have a Django based site on Nginx+FastCGI which keeps running into "504 timeout error" after about 30 minutes since FastCGI process restarted. I did a "ps -aux" check and a lot of FastCGI processes are with D status. How can I figure out which part of the site make FastCGI processes not responsing?

    Read the article

  • Django: GROUP BY two values

    - by AP257
    I would basically like to do the same as this question, but grouping by combinations of two values, rather than just one: SELECT player_type, team, COUNT(*) FROM players GROUP BY player_type, team; Does anyone know whether, and how, this is possible in Django? I'm using 1.2.

    Read the article

  • How to access image folder in django

    - by anc1revv
    I just started django and i want to access images uploaded by a user. here is my model: class Food(models.Model): name = models.CharField(max_length=100) price = models.DecimalField(max_digits=4, decimal_places=2) quantity = models.IntegerField(blank=True, null=True) description = models.CharField(max_length=200) location = models.CharField(max_length=100) time = models.DateTimeField() photo_thumbnail = models.ImageField(upload_to="images") photo_fullsize = models.ImageField(upload_to="images") i stored the image in the "images" folder below the html is this: img src="{{steak.photo_thumbnail}}" and steak.photo_thumbnail = images/steak_and_egg_thumbnail_1.png here is the error i get: [06/Jul/2012 19:08:24] "GET /menu/ HTTP/1.1" 200 99 [06/Jul/2012 19:08:24] "GET /menu/images/steak_and_egg_thumbnail_1.png HTTP/1.1" 404 2127

    Read the article

  • Pagination of Date-Based Generic Views in Django

    - by Apreche
    I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?

    Read the article

  • Django: saving pickled object

    - by pistacchio
    Hi, i have a large dictionary I'd like to save. I have pickled it using cPickle.dumps and saved the result into a TextField. When trying to retrieve it (cPicle.loads) i get the following error: loads() argument 1 must be string, not unicode Does anybody have any experience in serializing python objects and storing them in a DB using Django? Thanks in advance.

    Read the article

  • Creating temporary user accounts - Django

    - by RadiantHex
    Hi folks, I need to setup temporary User models for each visitors, where the visitors are obviously tied by session data. I might not be aware of it, but does Django support attaching data to Anonymous users? The only way, I am currently aware of, is to use the session dictionary part of the request object. Help would be very much appreciated!

    Read the article

  • How to span multile tables in Django

    - by ipartola
    The Django documentation gives en example like so: b = Blog.objects.get(id=1) b.entry_set.all() Which from what I understand results in 2 queries. What if I wanted to get the blog, the blog entries and all the comments associated with that entry in a number of queries that does not depend on the number of entries? Or do I have to drop down to SQL to do that?

    Read the article

  • Django for web2py developers

    - by carrier
    Now that I've gotten relatively familiar with web2py, I'd like to give Django a go. What are the main differences? What would be the most efficient way to get started taking into account web2py knowledge? (It must help to have some python application framework knowledge,no?) EDIT Also, if you've used both, can you offer an opinion on which you prefer and why?

    Read the article

  • Run a shell command from Django

    - by Badifunky
    Hello, I'm developing a web page in Django (using apache server) that needs to call a shell command to enable/dissable some daemons. I'm try to do it with os.system(service httpd restart 1>$HOME/out 2>$HOME/error) and this command doesn't return anything. Any idea how can i fix this?

    Read the article

  • onmouseover problems with JavaScript (rendered using django and django-imagekit)

    - by Michael Moreno
    I'm using Imagekit. View.py includes: def pics(request): p = Photo.objects.all() return render_to_response('Shots.html', {'p': p}) The following simple code in the template will generate associated images: {% for p in p %} <img src = "{{ p.display.url }}"> <img src = "{{ p.thumbnail_image.url }}"> {% endfor %} I'm attempting to generate a series of thumbnails {{ p.thumbnail_image.url }} which, when mouseover'd, will generate the slightly larger version of the image, {{ p.display.url }} via Javascript. The following code in the template attempts to do so: <html> <head> <HEAD> <script language="Javascript"> { image1 = new Image image2 = new Image image1.src = {{ p.thumbnail_image.url }} image2.src = {{ p.display.url }} </script> </head> <body> {% for p in p %} <a href="" onMouseOver="document.rollover.src= image2.src onMouseOut="document.rollover.src= image1.src"> <img src="{{ p.thumbnail_image.url }}" border=0 name="rollover"></a> {% endfor %} </body> </html> This will display the series of thumbnails, but the larger image will not display when mouseover'd. I believe it has to do with how I'm specifying the variable {{ p.display.url }}.

    Read the article

  • can't figure out serving static images in django dev environment

    - by photographer
    I've read the article (and few others on the subject), but still can't figure out how to show an image unless a link to a file existing on a web-service is hard-coded into the html template. I've got in urls.py: ... (r'^galleries/(landscapes)/(?P<path>.jpg)$', 'django.views.static.serve', {'document_root': settings.MEDIA_URL}), ... where 'landscapes' is one of the albums I'm trying to show images from. (There are several more of them.) In views.py it calls the template with code like that: ... <li><img src=160.jpg alt='' title='' /></li> ... which resolves the image link in html into: http://127.0.0.1:8000/galleries/landscapes/160.jpg In settings.py I have: MEDIA_ROOT = 'C:/siteURL/galleries/' MEDIA_URL = 'http://some-good-URL/galleries/' In file system there is a file C:/siteURL/galleries/landscapes/160.jpg and I do have the same file at http://some-good-URL/galleries/landscapes/160.jpg No matter what I use in urls.py — MEDIA_ROOT or MEDIA_URL (with expectation to have either local images served or from the web-server) — I get following in the source code in the browser: <li><img src=160.jpg /></li> There is no image shown in the browser. What am I doing wrong?

    Read the article

  • Django error - no module named

    - by Shreyas
    Here is my relevant directory structure (Windows 7, Python 2.7, virtualenv) -userProf - - manage.py - -UserProfile - sampleapp_db - urls.py - views.py - wsgi.py - __init__.py - -libs - - __init__.py - -allauth - - app_settings.py - - models.py - - tests.py - - urls.py - - utils.py - - - -account - - - admin.py - - - context_processors.py - - - models.py - - - urls.py - - - __init__.py - -socialaccount - - - admin.py - - - context_processors.py - - - models.py - - - urls.py - - - views.py - - - __init__.py - - - - -templates - -account - - - base.html - - - email.html -settings - base_settings.py - dev.py - __init__.py - -static -css I get the following error when I try to run this dango app Error: No module named account I have read other posts on SO that refer to the syspath being the issue or that the appname matches the project name Django Shell No module named settings ...as a result of this, I added the following statements in the base_settings.py file import sys base = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) base_parent = os.path.dirname(base) sys.path.append(base) sys.path.append(base_parent) sys.path.append(os.path.join(base,'libs')) sys.path.append(os.path.join(base,'libs','allauth','account')) I verified that the sys.path is correct by putting a break in PyCharm and evaluating sys.path Should I be putting this in manage.py? Some other SO postings referred to not being able to import the module but I can launch the python console and import UserProfile.libs.allauth.account without any exceptions being thrown! My base_setings.py has the following relevant section INSTALLED_APPS = ( 'UserProfile.libs.allauth.account', )

    Read the article

  • django - variable declared in base project does not appear in app

    - by unsorted
    I have a variable called STATIC_URL, declared in settings.py in my base project: STATIC_URL = '/site_media/static/' This is used, for example, in my site_base.html, which links to CSS files as follows: <link rel="stylesheet" href="{{ STATIC_URL }}css/site_tabs.css" /> I have a bunch of templates related to different apps which extend site_base.html, and when I look at them in my browser the CSS is linked correctly as <link rel="stylesheet" href="/site_media/static/css/site_tabs.css" /> (These came with a default pinax distribution.) I created a new app called 'courses' which lives in the ...../apps/courses folder. I have a view for one of the pages in courses called courseinstance.html which extends site_base.html just like the other ones. However, when this one renders in my browser it comes out as <link rel="stylesheet" href="css/site_tabs.css" /> as if STATIC_URL were equal to "" for this app. Do I have to make some sort of declaration to get my app to take on the same variable values as the project? I don't have a settings.py file for the app. by the way, the app is listed in my list of INSTALLED_APPS and it gets served up fine, just without the link to the CSS file (so the page looks funny). Thanks in advance for your help.

    Read the article

  • Python logging in Django

    - by Jeff
    I'm developing a Django app, and I'm trying to use Python's logging module for error/trace logging. Ideally I'd like to have different loggers configured for different areas of the site. So far I've got all of this working, but one thing has me scratching my head. I have the root logger going to sys.stderr, and I have configured another logger to write to a file. This is in my settings.py file: sviewlog = logging.getLogger('MyApp.views.scans') view_log_handler = logging.FileHandler('C:\\MyApp\\logs\\scan_log.log') view_log_handler.setLevel(logging.INFO) view_log_handler.setFormatter(logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')) sviewlog.addHandler(view_log_handler) Seems pretty simple. Here's the problem, though: whatever I write to the sviewlog gets written to the log file twice. The root logger only prints it once. It's like addHandler() is being called twice. And when I put my code through a debugger, this is exactly what I see. The code in settings.py is getting executed twice, so two FileHandlers are created and added to the same logger instance. But why? And how do I get around this? Can anyone tell me what's going on here? I've tried moving the sviewlog logger/handler instantiation code to the file where it's used (since that actually seems like the appropriate place to me), but I have the same problem there. Most of the examples I've seen online use only the root logger, and I'd prefer to have multiple loggers.

    Read the article

  • Does the same lame settings (--alt-preset standard) have differrent names?

    - by erikric
    I've always used windows, and therefore EAC to rip my CDs, but since I've started using Ubuntu more often, I decided to try to rip some albums there. I ended up using k3b (since I found it in the Ubuntu Software center. Tried to install RubyRipper first, but when 'sudo apt-get install ' or UDC fails, a Windows user like me is lost) The real question here is about the settings for the lame encoder. I'm used to just writing --alt-preset standard, and everything works like a charm, but the default in k3b look like this: lame -r --bitwidth 16 --little-endian -s 44.1 -h --tt %t --ta %a --tl %m --ty %y --tc %c --tn %n - %f I assume these are some sensible lame settings, and not a malicious perl script (although it looks like it). It seems to me like some of these ought to be there, and that I can not overwrite the whole thing with my good ol' --alt-preset. So, the question is do I need to replace anything, or is -h the same as old --alt-preset? Is it a difference between '--preset standard' and '--alt-preset standard'? And are those the same as -V 2?

    Read the article

  • Dynamic model choice field in django formset using multiple select elements

    - by Aryeh Leib Taurog
    I posted this question on the django-users list, but haven't had a reply there yet. I have models that look something like this: class ProductGroup(models.Model): name = models.CharField(max_length=10, primary_key=True) def __unicode__(self): return self.name class ProductRun(models.Model): date = models.DateField(primary_key=True) def __unicode__(self): return self.date.isoformat() class CatalogItem(models.Model): cid = models.CharField(max_length=25, primary_key=True) group = models.ForeignKey(ProductGroup) run = models.ForeignKey(ProductRun) pnumber = models.IntegerField() def __unicode__(self): return self.cid class Meta: unique_together = ('group', 'run', 'pnumber') class Transaction(models.Model): timestamp = models.DateTimeField() user = models.ForeignKey(User) item = models.ForeignKey(CatalogItem) quantity = models.IntegerField() price = models.FloatField() Let's say there are about 10 ProductGroups and 10-20 relevant ProductRuns at any given time. Each group has 20-200 distinct product numbers (pnumber), so there are at least a few thousand CatalogItems. I am working on formsets for the Transaction model. Instead of a single select menu with the several thousand CatalogItems for the ForeignKey field, I want to substitute three drop-down menus, for group, run, and pnumber, which uniquely identify the CatalogItem. I'd also like to limit the choices in the second two drop-downs to those runs and pnumbers which are available for the currently selected product group (I can update them via AJAX if the user changes the product group, but it's important that the initial page load as described without relying on AJAX). What's the best way to do this? As a point of departure, here's what I've tried/considered so far: My first approach was to exclude the item foreign key field from the form, add the substitute dropdowns by overriding the add_fields method of the formset, and then extract the data and populate the fields manually on the model instances before saving them. It's straightforward and pretty simple, but it's not very reusable and I don't think it is the right way to do this. My second approach was to create a new field which inherits both MultiValueField and ModelChoiceField, and a corresponding MultiWidget subclass. This seems like the right approach. As Malcolm Tredinnick put it in a django-users discussion, "the 'smarts' of a field lie in the Field class." The problem I'm having is when/where to fetch the lists of choices from the db. The code I have now does it in the Field's __init__, but that means I have to know which ProductGroup I'm dealing with before I can even define the Form class, since I have to instantiate the Field when I define the form. So I have a factory function which I call at the last minute from my view--after I know what CatalogItems I have and which product group they're in--to create form/formset classes and instantiate them. It works, but I wonder if there's a better way. After all, the field should be able to determine the correct choices much later on, once it knows its current value. Another problem is that my implementation limits the entire formset to transactions relating to (CatalogItems from) a single ProductGroup. A third possibility I'm entertaining is to put it all in the Widget class. Once I have the related model instance, or the cid, or whatever the widget is given, I can get the ProductGroup and construct the drop-downs. This would solve the issues with my second approach, but doesn't seem like the right approach.

    Read the article

  • IntegrityError: foreign key violation upon delete

    - by Lukasz Korzybski
    I have Order and Shipment model. Shipment has a foreign key to Order. class Order(...): ... class Shipment() order = m.ForeignKey('Order') ... Now in one of my views I want do delete order object along with all related objects. So I invoke order.delete(). I have Django 1.0.4, PostgreSQL 8.4 and I use transaction middleware, so whole request is enclosed in single transaction. The problem is that upon order.delete() I get: ... File "/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", line 28, in _commit return self.connection.commit() IntegrityError: update or delete on table "main_order" violates foreign key constraint "main_shipment_order_id_fkey" on table "main_shipment" DETAIL: Key (id)=(45) is still referenced from table "main_shipment". I checked in connection.queries that proper queries are executed in proper order. First shipment is deleted, after that django executes delete on order row: {'time': '0.000', 'sql': 'DELETE FROM "main_shipment" WHERE "id" IN (17)'}, {'time': '0.000', 'sql': 'DELETE FROM "main_order" WHERE "id" IN (45)'} Foreign key have ON DELETE NO ACTION (default) and is initially deferred. I don't know why I get foreign key constraint violation. I also tried to register pre_delete signal and manually delete shipment objects before delete on order is called, but it resulted in the same error. I can change ON DELETE behaviour for this key in Postgres but it would be just a hack, I wonder if anyone has a better idea what's going on here. There is also a small detail, my Order model inherits from Cart model, so it actually doesn't have id field but cart_ptr_id and after DELETE on order is executed there is also DELETE on cart, but it seems unrelated? to the shipment-order problem so I simplified it in the example.

    Read the article

< Previous Page | 70 71 72 73 74 75 76 77 78 79 80 81  | Next Page >