Guest User

Untitled

a guest
Jul 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #urls.py
  2.  
  3. urlpatterns = patterns('',
  4. # Example:
  5. # (r'^camperone/', include('camperone.foo.urls')),
  6.  
  7. # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
  8. # to INSTALLED_APPS to enable admin documentation:
  9. (r'^admin/doc/', include('django.contrib.admindocs.urls')),
  10.  
  11. # Uncomment the next line to enable the admin:
  12. (r'^admin/', include(admin.site.urls)),
  13. (r'^', include('cms.urls')),
  14. (r'^grappelli/', include('grappelli.urls')),
  15. (r'^usato/(\d+)/', "camper.views.usato"),
  16. # (r'^admin/form_designer/', include('form_designer.admin_urls')),
  17. # (r'^forms/', include('form_designer.urls')),
  18. )
  19.  
  20. #models.py
  21.  
  22. class Usato(models.Model):
  23. modello = models.ForeignKey(Modelli)
  24. km_percorsi = models.IntegerField()
  25. accessori = models.ManyToManyField(Accessori)
  26. anno_immatricolaz = models.IntegerField()
  27. note = models.TextField(max_length=500)
  28. prezzo = models.FloatField()
  29. def __unicode__(self):
  30. return u"%s" % (self.modello)
  31. def get_menu_title(self):
  32. return self.name
  33.  
  34. def get_absolute_url(self):
  35. return reverse('usato', args=[self.pk])
  36.  
  37. class Meta:
  38. verbose_name = "Camper Usato"
  39. verbose_name_plural = "Camper Usati"
  40.  
  41. #utils.py
  42. from camper.models import Usato
  43.  
  44. def get_usati(request):
  45. usati = list(Usato.objects.all())
  46. res = []
  47.  
  48. for usato in usati:
  49. res.append(usato)
  50. return res
  51.  
  52. #settings.py
  53.  
  54. CMS_NAVIGATION_EXTENDERS = (
  55. # ('cmsplugin_news.navigation.get_nodes','News navigation'),
  56. ('camper.utils.get_usati','Camper usati'),
  57. )
Add Comment
Please, Sign In to add comment