Search Results

Search found 3554 results on 143 pages for 'django modelforms'.

Page 94/143 | < Previous Page | 90 91 92 93 94 95 96 97 98 99 100 101  | Next Page >

  • How do I write a single-file Django application?

    - by obvio171
    I want to write a very small Django application in a single file, requiring all the appropriate modules and stuff, and then be able to run that as a normal Python script, like this: $ python myapp.py You can assume I won't render HTML, so I don't need templates (I'll return JSON or some other auto-generated string).

    Read the article

  • Django: What's the correct way to get the requesting IP address?

    - by swisstony
    I'm trying to develop an app using Django 1.1 on Webfaction. I'd like to get the IP address of the incoming request, but when I use request.META['REMOTE_ADDR'] it returns 127.0.0.1. There seems to be a number of different ways of getting the address, such as using HTTP_X_FORWARDED_FOR or plugging in some middleware called SetRemoteAddrFromForwardedFor. Just wondering what the best approach was?

    Read the article

  • Django/jquery: Address forms - dyamically adding state drop down list if country is United States?

    - by User
    I have a django html form for address information. There is standard street, city, state/province, postal code, country fields. The country field is a drop down list. How can I make the state/province field a drop down list if the selected country is united states and a free form text box if the country is anything else? I'd prefer not to have to do a round trip to the server so probably through jquery?

    Read the article

  • How do I collect a bunch of Django abstract models in a QuerySet?

    - by Thierry Lam
    I have the following abstract Django models: class Food(models.Model): name = models.CharField(max_length=100) class Meta: abstract = True In one of my view, I created a bunch of Food model: panino = Food(name='Panino') poutine = Food(name='Poutine') food = [panino, poutine] From the above, I'm not saving the model and storing the Food model in a regular Python list. I want to store the above food models in a QuerySet object. How can I do that without storing any data to the database?

    Read the article

  • Any reason not to use USE_ETAGS with CommonMiddleware in Django?

    - by allyourcode
    The only reason I can think of is that calculating ETag's might be expensive. If pages change very quickly, the browser's cache is likely to be invalidated by the ETag. In that case, calculating the ETag would be a waste of time. On the other hand, a giving a 304 response when possible minimizes the amount of time spent in transmission. What are some good guidelines for when ETag's are likely to be a net winner when implemented with Django's CommonMiddleware?

    Read the article

  • I am currently serving my static files in Django. How do I use Apache2 to do this?

    - by alex
    (r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}), As you can see, I have a directory called "media" under my Django project. I would like to delete this line in my urls.py and instead us Apache to serve my static files. What do I do to my Apache configs (which files do I change) in order to do this? By the way, I installed Apache2 like normal: sudo aptitude install apache2

    Read the article

  • Replace textfields with dropdown select fields

    - by 47
    I have three model classes that look as below: class Model(models.Model): model = models.CharField(max_length=20, blank=False) manufacturer = models.ForeignKey(Manufacturer) date_added = models.DateField(default=datetime.today) def __unicode__(self): name = ''+str(self.manufacturer)+" "+str(self.model) return name class Series(models.Model): series = models.CharField(max_length=20, blank=True, null=True) model = models.ForeignKey(Model) date_added = models.DateField(default=datetime.today) def __unicode__(self): name = str(self.model)+" "+str(self.series) return name class Manufacturer(models.Model): MANUFACTURER_POPULARITY_CHOICES = ( ('1', 'Primary'), ('2', 'Secondary'), ('3', 'Tertiary'), ) manufacturer = models.CharField(max_length=15, blank=False) date_added = models.DateField(default=datetime.today) manufacturer_popularity = models.CharField(max_length=1, choices=MANUFACTURER_POPULARITY_CHOICES) def __unicode__(self): return self.manufacturer I want to have the fields for model series and manufacturer represented as dropdowns instead of text fields. I have customized the model forms as below: class SeriesForm(ModelForm): series = forms.ModelChoiceField(queryset=Series.objects.all()) class Meta: model = Series exclude = ('model', 'date_added',) class ModelForm(ModelForm): model = forms.ModelChoiceField(queryset=Model.objects.all()) class Meta: model = Model exclude = ('manufacturer', 'date_added',) class ManufacturerForm(ModelForm): manufacturer = forms.ModelChoiceField(queryset=Manufacturer.objects.all()) class Meta: model = Manufacturer exclude = ('date_added',) However, the dropdowns are populated with the unicode in the respective class...how can I further customize this to get the end result I want? Also, how can I populate the forms with the correct data for editing? Currently only SeriesForm is populated. The starting point of all this is from another class whose declaration is as below: class CommonVehicle(models.Model): year = models.ForeignKey(Year) series = models.ForeignKey(Series) .... def __unicode__(self): name = ''+str(self.year)+" "+str(self.series) return name

    Read the article

  • django on appengine

    - by aks
    I am impressed with django.Am am currenty a java developer.I want to make some cool websites for myself but i want to host it in some third pary environmet. Now the question is can i host the django application on appengine?If yes , how?? Are there any site built using django which are already hosted on appengine?

    Read the article

  • Python web frameworks comparisons

    - by stupidLearner
    I recently asked a question on SO about Python web frameworks: http://stackoverflow.com/questions/4909306/python-web-frameworks-vs-java-web-frameworks-how-is-web-development-in-python-do I want to learn one just for fun but it also has to be able to help me deliver a proper working application. I am looking for a framework with lots of features, powerful, mature, with large community, good documentation, books etc. I need something that will help me be more productive in developing my app and not waste time figuring out how to do a certain thing in the framework or how to write workaround around the limitations of the framework. I was thinking one of the following: django, zope, turbogears, pylons. Off course the war is raging out there and there are other alternatives but seems Django is at the top... or is it just hype? I am interested in pros and cons of each. What was the best feature you think the framework has? What is the thing it lacks? What could have been done differently. Help me chose one to learn for starters.

    Read the article

  • Execute code every hour

    - by Linger
    I need to create a web service that executes every hour. It will be used to review data in a database and add alerts to a table in the same database if certain conditions are met/not met. What we currently have is: We have end devices that use Python to report to an Amazon Web Services (AWS) virtual server. The AWS server takes that information and stores it in a MySQL database. The AWS server is Linux running Django and Apache. I need to be able to have some python code run every hour that verifies the data that has been stored by the end devices. If certain conditions are not met then a record will be added to the alerts table in the database. We originally contracted to have the above setup created. I am new to Python, Django, and Apache. However, I have already made several changes to the Python code that sends and also receives the data from the end devices. I am a coder that is breaking into web programming. Does anyone have any recommendations on how I can do this?

    Read the article

  • Multiple sites with the same codebase in Python

    - by Jimmy
    I am trying to run a large amount of sites which share about 90% of their code. They are simply designed to query an API and return the results. They will have a common userbase / database but will be configured slightly different and will have different CSS (perhaps even different templating). My initial idea was to run them as separate applications with a common library but I have read about the sites framework which would allow them to run from a single instance of Django which may help to reduce memory usage. https://docs.djangoproject.com/en/dev/ref/contrib/sites/ Is the site framework the right approach to a problem like this, and does it have real benefits over running separate applications? Initially I thought it was, but now I think otherwise. I have heard the following: Your SITE_ID is set in settings.py, so in order to have multiple sites, you need multiple settings.py configurations, which means multiple distinct processes/instances. You can of course share the code base between them, but each site will need a dedicated worker / WSGIDaemon to serve the site. This effectively removes any benefit of running multiple sites under one hood, if each site needs a UWSGI instance running. Alternative ideas of systems: https://github.com/iivvoo/django_layers https://github.com/shestera/django-multisite I don't know what route to be taking with this.

    Read the article

  • Social Network ( Help) [on hold]

    - by brunocascio
    I am in a great "problem" so to speak , and I need opinions to decide. The problem is to create a social network without knowing the number of users who use it (but if thinking if they were sufficient ) . The question is which language and framework to use .... I do not mind having to learn new technologies and / or languages ??. I am among PHP ( Laravel - Symfony - other? ) Ruby ( Ruby on Rails 4? ) Javascript ( Ember , express, locomotive , other? ) Python ( Django ) Java ( Grails , Play, other?) I have experience in both PHP and frameworks. In Symfony developed part of it, but I got tired having to do a thousand configurations for all . I know very little about Ruby , but I saw very easy . I do not know are saying the performance. Javascript costs me to get used to their paradigm , and do not know if at all sure to cover everything with Javascript. Django and python ( very poor knowledge ) Java , experience in data structure and android , but not web . Regarding the / s databases: In my head I have to MongoDB and costs change of opinion by another database with respect to documentation and EASE performance . But .......... frameworks have no support at all clear . I also thought of mixing technologies for using a tecnlogía backend and the frontend other. As I read in the new social network Origo . They use Symfony for REST and javascript for the frontend . ( Backbone , Underscore and RequireJS ) What do you recommend me ?

    Read the article

  • Lighting Fast CMS, a Django based CMS. Any experiences?

    - by Melmacian
    I've just came across Lighting Fast CMS, which seems to be very promising Django based content management system. Documentation seem to be very good, even though it is still in beta stage. It also has very nice buildout based installation. Also core Components of it seem to be nicely decoupled. Does anyone have any experiences with it yet? How much one can customize it with extensions? How's extension development in general compared to Drupal or Plone? I'm hoping that I could do some projects with it instead of Plone or Drupal. Those both are great, but extending them ain't too nice. The project can be found here: http://www.lfcproject.com/

    Read the article

  • How to convert this query to a "django model query" ?

    - by fabriciols
    Hello ! What i want is simple : models : class userLastTrophy(models.Model): user = models.ForeignKey(userInfo) platinum = models.IntegerField() gold = models.IntegerField() silver = models.IntegerField() bronze = models.IntegerField() level = models.IntegerField() rank = models.IntegerField() perc_level = models.IntegerField() date_update = models.DateTimeField(default=datetime.now, blank=True) total = models.IntegerField() points = models.IntegerField() class userTrophy(models.Model): user = models.ForeignKey(userInfo) platinum = models.IntegerField() gold = models.IntegerField() silver = models.IntegerField() bronze = models.IntegerField() total = models.IntegerField() level = models.IntegerField() perc_level = models.IntegerField() date_update = models.DateTimeField(default=datetime.now, blank=True) rank = models.IntegerField(default=0) total = models.IntegerField(default=0) points = models.IntegerField(default=0) last_trophy = models.ForeignKey(userLastTrophy, default=0) I have this query : select t2.user_id as id, t2.platinum - t1.platinum as plat, t2.gold - t1.gold as gold, t2.silver - t1.silver as silver, t2.bronze - t1.bronze as bronze, t2.points - t1.points as points from myps3t_usertrophy t2, myps3t_userlasttrophy t1 where t1.id = t2.last_trophy_id order by points; how to do this with django models ?

    Read the article

  • Python/Django: Which authorize.net library should I use?

    - by Parand
    I need authorize.net integration for subscription payments, likely using CIM. The requirements are simple - recurring monthly payments, with a few different price points. Customer credit card info will be stored a authorize.net . There are quite a few libraries and code snippets around, I'm looking for recommendations as to which work best. Satchmo seems more than I need, and it looks like it's complex. Django-Bursar seems like what I need, but it's listed as alpha. The adroll/authorize library also looks pretty good. The CIM XML APIs don't look too bad, I could connect directly with them. And there are quite a few other code snippets. What's the best choice right now, given my fairly simple requirements?

    Read the article

< Previous Page | 90 91 92 93 94 95 96 97 98 99 100 101  | Next Page >