this is a model of the view table.
class QryDescChar(models.Model):
iid_id = models.IntegerField()
cid_id = models.IntegerField()
cs = models.CharField(max_length=10)
cid = models.IntegerField()
charname = models.CharField(max_length=50)
class Meta:
db_table = u'qry_desc_char'
this is the SQL i use to create the table
CRE...
I don't want someone visit my site to comment that only spaces, breaklines on the form. How do I use the command "if" in this case? Thanks for answers !
...
I have a model with no primary key. it has the id's from other models. I want to call iid_ id.
For example iid_id = 1.
There are 21 rows with the number 1. I want to grab all the rows and display them on a HTML table.
The Model:
class QryDescChar(models.Model):
iid_id = models.IntegerField()
cid_id = models.IntegerField()
...
I have a contact/address app that allows users to search the database for contact entries. The current view will return an object (Entry()) and display its fields. The code is as follows:
def search_page(request):
form = SearchForm()
entrylinks = []
show_results = True
if request.GET.has_key('query'):
show_resu...
Hi, in my Django application I've got a form with a ChoiceField that normally allows to choice between a range of integer values.
class FormNumber(forms.Form):
list=[]
for i in range(1, 11):
list.append((i,i))
number=forms.ChoiceField(choices=list, initial=1)
Now I need to override the default choices list from a view method in some ...
This is my form on models.py
class ItemForm(forms.Form):
itemname = forms.CharField(max_length=100)
itemwording = forms.CharField(max_length=100)
notes = forms.CharField()
abundance = forms.IntegerField(max_value=10)
collunit = forms.CharField(max_length=50)
litref = forms.CharField(max_length=100)
litkey = ...
I would like to know if I can display a view inside another view with django.
This is what I tried to do:
def displayRow(request, row_id):
row = Event.objects.get(pk=row_id)
return render_to_response('row.html', {'row': row})
def listEventsSummary(request):
listEventsSummary = Event.objects.all().order_by('-id')[:20]
r...
I can see the problem, I attached my code and error page.
In my template, I have:
{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
In my view, I have:
def downloads(request):
"""
Downloads page, a user facing page for the trade members to downloads POS etc
"""
if not authenticated_user(request):
return H...
Hi!
I have an app that's about presenting fictional simplified cities.
Please consider the following Django models:
class City(models.Model):
name = models.CharField(...)
...
TYPEGROUP_CHOICES = (
(1, 'basic'),
(2, 'extra'),
)
class BldgType(models.Model):
name = models.CharField(...)
group = models.IntegerFi...
Base Account
class BaseAccount(models.Model):
user = models.ForeignKey(User, unique=True)
def __unicode__(self):
"""
Return the unicode representation of this customer, which is the user's
full name, if set, otherwise, the user's username
"""
fn = self.user.get_full_name()
if fn:
return fn
return sel...
I'm using django-filter to drill down and would like to create breadcrumbs for each item that was filtered. For example:
Price ranges:
10,000+
5,000-9,999
1,000-4,999
0-999
Bedrooms:
4
3
2
1
Each of the items under Price ranges and Bedrooms would be a link to drill down in a queryset.
I'd like to create a breadcrumb such as Price ra...
Here is my URL pattern:
news_info_month_dict = {
'queryset': Entry.published.filter(is_published=True),
'date_field': 'pub_date',
'month_format': '%m',
}
and
(r'^(?P<category>[-\w]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+).html$',
'object_detail', news_info_month_dict, 'news_detail'),
But t...
I'm rolling a custom comment app that can take any object and allow the user to post comments (much like the one that comes with django.contrib).
My first thought, since none of the form is specific to any particular view, was to put it in a template tag:
@register.inclusion_tag('comments/add.html', takes_context=True)
def add_comment(...
I have a custom model manager that looks like this:
class MyManager(models.Manager)
def get_query_set(self):
'''Only get items that are 'approved' and have a `pub_date` that is in
the past. Ignore the rest.'''
queryset = super(MyManager, self).get_query_set()
queryset = queryset.filter(status__in=('a...
Suppose I have:
ds = datetime.datetime.now
dd = Entry.objects.get(pk=id).pub_date
How to compare 2 objects above? I want to get the time difference between them.
Please help me solve this problem. Thank you very much !
...
I have the following:
class AccountAdmin(models.Model):
account = models.ForeignKey(Account)
is_master = models.BooleanField()
name = models.CharField(max_length=255)
email = models.EmailField()
class Meta:
unique_together = (('Account', 'is_master'), ('Account', 'username'),)
If I then create a new Accou...
I'm building a Blog in Django (using Generic Views) and I use the same template for both my date based and list detail views. I'm trying to setup pagination, but I want to do so with URL patterns rather than using an ugly ?page=1 url suffix.
The problem is in the actual html template, I cannot find a way to determine which view was used...
I have a simple view function that's designed to allow the user to choose from items listed in an html table (records). Clicking on a record should divert the user to the template from which he can edit that specific record. The code is as follows:
def edit_record(request):
if request.method == 'POST':
a=ProjectR...
I have a basic search view. It currently queries the db for any objects from a particular client. The view code is as follows:
def search_page(request):
form = PrdSearchForm()
prdlinks = []
show_results = True
if request.GET.has_key('query'):
show_results = True
query ...
I have a urlpattern that brings a template that allows the fields of a model instance to be viewed:
(r'^display/(?P<id>\w+)/', display_record),
I also have a view function that allows a single instance to be edited. When the object is saved, it simply returns to the same template:
if form.is_valid():
form.save()
retur...