Re: JSON or YAML?
Thanks for your input everybody! On Sat, Aug 31, 2013 at 10:16 AM, Agnese Camellini < agnese.camell...@gmail.com> wrote: > I'm using JSON becuase of it's compatibility with javascript and python > both. I never used YAML but i think the compatibility's problem are bigger > with YAML than json. > > My 2 cents. > Agnese > > > 2013/8/31 Andre Terra > >> It depends on where your data is coming from. YAML has less cruft in it, >> so if you're writing your own serializer you can consider it to have an >> advantage over JSON. >> >> OTOH, many applications can already export to JSON, so you can leverage >> that if that's the case. >> >> Finally, If you're writing anything by hand, YAML is much faster. >> >> >> Cheers, >> AT >> >> >> On Fri, Aug 30, 2013 at 4:55 PM, Rich Haase wrote: >> >>> Personal preference. Python has excellent libraries to support parsing >>> both JSON and YAML. >>> >>> Sent from my iPhone >>> >>> On Aug 30, 2013, at 7:34 AM, Floor Tile wrote: >>> >>> Helle everybody, >>> >>> Just a short and simple question: >>> >>> It seams that both JSON and YAML can be used for initial data loading. >>> (among other data types but I don't care about them for the moment) >>> But can't figure out what the up and/or downsides of them are. >>> Is it purely a matter of personal preference or there one better to use >>> than the other for initial data loading. And which one would be the most >>> preferred, if this is the case? >>> >>> Many thanks in advance! >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users+unsubscr...@googlegroups.com. >>> To post to this group, send email to django-users@googlegroups.com. >>> Visit this group at http://groups.google.com/group/django-users. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users+unsubscr...@googlegroups.com. >>> To post to this group, send email to django-users@googlegroups.com. >>> Visit this group at http://groups.google.com/group/django-users. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/django-users. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: JSON or YAML?
In that case I'll go for JSON too as I'm already familiar with it. Thanks for the quick reply. On Fri, Aug 30, 2013 at 2:37 PM, Some Developer wrote: > On 30/08/2013 14:34, Floor Tile wrote: > >> Helle everybody, >> >> Just a short and simple question: >> >> It seams that both JSON and YAML can be used for initial data loading. >> (among other data types but I don't care about them for the moment) >> But can't figure out what the up and/or downsides of them are. >> Is it purely a matter of personal preference or there one better to use >> than the other for initial data loading. And which one would be the most >> preferred, if this is the case? >> >> Many thanks in advance! >> > > Personal preference. I use JSON simply because it seems to be more widely > used in general. But choose whichever you want. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to > django-users+unsubscribe@**googlegroups.com > . > To post to this group, send email to django-users@googlegroups.com. > Visit this group at > http://groups.google.com/**group/django-users<http://groups.google.com/group/django-users> > . > For more options, visit > https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
JSON or YAML?
Helle everybody, Just a short and simple question: It seams that both JSON and YAML can be used for initial data loading. (among other data types but I don't care about them for the moment) But can't figure out what the up and/or downsides of them are. Is it purely a matter of personal preference or there one better to use than the other for initial data loading. And which one would be the most preferred, if this is the case? Many thanks in advance! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
How to get the right url of models in generic views?
#urls.py from .models import Entry from django.conf.urls import patterns, url from django.views.generic.dates import (ArchiveIndexView, YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView, ) urlpatterns = patterns('', url(r'^(?P\d{4})/(?P\w{3})/(?P\d{2})/(?P[-\w]+)/$', DateDetailView.as_view(model=Entry, date_field='pub_date' ), ), url(r'^(?P\d{4})/(?P\w{3})/(?P\d{2})/$', DayArchiveView.as_view(model=Entry, date_field='pub_date', template_name='blog/entry_archive.html', ), ), url(r'^(?P\d{4})/(?P\w{3})/$', MonthArchiveView.as_view(model=Entry, queryset=Entry.objects.order_by('-pub_date'), context_object_name='latest', date_field='pub_date', template_name='blog/entry_archive.html', ), ), url(r'^(?P\d{4})/$', YearArchiveView.as_view(model=Entry, queryset=Entry.objects.order_by('-pub_date'), context_object_name='latest', date_field='pub_date', template_name='blog/entry_archive.html', make_object_list=True, ), ), url(r'^$', ArchiveIndexView.as_view(model=Entry, date_field='pub_date', ), ), ) I'm having a problem getting the right urls of model instances in generic class based views in Django 1.5. I have the following code: #models.py import datetime from django.contrib.auth.models import User from django.db import models from taggit.managers import TaggableManager from markdown import markdown class Category(models.Model): title = models.CharField(max_length=250, help_text="Maximum 250 characters.") slug = models.SlugField(unique=True, help_text="Sugested value will be generated from title. Must be unique") description = models.TextField() class Meta: ordering = ['-title'] verbose_name_plural = 'Categories' def __unicode__(self): return self.title def get_absolute_url(self): return 'categories/%s/' % self.slug class Entry(models.Model): LIVE_STATUS = 1 DRAFT_STATUS = 2 HIDDEN_STATUS = 3 STATUS_CHOICES = ( (LIVE_STATUS, 'Live'), (DRAFT_STATUS, 'Draft'), (HIDDEN_STATUS, 'Hidden'), ) status = models.IntegerField(choices=STATUS_CHOICES, default=LIVE_STATUS) title = models.CharField(max_length=250) slug = models.SlugField(unique_for_date='pub_date') excerpt = models.TextField(blank=True) excerpt_html = models.TextField(editable=False, blank=True) body = models.TextField() body_html = models.TextField(editable=False, blank=True) pub_date = models.DateTimeField(default=datetime.datetime.now()) author = models.ForeignKey(User) enable_comments = models.BooleanField(default=True) categories = models.ManyToManyField(Category) tags = TaggableManager() class Meta: verbose_name_plural = 'Entries' ordering = ['-pub_date'] def __unicode__(self): return self.title def save(self, force_insert=False, force_update=False): self.body_html = markdown(self.body) if self.excerpt: self.excerpt_html = markdown(self.excerpt) super(Entry, self).save(force_insert, force_update) @models.permalink def get_absolute_url(self): return ('entry', (),{ 'year': self.pub_date.strftime('%Y'), 'month': self.pub_date.strftime('%b'), 'day': self.pub_date.strftime('%d'), 'slug': self.slug, } ) When I manually type an url in the browser the archives or entries are shown. So when giving in "localhost://news/2013/jul/24/entry-name" the entry is shown. And when giving in "localhost://news/2013/" a list is presented. So the urls are valid but in the list-views (archives) the links that are printed on the screen are not linked to the the right url. They are linked to the url of the present page. Can someone help me ? Many thanks in advance! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: new field in models
Hello Harjot I think you should look at South: south.aeracode.org/ For the docs you can go to: south.readthedocs.org/ Hope it helps On Mon, Jul 22, 2013 at 9:53 AM, Harjot Mann wrote: > In django when we add a new field in existing class, we need to drop > the table and then run the syncdb again. Is there any alternative for > it so that we can add the field without dropping the table?? > > -- > Harjot Kaur Mann > Blog: http://harjotmann.wordpress.com/ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
How to use context_processors (part X)?
*Sorry for multiple posts for the same subject!! I had some difficulties getting it right due to some stupidity on my side!* Hello everyone, I'm puzzling for some time now to get a solution for my following problem. I hope someone can help me. I need some context to be filtered before it's rendered in a template. To do this I got the following piece of code saved in catalog_context_processors.py : from catalog.models import Category def filter_active_category(**request): return { 'active_categories': Category.objects.filter(is_**active=True), 'request': request } To make use of this context processor I need to get the file into TEMPLATE_CONTEXT_PROCESSORS. (right?) When I search the internet almost every hit I get, tells me I have to over-write TEMPLATE_CONTEXT_PROCESSORS in my settings file by copying this variable-declaration from the global settings to my settings and add my file ( catalog_context_processors ). I have a feeling that it is a much better (cleaner) solution if I add the following to my settings.py: TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_**CONTEXT_PROCESSORS + ( 'context_processors', ) I have the following questions which I hope somebody can answer: 1. Am I right too use this construction at all? Or is there a better solution to get this done in Django? 2. Are there best practices for this construction? With this I mean; if this is the way too go...Where should the "context_processors.py" live? (Which directory?) OhI'm using Django 1.5.1. Many thanks in advance for any pointers in the right direction!! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Custom context_processors
Hello everyone, I'm puzzling for some time now to get a solution for my following problem. I hope someone can help me. I need some context to be filtered before it's rendered in a template. To do this I got the following piece of code saved in catalog_context_processors.py : from catalog.models import Category def filter_active_category(request): return { 'active_categories': Category.objects.filter(is_active=True), 'request': request } To make use of this context processor I need to get the file into TEMPLATE_CONTEXT_PROCESSORS. (right?) When I search the internet almost every hit I get, tells me I have to re-define TEMPLATE_CONTEXT_PROCESSORS in my settings file, copy the contents of this variable from the global settings to my settings and add my file ( catalog_context_processors ). I have a feeling that it is a much better (cleaner) solution if I add the following to my settings.py: TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( 'context_processors', ) I have the following questions which I hope somebody can answer: 1. Am I right too use this construction at all? Or is there a better solution to get this done in Django? 2. Are there best practices for this construction? With this I mean; if this is the way too go...Where should the "context_processors.py" live? (Which directory?) OhI'm using Django 1.5.1. Many thanks in advance for any pointers in the right direction!! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.