Questions tagged [django-1.4]

1

votes
1

answer
2.2k

Views

Django 1.4 Deployment and os.environ.setdefault

In the new Django 1.4 project layout, I have a declaration of os.environ.setdefault on manage.py and wsgi.py inside the project folder. What is the difference between the two? Also, if I have this settings structure: mysite |-- mysite | |-- settings | |-- base.py | |-- dev.py | |-- productio...
yretuta
1

votes
2

answer
752

Views

is there no way to use mongodb on django 1.4 yet? [closed]

i'd like to use mongodb on django 1.4.. there is no nonrel for it yet.. the guilde is still for 1.3 http://django-mongodb.org/topics/setup.html is there any other way?!?! other tutorial or something?!
user1320189
1

votes
1

answer
65

Views

Buildin template tags seem to break i18n

And just when I thought I am finished with the Internationalization and timezones and can finally move on to more interesting features, one last time I got bitten. :) Within my template as long as I have the following, the template automatically converts the datetime from UTC into my currently selec...
Houman
1

votes
1

answer
727

Views

Make LiveServerTestCase not to call setUp() before each test

I have one problem with testing django app by using LiveServerTestCase. LiveServerTestCase execute setUp() function before executing each test. But I'm using factory-boy's factories to create objects for testing (users, items, etc...). And the same objects are created before executing each test. How...
Dmitry Belaventsev
1

votes
1

answer
254

Views

Custom admin interface in Django

Django's documentation provides an easy way of installing admin app. It assumes the structure of files as follows: mysite/ manage.py mysite/ settings.py #adding `admin` under `INSTALLED_APPS` __init__.py urls.py #adding urls wsgi.py myapp/ __init__.py admin.py #creating this file models.py views.py...
xan
1

votes
1

answer
858

Views

Django admin - Email username and password on user creation

I'm using django-1.4.3 and the superuser can create users and assign password to them. Here I'm using django-email-as-username to enable users to login with their email as username. When the superuser adds a new user, the newly added user should be notified through email with his username and passwo...
arulmr
1

votes
1

answer
865

Views

django: How to pass variable to class?

urls.py url(r'^customer/(?P[^\s]+)/$', customerDetailView.as_view(), name='customerDetailView'), #pass 'name' variable and views.py class customerDetailView(DetailView): context_object_name = 'customerDetail' template_name = 'customer.html' allow_empty = True def __init__(self, name=None, *args): se...
chobo
1

votes
1

answer
2.1k

Views

Static files: No such file or directory error in Django 1.4 [closed]

I created an app locally with the django development server and now want to host it on the web. I uploaded and installed everything on a server with python 2.7, django 1.4.5 and flup. Everything works fine until I try to use any static files. When my site tries to open a textfile it says: 'No such...
36milesperhour
1

votes
1

answer
105

Views

Sort table by a column and set other column to sequential value to persist ordering

So I'm not sure whether to pose this as a Django or SQL question however I have the following model: class Picture(models.Model): weight = models.IntegerField(default=0) taken_date = models.DateTimeField(blank=True, null=True) album = models.ForeignKey(Album, db_column='album_id', related_name='pict...
DanH
1

votes
1

answer
71

Views

Python Classes Foreign Keys Inheritance

I wonder - is it possible to inherit classes like this? For exmple, i have 2 abstract classes: class Book(models.Model): name = models.TextField() class Meta: abstract = True class Page(models.Model) num = models.IntegerField() book = models.ForeignKey('Book') class Meta: abstract = True And so - I...
Tosh
1

votes
1

answer
232

Views

Date range in python where result value must be in string format

i want date range between two dates. the result value will be like it should support for string operations or it should be in string. i have tried the following code but i am not at all doing anything with the date object. import datetime def generate_dates(start_date, end_date): td = datetime.timed...
Krish gopi
1

votes
1

answer
109

Views

How to restrict one url to only one view in django urls

I am facing problem in urls.My project name is Stock and my app name is Stock_app, Stock urls.py: urlpatterns = patterns('', url(r'^goc/', include('stock_app.urls')), url(r'^goc_range/', include('stock_app.urls')), ) in my stock_app urls.py urlpatterns = patterns('stock_app.views', url(r'^(\w+)/(\d...
Krish gopi
1

votes
1

answer
5.2k

Views

'bootstrap3' is not a valid tag library: ImportError raised loading bootstrap3.templatetags.bootstrap3: cannot import name force_text

I am going through tutorials on django-bootstrap by this link : 'https://pypi.python.org/pypi/django-bootstrap3https://pypi.python.org/pypi/django-bootstrap3' in my settings.py: INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites'...
Krish gopi
1

votes
1

answer
525

Views

list index out of range error when saving objects in admin after upgrade from Django 1.4 to 1.6

I have recently upgraded my 1.4 project to 1.6 and after working out some of the deprecation problems I have reached another one that I have not been able to solve. Every time I either try to save a new object or edit an exisiting one I get a list index out of range error. I understand what the erro...
Austin
1

votes
1

answer
930

Views

Django Nose ImportError: no modules named urls

I started using django-nose because I wanted to to run only my apps' tests via python manage.py test, but I'm running into this ImportError: no modules named urls. This project is using Django 1.4. The folder structure is like so: project ├── manage.py ├── project ├── apps │ ...
Huey
1

votes
2

answer
406

Views

Django: filter by aggregate

I am trying to filter by a value calculated using aggregates. Currently I am doing this: max_val = some_queryset.aggregate(max_val=Max('some_prop'))['max_val'] some_queryset.filter(some_prop=max_val) Is there a way I can use max_val to filter, all done in a single query? Unfortunately I am using Dja...
dabadaba
1

votes
2

answer
1.4k

Views

what wrong with my models.py

I am using Django 1.4 with PostgreSQL 9.1.4 what wrong with my models.py class UserProfile(models.Model): ROLES_TYPE = ( ('Employee', 'Employee'), ('Employor', 'Employor'), ) user = models.OneToOneField(User, related_name='Profile') role = models.CharField(max_length=15, choices=ROLES_TYPE) class St...
jayapal d
1

votes
2

answer
488

Views

django-registration - redirecting to registration form and displaying message

After succesfully registering, the user is redirected to the template 'registration_complete.html'. Is there any way of changing this behaviour to redirecting the user to the registration page and displaying a message? I thought of doing something like this in registration_complete.html: {% include...
AlexBrand
1

votes
1

answer
698

Views

Change ChoiceField option after clean method in Django form

Is there any way to change a form element after the form is cleaned? There's some form logic that is affected by other fields. In certain cases I want to add an additional choice to a ChoiceField after the clean function runs if the form is invalid. Is there a way to do this?
Jordan Reiter
1

votes
4

answer
2.8k

Views

How can you display the results of a script in real-time for a Django 1.4 website?

So after finding out how to display the results of scripts on a Django website, I thought I'd be able to display the likes of live CPU information using SAR however whenever I change my code and refresh the webpage it doesn't load up and constantly looks like it's trying to load the webpage. The onl...
Mark O'Sullivan
1

votes
1

answer
495

Views

How to search in ManyToManyField

I am new to django, and I am trying to make a query in a Many to many field. an example of my query: in the Models I have class Line(models.Model): name = models.CharField('Name of line', max_length=50, blank=True) class Cross(models.Model): lines = models.ManyToManyField(Line, verbose_name='Lines c...
نوار مكيس
1

votes
2

answer
743

Views

Django delete all cookies for all users

I have the django view to set the value in cookies 'no_show_dialog' when a user clicks 'Don't remind me anymore' in the modal dialog. Now i changed that dialog completely and want to reset that cookie for all users, so they will have to see it again at least once. I know there is a way to delete the...
Feanor
0

votes
0

answer
3

Views

How to increase visibility_timeout

We're using Django 1.4.22 and celery 3.1.25 with REDIS. The default value for visibility_timeout is one hour and it is too small for our jobs. How can we increase visibility_timeout to 6 hours? My attempt was to set in Dkjango's setting.py this: BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 3600...
user3429660
1

votes
2

answer
303

Views

How to use template within Django template?

I have the django template like below: {{ mylist.0.title }} {{ mylist.0.text|truncatewords:50 }} ... (the actual template is quite big) It should be used 10 times on the same page, but 'external' html elements are different: *django template here - mylist.0, truncatewords:50 * *django template here...
LA_
17

votes
6

answer
12.6k

Views

'admin' is not a registered namespace in Django 1.4

I'm attempting to upgrade quite a large Django project to the newly released Django 1.4, and I'm having some issues when running python manage.py test. Lots of the internal tests which passed in Django 1.3 are now failing, with really odd messages that I can't seem to fix. One that appears the most...
Rob Golding
17

votes
4

answer
3.7k

Views

How to bind multiple reusable Django apps together?

I try my best to write reusable Django apps. Now I'm puzzled how to put them all together to get the final project. Here is an example of what I mean: I have a picture app that stores, resizes and displays images. Also I have a weblog app that stores, edits and displays texts. Now I want to combine...
JasonTS
6

votes
2

answer
2k

Views

How to set up Django models with two types of users with very different attributes

Note: I've since asked this question again given the updates to Django's user model since version 1.5. I'm rebuilding and making improvements to an already existing Django site and moving it over from Webfaction to Heroku, and from Amazon's SimpleDB to Heroku Postgres (though testing locally on Sqll...
jdotjdot
4

votes
3

answer
1.1k

Views

Are Instance variables of class-based-views persistent?

I've just started using class-based views in django. But there's an issue that is confusing for me. I ran the following code snippet with django 1.4.1 with multithreaded development server. class TestView(TemplateView): template_name = 'test.html' count = 0 mylist = [1, ] def get(self, request, *arg...
user1603806
2

votes
1

answer
153

Views

Reverse not found for my custom model admin urls after reload(sys.modules['urls.py'])

After doing following when I call reverse for my custom model admin url its giving me Reverse not found and before reloading urls.py reverse working fine. def _reset_urls(self, urlconf_modules): '''Reset `urls.py` for a set of Django apps.''' for urlconf in urlconf_modules: if urlconf in sys.modules...
Waheed Ahmed
2

votes
1

answer
1.8k

Views

how to check a previous value on a django model

I've got a django model with a field that i want to be always greater than the previous one of the same model instance after an update, like this: class MyModel(models.Model): version = models.FloatField() prev_value = 0 def clean(self): if self.version
loki
2

votes
1

answer
1.8k

Views

Django: problems while loading custom filters in the base template file while using template inheritance

When doing the {% load custom_filters %} in the template, after {% extends 'base.html' %} everything works fine, but when I move the load to the base.html template the filter gets a weird behaviour. This is my custom_filters.py: from django import template from django.template.defaultfilters import...
olofom
2

votes
2

answer
1.2k

Views

Django get_object_or_404 with select_related causes form checkbox widget weird behavior : Django 1.4 bug?

I come with a really strange Django 1.4 behaviour wich sounds like a bug to me. I looked anywhere if someone experienced it, but didn't find anything. My concern is about Django form creation using ModelForm, with a model containing boolean field. Let Post and Topic two models wich should look like...
user650108
2

votes
1

answer
814

Views

Django: What's the purpose of the LANGUAGE_CODE setting?

I've made a prototype site with working i18n text translations. But whatever I put in LANGUAGE_CODE setting in the settings.py, I see no effect on my pages. It seems to be always overridden by the locale finder middleware. The django's documentation does not give much explanations. What's the true p...
Bogey Jammer
3

votes
3

answer
1.6k

Views

Django 1.4 on GAE: sqlite “ImportError: cannot import name utils”

I'm trying to get sqlite3 support working on Django 1.4 on Google App Engine 1.7.4 on Python 2.7. I fiddled around with the 'Google Cloud SQL' database backend, all worked well (syncdb, insert/update/delete, ...). But then I enabled sqlite (as Google Cloud SQL is slow when on localhost): import os i...
hansaplast
2

votes
2

answer
352

Views

Static file management in Django1.4

I've been confused with static files in Django for days. I found one solution that worked fine. But it collapsed when I set DEBUG=False. So I build up a new project and do some tests to get a clearer look. First I create a project with the default settings. Then I changed some lines of the setting f...
Mike Lee
2

votes
1

answer
601

Views

Passing Parameters to An Overrode View in Django/Allauth

With Django 1.4 and Allauth, I'm trying to have 2 different signup pages. When I say different, I mean 2 different URLs and 'html layouts'. Here's what I did so far. It 'works', but it doesn't pass the 'is_alternate_template' variable to the HTML template: In urls.py: url(r'^accounts/', include('all...
mrmuggles
2

votes
1

answer
234

Views

Strange new directory structure in Django-1.4.1?

I've just installed the latest version of Django (1.4.1) on Ubuntu 12.04. The new docs and everything else I've been able to find seems to think the directory structure should be as follows: mysite/ manage.py mysite/ __init__.py settings.py urls.py wsgi.py However, running $ django-admin.py startpro...
BenjaminRH
2

votes
0

answer
798

Views

When upgrading django 1.4 to 1.6 users left unauthorized

On production host we have installed django 1.4 and wanted to upgrade it to latest release (1.6) After all needed changes are done we installed it and faced with the fact that all of our users were not authorized after restarting uwsgi processes. Even that definition did not help: SESSION_SERIALIZER...
Vitaly Volkov
3

votes
2

answer
2.7k

Views

Django 1.4 static files problems and don't render at other urls of my project

Here are my settings: STATIC_ROOT = '/home/tony/Documents/mysite/mysite/' STATIC_URL = '/static/' STATICFILES_DIRS = ( '/home/tony/Documents/mysite/mysite/static/', ) And here I refer my stylesheet(This gives me an error): And the error in the log: [06/Apr/2012 13:36:09] 'GET /css/reset.css HTTP...
Tony Kyriakidis
3

votes
2

answer
2.4k

Views

date_format Django 1.4 with correct timezone

Okay simple question (I think). I have a DateTime field (auto_add_now) and when output to a template {{ edited|date:'DATETIME_FORMAT' }} I get the expected result of 'Sept. 16, 2012, 12:01 p.m.' But unfortunately things are slightly more complicated since I am using Backbone.js and need to pass the...
byoungb

View additional questions