Search Results

Search found 15813 results on 633 pages for 'django settings'.

Page 65/633 | < Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >

  • Your Django Development process/steps (Step by Step)

    - by AJ
    I want to know step by step process of how folks develop on Django here. I have seen that whenever I try to create a website in Django, I always get confused amongst: DB Schema/models.py UI/Template Structure Login module urls.py views.py How do you approach this? I may have missed something. You do not need to elaborate everything, just stepwise what you do. If you do two things at the same time (or side-by-side), that would also be helpful to mention. Thanks a lot.

    Read the article

  • Django: switch language of message sent from admin panel

    - by yoshi
    I have a model, Order, that has an action in the admin panel that lets an admin send information about the order to certain persons listed that order. Each person has language set and that is the language the message is supposed to be sent in. A short version of what I'm using: from django.utils.translation import ugettext as _ from django.core.mail import EmailMessage lang = method_that_gets_customer_language() body = _("Dear mister X, here is the information you requested\n") body += some_order_information subject = _("Order information") email = EmailMessage(subject, body, '[email protected]', ['[email protected]']) email.send() The customer information about the language he uses is available in lang. The default language is en-us, the translations are in french (fr) and german (de). Is there a way to use the translation for the language specified in lang for body and subject then switch back to en-us? For example: lang is 'de'. The subject and body should get the strings specified in the 'de' translation files.

    Read the article

  • Filter across three tables using Django

    - by Vanessa MacDougal
    I have 3 django models, where the first has a foreign key to the second, and the second has a foreign key to the third. Like this: class Book(models.Model): year_published = models.IntField() author = models.ForeignKey(Author) class Author(models.Model): author_id = models.AutoField(primary_key=True) name = models.CharField(max_length=50) agent = models.ForeignKey(LitAgent) class LitAgent(models.Model): agent_id = models.AutoField(primary_key=True) name = models.CharField(max_length=50) I want to ask for all the literary agents whose authors had books published in 2006, for example. How can I do this in Django? I have looked at the documentation about filters and QuerySets, and don't see an obvious way. Thanks.

    Read the article

  • Creating a custom widget using django for use on external sites

    - by ajt
    I have a new site that I am putting together and part of it has statistics for the site's users. I would like to create a widget that others can use on another website by invoking javascript that reads data from my server and shows that statistics for a given user, but I am having a hard time finding specific tutorials that covers this in django. I have seen the link at Alex Maradon's site [0], but it looks to me like that is passing html back to the widget and I am having a hard time figuring out how to do this using something like xml. Are there any django apps for doing this or does anyone know of good how-tos? [0] http://alexmarandon.com/articles/web_widget_jquery/

    Read the article

  • Custom Django tag & jQuery

    - by pocoa
    I'm new to Django. Today I created some Django custom tags which is not that hard. But now I wonder what is the best way to include some jQuery or some Javascript code packed into my custom tag definition. What is the regular way to include a custom library into my code? For example: {% faceboxify item %} So assume that it'll create a specific HTML output for Facebox plugin. I just want to learn some elegant way to import this plugin into my code. I want the above definition to be enough for all functionality. Is there any way to do it? I couldn't find any example. Maybe I'm missing something.. Thank you.

    Read the article

  • Single database with multiple instances of Django

    - by jwesonga
    I have a Django project where the company will have a main site like www.ourcompany.org and a bunch of sub-domains like project.ourcompany.org. Content appearing in the sub-domains like case studies should also appear in the main site. I've decided to use multiple instances of Django BUT one database for each sub-domain so that I can have some flexibility and take advantage of the Sites framework. What I'm not sure of is how to access the models across the multiple instances. If I have a model: class CaseStudy(models.Model): title=models.CharField(max_length=100) site=models.ManyToMany(Site) Do I need to create this model in every instance so that I can have access to the object?

    Read the article

  • Model Django Poll

    - by MacPython
    I followed the django tutorial here: http://docs.djangoproject.com/en/dev/intro/tutorial01/ and now I am at creating a poll. The code below works fine until I want to create choices, where for some reason I always get this error message: line 22, in unicode return self.question AttributeError: 'Choice' object has no attribute 'question' Unfortunatley, I dont understand where I made an error. Any help would be greatly appreciated. Thanks for the time! CODE: import datetime from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question def was_published_today(self): return self.pub_date.date() == datetime.date.today() class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def __unicode__(self): return self.question

    Read the article

  • Django equivalent to paster for backend processes

    - by intractelicious
    I use pylons in my job, but I'm new to django. I'm making an rss filtering application, and so I'd like to have two backend processes that run on a schedule: one to crawl rss feeds for each user, and another to determine relevance of individual posts relative to users' past preferences. In pylons, I'd just write paster commands to update the db with that data. Is there an equivalent in django? EG is there a way to run the equivalent of python manage.py shell in a non-interactive mode?

    Read the article

  • Django Inherited Field Access

    - by Rick
    As of the most current version, Django does not allow a subclass to have a variable with the same name as a variable in its superclass, if that variable is a Field instance. I need a subclass to modify this variable, which I call 'department'. Calling my classes super and sub, I need sub to modify the department variable it inherits from super. If I redeclare it, Django throws a field error. Of course, if I don't, department is not in scope for reassignment. If super has no department I get database errors. I get weird behaviour when I try rewriting init: def __init__(self): super(theSuperClass, self).__init__() TypeError: super(type, obj): obj must be an instance or subtype of type Anyone have any idea how to do this?

    Read the article

  • A simple group-by (no count) in Django

    - by Daniel Quinn
    If this were raw-SQL, it'd be a no-brainer, but in Django, this is proving to be quite difficult to find. What I want is this really: SELECT user_id FROM django_comments WHERE content_type_id = ? AND object_pk = ? GROUP BY user_id It's those last two lines that're the problem. I'd like to do this the "Django-way" but the only thing I've found is mention of aggregates and annotations, which I don't think solve this issue... do they? If someone could explain this to me, I'd really appreciate it.

    Read the article

  • Halting Django's dev server via page request?

    - by Ben Blank
    I'm looking at writing a portable, light-weight Python app. As the "GUI toolkit" I'm most familiar with — by a wide margin! — is HTML/CSS/JS, I thought to use Django as a framework for the project, using its built-in "development server" (manage.py runserver). I've been banging on a proof-of-concept for a couple hours and the only real problem I've encountered so far is shutting down the server once the user has finished using the app. Ideally, I'd like there to be a link on the app's pages which shuts down the server and closes the page, but nothing I see in the Django docs suggests this is possible. Can this be done? For that matter, is this a reasonable approach for writing a small, portable GUI tool?

    Read the article

  • What is a django QuerySet?

    - by gath
    Guys, When i do this >>> b = Blog.objects.all() >>> b i get this >>>[<Blog: Blog Title>,<Blog: Blog Tile>] When i query what type b is, >>> type(b) i get this >>> <class 'django.db.models.query.QuerySet'> What does this mean? is it a data type like dict, list etc? An example of how i can build data structure like a QuerySet will be appreciated. I would want to know how django build that QuerySet (the gory details) Gath.

    Read the article

  • How to localize static content in database with Django

    - by man with python
    My app has tables for languages and countries (actually django-countries at the moment, but open for suggestions). The tables are populated when I initialize the database and remain static after that. What would be the ideal localization mechanism for the contents of these tables, so that I can show the country and language names to users in their chosen site language? I'm aware of projects like django-multilingual and transdb, but IMO they are more suitable for dynamic content, i.e. stuff that's supposed to be modified. Please englighten me!

    Read the article

  • django - order query set by postgres function

    - by thebiglife
    My initial question was here and was related to the postgres backend. http://stackoverflow.com/questions/2408965/postgres-subquery-ordering-by-subquery Now my problem has moved onwards to the Django ORM layer. I essentially want to order a query by a postgres function ('idx', taken from the above stackoverflow work) I've gone through trying to use model.objects.extra(order_by ) or simply order_by but I believe both of these need the order_by parameter to be an attribute or a field known to Django. I'm trying to think how to solve this without having to revert to using an entirely raw SQL query through a model manager.

    Read the article

  • User authentication in Django. Problems with is_authenticated

    - by tim
    I have one problem with users menu. So, I want, that authenticated user can see his/her profile page and logout (links) in menu. It works (when I logging in) on index page: index, page1, profile, logout ,but, if I go to the, for example, page1 I can see in menu: index, page1, login, not profile and logout. How to fix it? in urls: url(r'^accounts/login/$', 'django.contrib.auth.views.login' ), url(r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login' ), url(r'^accounts/profile/$', 'my_app.views.profile' ), in views: def profile(request): if not request.user.is_authenticated(): return HttpResponseRedirect("/accounts/login/") else: user = request.user.is_authenticated() return render_to_response('profile.html',locals()) Part of index.html: {% if user.is_authenticated or request.user.is_authenticated %} <li><a href="/accounts/profile/">Profile</a></li> <li><a href="/accounts/logout/">logout</a></li> {% else %} <li><a href="/accounts/login/">login</a></li> {% endif %} login.html: {% extends "index.html" %} {% load url from future %} {% block application %} {% if form.errors %} <p>Try one more time</p> {% endif %} <form method="post" action="{% url 'django.contrib.auth.views.login' %}"> {% csrf_token %} <table> <tr> <td>{{ form.username.label_tag }}</td> <td>{{ form.username }}</td> </tr> <tr> <td>{{ form.password.label_tag }}</td> <td>{{ form.password }}</td> </tr> </table> <input type="submit" value="Login" /> <input type="hidden" name="next" value="{{ next }}" /> </form> {% endblock %} profile.html: {% extends "index.html" %} {% block application %} {% if request.user.is_authenticated %} <p>Welcome, {{ request.user.username }}. Thanks for logging in.</p> {% else %} <p>Welcome, new user. Please log in.</p> {% endif %} {% endblock %}

    Read the article

  • Django, javascript and code ruse problem

    - by dragoon
    Hi, I have some sort of a design problem with my Django AJAX application. I have a template where I initialize js variable from django context variable like so: var test = "{{ test }}"; This variable is than used in a number of js functions that are needed for interface to work properly. So now I'm trying to reuse some content from this page in another page that loads it dynamically on some user interaction using jQuery.load(..), and I don't see any way how I can initialize that variable, so js functions don't work now. Is there any solution for this or may be I'm doing it wrong? Thanks.

    Read the article

  • default model field attribute in Django

    - by Rosarch
    I have a Django model: @staticmethod def getdefault(): print "getdefault called" return cPickle.dumps(set()) _applies_to = models.TextField(db_index=True, default=getdefault) For some reason, getdefault() is never called, even as I construct instances of this model and save them to the database. This seems to contradict the Django documentation: Field.default The default value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created. Am I doing something wrong? Update: Originally, I had this, but then I switched to the above version to debug: _applies_to = models.TextField(db_index=True, default=cPickle.dumps(set())) I'm not sure why that wouldn't work.

    Read the article

  • Database Error django

    - by Megan
    DatabaseError at /admin/delmarva/event/ no such column: delmarva_event.eventdate I created a class in my models.py file: from django.db import models from django.contrib.auth.models import User class Event(models.Model): eventname = models.CharField(max_length = 100) eventdate = models.DateField() eventtime = models.TimeField() address = models.CharField(max_length = 200) user = models.ForeignKey(User) def __unicode__(self): return self.eventname and now when i try to view my events in my admin or my main_page it gives me the error that there is no eventdate. I tried syncing the db again but nothing changed. Also, I hashtagged eventdate out to see if I get a different error and then it states that delmarva_event.eventtime does not exist as well. I It is weird because it does not have a problem with eventname. Any suggestions would be greatly appreciated!

    Read the article

  • Django Redundancy

    - by Sunsu
    I've read many things about scaling Django and the new multiple-DB support makes it so much easier. However, I have not been able to find much information on good ways to create a fully redundant system (not just one that scales). I realize there are many things that go into this problem, but the real thing I'm having trouble solving well is Database redundancy. Is it possible to set up a "write slave" using django's new multiple-DB support? If I had IP failover support it seems like having a write slave would help solve the problem. Simple MySQL replication doesn't seem like it will work due to slave lag right? What's the typical method of creating a redundant database system? Any input or guidance you guys have would be greatly appreciated. I realize I could be asking the wrong questions!

    Read the article

< Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >