Skip to content

Tag: django

Django REST Framework and FileField absolute url

I’ve defined a simple Django app that includes the following model: (Technically yes, that could have been an ImageField.) In a template, it’s easy enough to include the MEDIA_URL value (duly coded in settings.py) as a prefix to the thumbnail URL. The following works fine: Using DRF, I’ve de…

Django – login required for POST but not GET?

So I’m trying to do a site with user editable tags on items. I want users to be able to edit tags on the page only if they are logged in, but everyone should be able to view the page. The edits are done through a modelform. I can’t use the login_required decorator on the whole view because then on…

Best way of linking to a page in Django

I managed to create a URL tag for my index. But right now I’m confused how to add links to other pages. I put this on my urls.py The next thing I put this tag into the href: But what if I wanted to create a new page and would be linking to it. How would I do it the

AttributeError ‘tuple’ object has no attribute ‘get’

I have a Django application. But i can’t an error that i have been struggling with for some time now. And this is the traceback django provides me. I have a hard time figuring out why this error occurs. How can i find out where that tuple is in my code? The view: Answer You are returning a tuple here:

Access-Control-Allow-Origin in Django app

I’m developing a Phonegap app for my Django based app, but when trying to make Ajax calls I get this error: How can I make it so my Django app allows cross origin for some urls? Here’s my Ajax code: Answer Django by default does not provide the headers necessary to provide cross origin. The easies…

Django got an unexpected keyword argument

I’m trying to create an archive so I pass to the view the arguments year and month. However, I get an error with the code below and I can’t figure out what it means and how to solve it: What can be wrong? views.py urls.py Update: models.py Template Update 2: error Answer There is something wrong w…