I want to show the human-readable name for the type selected but I
keep getting the stored value.
TYPE_CHOICES = (
('0', 'Basic'),
('1', 'Full'),
('2', 'Intermediate'),
)
class ServiceType(models.Model):
type = models.IntegerField(max_length=1, choices=TYPE_CHOICES)
amount = models.DecimalField(max_digits=10, ...
How can I create more than one ModelAdmin for the same model, each customised differently and linked to different URLs?
Let's say I have a Django model called Posts. By default, the admin view of this model will list all Post objects.
I know I can customise the list of objects displayed on the page in various ways by setting variables ...
I have a Customer class linked to several other classes via foreign key. I want to have the forms working in such a way that if the submitted customer record already exists, then this record will be used as the foreign key for the dependent class.
I've declared the Customer class as:
class Customer(CustomerBaseInfo):
date_time_ad...
Hello,
I have a base template file which is base.html and every other template extends to it and generates content using its blocks.
Now, at my base.html file I want to include a variable that will be using some variable such as querylist.
In example:
assume I hav some NavigationObject model and at the base.html
I want to loop throug...
Django has the sites framework to support multiple web site hosting from a single Django installation.
EDIT (below is an incorrect assumption of the system)
I understand that middleware sets the settings.SITE_ID value based on a lookup/cache of the request domain.
ENDEDIT
But when testing locally, I'm at http://127.0.0.1:8000/,...
I have a Django application in which I want to change a field from a ForeignKey to a ManyToManyField. I want to preserve my old data. What is the simplest/best process to follow for this? If it matters, I use sqlite3 as my database back-end.
If my summary of the problem isn't clear, here is an example. Say I have two models:
class...
Here's an interesting problem, I have a list of users that I list in order of rating, and where two users have the same rating, I have a random number that I use to make sure the list won't always be the same.
Currently I do this by executing a query:
select app_model1.column1, app_model1.colum2, app_model2.column3
from app_mode...
I have 3 models in a Django app, each one has a "hostname" field. For several reasons, these are tracked in different models.:
class device(models.Model):
...
hostname = models.CharField(max_length=45, unique=True, help_text="The hostname for this device")
...
class netdevice(models.Model):
...
hostname = models.CharField(max_length=4...
Is there anyway to load one fixture and have it load multiple fixtures?
I'd ideally like to type:
python manage.py loaddata all_fixtures
And have that load all of the data instead of having to type everything. Is this possible?
...
It would be nice to be able to refer to a set "static" folder as a variable instead of having to keep track of a specific URL that might need to be changed if static media gets moved to a CDN later on.
For example, this:
<script src="{static_media}/js/jquery-1.4.min.js"></script>
Instead of this:
<script src="/static/js/jquery-1.4.m...
How do you implement MailMerge in django instead of using EmailMessage?
...
I'm writing a custom widget that requires some supporting javascript code that I need output somehwere.
The options are:
Dump it right after the html code.
Append it to the form's media.
Append it to a global onReady section.
My gut instinct is to avoid things like:
<!-- original widget output -->
<input id="date" />
<-- Appended j...
Hello,
assume I have this little model:
class Deal(models.Model):
purchases = models.IntegerField(default=0)#amount of purchases so far
increase_purchases(self,to_add):
self.update( purchases =self.purchases + to_add)
when I try to use this increase_purchases model from shell:
>>> x = Deal.objects.get(id=1)
>>> x.inc...
I've got mechanize setup and working with python. I am adding support for using a proxy, but how do I check that I am actually using the proxy?
Here is some code I am using:
ip = 'some proxy ip address'
br.set_proxies({"http://": ip} )
I started to wonder if it was working because just to do some testing I typed in:
ip = 'asdfasd...
Hello,
I would like to make a custom admin page for one of my application with django. I've created a change_form.html and fieldset.html in admin/myapp/mymodel of my template folder. I am now able to customize the page.
mymodel has an ImageField and I would like to display this image on the page. I guess this is possible because the Im...
thanks
only need 'python manage.py startapp xx' ???
...
I am a java devloper.Is there some django/ruby on rails kind of framework for java?
I dont like to create the admin panel for each project i do.Its boring to same thing again and again.
Also for my new project i have a short deadline and i would like to use some kind of java framework that speeds devlopment.
...
I have a TabularInline admin layout, all works fine except I'd like to have it show something other than the Obj.__unicode__ value on the top left of each row.
My TabularInline is a photologue ImageModel model, so I'd like it to show me the thumbnail instead of the regular __unicode__ result.
I tried to change __unicode__ to output the...
I have a parent template that contains a generic navigation menu. I want to be able to add class="selected" to the appropriate menu option.
I want to be able to set a variable in a child template, for example:
{% set menu = "products" %}
and do:
{%ifequal menu "products" %}class="selected"{% endifequal %}
I don't want to set a val...
Hi,
I'm trying to create site using Django framework. I looked on tutorial on Django project site but contains much information which I don't need. I have python scripts which provides output and I need to have this output on the web. My question is how simply manage Django to have link which start the script and provides its output on ...