django-1.3

Function-based generic views have been deprecated

前提是你 提交于 2019-12-11 03:07:37
问题 DeprecationWarning: Function-based generic views have been deprecated; use class-based views instead. I keep getting this warning, when I'm running my site. What does this mean and how can I fix it? 回答1: Django 1.3 introduced class-based views and also added a range of generic class-based views. Django also has documentation about migrating function-based views to class-based views. There is not really much more to say about it: your project currently uses function-based views whereas class

How do I display most recent week items by default with WeekArchiveView?

家住魔仙堡 提交于 2019-12-11 02:38:48
问题 I'm astonished by how little documentation on class-based generic views there is. Anything slightly more complex than a trivial sample has to get done through guesswork, trial and error. I want to use WeekArchiveView to display a week's item list. There's my urls.py entry: url(r'^items/(?P<year>\d{4})/week/(?P<week>\d{1,2})/$', ItemWeekArchiveView.as_view()) When no year or week is specified, I get an error page. I want them to equal today's year and week by default. What is the right place

How to show an image in template uploaded from admin panel Django 1.3

折月煮酒 提交于 2019-12-08 12:33:26
问题 I'm a newbie to django. I'm developing a project in django 1.3. Problem is I'm uploading a image from the admin panel class About(models.Model): image = models.ImageField(upload_to='about') files = models.FileField(upload_to='about') Here is my template tag <img class="profile_pic" src="{{ about.image }}" /> My setting file is as below MEDIA_ROOT = path("media/") MEDIA_URL = '/media/' STATIC_ROOT = '' STATIC_URL = '/static/' ADMIN_MEDIA_PREFIX = '/static/admin/' STATICFILES_DIRS = ( path(

How do I paginate WeekArchiveView?

徘徊边缘 提交于 2019-12-07 14:24:39
问题 In continuation of my struggle with WeekArchiveView, how do I paginate it by week? All I want is: to know if there is next / previous week available; in case there is, provide a link in the template. I'd like it to also skip empty weeks. The source shows get_next_day / get_prev_day and get_next_month / get_prev_month are available, but nothing for weeks. 回答1: That is definitely interesting. Sure enough MonthMixin includes get_next_month / get_prev_month methods, and DayMixin includes get_next

Django 1.3 CreateView/ModelForm: unique_together validation with one field excluded from form

丶灬走出姿态 提交于 2019-12-06 07:45:09
问题 I am looking for a simple answer by example to this common problem. The answers I found so far leave out critical points for us beginners. I have an app where almost every model has a ForeignKey to User, and there is a unique_together constraint, where one of the fields is always 'user'. For example: class SubscriberList(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=70) date_created = models.DateTimeField(auto_now_add=True) class Meta: unique_together = ( (

How do I paginate WeekArchiveView?

被刻印的时光 ゝ 提交于 2019-12-05 18:38:57
In continuation of my struggle with WeekArchiveView , how do I paginate it by week? All I want is: to know if there is next / previous week available; in case there is, provide a link in the template. I'd like it to also skip empty weeks. The source shows get_next_day / get_prev_day and get_next_month / get_prev_month are available, but nothing for weeks. That is definitely interesting. Sure enough MonthMixin includes get_next_month / get_prev_month methods, and DayMixin includes get_next_day / get_prev_day methods. However, both YearMixin and WeekMixin have no functional equivalent in their

Whats is the best way to migrate folder and files structure from django1.3 to django1.4?

筅森魡賤 提交于 2019-12-05 17:03:37
问题 I have a little project created with django1.3 and I want to migrate it to django1.4 but since the files structure change a little, what is the best way to migrate? 回答1: Read https://docs.djangoproject.com/en/dev/releases/1.4/ first. For a quick run, just update env from Django1.3 to 1.4, tweak settings file and project code by fixing any incompatibility warning and imports issue. For a clean update, better to create an empty project w/ the same name of the current project and migrate it w/

How to specify something other than pk or slug for DetailView

≯℡__Kan透↙ 提交于 2019-12-05 03:13:16
I was wondering if it was possible to use something besides a pk or slug when you are using a DetailView in Django 1.3. For example, I currently have: url(r'^mymodel/(?P<pk>\d+)/$', MyDetailView.as_view()) as my url. Say I wanted something like: url(r'^mymodel/(?P<name>\d+)/$', MyDetailView.as_view()) where name would be a field in the model. Is there anyway to have the DetailView use that to 'grab' the object I want and pass it on to my template? A slug doesn't have any particular significance in Django. It's just a name for a field that identifies a row. If your slug is called something else

Django 1.3 CreateView/ModelForm: unique_together validation with one field excluded from form

孤者浪人 提交于 2019-12-04 14:05:55
I am looking for a simple answer by example to this common problem. The answers I found so far leave out critical points for us beginners. I have an app where almost every model has a ForeignKey to User, and there is a unique_together constraint, where one of the fields is always 'user'. For example: class SubscriberList(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=70) date_created = models.DateTimeField(auto_now_add=True) class Meta: unique_together = ( ('user', 'name',), ) def __unicode__(self): return self.name A SubscriberList is always created by a

how to get POST data in django 1.3

为君一笑 提交于 2019-12-03 03:49:15
Hey, I am following this tutorial to learn to make a wiki page with Django. However, it is made in django 0.96 and I use Django 1.3 so there are some things that are different. Some I already fixed myself, however this one I can't seem to make it work. I made a form that submits data to a view. This is the form: <form method="post" action"/wikicamp/{{page_name}}/save/">{% csrf_token %} <textarea name="content" rows="20" cols="60">{{content}}</textarea><br> <input type="submit" value="Save Page"/> </form> and the /wikicamp/{{page_name}}/save/ url redirects to the save_page view: from django