I would like create authentication in Django. I'm trying to do everything according to this. Unfortunately, at this moment I have two problems. Firstly, when I try to add from rest_framework.authtoken import views I have conflict with from companies
I have an Instructor model, which has a many to many field to a Client model. (Instructor.clients) The model: class InstructorProfile(models.Model): '''Instructor specific profile attributes ''' # Fields office_number = models.CharField(max_length=30
How do you check if a Django object is None in js? I currently have a variable person that stores a Django object or None. In my js I have: if ({{person}} != None) { execute_function({{person}}) } What seems to be the issue here?John Smiths answer ma
I'm using Django-Angular and trying to post a form and obtain data in back-end..I'm able to achieve this but found that the page is reloading while saving the form. How can we achieve the same without page render? forms.py def home(request): if 'appl
I need a help with time-limit. I want to show user how many time he has got to rent a car. This is my views: class CarRentView(RedirectView): permanent = False query_string = True model = Car def date_of_return(request): car = Car.objects.all() car.r
I have a small problem with figuring out how {% url 'something' %} works in django templates. When I run my website in debug mode, I see this in stdout: web_1 | [21/Dec/2015 11:29:45] "GET /accounts/profile HTTP/1.1" 302 0 web_1 | /usr/local/lib
Is there a way in django to declare a custom template tag "on the fly"? For example, if I have a page that renders an a tree structure and for my tag to work, it needs the root and the leaf. Since I now that I will use this tag only with this ro
I was trying to run django app on docker container. Followed steps mentioned at https://docs.docker.com/compose/django/ But after running the command docker-compose run web django-admin.py startproject composeexample . I facing error PermissionError:
I have those models: class TimeZone(models.Model): name = models.CharField(max_length = 40, unique = True, editable = False) def tz(self): return pytz.timezone(str(self.name)) class Place(models.Model): name = models.CharField(max_length=200) timezon
I have a model object with a two methods: expired and pending. The expired manager works fine and updates the field. The pending manager does not work. Here is my code. Side note: I set pending to true in a view. models.py: class Job(models.Model): e
I've been working with Django locally and now I'm trying to push some code to a production Apache environment on an Ubuntu server I have running (http://www.youtube.com/watch?v=hBMVVruB9Vs). However, I just get a list of files in the directory and no
In a model I usually put a "uuid" field for friendly URI, also a "slug" field. Say I have a model named "SomeModel", by overriding its save() method, I can generate a uuid and a slug when it's being saved: class SomeModel(mod
I'm stuck on a Django ORM issue that is bugging me. I have a set of models linked by a foreign key but the requirements are a bit odd. I need to list items by their relation's relation. This is hard to explain so I've tried to depict this below, give
I just deployed my first django app to the Heroku platform. I basically followed this tutorial, just that instead of creating a dummy django-admin.py startproject hellodjango . django app, I used my app that currently works on my Windows PC. When dep
I have an ajax login view. I can log in ok but when I log in incorrectly my json returns: {"errors": {}} My view is as follows: def ajaxlogin(request): from forms import LoginForm form = LoginForm(request.POST) logged_in = False username = reque
When I get a request for a path that includes the word 'self' I want to replace it with the user id before matching it to a URL. I tried using a middleware like this: def process_request(self, request): if '/self/' in request.path: request.path = req
I have the following model structure Country, City(fk=country) and School(fk=city). Now I want to get list of countries with city, if city has a school. In my template, I want to do for country in countrylist for city in getcitieswithschool Can I get
I have a set of document objects and label objects, and I want those two objects to be linked. It's a typical many-to-many relationship. I have the following code: Models.py: class Document(models.Model): title = models.CharField(max_length=50, uniqu
Trying to save a bunch of objects but with a custom form: class CustomForm(forms.ModelForm): class Meta: model = Widget complexify = models.BooleanField() When complexify is checked, i need to do some complex operations on the widget object. I can't
I try to implement pagination structure in Django with some sort options however, I can't figure out how can I do that properly. views.py def search(request): eList = Employer.objects.filter(eminence__lt=4).order_by('-eminence') paginator = Paginator
I am using this def ajax_create( request ): if request.is_ajax(): form = SourceForm() template = 'ajax_form.html' data = { 'form': form, } return render_to_response( template, data, context_instance = RequestContext( request ) ) I get this error ajax
I need to obtain a queryset of a foreignkey but I haven't been able to figured out how. I have the following model: class Contact(models.Model): owner = models.ForeignKey(CustomUser, related_name='contact_set') referenced = models.ForeignKey(CustomUs
I'm trying to upload an image file in django admin inlines and getting UnicodeEncodeError when trying to upload a file with a filename containing non-ascii characters: File "/usr/local/lib/python2.6/site-packages/django/db/models/fields/files.py"
I have a Django project, let's say "project1". Typical folder structure for applications is: /project1/ /app1/ /app2/ ... __init__.py manage.py settings.py urls.py What should I do if I want to hold all of my applications in some separate folder
I'm developing an app (an API) in python and I would like to offer some of its functionality through a web interface (like web services do). I've been looking at django, but I don't know if really fits well in my idea. I only want to create a web pag
i have an application, and in my urls.py i have something like that: urlpatterns = patterns('', url(r'^profile_view/(?P<id>\d+)/$', profile_view, name='profile_view'),) meaning that the profile_view function has id as a parameter. Now, i want to cal
I'm looking into the various methods of rate limiting the Django admin login to prevent dictionary attacks. One solution is explained here: http://simonwillison.net/2009/Jan/7/ratelimitcache/ However, I would prefer to do the rate limiting at the web
For example, I have a model Posts and Comments. Post.objects.annotate(Count('comment')) I am making such query to get count of comments for every post. But in template i should check if this value greater than 4. As I know there is no such templateta
I've done a bit of reading related to the concurrency issues with sqlite, but I don't see how they'd apply to Django since it's inherently single threaded. I'm not using any multiprocess modules either. I have absolutely no experience with concurrent
I'm writing a url rewrite in django that when a person goes to http://mysite.com/urlchecker/http://www.google.com it sends the url: http://ww.google.com to a view as a string variable. I tried doing: (r'^urlchecker/(?P<url>\w+)/$', 'mysite.main.view